SADX Level Design Tutorial, Part 1

Discussion in 'Engineering & Reverse Engineering' started by Dude, Jun 23, 2010.

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

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    This tutorial will show you how to begin construction on a new level using SADXLVL and 3dsmax. First off, you'll need:

    1. The latest version of SADXLVL
    2. A copy of 3dsmax 9 or later (although theoretically any version should work)
    3. My latest <a href="http://forums.sonicretro.org/index.php?showtopic=21481" target="_blank">SADX Compiled Mesh Exporter</a>
    4. And lastly, (and most importantly) A copy of SADX that you plan on building from. I personally recommend the US version, as it is the one with the disassembly.

    Open SADXLVL. When it opens, point it to your sonic.exe and then select the level you want to edit. I'll be picking a clean sonic.exe and selecting emerald coast act 1. Let's decide on an edit now and start thinking about what to model. For simplicity's sake, Let's pick the dock area as illustrated here:

    [​IMG]


    Now we'll need to get a reference to import in 3dsmax so we can have proper axes and scaling. To do this, we select the surrounding models and export them to an obj file, using File -> Export -> OBJ -> Selected. A dialog box will appear asking the export destination. It's best to make a new folder for this, as SADXLVL gives you alot of PNG files when you export. I saved mine in a folder called /Exports (in my sadx folder), and the file out.obj.

    Now you'll need to load 3dsmax. Select File - Import, and in the dialog drop down, select *.obj as the extension type. Locate the file you exported previously and load it. The box you get should look a little something like this, depending on which version of 3dsmax you're using.

    [​IMG]

    The most important thing here is that "Rotate Model" is NOT checked. Select OK. You'll notice right away that your scene is untextured, and that local coordinates have been converted to global, destroying pivot point data. This isn't much of a concern unless you're placing lots of the same model in the scene. But since we're only placing one and using the original scene as reference, this isn't a very big deal. My scene in 3ds looks a little like this:

    [​IMG]

    Fortunately for us, SADXLVL exported the entire PVM as a set of PNG files. There is a problem however. The export script exports UV's upside down. I don't know why and I don't know how to fix it. A good workaround however, is to use PVR viewer to flip every PNG file at once. It can do that. Instantly. It's awesome. Anyways, now that you've flipped them all, its time to get them into the scene. Click on the Material Editor in the upper right hand corner of MAX's toolbar:

    [​IMG]

    Which will bring up the Material Editor, which looks a little bit like this:
    [​IMG]
    The first material should already be selected. In the Material Editor window, right next to the dropdown that says "01-Default" is the material's type designation. Click on it and a new window will come up. Pick "Multi/Sub-Object" from the list, and then "discard" in the next winow. You should be dumped back off into the Material Editor, but this time it looks different:
    [​IMG]
    Each of those mini-slots is effectively a new material packed into the first one. This is how we'll be having multiple textures/materials on a single model. Awesome, huh? Anyways, pick the first one. There will be a blank button next to the material's diffuse channel. Click on it. Another huge list window will pop up. Click bitmap (hint: It's the first one in the list) and press OK. A file dialog will come up. Go to your /Export directory and set the drop down dialog type to PNG.

    [​IMG]

    As you can see, every texture in the PVM is here. You can only do one at a time, but you don't have to do them all, just the ones you need. After you pick the image, you'll be on the 'map' level of your current sub material. There's a checkered box next to the drop down. Click it. This will show the map in the viewport.

    [​IMG]

    Then, click the drop-down and go back to "01-Default". This will take you back to the root of your level's material. Repeat this step with every texture you plan on using. I only needed four.
    [​IMG]

    Now it's time to get to the actual modeling. There are a billion ways to do this, and everyone does it differently. But I'll be doing it the cheap way by doing box modeling. Close the material editor and go back to the scene. Zoom in on the bridge area. Then, in the right-side toolbar, select the create tab (will probably be selected already) and pick the box primitive. Click and drag in the scene to make the box. Go to the Modify tab and you should see "Box" under the list of modifiers.

    [​IMG]

    Now you'll want to right-click on the "Box" entry and convert it to either Editable Mesh, or Editable Poly. The choice is yours really, but it MUST be an Editable Mesh BEFORE export. Editable Poly is alot easier to work with, so I usually make new models in Editable Poly, then convert before I export. After I've picked a modifier, I get to town editing the Mesh. Since that's basic stuff and outside the scope of this tutorial, we'll jump to my finished, untextured model. Don't forget that you can use smoothing groups to edit the smoothing of your model. They're stored in the vertex normals upon export.

    [​IMG]

    As you can see, it still needs to be textured. Select the model and open the material editor. There's a small button with an arrow and a cube. It will assign the selected material to the selected model. After this step you should get something like this:

    [​IMG]

    Now, close the Material Editor and select the model. In the modifiers tab, go to the polygon selection level, and select eveything you want to be the rock texture, like so:

    [​IMG]

    Now, with those faces selected, scroll the modifier rollout all the way down to the "polygon properties" subheading. In the "Set ID" field, punch in the number of the material you wanted to use. In my case, it was 4 for the rock texture.

    [​IMG]

    Do this for the rest of the model as well. Then you'll need to UV map everything. Again, outside the scope of the tutorial. Most SADX textures and models are designed to use 'Face' mapping. But this isn't the best way to do things, so I encourage people to do better. Anyways, fast forward to my textured and UV mapped model:

    [​IMG]

    If you look at the object's rotation values, you'll notice its rotated on 2 seperate axes. This is unacceptable and makes extra work for us if we don't fix it, so go to the hierarchy tab, scroll down and click "reset transform". You should also use "affect pivot only" and "center to object" at this point. Convert it back to an editable mesh and you're ready for export. In the Utilities tab, select "MAXScript". Then click "Run script" and locate my exporter script. Select "SA Compiled Mesh Exporter" from the drop-down list and you should have the following:

    [​IMG]

    The settings pictured above work best for SADXLVL, but if you know what you're doing and you're doing things in a hex editor, you can use the other key settings. Remember that your export directory cannot have spaces in it or your output file will be corrupt. Now all you have to do is export, and 3dsmax will generate an out.nj file. Go back to SADXLVL, and then click "View -> Show Invisible" You'll see an invisible collision model for the second half of the dock. Select it, then open the Level Editor window. Use the flags box to zero out the flags, or shut off all of the checkboxes. Your choice. Go back to "View -> show Visible" and do the same thing for the last 2 models in the dock, leaving only this one:

    [​IMG]

    Select the last dock model, then click "File -> Import -> .nj file" and direct the dialog to the model you've made. Congrats! Your model is now just barely ingame, and should look like this:

    [​IMG]

    Now, in the level editor box, click "compute" to fix the collision sphere. Then, click Editors -> Texture Picker, and use that to update the texture ID's until your model is texture the way you want.

    [​IMG]

    That's it! Save and play. Emerald coast should look like this ingame:
    <!--id1--><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/yonPAy5FKV4&"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/yonPAy5FKV4&" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object><!--id2-->
     
  2. Hinchy

    Hinchy

    Up And Down And All Around Oldbie
    1,952
    19
    18
    Lafayette, LA, USA
    I want to make a fangame before I die
    Dude you are officially super duper hero number one. This is what I have been waiting for since the dawn of SADX hacking. I am currently giddy as hell and can't believe it's finally here.
     
  3. This is absolutely awesome. Inserting custom models this way, is easier than ever. Both you and MainMemory, fantastic work.
     
  4. Woofmute

    Woofmute

    Y and -Y and XYZ-X-Y-Z. Member
    184
    0
    16
    Hacking and researching Rez.
    This is a nifty tutorial, though my game crashes when loading Emerald Coast. Probably a really simple mistake on my part, so I'll try again tomorrow.
     
  5. Aquaslash

    Aquaslash

    Emerald Dragoon Moderator
    2,818
    0
    16
    Hampton, VA
    The S Factor: Sonia and Silver
    well now, this is pretty slick. However, I'm gonna need to learn actual modeling and texturing before it's of any use to me :/

    That and I should probably finish my other projects first
     
  6. Great, I've actually managed to do it :P

    Is there a way to add new textures to a PVM? I'm sure there was a tool for it a while back.
     
  7. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,450
    79
    28
    SonLVL
    Adding textures to a PVM can be done with any PVM editor, however editing the corresponding list in sonic.exe is a bit more complicated. You have to locate 0xC * [numtextures] bytes of free space, point the texture list header there and adjust the count. Doing this manually would leave it marked as free space in the table used by both SADXLVL and SADXTweaker, I think I could add something to SADXTweaker for it.
     
  8. I meant like add a brand new one, rather than replacing an old one, is that what you meant too? I think it would be rather handy to be able to do it in SADXTweaker rather than having to have loads of separate programs running.
     
  9. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    <!--quoteo(post=471647:date=Jun 24 2010, 10:59 AM:name=ultima espio)--><div class='quotetop'>QUOTE (ultima espio @ Jun 24 2010, 10:59 AM) <a href="index.php?act=findpost&pid=471647">[​IMG]</a></div><div class='quotemain'><!--quotec-->I meant like add a brand new one, rather than replacing an old one, is that what you meant too? I think it would be rather handy to be able to do it in SADXTweaker rather than having to have loads of separate programs running.<!--QuoteEnd--></div><!--QuoteEEnd-->


    Yeah, that's what he meant. You see, for every pvm there is a corresponding texture list in sonic.exe. If you expand the pvm without expanding the list, you can't use your additions.
     
  10. Woofmute

    Woofmute

    Y and -Y and XYZ-X-Y-Z. Member
    184
    0
    16
    Hacking and researching Rez.
    I get this obj importer menu-
    [​IMG]
    Any idea what settings I'll need to use?
     
  11. Jeztac

    Jeztac

    Member
    100
    0
    0
    Sonic R-DX
    Deselect "Flip ZY-axis" and "Reset scene" then click import.
     
  12. MarkeyJester

    MarkeyJester

    ♡ ! Resident Jester
    2,042
    103
    43
    Japan
    Wow, SADX hacking is reaching a new level of production I see, brilliant work! I can't wait to see some more awesome and fun levels being made out of this, someone right now should make a brand new unique level out of it that no-one has ever seen before, and push the games possibilities to the max.
     
  13. Azu

    Azu

    I must be stupid. Member
    So, we can actually make whole new levels?
     
  14. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,450
    79
    28
    SonLVL
    Aside from coding new objects, yes and it's been possible for a while. SADXLVL just makes it a lot easier.
     
Thread Status:
Not open for further replies.