don't click here

Dude's sadx Model Tools, version 1.4

Discussion in 'Engineering & Reverse Engineering' started by Dude, Sep 20, 2009.

Thread Status:
Not open for further replies.
  1. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    Well after a long time working, I'm ready to release my latest set of hacking tools. This release has all of the old stuff, plus 2 big things that I'm sure people will love.

    New features:
    - An almost perfect maxscript model exporter that exports split model data. The exported data can be re-compiled by hand with notepad and a hex editor.
    - A new program called sadxmdl_porter.exe. This program takes a model chunk (everything from material data to the end of the attach data) and a base address in sonic.exe where you want to insert it, and fixes all of the pointers so you can paste the file into sonic.exe

    [​IMG]

    download


    How to use the exporter
    If you are exporting a single mesh model:
    1. open 3dsmax, load your scene with the model in question. Select the model piece you want to export and make sure the pivot point is centered to the model. In the toolbar on the right hand side of the screen, go to the "utilities" tab and click the MaxScript button. Then press "Run script" and locate the exporter script. The rollout should show up. Check all of the boxes, pick the export directory and press "Export Data"

    2. Now that you have your split model data you can start putting them together. Open Hex workshop and Notepad. You'll need to grab a material struct, either premade from sonic.exe/chrmodels or construct it yourself. Paste the material struct into a new file in Hex Workshop. Save the file as "Model.nj"

    3. Go to the end of "Model.nj" and write down the address in notepad as "Mesh 1; poly". Open out.ply and paste it at the end of the material data and write the new file end address as "Mesh1; uv". Open out.uv and paste its contents into model.nj.

    4. Write down the new end address in your log file as "meshes". Go back to model.nj in hex workshop and insert 0x1c bytes. The first byte is the material ID, which will need to be 00, but increments with each mesh we add. The second byte will need to be 0x00 also, this means the model is using trilists. The next 2 bytes are a short int for how many polygons are in the mesh. Get this number from 3dsmax by selecing the model, going into triangle mode and doing "Select All". Max will report the number of tris in the sidebar on the right. The next 4 bytes are the pointer to the poly data, which we wrote down in step 3. Skip ahead 0xc bytes. The next 4 bytes will be a pointer to the UV data, which we also wrote down in step 3. The next 4 bytes are padding and then we should be at the end of the file.

    5. Go to the end of the file, write down the address as "vertex data". Open out.vt and paste the data at the end of model.nj

    6. Go to the end of the file, write down the address as "vertex normals". Open out.vn and paste the data at the end of model.nj You've now added all of the model data. Only one last thing to process.

    7. Insert 0x2c bytes. This will be our ATTACH data. The first 4 bytes are the pointer to the vertex data (step 5). The second 4 are pointer to the normal data (step 6). The next 4 are the number of verticies in the model (retrieved the same was as the poly total was). The next 4 is the pointer to the mesh data (step 4). The next 4 is the pointer to the material data (should be 0 in this case). The next 2 bytes are the mesh count, then the next 2 are the material count (both 1 in this tutorial). The next 0xc bytes are the relative coordinates for the center of the model in floats (should also be 0 because we centered the pivot in step 1), and the next float is the radius of the model, and the last 4 bytes are padding. Save Model.nj and make a backup of it.

    8. Run sadxmdl_porter.exe. Tell it the name of the nj file you made earlier, then give it the address you plan on putting the model in sonic.exe. The program is verbose sometimes, this is normal. It will also generate an out.log. This is useful for debugging but you shouldn't need it unless something went wrong.

    9. congrats, model.nj is now ready to be put in sonic.exe. You'll still need to give it a seg, and a COL if you're using it for levels but the model data is done.

    I'll make the tutorial for doing multiple mesh models later.
     
  2. Azookara

    Azookara

    come and see him Member
    I watched the videos of this on Youtube, and then I saw the shark. I laughed so hard I almost cried. =P

    Really, this is neat stuff. It looks like the community is finding out how to take this game apart more and more every day....
     
  3. Harmony Friends

    Harmony Friends

    it's the whole gang Oldbie
    I am so confused on how to rip things with this. I find the amount of col structs for Ice Cap segment 0 from 4 bytes before 10755376 - which is 59. I go back to each COL struct in there in reverse, and I'm pretty sure the models are between 13866820 and 14874740. But then I rip these models and I get a bunch of unrelated crap. It's a problem with my technique, as I got similar results from trying to rip Twinkle Park. HALP
     
  4. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    OK this is the proper technique for doing so and when I finish writing my level ripper it will work like this:
    1. store the value for number of col structs (in your case 59)
    2. skip 4 bytes (I dunno what the 0c means but its *almost* always there)
    3. The next value is a float (in your case 3000)
    4. the 4 bytes after that point to the beginning of the col structs, subtract the key and follow it.
    5. Take the stored value for col number and multiply it by 0x24 (36)
    6. Take the result (84c) and select a block of that many bytes, starting from the address pointed to in step 4.
    7. Copy that into a new file, then start reading from it using the col format and rip each level model one at a time. (this may require a custom ripper)
    8. Finished level rip.
     
  5. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    Bump, update at the top.
     
  6. SANiK

    SANiK

    Tech Member
    413
    0
    16
    Dear Dude: I am so fucking proud of you. You're like a brother to me.

    "Does this mean you'll go back to the SADX/Sonic scene?"
    Sadly no. :O

    Keep up the great work though.
     
  7. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    New version released, this one does the pivots for you, saving hours of work and needless exhaustion. Tutorial and further updates coming eventually.
     
  8. MainMemory

    MainMemory

    Has-Been Modder Tech Member
    4,819
    408
    63
    Myself
    Would it kill you to use hexadecimal for the addresses? I would like to have some consistency. The number of objects can stay in decimal.
     
  9. Harmony Friends

    Harmony Friends

    it's the whole gang Oldbie
    I messged this to Dude but if any of you guys can help me with this it'd sure be appreciated.

     
  10. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    Well after a long time working, I'm ready to release my latest set of hacking tools. This release has all of the old stuff, plus 2 big things that I'm sure people will love.

    New features:
    - An almost perfect maxscript model exporter that exports split model data. The exported data can be re-compiled by hand with notepad and a hex editor.
    - A new program called sadxmdl_porter.exe. This program takes a model chunk (everything from material data to the end of the attach data) and a base address in sonic.exe where you want to insert it, and fixes all of the pointers so you can paste the file into sonic.exe

    [​IMG]

    download


    How to use the exporter
    If you are exporting a single mesh model:
    1. open 3dsmax, load your scene with the model in question. Select the model piece you want to export and make sure the pivot point is centered to the model. In the toolbar on the right hand side of the screen, go to the "utilities" tab and click the MaxScript button. Then press "Run script" and locate the exporter script. The rollout should show up. Check all of the boxes, pick the export directory and press "Export Data"

    2. Now that you have your split model data you can start putting them together. Open Hex workshop and Notepad. You'll need to grab a material struct, either premade from sonic.exe/chrmodels or construct it yourself. Paste the material struct into a new file in Hex Workshop. Save the file as "Model.nj"

    3. Go to the end of "Model.nj" and write down the address in notepad as "Mesh 1; poly". Open out.ply and paste it at the end of the material data and write the new file end address as "Mesh1; uv". Open out.uv and paste its contents into model.nj.

    4. Write down the new end address in your log file as "meshes". Go back to model.nj in hex workshop and insert 0x1c bytes. The first byte is the material ID, which will need to be 00, but increments with each mesh we add. The second byte will need to be 0x00 also, this means the model is using trilists. The next 2 bytes are a short int for how many polygons are in the mesh. Get this number from 3dsmax by selecing the model, going into triangle mode and doing "Select All". Max will report the number of tris in the sidebar on the right. The next 4 bytes are the pointer to the poly data, which we wrote down in step 3. Skip ahead 0xc bytes. The next 4 bytes will be a pointer to the UV data, which we also wrote down in step 3. The next 4 bytes are padding and then we should be at the end of the file.

    5. Go to the end of the file, write down the address as "vertex data". Open out.vt and paste the data at the end of model.nj

    6. Go to the end of the file, write down the address as "vertex normals". Open out.vn and paste the data at the end of model.nj You've now added all of the model data. Only one last thing to process.

    7. Insert 0x2c bytes. This will be our ATTACH data. The first 4 bytes are the pointer to the vertex data (step 5). The second 4 are pointer to the normal data (step 6). The next 4 are the number of verticies in the model (retrieved the same was as the poly total was). The next 4 is the pointer to the mesh data (step 4). The next 4 is the pointer to the material data (should be 0 in this case). The next 2 bytes are the mesh count, then the next 2 are the material count (both 1 in this tutorial). The next 0xc bytes are the relative coordinates for the center of the model in floats (should also be 0 because we centered the pivot in step 1), and the next float is the radius of the model, and the last 4 bytes are padding. Save Model.nj and make a backup of it.

    8. Run sadxmdl_porter.exe. Tell it the name of the nj file you made earlier, then give it the address you plan on putting the model in sonic.exe. The program is verbose sometimes, this is normal. It will also generate an out.log. This is useful for debugging but you shouldn't need it unless something went wrong.

    9. congrats, model.nj is now ready to be put in sonic.exe. You'll still need to give it a seg, and a COL if you're using it for levels but the model data is done.

    I'll make the tutorial for doing multiple mesh models later.
     
Thread Status:
Not open for further replies.