X-CulT Community Forums: SADX level editing tutorial - X-CulT Community Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

SADX level editing tutorial not 56k safe

#1 User is offline   Dude

Icon
Posts:
276
Joined:
01-January 06
Gender:
Male
Country:
Puerto Rico
Interest:
Hacker

Posted 09 March 2009 - 09:53 PM

Dude's sadx level editing tutorial.I apologize in advance for the image situation in this tutorial - if anyone can make the images smaller without sacrificing the ability to read the numbers, feel free to downsample them for me. You can also view this tutorial off the board on my websiteIn this tutorial I will explain how to create a semi-original level layout for sonic adventure dx pc, using 3d studio max and a hex editor. The first thing you will need to do is isolate the area in the game you want to manipulate. For this tutorial, this quick rip of Emerald Coast part 1 (download here) will suffice for learning the basics (a word of warning: this rip is far from accurate, and shouldn't be used for anything other than this tutorial. I'll make a better rip later).Also, when working with 3d models imported from sadx, make sure you leave the 'rotate model' option unchecked in your obj import and export plugin. This will cause the viewports to be inaccurate, but our x,y,z coordinates will be accurate for object placement because of this.After ripping the desired data using sadx, navigate to the section of the level you'd like to change, for this example, we will be moving the island immediately after the first loop as pictured here:Posted ImageNow, using the top (back) view, lets select the island's parts. Notice the island is cut into 15 objects, as seen here:Posted ImageNow, lets move and rotate those pieces like so:Posted Imageok, now that we've moved the island's geometry, we'll have to start updating the collision and rendering data. Its tedious and alot of work, but it is all necessary for the edits to show up properly ingame. To keep myself from accidentally moving other pieces of the level, I've frozen everything except for our island. Deselect everything, and then select the dark green part of the island that makes up the tip.Posted ImageNotice that it is named "objgroup12202980_22" This tells us important information about where to find its data in sonic.exe. To make it easier to remember, lets rename it to "Island1_12202980". Now unfortunately, the level ripper doesn't properly import pivot information, and since we've moved the island, that data would be obsolete anyways, so go over to the hierarchy tab with the tip of the island selected and click the button that says "affect pivot only" and then click "center to object", then turn off "affect pivot only". This helps us establish where the center of the object is, which we'll need for the rendering and collision data. Keep this piece of the island selected (make sure only one part of the island is selected), and go to "file -> export selected". Select "alias-wavefront OBJ" for the file format, and then save the file as "Island1.obj" in the same directory your OBJ2VT.exe program is. Uncheck "rotate model", and make sure the 'scale' field is at 1.0.Drag Island1.obj onto OBJ2VT.exe, and when prompted, press any key. A new file called out.vt will appear in the directory. This is our vertex tree, and it is full of raw vertex data in a format that sadx will happily accept. Now we need to figure out where it goes. Our object name contains the numbers "12202980", and this is the decimal offset in sonic.exe where the main data for our island object goes. Open sonic.exe in hex workshop. Press "ctrl+g" to bring up the goto box, and enter those numbers. Make sure the radio button for 'dec' is selected.Posted Imagepress enter, and it should take you to this locationPosted ImageThe first 4 bytes I have selected are flags that determine wether or not the model can be transformed by sonic.exe ingame, pay it no mind for now. Go over 4 bytes to where it says "B8 33 FA 00" This is a pointer to the ATTACH structure of the model (outlined in sanik's notes). The attach structure is useful to us for 2 reasons:- it points to the vertex data, which we need to replace with the contents of out.vt- and it contains data telling the game where the object can be seen from.Posted ImageIf you look down in the data inspector, you'll see "16397240"; this is how "B8 33 FA 00" translates into a long integer (4 byte whole number). This number tells us where the aforementioned ATTACH structure resides in the game's ram, NOT where it resides in sonic.exe. To find where we need to go in sonic.exe, we will have to do some subtraction. We take the value "16397240" and subtract it from the pointer key "0x400000" (hex), or "4194304" (dec). 16397240 - 4194304 = 12202936. Use ctrl+g again, and this time enter "12202936". It should take you here:Posted ImageWe're not far from where we started, the difference between the OBJ struct and the ATTACH struct is always marginal, but this isn't always the case. Sometimes the game likes to play tricks, so always do your pointer math. Anyways, now that we're at the ATTACH structure, lets take a look around:Posted Imagethe data inspector reveals that our vertex pointer is "16394360", which after the key comes out to be 12200056. use ctrl+g again, and after you've arrived at "12200056", open out.vtPosted ImageSelecting everything in out.vt reveals it to contain a total of 0x5a0 (hex) bytes. Copy the contents of out.vt, then go back to "12200056" in sonic.exe. Click select block, and when the box comes up, enter 0x5a0, making sure the 'hex' radio button is selected.Posted ImagePress enter, and then paste. If any byte shifting occured, you messed up. Don't save just yet, go back to the ATTACH structure.Posted Imagego to the object center, and select the first 4 bytes. Now go back to 3dsmax and select the x origin of the object.Posted Imagecopy this number, then run back to hex workshop and paste that number into the data inspector under the 'float' entry.Posted Imagerepeat this with the y and z coordinates, until your attach struct looks like this:Posted ImageWe're almost done with the attach struct, but we need one last piece of data to tell the game how big our island piece is. Go back into 3d studio, and create a new sphere at the same origin point as your island piece. Expand its radius using the radius handle (not the scale tool) until the sphere barely encompasses all of the island.Posted Imagecopy this value, and paste it into the the last remaining entry (object radius), and your attach struct should look like this:Posted Imageyou're almost there! If you were to save sonic.exe now, your object would appear exactly as it is supposed to, but you would fall through any part that wasn't in the same area as before. Select the rendering data you added to the ATTACH struct and paste it into a new file, like here:Posted ImageNow we have to find some data that we can't find from the OBJ or ATTACH structs - the COL struct. To find the col struct we go back to our original numbers ("Island1_12202980" if you forgot), and instead of subtracting our key, this time we ADD it. 1220298 + 4194304 = 16397284. Now this number we just got isn't actually going to tell us anything, because we already are at the place it is telling us to go. So instead of going to 5414602, we find it by pressing ctrl+f. Set the type to '32 bit unsigned long', and then paste '16397284' into the value box. If hex workshop asks you to continue again at the beginning of the file, say ok. It should find a result at 11101328 (dec). We are roughy halfway through the COL struct.Posted ImageAs a general rule, col structs where the object is meant to be visible end in 80. We can use this to find the whole struct, as pictured here:Posted ImageSelect the first 0x10 bytes of the struct and replace them with the radius data you entered into the ATTACH struct earlier, like so:Posted ImageNow save your sonic.exe as EmeraldCoast.exe, and run it. Upon loading emerald coast and going to the loop, you should see this:Posted ImageIts a little low, but shouldn't it be right where we placed it? Not quite, you see there are some coordinates in the OBJ struct that move the model an additional distance - this is for objects that are used more than once, or possibly for other reasons. Remember how the OBJ struct had an attach pointer? Well right after that are 3 more floats that tell the game how far from the vertex data to render the object. In this case, we'll need to zero out this data. Open your EmeraldCoast.exe in hex workshop again, and use ctrl+g to go to 12202980. Here we find the offending value (-23.0)Posted Imagezero out that number, save and re-load. You should get this:Posted ImageNow thats more like it! You'll notice you still can't move past the old barriers though. We've moved them in 3d studio but not in sonic.exe. You have two options here:- get rid of them altogether by making their mesh total in the attach struct 0- move them using the process above to match their new location.Anyways, repeat the process for all 15 of the level pieces if you so desire. It will help you to take notes so you can quickly jump to any OBJ, ATTACH, COL, or VERTEX struct you need to in case you need to change something. My list entries for this island are below:
Emerald Coast Edits:Island1_12202980attach struct - 12202936vertex struct - 12200056col struct - 11101328Island1_Caustics_12718652attach struct - 12718608vertex struct - 12717168col struct - 11114540Island1_Waves_12744884attach struct - 12744840vertex struct - 12743880col struct - 11115152Island2_12211512attach struct - 12211468vertex struct - 12208176col struct - 11101364Island2_Caustics_12721692attach struct - 12721648vertex struct - 12719920col struct - 11114576Island2_Waves1_12746960attach struct - 12746916vertex struct - 12746216col struct - 11115224Island2_waves2_12745940attach struct - 12745896vertex struct - 12745176col struct - 11115188Island3_12222040attach struct - 12221996vertex struct - 12220048col struct - 11101436Island3_sand_12217228attach struct - 12217184vertex struct - 12214880col struct - 11101400island4_12226328attach struct - 12226284vertex struct - 12224144col struct - 11101472island4 shadow_12697132attach struct - 12697088vertex struct - 12696752col struct - 11114180island5_12643760attach struct - 12643716vertex struct - 12639752col struct - 11113676island3_wall_12633620attach struct - 12633576vertex struct - 12632904col struct - 11113640island6_12646608attach struct - 12646564vertex struct - 12645432col struct - 11113712
and lo, a level was changed:Posted ImageIts alot of work, and it took me roughly an hour. I kind of cheated (I used one sphere data for all of the ATTACH and COL structs, because I accidentally corrupted the exe while working, and had to restore a backup), but it works ingame. You can download my finished 3dsmax file here. And if you get lost, or need help figuring out what data does what, you can download my EmeraldCoast.exe, and use Hex workshop to do a file compare on the original executable vs. this one. As you've no doubt noticed, the camera is now totally out of whack with the level. For now, just use free cam. I'll do a camera file tutorial sooner or later.-DudeAlso http://x-hax.cultnet.net/Docs has every piece of research I've ever done.

#2 User is offline   Nova

  • トップをだらえ!
Icon
Posts:
1,425
Joined:
11-January 06
Gender:
Male
Country:
England
Interest:
Weeaboo
Location:
East Sussex

Posted 10 March 2009 - 09:55 AM

Very nice tutorial and pretty comprehensive too.Almost makes me want to crack out SADX PC and give this a go. A good idea would be to make a topic dedicated to listing all the tutorials that have been submitted to the hacking forum and list them all in one place to further reduce the risk of people asking dumbshit questions.

#3 User is offline   Overlord

  • Postcount whoring since 2003~
Icon
Posts:
3,702
Joined:
03-January 06
Gender:
Male
Country:
United Kingdom
Interest:
Programmer
Location:
Berkshire, UK

Posted 10 March 2009 - 03:39 PM

My GOD you have a hideous Windows theme. =PNice tutorial.

#4 User is offline   biggestsonicfan

  • Unleashed isn't doing well? D=
Icon
Posts:
1,087
Joined:
01-January 06
Gender:
Male
Country:
United States
Interest:
Hacker
Location:
/loc

Posted 10 March 2009 - 04:48 PM

I wish I had this kind of comprehensive knowledge of how Sonic the Fighters models worked! Excellent stuff Dude!

#5 User is offline   The Government

  • embrace the end
Icon
Posts:
1,058
Joined:
17-March 06
Gender:
Male
Interest:
Asshole
Location:
[unknown]

Posted 11 March 2009 - 12:15 AM

those are some purple fucking windows you got going on there

#6 User is offline   Hinchy

  • i mean it!!!!!!!!!!1
Icon
Posts:
455
Joined:
31-December 05
Gender:
Male
Country:
United States
Interest:
Nuisance
Location:
place

Posted 16 March 2009 - 07:54 PM

dude why is this fucker not family anymore? he fucking owns.ALSO: posting my object layout editing tutorial. compared to everything explained above, this is easy shit, but for the sake of being able to edit all parts of a level, I'll post it here.----------------------------Tools You'll Needa hex editor (I use Hex Workshop)Cheat Engine----------------------------How Do I Find The Level Layouts?Level layouts are stored as .bin files in the /system/ directory of the SADX folder. They're always in a specific format. I know you all hate Sonic Retro here, but this section of their wiki has all the info to find the file you want to edit. I'm way too lazy to repost that shit.Once you've got your file, open it with your hex editor. Now... I want you to blank it. (Make a backup first.) We'll add new objects instead.----------------------------How Do I Place Objects?Now, the object format. Every file starts with a 32 byte (20 in hex) header in the following format, where red is an unsigned long containing the total amount of objects in the level.00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00(If you ever forget the amount of objects, take the offset of the very last object, divide in hex by 20, and convert to decimal.)Then, each object takes this format:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00The first byte is the object type. You can find what byte corresponds to each object here.You can leave the next byte alone.This unsigned short is the X rotation of the object in BAMS (Binary Angle Measurement System - Google is your friend).This unsigned short is the Y rotation of the object in BAMS.This unsigned short is the Z rotation of the object in BAMS.This float is the X position of the object.This float is the Y position of the object.This float is the Z position of the object.This section is for the object's specific properties. Refer to later in this guide to set these. This section does not apply to most objects.So, now that we've got that business out of the way, let's get to actually placing objects. Open up SADX and put the focus on it in Cheat Engine (click the little rainbow bordered icon in the upper left). Now, click "add address manually" and add these values:Sonic X - 03B2CAB0 Sonic Y - 03B2CAB4 Sonic Z - 03B2CAB8 Now, start a level in SADX and play around. You'll notice the values changing. Move Sonic (or whatever char) to the position you want to place your new object at. Pause the game, and paste the values from Cheat Engine into the floats I specified earlier. Save, and then quit/start the level again, and voila! Your object is there.----------------------------Editing Advanced ObjectsItem Box:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00Change this float to a specific type for each item box. For the list of item box types, go here.----------------------------Jump Pad:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00This float is the number of the jump pad (1-5, 0 is end).This float is the number of the destination jump pad (2-5, 0 is end).----------------------------Rocket:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00This float is the X coordinate of the rocket's destination.This float is the Y coordinate of the rocket's destination.This float is the Z coordinate of the rocket's destination.----------------------------Dash Panel:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00This float controls the speed of the dash panel. If left unchanged, the speed will be set to it's default. ----------------------------That's it.

This post has been edited by YesIAmAnIdiot: 17 March 2009 - 04:17 PM


#7 User is offline   Nova

  • トップをだらえ!
Icon
Posts:
1,425
Joined:
11-January 06
Gender:
Male
Country:
England
Interest:
Weeaboo
Location:
East Sussex

Posted 17 March 2009 - 03:55 AM

This is quite possibly the most colourful thread ever.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users