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

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

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.
This post has been edited by Dude: 29 April 2010 - 12:39 PM


00
