Level Replacement - X-Hax/SADXModdingGuide GitHub Wiki

image

Introduction

Custom levels have been possible for years now, one of the very first custom stage was Sonic RDX. Back in the day, replacing a level was a lot of work. However, thanks to Justin, ItsEasyActually and other modders, the whole process is now easier and faster, although, this is still a pretty long and sometimes challenging task.

In this tutorial, we will learn how to import a new level from scratch. Note that if you want to make custom objects for your level, you will need coding, that part will be covered in a different tutorial. However, if you simply plan to add basic objects like checkpoint, rings etc. then you won't need a DLL Mod.

Requirement:

• SA Tools (download)

• Blender (download)

• Justin’s SA addon (download, guide)

• Patience and perseverance

Part 1 Making your new Map

Once you have the blender addon installed, you can go to the SA Tools folder then Run SAToolsHub, create a new project, then follow the guide to set up a SADX project, once it’s done, we can actually start.

image

Getting the map

Obviously your first step is to get the map that you want to port in the game. Most people will get it on Model Resource or any other link found on Google. Sometimes you may have to directly extract the map from the game that you want if you can’t find it on the internet.

I recommend using a map not too big, preferably from a game that came from the same era as PS2/ GameCube/Xbox or before. Mostly because using a modern map might be too greedy and could result to the game (or even the addon) not being able to handle it. Another reason is, on a rare occasion, you can have the addon not able to handle auto textures for your stage and you will have to manually assign each textures and trust me you don't want to do that.

Besides the criteria above, you should be able to use any map you want, as long as you are able to import it in Blender. I'm claryfing that here because I know some people think porting SA2 stages is possible "just" because SA2 is using the same engine, but no, it makes the process easier and quicker, but that's all.

So, you have your map, you can now import it in Blender and… let the fun start. If you never used Blender before, I can tell you this won’t be a fun task.

Importing a map to Blender

Start by removing the cube light and camera. Right click on “Collection” -> Delete Hierarchy.

Now go to File -> Import then select whatever format your map is and import it.

If your map comes with an armature (sometimes they do for some reason.), you can delete it, you only need the meshes.

Small tip, press N to open Blender's toolbox then go to “View” and increase the number on the “End” field. (Something like 100 000 is good.) You can thank me later.

image

Since we have the Blender toolbox open, let's use this opportunity to talk quickly about how to use the addon. In the toolbox, you should see a tab called "SA Tools", that's where most of the features of the addon are available so please remember that for the future. Every time you want to do something with the addon such as collision or textures, press N and go to the SA Tools tab.

image

Once you are on the SA Tools tab, click on "Scene Information" and check "Enable level Tools". We will need that later.

image

Also, if you want to see the textures of your map, you need to click on the arrow on top and select “texture”

image

Alternately you can click directly on “Viewport Shading” at the top right of Blender but this will cost extra performance.

image

If the map is still blank after that, then your textures aren’t loaded properly. Please note that the way the map looks in Blender will be different in-game, this includes transparency and other extra stuff.

Scaling the map:

Each game has different size, difference perspective or whatever you want to call that. There is 99.9% of chance that the map you downloaded is either; too big or too small for SADX and so it won’t render properly in-game. Thankfully, we can fix that by manually scaling it.

Each modder has their own preference to do that, personally, I like to import Sonic Model to have a visual cue on how I should adjust the size of the map. If you have the game files extracted (you do if you did a new project with Tool Hub). You can do File -> Import -> Sonic Adv Mdl. Then import Sonic character from your Project folder. (It should be located at “figure/sonic/models”). Once it’s done, you will be able to see what adjustments your map need. Select all the meshes from your map (make sure to not select Sonic if you imported him) then press S, this will enable the scale feature from Blender. You can now adjust the size of the map with your mouse.

image

Example of a map being scaled with Sonic model

(Note: you can hold CTRL during the process to get a more precise size.)

Once you reach an acceptable size, you can stop. Delete the Sonic model, then press Ctrl + A and select “All transforms”. This will make Blender applies all the change that you just did. Please remember this manip, we will do it a lot in this tutorial.

Setting Collisions:

