Actions

SCHG

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

From Sonic Retro

m (ATTACH Struct)
(Moved to Model Editing.)
Line 1: Line 1:
__NOTOC__
+
{{delete}}
{{WIP}}
 
{{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.<br />
 
For sonic.exe, subtract 0x00400000.<br />
 
For chrmodels.dll, subtract 0x10000000.<br />
 
For the dreamcast version, subtract 0x0C900000.<br />
 
<br />
 
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|OBJECT Struct]].
 
==MESH Struct==
 
The game loads as many of these structs as indicated in the attach struct. The format is as follows.
 
{| class="prettytable"
 
!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
 
| [[#Poly Data|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]].
 
 
 
==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!
 
 
 
{| class="prettytable"
 
!Offset||Type||Description||Notes
 
|-
 
| 0
 
| Pointer
 
| [[#VERTEX Struct|Vertices]]
 
|
 
|-
 
| 4
 
| Pointer
 
| [[#VERTEX Struct|Normals]]
 
| If this is null, the model doesn't use normals.
 
|-
 
| 8
 
| 4 Bytes
 
| Vertex/Normal Total
 
|
 
|-
 
| C
 
| Pointer
 
| [[#MESH Struct|Meshes]]
 
|
 
|-
 
| 10
 
| Pointer
 
| [[#MATERIAL Struct|Materials]]
 
|
 
|-
 
| 14
 
| 2 Bytes
 
| Mesh Total
 
|
 
|-
 
| 16
 
| 2 Bytes
 
| Material Total
 
|
 
|-
 
| 18
 
| Float[3]
 
| Center
 
|
 
|-
 
| 24
 
| Float
 
| Radius
 
|
 
|-
 
| 28
 
| 4 Bytes
 
| Null
 
|
 
|}
 
 
 
==OBJECT Struct==
 
{| class="prettytable"
 
!Offset||Type||Description||Notes
 
|-
 
| 0
 
| 4 Bytes
 
| Flags
 
| ???
 
|-
 
| 4
 
| Pointer
 
| [[#ATTACH Struct|Attach]]
 
|
 
|-
 
| 8
 
| Float[3]
 
| Position
 
|
 
|-
 
| 14
 
| 4 Bytes[3]
 
| Rotation
 
| only read first 2 bytes of each
 
|-
 
| 20
 
| Float[3]
 
| Scale
 
|
 
|-
 
| 30
 
| Pointer
 
| [[#OBJECT Struct|OBJECT Child]]
 
|
 
|-
 
| 34
 
| Pointer
 
| [[#OBJECT Struct|OBJECT Relate]]
 
|
 
|}
 

Revision as of 18:38, 21 December 2009

S3delete.png
This page or image should be deleted.