Sonic Adventure/Model Format
From Sonic Retro
SCHG: Sonic Adventure | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Dreamcast Gamecube 2004 PC 2010 PC | ||||||||||||||||
|
Contents
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 DLL files, subtract 0x10000000.
For BIN files from the dreamcast version, subtract 0x0C900000.
For 1st_read.bin from the dreamcast version, subtract 0x8C010000.
Nothing is currently known about the Gamecube version.
Model format
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!
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.
MATERIAL 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 | 4 Bytes | Diffuse Color | in 0xAARRGGBB format |
4 | 4 Bytes | Specular Color | in 0xAARRGGBB format |
8 | Float | Exponent | |
C | 4 Bytes | 28-bit Texture ID, 4 bits unused | |
10 | 4 Bytes | Material flags |
POLY struct
Triangles
Three shorts, indicating the vertices to use.
Quads
Four shorts, indicating the vertices to use.
Strips
A byte indicating the number of strips to load, a byte indicating the direction to read the strips in, followed by an array of shorts indicating which vertices to use.
VColor struct
An array of ints in 0xAARRGGBB format for each vertex in the strip.
UV struct
An array of two shorts representing the U and V coordinates for each vertex in the strip.
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 | 2 Bytes | Low 14 bits Material ID | High 2 bits Poly Type: 0 = Triangles, 1 = Quads, 2 or 3 = Strips |
2 | 2 Bytes | Poly Total | This is how many polys to load |
4 | Pointer | Polys | Read notes on poly data |
8 | Pointer | Pattr | Unused by sadx (maybe), but are part of official sega model format |
C | Pointer | PolyNormal | If it's non-zero, points to an array containing two Floats for each POLY. |
10 | Pointer | Vertex Colors | |
14 | Pointer | UV Coordinates | |
18 | 4 Bytes | Null | Only in DX version. |
VERTEX struct
A Float[3] for each vertex, times the total specified in the ATTACH Struct.
ATTACH struct
Offset | Type | Description | Notes |
---|---|---|---|
0 | Pointer | Vertices | |
4 | Pointer | Normals | |
8 | 4 Bytes | Vertex/Normal Total | |
C | Pointer | Meshes | |
10 | Pointer | Materials | |
14 | 2 Bytes | Mesh Total | |
16 | 2 Bytes | Material Total | |
18 | Float[3] | Center | |
24 | Float | Radius | |
28 | 4 Bytes | Null | Only in DX version. |
OBJECT struct
Offset | Type | Description | Notes |
---|---|---|---|
0 | 4 Bytes | Flags | See section below. |
4 | Pointer | Attach | |
8 | Float[3] | Position | |
14 | Int[3] | Rotation | Signed BAMS (0x10000 = 360°) |
20 | Float[3] | Scale | Ignored for level geometry. |
2C | Pointer | OBJECT Child | |
30 | Pointer | OBJECT Relate |
Flags
These flags have (or don't have) various effects on how the model data is used.
Bit | Value (hex) | Description |
---|---|---|
0 | 1 | Don't apply position values. Seems to have no actual effect. |
1 | 2 | Don't apply rotation values. Seems to have no actual effect. |
2 | 4 | Don't apply scale values. Seems to have no actual effect. |
3 | 8 | Don't render this model. Does not affect level geometry. |
4 | 10 | Don't process children. Seems to have no actual effect. |
5 | 20 | Rotation values are in ZYX order. Seems to have no actual effect. |
6 | 40 | Don't include this model for animations. |
7 | 80 | Don't include this model for morphs. |
Model Editing Tutorial
(For SADXPC)
Disclaimer
"The information below on model editing is old, outdated, and generally a pain. It should be ignored, but for the moment I am way too lazy to give it an update proper. Look to the right for a list of much more useful, up-to-date, and pertinent information." - Dude
Alright, so you want to edit models in SADX.
First off you need to think of what character you want to edit.
Let's say you want to do Sonic. His head model is name group5674388.
The 5674388 is the decimal offset in CHRMODELS.DLL you need to go to. Use a calculator to convert this number to hexadecimal; in this case the value is 569594.
Open CHRMODELS.DLL in a hex editor. Open the "go to" window (usually done by pressing Ctrl+G). If your editor supports decimal you can just paste in the original value, or you can choose hexadecimal and use that number. Most models end in something like _4 or _20; you only need the numbers before the dash.
Once you have gone to the offset for Sonic's head, you will see 04 00 00 00 (or 0400 0000, depending on how your hex editor is set up; every 2 numbers/letters is one hex byte).
So you want to skip the first 4 bytes, in this case that is 04 00 00 00. You should now see 68 95 56 10 (or another value for a different model). These four bytes are the next offset you want to go to, but they are in little endian and have had 10000000 added to them. Reverse the order of the bytes and subtract 10000000 to get 00569568, and then go to this address.
This time we do NOT skip the first 4 bytes, we select the first 4 bytes which are 78 73 56 10 and once again, reverse the byte order and subtract 10000000. You should get 00567378.
Go to this offset. You are now at the model =D. what you need to do now, is export your edited model in .obj format. (When editing the model do not use symmetry modifiers or mirror the model! You must edit each vertex by hand, you can't mirror it)
Drop your .obj file on obj2vt.exe and you will get an out.vt. Open the out.vt in a hex editor and check how many bytes it has. Off the top of my head, I believe sonic has around 4,000 something. well, check how many bytes that has, and go back to CHRMODELS.DLL. Select a block, the same size as the other file and hit the delete key. Go back to out.vt and select everything and copy it. Paste it in CHRMODELS.DLL were you deleted the old model.
Save, and it should work.
Animation format
Offset | Type | Description |
---|---|---|
0 | Pointer | Model (OBJECT Struct) |
4 | Pointer | Section 2 |
Offset | Type | Description |
---|---|---|
0 | Pointer | Frame Data |
4 | 4 Bytes | Total frame count |
8 | 2 Bytes | Data flags |
A | 2 Bytes | Number of pointer/frame count pairs |
Flags:
0x1: Contains Position data
0x2: Contains Rotation data
0x4: Contains Scale data
The next section contains data in the following order, as the flags dictate:
Position Data pointer
Rotation Data pointer
Scale Data pointer
4 Byte Position Data frame count
4 Byte Rotation Data frame count
4 Byte Scale Data frame count
Position/Scale data:
Offset | Type | Description |
---|---|---|
0 | 4 Bytes | Frame number |
4 | Float | X |
8 | Float | Y |
C | Float | Z |
Rotation data:
Offset | Type | Description |
---|---|---|
0 | 4 Bytes | Frame number |
4 | 4 Bytes | X |
8 | 4 Bytes | Y |
C | 4 Bytes | Z |
If the position, rotation and scale data exist, they will override the values from the OBJECT Struct.
Character Node Hierarchy
The following is a list of the node hierarchies for each playable character in the game.
Sonic/Super Sonic/Metal Sonic
- This list is based on observations when the model is viewed in SAMDL. As such, it's inaccurate for the time being.
ID | Description |
---|---|
0 | Root node |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | Chest |
11 | Face (Parent) |
12 | Face (Parent 2) |
13 | |
14 | Right Eye (Parent) |
15 | Right Eye (Parent 2) |
16 | |
17 | Right Eye |
18 | Left Eye (Parent) |
19 | Left Eye (Parent 2) |
20 | |
21 | Left Eye |
22 | Head |
23 | Sclera |
24 | Right Arm (Parent) |
25 | Right Arm (Parent 2) |
26 | Right Bicep (Parent) |
27 | Right Elbow (Parent) |
28 | |
29 | Right Wrist |
30 | Right Palm |
31 | Right Thumb |
32 | Right Fingers |
33 | Right Elbow |
34 | Right Bicep |
35 | Left Arm (Parent) |
36 | Left Arm (Parent 2) |
37 | Left Bicep (Parent) |
38 | Left Elbow (Parent) |
39 | |
40 | Left Wrist |
41 | Left Palm |
42 | Left Thumb |
43 | Left Fingers |
44 | Left Elbow |
45 | Left Bicep |
46 | Right Leg (Parent) |
47 | Right Leg (Parent 2) |
48 | Right Thigh (Parent) |
49 | Right Knee (Parent) |
50 | |
51 | Right Calf |
52 | Right Heel |
53 | Right Toe |
54 | Right Knee |
55 | Right Thigh |
56 | Left Leg (Parent) |
57 | Left Leg (Parent 2) |
58 | Left Thigh (Parent) |
59 | Left Knee (Parent) |
60 | |
61 | Left Calf |
62 | Left Heel |
63 | Left Toe |
64 | Left Knee |
65 | Left Thigh |
66 | Tail (Parent) |
67 | Tail (Parent 2) |
68 | |
69 | Tail |
70 | |
71 | |
72 |
Tails
- This list is based on observations when the model is viewed in SAMDL. As such, it's inaccurate for the time being.
ID | Description |
---|---|
0 | Root node |
1 | |
2 | |
3 | |
4 | Face (Parent) |
5 | |
6 | |
7 | Head |
8 | Right Eye |
9 | Left Eye |
10 | Right Arm (Parent) |
11 | |
12 | |
13 | |
14 | |
15 | Right Wrist |
16 | Right Palm |
17 | Right Fingers |
18 | Right Thumb |
19 | Right Elbow |
20 | Right Bicep |
21 | Left Arm (Parent) |
22 | |
23 | |
24 | |
25 | |
26 | Left Wrist |
27 | Left Palm |
28 | Left Fingers |
29 | Left Thumb |
30 | Left Elbow |
31 | Left Bicep |
32 | Right Leg (Parent) |
33 | |
34 | |
35 | |
36 | |
37 | Right Calf |
38 | Right Heel |
39 | Right Toe |
40 | Right Knee |
41 | Right Thigh |
42 | Left Leg (Parent) |
43 | |
44 | |
45 | |
46 | |
47 | Left Calf |
48 | Left Heel |
49 | Left Toe |
50 | Left Knee |
51 | Left Thigh |
52 | |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | Chest |
59 | Right Tail (Parent) |
60 | |
61 | |
62 | Right Tail |
63 | Left Tail (Parent) |
64 | |
65 | |
66 | Left Tail |
67 |
Knuckles
- This list is based on observations when the model is viewed in SAMDL. As such, it's inaccurate for the time being.
ID | Description |
---|---|
0 | Root node |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | Face (Parent) |
11 | |
12 | |
13 | Right Eye (Parent) |
14 | |
15 | |
16 | Right Eye |
17 | Left Eye (Parent) |
18 | |
19 | |
20 | Left Eye |
21 | Head |
22 | Sclera |
23 | Right Arm (Parent) |
24 | |
25 | |
26 | |
27 | |
28 | Right Wrist |
29 | Right Palm |
30 | Right Thumb |
31 | Right Fingers |
32 | Right Elbow |
33 | Right Bicep |
34 | Left Arm (Parent) |
35 | |
36 | |
37 | |
38 | |
39 | Left Wrist |
40 | Left Palm |
41 | Left Thumb |
42 | Left Fingers |
43 | Left Elbow |
44 | Left Bicep |
45 | Right Leg (Parent) |
46 | |
47 | |
48 | |
49 | |
50 | Right Calf |
51 | Right Heel |
52 | Right Toe |
53 | Right Knee |
54 | Right Thigh |
55 | Left Leg (Parent) |
56 | |
57 | |
58 | |
59 | |
60 | Left Calf |
61 | Left Heel |
62 | Left Toe |
63 | Left Knee |
64 | Left Thigh |
65 | Tail (Parent) |
66 | |
67 | |
68 | Tail |
69 | |
70 | |
71 | |
72 | Chest |
Amy
- This list is based on observations when the model is viewed in SAMDL. As such, it's inaccurate for the time being.
ID | Description |
---|---|
0 | Root node |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | Face (Parent) |
11 | |
12 | |
13 | Right Eye (Parent) |
14 | |
15 | |
16 | Right Eye |
17 | Left Eye (Parent) |
18 | |
19 | |
20 | Left Eye |
21 | Head |
22 | Headband |
23 | Sclera |
24 | Left Eyelash |
25 | Right Eyelash |
26 | Right Arm (Parent) |
27 | |
28 | |
29 | |
30 | |
31 | Right Wrist |
32 | Right Palm |
33 | Right Thumb |
34 | Right Fingers |
35 | Hammer Handle |
36 | Hammer Head |
37 | Right Elbow |
38 | Right Bicep |
39 | Left Arm (Parent) |
40 | |
41 | |
42 | |
43 | |
44 | Left Wrist |
45 | Left Palm |
46 | Left Thumb |
47 | Left Fingers |
48 | Left Elbow |
49 | Left Bicep |
50 | Right Leg (Parent) |
51 | |
52 | |
53 | |
54 | |
55 | Right Calf |
56 | Right Heel |
57 | Right Toe |
58 | Right Knee |
59 | Right Thigh |
60 | Left Leg (Parent) |
61 | |
62 | |
63 | |
64 | |
65 | Left Calf |
66 | Left Heel |
67 | Left Toe |
68 | Left Knee |
69 | Left Thigh |
70 | Tail (Parent) |
71 | |
72 | |
73 | Tail |
74 | |
75 | |
76 | |
77 | Chest |
Big
- This list is based on observations when the model is viewed in SAMDL. As such, it's inaccurate for the time being.
ID | Description |
---|---|
0 | Root node |
1 | |
2 | |
3 | Right Leg (Parent) |
4 | |
5 | |
6 | |
7 | Right Heel |
8 | Right Toe |
9 | Right Calf |
10 | Right Thigh |
11 | Left Leg (Parent) |
12 | |
13 | |
14 | |
15 | Left Calf |
16 | Left Heel |
17 | Left Toe |
18 | Left Thigh |
19 | Tail (Parent) |
20 | |
21 | |
22 | Tail |
23 | Stomach (Below the Belt) |
24 | |
25 | |
26 | |
27 | Right Arm (Parent) |
28 | |
29 | |
30 | |
31 | |
32 | Right Wrist |
33 | Right Palm |
34 | Right Fingers |
35 | Right Thumb |
36 | Right Elbow |
37 | Right Bicep |
38 | Left Arm (Parent) |
39 | |
40 | |
41 | |
42 | |
43 | Left Palm |
44 | Left Fingers |
45 | Left Thumb |
46 | Fishing Rod |
47 | Fishing Rod Reel |
48 | Fishing Rod Reel Handle |
49 | Left Wrist |
50 | Left Elbow |
51 | Left Bicep |
52 | |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | Face (Parent) |
59 | |
60 | |
61 | Jaw |
62 | Head |
63 | Right Eye |
64 | Left Eye |
65 | Right Iris |
66 | Left Iris |
67 | Right Whiskers |
68 | Left Whiskers |
69 | |
70 | Chest |
71 | Belt Buckle |
72 | Loose Belt Flap |
E-102 Gamma
- This list is based on observations when the model is viewed in SAMDL. As such, it's inaccurate for the time being.
ID | Description |
---|---|
0 | Root node |
1 | |
2 | |
3 | Right Leg (Parent) |
4 | |
5 | |
6 | |
7 | |
8 | Right Calf |
9 | Right Leg Wheel Hub |
10 | Right Leg Wheel |
11 | Right Heel |
12 | Right Toe |
13 | Right Knee |
14 | Right Thigh |
15 | Left Leg (Parent) |
16 | |
17 | |
18 | |
19 | |
20 | Left Calf |
21 | Left Leg Wheel Hub |
22 | Left Leg Wheel |
23 | Left Heel |
24 | Left Toe |
25 | Left Knee |
26 | Left Thigh |
27 | |
28 | |
29 | |
30 | Chest |
31 | Right Arm (Parent) |
32 | |
33 | |
34 | |
35 | |
36 | Gun |
37 | Gun Handle |
38 | Right Elbow |
39 | Right Bicep |
40 | Left Arm (Parent) |
41 | |
42 | |
43 | |
44 | |
45 | Left Wrist |
46 | Left Palm |
47 | Left Fingers |
48 | Left Thumb |
49 | Left Elbow |
50 | Left Bicep |
51 | Face (Parent) |
52 | |
53 | |
54 | Head |
55 | Left Eye |
56 | Right Eye with "nose" markings |
57 | Lower Chest |
58 | |
59 | |
60 | |
61 | |
62 | |
63 | |
64 | |
65 | |
66 | |
67 | |
68 | |
69 | |
70 | |
71 | |
72 | |
73 | Exhaust Belt |
74 | Metallic Flap |
75 | Headlight Base |
76 | Headlight |
References