Actions

SCHG

Sonic Heroes/Model Format

From Sonic Retro

Revision as of 10:56, 8 January 2017 by Igorseabra4 (talk | contribs) (Created page with "{{SCHG SH}} Sonic Heroes runs on a modified version of the RenderWare engine. Due to that, much of the model information regarding games created on similar versions of it, su...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
SCHG: Sonic Heroes
Main Article
Mechanic Editing

DOL Editing
EXE Editing
Music Pointers
Object Parameter Data
Relocatable Editing (PC)
File Offsets

Model Editing
Collision Format
Model Format
Level Editing

Camera Editing
Event Editing
ID list
Indirect Editing
Light Editing
Level List
Object Editing
Object Porting
Spline Editing
Texture Animation Editing
Visibility Editing

Particle Editing
Particle Editing
Sound Editing
Music List

Sound Editing
Voices

SCHG How-Tos

Custom Object Material Effect Tutorial
Level Editing Tutorial


Sonic Heroes runs on a modified version of the RenderWare engine. Due to that, much of the model information regarding games created on similar versions of it, such as Tony Hawk's Pro Skater 3 and some games of the Grand Theft Auto franchise applies to it as well. However, Sonic Heroes still has data which is specific for itself. There are currently no public tools that can generate custom models that are fully compatible with Sonic Heroes. The information on this page applies to the PC version only. The Gamecube version of the game uses a slighly different format.

Object Models

Models for objects and characters are located in DFF files, contained inside ONE archives. Those models can be imported and viewed in model editors using existing scripts for other games.

Level Models

Level models in Sonic Heroes are located in little endian BSP (binary space partitioning) files, contained inside .ONE archives in the dvdroot folder. Multiple BSPs are in each ONE archive, for the game to know which ones to display, it uses the *_blk.bin file. The archives can be opened with HeroesONE, and can be converted to OBJ using a modified version of BSP2OBJ.

Each BSP is a stream of binary data, divided into multiple sections, which can have multiple children and sibling sections. Each section starts with an array of three int32: the first one is an identifier for the section type, then there's the total size of the section, then there's 0x1400FFFF, which is the RenderWare engine version identifier (it's little endian so it's displayed FF FF 00 14 in the hex editor).

The total size of the section, as said above, includes the section itself and all children sections, but does not include this 0x0C byte "header". So get the total number of bytes in the section and subtract 0x0C to put there. Notice where each section starts and ends. All sections included into another one are children. The WORLD section, which includes the entire file, has in its header the total number of bytes in the file minus 0x0C.

Note that "struct" sections have an identifier of 0x01, "extension" sections have an identifier of 0x03 and all other sections have different identifiers. Most extensions do nothing, except for the Atomic Extension, which contains the Bin Mesh PLG section which contains triangle strips.

The file is little endian. It has the following structure, in order:

// WORLD SECTION
int32 0x0B // section identifier
int32 // section size
int32 0x1400FFFF

// MODEL HEADER STRUCT
int32 0x01 // section identifier
int32 // section size (always 0x40)
int32 0x1400FFFF
int32 0x01 // unknown, always this value
00 00 00 80 // unknown, always this value
00 00 00 80 // unknown, always this value
00 00 00 80 // unknown, always this value
int32 // number of triangles (numTriangles)
int32 // number of vertices (numVertices)
00 00 00 00 // unknown, always this value
01 00 00 00 // unknown, always this value
00 00 00 00 // unknown, always this value
0D 00 01 40 // unknown, always this value
float32[3] // Boundary box min
float32[3] // Boundary box max

// END MODEL HEADER STRUCT

// MATERIAL LIST SECTION
int32 0x08 // section identifier
int32 // section size
int32 0x1400FFFF

// MATERIAL NUMBER STRUCT
int32 0x01 // section identifier
int32 // section size
int32 0x1400FFFF
int32 // number of materials (numMaterials), materials are ordered by a zero-based index
numMaterials*int32 0xFFFFFFFF // there is a -1 for each material

// END MATERIAL NUMBER STRUCT

// MATERIAL SECTION // this section occours numMaterials times
int32 0x07 // section identifier
int32 // section size
int32 0x1400FFFF

// MATERIAL STRUCT
int32 0x01 // section identifier
int32 // section size (always 0x1C)
int32 0x1400FFFF
int32 0x00 // ununsed flags
int8[4] RGBA // Material RGBA (usually 255, 255, 255, 255)
int32 0x2DF53E84 // always this value, unused
bool32 // uses texture? (uzually 0x01)
float32[3] // ambient, specular, diffuse // don't know if these are used. always (1, 1, 1)

// END MATERIAL STRUCT

// TEXTURE SECTION
int32 0x06 // section identifier
int32 // section size
int32 0x1400FFFF

// TEXTURE FLAG STRUCT
int32 0x01 // section identifier
int32 // section size (always 0x04)
int32 0x1400FFFF
int8 // byte, texture filtering mode (usually 0x02)
4bit // half the byte: U adressing mode (usually 0001)
4bit // half the byte: V adressing mode (usually 0001)
bool8 // byte: use mipmap? (usually 0x01)

// END TEXTURE FLAG STRUCT

// DIFFUSE TEXTURE NAME SECTION
int32 0x02 // section identifier
int32 // section size
int32 0x1400FFFF
string // texture name

// END DIFFUSE TEXTURE NAME SECTION

// ALPHA TEXTURE NAME SECTION // unused section, alphas are set in the TXD
int32 0x02 // section identifier
int32 // section size (always 0x04)
int32 0x1400FFFF
string // alpha texture name (unused, always left blank)

// END TEXTURE ALPHA NAME SECTION

// TEXTURE EXTENSION // this section does absolutely nothing
int32 0x03 // section identifier
int32 // section size (0x00)
int32 0x1400FFFF

// END TEXTURE EXTENSION

// END TEXTURE SECTION

// MATERIAL EXTENSION // this section does absolutely nothing
int32 0x03 // section identifier
int32 // section size (0x00)
int32 0x1400FFFF

// END MATERIAL EXTENSION

// END MATERIAL SECTION

// END MATERIAL LIST SECTION

// ATOMIC SECTION
int32 0x09 // section identifier
int32 // section size
int32 0x1400FFFF

// ATOMIC STRUCT
int32 0x01 // section identifier
int32 // section size
int32 0x1400FFFF
int32 // model flags (usually 0x00)
int32 // number of triangles (numTriangles)
int32 // number of vertices (numVertices)
float32[3] // Boundary box min
float32[3] // Boundary box max
0x2F50D984 // always this, unknown
int32 0x00 // unknown, always 0x00
numVertices*float32[3] // X, Y, Z position coordinate for each vertex
numVertices*int8[4] // RGBA vertex color for each vertex
numVertices*float32[2] // U, V texture mapping coordinate for each vertex
numTriangles*int16[4] // (materialIndex, vertex1, vertex2, vertex3) index for each triangle

// END ATOMIC STRUCT

// ATOMIC EXTENSION
int32 0x03 // section identifier
int32 // section size
int32 0x1400FFFF

// BIN MESH PLG SECTION
int32 0x050E // section identifier
int32 // section size
int32 0x1400FFFF
uint32 // flags (0 = tri list, 1 = tri strip; Sonic Heroes always uses tri strips)
uint32 // number of meshes (numMeshes; usually same number of materials)
uint32 // total number of indices
numMeshes*(
    uint32 // number of indices (numIndices)
    uint32 // material index
    uint32[numIndices] // vertex indices
)

// END BIN MESH PLG SECTION

// END ATOMIC EXTENSION

// END ATOMIC SECTION

// WORLD EXTENSION // this section does absolutely nothing
int32 0x03 // section identifier
int32 // section size (0x00)
int32 0x1400FFFF

// END WORLD EXTENSION

// END WORLD SECTION

Texture Flag Struct Settings

Texture filtering modes (unsure if all of them work in SH)
  • 0 - FILTERNAFILTERMODE (filtering is disabled)
  • 1 - FILTERNEAREST (Point sampled)
  • 2 - FILTERLINEAR (Bilinear)
  • 3 - FILTERMIPNEAREST (Point sampled per pixel mipmap)
  • 4 - FILTERMIPLINEAR (Bilinear per pixel mipmap)
  • 5 - FILTERLINEARMIPNEAREST (Mipmap interp point sampled)
  • 6 - FILTERLINEARMIPLINEAR (Trilinear)
Texture addressing modes (unsure if all of them work in SH)
  • 0 - TEXTUREADDRESSNATEXTUREADDRESS (no tiling)
  • 1 - TEXTUREADDRESSWRAP (tile in U or V direction)
  • 2 - TEXTUREADDRESSMIRROR (mirror in U or V direction)
  • 3 - TEXTUREADDRESSCLAMP
  • 4 - TEXTUREADDRESSBORDER
Sonic Community Hacking Guide
General
SonED2 Manual | Subroutine Equivalency List
Game-Specific
Sonic the Hedgehog (16-bit) | Sonic the Hedgehog (8-bit) | Sonic CD (prototype 510) | Sonic CD | Sonic CD (PC) | Sonic CD (2011) | Sonic 2 (Simon Wai prototype) | Sonic 2 (16-bit) | Sonic 2 (Master System) | Sonic 3 | Sonic 3 & Knuckles | Chaotix | Sonic Jam | Sonic Jam 6 | Sonic Adventure | Sonic Adventure DX: Director's Cut | Sonic Adventure DX: PC | Sonic Adventure (2010) | Sonic Adventure 2 | Sonic Adventure 2: Battle | Sonic Adventure 2 (PC) | Sonic Heroes | Sonic Riders | Sonic the Hedgehog (2006) | Sonic & Sega All-Stars Racing | Sonic Unleashed (Xbox 360/PS3) | Sonic Colours | Sonic Generations | Sonic Forces
Technical information
Sonic Eraser | Sonic 2 (Nick Arcade prototype) | Sonic CD (prototype; 1992-12-04) | Dr. Robotnik's Mean Bean Machine | Sonic Triple Trouble | Tails Adventures | Sonic Crackers | Sonic 3D: Flickies' Island | Sonic & Knuckles Collection | Sonic R | Sonic Shuffle | Sonic Advance | Sonic Advance 3 | Sonic Battle | Shadow the Hedgehog | Sonic Rush | Sonic Classic Collection | Sonic Free Riders | Sonic Lost World
Legacy Guides
The Nemesis Hacking Guides The Esrael Hacking Guides
ROM: Sonic 1 | Sonic 2 | Sonic 2 Beta | Sonic 3

Savestate: Sonic 1 | Sonic 2 Beta/Final | Sonic 3

Sonic 1 (English / Portuguese) | Sonic 2 Beta (English / Portuguese) | Sonic 2 and Knuckles (English / Portuguese)
Move to Sega Retro
Number Systems (or scrap) | Assembly Hacking Guide | 68000 Instruction Set | 68000 ASM-to-Hex Code Reference | SMPS Music Hacking Guide | Mega Drive technical information