Actions

SCHG

Sonic Adventure DX: PC/Model Locations

From Sonic Retro

Revision as of 11:47, 20 May 2010 by MainMemory (talk | contribs) (Model Format)

Template:SCHG SADX:PC This page is about models.

Model Locations

sonic.exe

Key=0x00400000

Misc. Objects

Address Description Parent Child Sibling
4B4834 Ring None None None
4BFEF4 Rocket Platform None 4BF6B4 None

Dr. Eggman (Cutscenes)

Address Description Parent Child Sibling
49C830 Root of Model None 49C734 None

Amy's Birdie

Address Description Parent Child Sibling
582410 Right Wing 58251C (Right Arm) None None
58251C Right Arm 5827A4 (Left Arm) 582410 (Right Wing) None
582698 Left Wing 5827A4 (Left Arm) None None
5827A4 Left Arm 582940 (Tail) 582698 (Left Wing) 58251C (Right Arm)
582940 Tail 583EE0 (Head) None 5827A4
583EE0 Head 584EAC (Body) None 582940 (Tail)
58418C Right Foot 58443C (Left Foot) None None
58443C Left Foot 584EAC (Body) None 58418C (Right Foot)
584EAC Body None 58443C (Left Foot) 583EE0 (Head)

CHRMODELS.DLL

Key=0x10000000

Sonic

Address Description Parent Child Sibling
55E76C Tail 55E7D0 None None
55F330 Left Shoe Toe
55F948 Left Shoe Heel
560DD0 Right Shoe Toe
5613F8 Right Shoe Heel
563D0C Right Arm Elbow
565C34 Eye Globe 569594 (Head) None None
569594 Head 56998C 565C34 (Eye Globe) None
5698F0 Right Eye
569CE8 Left Eye
56AD48 Body 56ADE4 569E20 None
56AF50 Root of Model (No model data) None 56AF1C None
57BC44 Jump Ball None None None
57D788 Cutscene Mouth 5812AC (Head) None None
5812AC Cutscene Head None 57D788 (Mouth) None
583284 Crystal Ring None None 564CD0
583904 Crystal Ring item None None None
Rolling
Address Description Parent Child Sibling
5729CC Root of Model (No model data) None 572998 None
Metal Sonic
Address Description Parent Child Sibling
58F808 Head 58FAAC 58DB0C None
591068 Root of Model (No model data) None 591034 None
Super Sonic
Address Description Parent Child Sibling
62C4CC Head 62C8C4 628B54 None
62DE88 Root of Model (No model data) None 62DE54 None
62FE6C Jump Ball None None None
Light Speed Dash
Address Description Parent Child Sibling
6837E8 Root of Model (No model data) None None 6837B4
Misc. Models
Address Description Parent Child Sibling
7276E4 Snowboard None None None

Tails

Address Description Parent Child Sibling
42AD54 Root of Model (No model data) None 42AD20 None

Knuckles

Address Description Parent Child Sibling
2E23B0 Root of Model (No model data) None 2E237C None

Amy

Address Description Parent Child Sibling
16460 Root of Model (No model data) None 1642C None

Gamma

Address Description Parent Child Sibling
207290 Root of Model (No model data) None 20725C None

Big

Address Description Parent Child Sibling
12541C Root of Model (No model data) None 1253E8 None

ADV02MODELS.DLL

key=0x10000000

Address Description Parent Child Sibling
261F08 Mecha Sonic None 26178C None

Model Format

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 the dreamcast version, subtract 0x0C900000.

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 BRGA format
4 4 Bytes Specular Color in BRGA format
8 4 Bytes Unknown
C Byte Texture ID
D 4 Bytes? Unknown
11 Byte Unknown
12 Byte UV Clamping
13 Byte End of MATERIAL Struct Always $94

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 BGRA colors 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 Byte Material ID
1 Byte Poly Type $00 = Triangles, $40 = Quads, $C0 = Strips
2 Short Poly Total This is how many polys 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

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 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

OBJECT Struct

Offset Type Description Notes
0 4 Bytes Flags See section below.
4 Pointer Attach
8 Float[3] Position
14 4 Bytes[3] Rotation only read first 2 bytes of each
20 Float[3] Scale
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 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 16 This model has no children. Seems to have no actual effect.
5 32 Rotation values are in ZYX order. Seems to have no actual effect.
6 64 Don't include this model for animations. Does not affect level geometry.
7 128  ??? Seems to have no actual effect.

Model Editing Tutorial

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 Locations

CHRMODELS.DLL

Sonic

Address Description
59F424 Metal Sonic's Hover
5C310C Standing
5D9674 Spin
Super Sonic
638ECC Super Sonic Standing

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 Unknown
A 2 Bytes Unknown

The next section contains 0x10 bytes for each model piece.

Offset Type Description
0 Pointer Position Data
4 Pointer Rotation Data
8 4 Bytes Position Data frame count
C 4 Bytes Rotation Data frame count

Position 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

The position and rotation data if they exist will override the values from the OBJECT Struct.

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