Actions

SCHG

Difference between revisions of "Sonic Adventure DX: PC/Model Format"

From Sonic Retro

(Contributing =])
m (OBJECT Struct)
Line 117: Line 117:
 
| 4 Bytes
 
| 4 Bytes
 
| Flags
 
| Flags
|  
+
| ???
 
|-
 
|-
 
| 4
 
| 4

Revision as of 20:27, 23 November 2009


Exclamation.svg This article is a work in progress.
Its content and location may change completely and frequently until this notice is removed.

Template:SCHG SADX:PC

Remember: all pointers are 4 Bytes, and need to have a key subtracted from them to find the correct location in a file.
For sonic.exe, subtract 0x00400000.
For chrmodels.dll, subtract 0x10000000.
For the dreamcast version, subtract 0x0C900000.

Note: these are listed in the order they will appear in the file. However, it is likely that you will start at the OBJECT Struct.

MESH Struct

The game loads as many of these structs as indicated in the attach struct. The format is as follows.

offset Type Description Notes
0 Byte Material ID
1 Byte Poly Type Always use $C0 (strips)
2 Short Poly Total This is how many strips to load
4 Pointer Polys Read notes on poly data
8 Padding (0x8) PNormal and Pattr Unused by sadx, but are part of official sega model format
10 Pointer Vertex Colors
14 Pointer UV Coordinates

VERTEX Struct

A Float[3] for each vertex, times the total specified in the ATTACH Struct.

ATTACH Struct

As a rule, data sets occur in the reverse order that these pointers do. In a non-hacked model, the model data always starts with the material structs and goes down the file to the vertex struct, with the exception of the vertex struct. The verts occur right after the mesh struct and the normals are the last data set before the attach struct. The tools sonic team used strictly followed that rule, but the game can operate outside of that constraint so make sure your pointers are always accurate. A crashing game usually means a bad pointer!

Offset Type Description Notes
0 Pointer Vertices
4 Pointer Normals If this is null, the model doesn't use normals.
8 4 Bytes Vertex/Normal Total
C Pointer Mesh
10 Pointer Material
14 2 Bytes Mesh Total
16 2 Bytes Material Total
18 Float[3] Center
24 Float Radius
28 4 Bytes Null

OBJECT Struct

Offset Type Description Notes
0 4 Bytes Flags  ???
4 Pointer Attach
8 Float[3] Position
14 4 Bytes[3] Rotation only read first 2 bytes of each
20 Float[3] Scale
30 Pointer OBJECT Child
34 Pointer OBJECT Relate