Now let's talk about collisions. This is the most important step followed by textures so please read that multiple times if you have to. You don’t want Sonic to not be able to stand on the map, so you will need to add collisions, but how do you do that? It’s not really hard, but this task can become incredibly annoying and long depending on the map form. Anyway, first you have to make sure that your map is split into different meshes, if the whole map is only one giant mesh, this won’t work. So first of all, select that one mesh, then press tab to swap to “Edit Mode”. Next, press A to select the whole mesh then press P -> By material. This will split the whole map into different meshes. Re press tab to go back to Object Mode. You can now apply all transform again.

Now to actually set up collision, select a mesh that need a collision (the ground for example) then press N -> "SA Tools" -> "Surface Flags" then check “Solid” and “Visible”.

ALL YOUR MESHES SHOULD HAVE THE FLAG "VISIBLE" EVEN IF THEY AREN'T COLLISION, OTHERWISE THEY WON'T SHOW UP IN-GAME!!!

image

Congrats, you made a collision. Now you can repeat that for every mesh that will need it, this is why this step can take forever.

One thing you can do to make this process a bit quicker is using the "Quick Edit menu". From the "SA Tools" tab, look for "Quick Edit Menu" then check "LandEntry Quick Edit". Next, click on the arrow to show the whole thing and again, check "Visible" and "Solid". Finally, press the big button "SET" to apply everything.

