Modding a Basic S3D

Started by Lowkee33, December 28, 2011, 03:36:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


A model of AaronGraham's brought up a discussion about models, namely, editing them in Reader.  As it turned out, his model is a superb example for me to explain pretty much everything I have learned about S3Ds.

The goal of this tutorial is to explain how to reduce the amount of faces the LOD contains. This will make it easier for SC4 to render in-game.  We could also reduce the amount of FSH it uses (to speed up load time), but perhaps that is better for another tutorial.

There are two main things that make this model such a good example.  It uses more than one FSH in zoom 5+6 and it has a custom LOD.  There is also a little bonus item, which we will get to.

First, a little explanation about LODs.  An LOD is basically a set of vertices (points) that are grouped together to form triangles.  Each triangle has part of an image laid on it, and that is what we see in-game.  If one were to make a simple building 30x30x80 meters large in BAT, and then click re-fit LODs, an LOD would be made  that looks something like the #1 in the image below.  However, this building is too big to fit on one FSH, so it needs to be split into pieces (#2).  The LOD is not re-formed however, faces are simply added to the it (#3).  This leaves us with a model that has many more faces than necessary.  #4 shows us what we want, and this can be done in Reader.

Moving on to the real model.  Opening Aaron's model up we see this in the 0x0003400 S3D:

I have both the textures and the LOD visible.  We can see that it has been split into 3 Groups, meaning that there are 3 FSH associated with this Z/R.  The LOD is much more complicated than the picture I made, but perhaps you can see that the faces could be better organized.  Lets start with Group 2, the middle section.  One thing that makes this piece have more faces than needed is that it has faces that are not even visible, lets rotate this view to get a better look.

There are 4 sections in the image.  The actual face of the building (the part that is visible in that Z/R), two narrow strips (part of the custom LOD), and finally a little box (this is an entrance way).  The first thought would be to remove the non-visble sections, but this is a little hasty.  That entrance way is important.  When PIMX creates a Desc, it calculates the Occupant Size from this Z/R.  The entrance way is the furthest to the "left" part of the model, and we will get a bad Occupant Size if it is removed.  The strips can be removed.  I see that they lead to more important things in the roof piece, so for this piece they are unneeded.

So, how to start?  These lines we see in the images are the faces of the LOD, formed by the vertices.  It is a matter of removing the vertices that that we do not want to keep.  Counting the entrance (which might as well be intact), that will be 12 vertices to keep. Clicking on the Vert Tab and then Group 2, we see the list of vertices.

There will be 6 vertices in the face of the building.  the first 4 are relatively simple to find, they are in the far corners of the UV Map.  By mousing over them we can read their U,V values, and then relate this to the U,V values that are found in the Vert tab.  There are a lot of points here, and it will be touch to figure out which one is which.  I like to use the 3D map, and relate it to the data in the UVMap tab.  For the Entrance, I can see that the U values will be somewhere between 0.1-0.3 and will not be close to 0 or 1.

These values can be copy/pasted to/from excel, so that can speed some things up.  Here are the vertices, you can order them in whatever way will help you.  As you see, the model is hurting right now.

The next step will be to correct all of the triangles in the Indx Tab.  Each vertex is given a number in the Vert tab.  We fill the Indx tab with 3 sets of numbers to form triangles.  The texture is already part of the vertices, so we should see the model snap back into place:

We aren't quite ready to check in-game.  The Prim tab needs to be updated:

This image is a little interesting.  While we have three groups, there are only two blocks in the Prim Tab.  This is because Groups can share blocks.  The Data we are editing in this tab is the Number of Vertices.  Since Group 0 and Group 1 have the same amount of triangles, they have the same amount a vertices.  Hence, they share a block here.  I reduced the amount of vertices from 108 to 24 (3 times the amount of triangles), so I need to correct this here.

Lets check in-game:

What happened?  The same error will occur if the Number of Vertices is set wrong, but I know this isn't the case.  Everything looks right in Reader.  In fact, things look right in PIMX too.

What has happened is that I formed the triangles wrong in Reader.  While I put the correct vertex numbers in (things are okay in Reader), I put them in the wrong order.  The rows of triangles can be in any order, but the columns of vertices must be correct.  I can't say I know exactly the pattern, but so far counter-clockwise from the upper-left seems to be good:

Group 0 (the base of the building) is pretty straight forward.  It has no non-visible sections.  It does have an entrance piece though.  In order to make the least amount of faces possible, I make the building as if the entrance doesn't exist, and then add it after.

Again, the Prim must be fixed.  This time it is a little different.  We need to make a new Block because Group 0 and Group 1 don't have the same amount of vertices.  Straight forward, right-click and add group.  We also need to associate the S3D group with the new Prim Group.  This is done in the Anim tab:

(These are apparently rendered out of order, which puts some thought into it.  This tab is ordered by the order of the Materials (FSH), not the groups.  You'll see, it's tricky to selet the group 2 material in the UVmap tab...)

Anyway, to set S3D Group 0 to use Prim Group 2, we just change that Prim Block from a 0 to a 2.  We can keep things organized though.  How about set all of these groups to the values they actually are. We'll have to correct the Prim values accordinly, but I think it's better off this way.

Finally, we move on to the roof:

The roof is where we meet another aspect of the custom LOD, so it doesn't have a cube shape.  The LOD is raised above the roof in consideration of the water tower.  Note the three vertices aroudn the water tower, and the vertex above them.  There are faces that go down from them.  These down faces are important for the other rotations, but they don't do anything for this one.

This is an image of the triangles I used, and the indexing needed.  I show it to display the strange (to me) order that vertices must be in:

In total, this process has dropped this Z/R from 92 triangles on the LOD to 28.  We can still go further on the roof piece, but we're getting down to diminishing returns.  This is a tutorial though...

And the complete model:

That about does it (for this Z/R!)!  I guess I will have to make another tutorial.  It will deal with making the model use less FSH, as well as how to actually move the vertices.  Hope you enjoyed.