Some tips and info about Collisions in general:

  • SADX uses the visual geometry as collision most of the time (which means the collision aren't a separate model unlike SA2).
  • Small collisions tend to not work, it's best to have a model big enough but not too big either. You can join meshes if needed (select meshes and press ctrl + J).
  • Ideally, each model that will be a collision should have a dimension inferior to 1000. (You can check that in the Item tab when you press N).
  • If the model is too big, you can manually make it smaller in Edit Mode. (Select a part of the model, press P then "By selection".)
  • You shouldn't have collisions bigger than that.
  • You can import original level from the game to see how they did it, that can sometimes help. (They can be found in your project files.)
  • Complex collisions models like stairs/buildings/towers tend to not work properly. It's best to make a simpler model yourself for them. (For example, SADX tends to use a simple plane/slope for stairs. You can easily add simple model form with the top bar menu "Add -> Mesh".)
  • If one of your model is too spaced like this, select it in Edit Mode, then press P -> "By Loose part".
  • The game has just a terrible collision system in general, so this will be trial and error most likely.

Setting Textures

Great we have our collisions, now the next step is to make the textures of our map working for both: the game, and Blender. This part is really important if you want to make your map working in-game so please read carefully. Let’s start.

We need to open the original level that we will replace in SALVL to get its "Textlist pointer". If you don't know, a Textlist is what the game uses to determine which textures are loaded. Most of the time, the geometry file of a level store data (such as textlist) so the game can read information from them directly. In that case, you will need to add the Texlist pointer from the level you are replacing so the game will be able to apply the textures to your stage properly. Each level has an unique textlist pointer that you can get by opening the stage you want to replace in SALVL. Let's see how to do it quickly.

Go back to SA Tool Hub, open the project that you created at the start of the tutorial, then open SALVL.

image

Once SALVL is open, select the level you are replacing, in this tutorial I will use Emerald Coast act 1. Next, go to "Tools" -> "Edit Level Info..."

image

Look for "Texture List", copy the address, then go back to Blender.

Click on "SA Tools" tab again then click on: "Level Info" -> "Textlist Pointer". From that field, paste the Texlist pointer that you did copy earlier.

image

Example if you replace Emerald Coast

Adding the textlist pointer is important because otherwise the geometry won’t show up in-game.

You may have noticed that there is a empty field "Texture Filename", don't worry, we will fill that later.

Making a Texture Pack:

Now that your geometry has the textlist pointer, you need to make a new Texture Pack. Leave Blender for now and go back to your SA Tools folder. Open Texture Editor and select "File" -> "New" -> "PVMX".

image

Now, click on “Add...” and, as you guessed, you can now import all your textures. Great, your texture pack is ready. Go to “File” -> “Export Texture Packs” and give it a name. This will create a folder with all the textures inside. Now you can also save your textures as a PVMX, this file will be used by the game to load the textures, so don’t lose it.

Setting Textures to your map:

We will now make Blender loads the textures that you just exported. Click on "SA Tools" tab again, then click on "Scene Information" -> “Texture List Info”.

You should see a small arrow on the right side: click on it -> “Import SA TexFile”.

image

Browse your files and go to the folder that you exported earlier with Texture Editor (the one that has all the textures) select the txt file and here we go, you should see something like this:

image

Look for the “Tex-file name” field, you need to put the name of your textures pack that you created with Texture Editor earlier. The name MUST match your textures pack, this is really important since this is where the game will take the information to know which PVM it needs to load. Otherwise the textures won’t be loaded and the game will crash. Note that both actions that we just did can be done from SALVL too.

Assigning new texture ID

Luckily this process is now a lot faster than what it used to be (most of the time at least).

  • Make sure your textures pack is loaded.
  • Click on "Auto Assign Textures" from "Scene Information" (SA Tools Tab).
  • Click on "Update Materials"

If everything has been done correctly, the textures of your map should now have their tex ID assigned properly. If all the textures look very wrong, then it failed. In that case, you will have to manually assign all the tex IDs. If it worked you can skip the next section of this guide.

Fixing Tex ID Manually (skip if it worked for you)

This is where the fun start, and by fun, I mean that you will most likely understand what the word “pain” means. You need to manually assign the correct texture ID to each mesh.

Let’s do it. Select the first mesh of your map, then go to “Material Properties” from the SA Tools tab. Now Look for “SA Material Properties”, notice the “Texture ID”, that’s the part that we are interested for. You will now need to assign the correct ID. Blender should show you the name of the texture that it needs. For example, let’s say the name of the texture is “material0137”, then you can check in Texture Editor to see which ID matches this name.

image

If the mesh has multiple materials, you will have to set the id for all of them. Repeat the whole process for every mesh. During this task, you can check if your textures are assigned properly by simply clicking on “Update Materials”.

Exporting your Map:

Congratulation you made it really far, this is the final step for the Blender part. Make sure you are in object Mode, then press A to select everything, Ctrl + A -> Apply all Transform. Then right click -> “Set Origin” -> “Origin to Geometry”. Before we export, I recommend that you turn on the console to have the log in real time in case the export fail. To do that go to the Window menu and select “Toggle system Console”. Now you are ready to export: File -> Export -> SA Formats -> SA1 Level. Check the case “Console Output” so you can see the log in real time, then click on “SA1 level”.

Patience, the process can take between 5 seconds and 10 minutes depending on the size of the map and other factors. Note that if it takes more, you most likely did something wrong somewhere. If it freezes on a specific mesh and never unlock itself, then something is wrong with it, it could be the collision that you set. With that said, the Blender part is done.

Part 2 Building your Mod

Congratulation, you have a map ready (also called LandTable by the game which is the geometry if you don't know.) At this point, I bet you would like to see your level in-game (well, if you haven’t tried already). Let’s just do that.

Open your project folder (the one you created with Tool hub at the beginning of this tutorial), look for the level folder you are replacing. In this tutorial I'm replacing Emerald Coast Act 1, so I'll use the folder "stg01_beach". From here, you can see multiple files, look for the ones starting with "landtableXXX". Each Landtable in the folder matches a specific act from the level. For EC case, "landtable0100.c.sa1lvl" is the first act of Emerald Coast, so this is the one I will replace.

The main idea is to rename your map by the same name of the one you are replacing, then replace the file in your project folder.

image

Now you can open SA Tools Hub, then click on “Build Option” (the icon with a hammer.)

image

A new window will open, this one allows you to select the data from your project that you want to build with your mod.

image

Once you checked what you need, click on “Automatic” this will make SA Tools Hub automatically detect what files got edited and build them to make your mod. You’re almost done, now you can go to your SADX mods folder (where the game is installed) then look for your mod. (It should have your project name). If you open it, it should look like this:

image

Finally, you need to add your texture pack that you created earlier. Create a folder and name it "textures", put your PVMX there, then you’re done.

You can now start the Mod Manager, check your mod and test it. If you want to save time with your tests, go to the Debug tab of the Mod Manager, check “Level:” select the level you replaced, then click on “Play” this will boot the game directly on the stage, if you crash instantly, then you know you did something wrong.

image

Don’t forget that pretty much any other mod that edits the same level than you will overwrite your changes such as DC Conversion, so make sure to disable the level you are replacing in the mod settings.

image

You can also change the start position in your mod folder, you will find a "figure" folder with an ini file that contains the start position for every character and level.

See you in a next tutorial for SET Object and other tweaks to improve / complete your level.