• Welcome to SC4 Devotion Forum Archives.

Tutorial on making my s3d props.

Started by buddybud, February 08, 2009, 01:11:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

buddybud

Moved from nam tutorials. Also this information pertained to an outdated verision of ilive reader so mostly doesnt help much :P

QuoteThese files are unstable in reader so please follow the instructions. They use hex decode view and text view for a reason. Why i dont know, but if you doubt me please play with them first and provide a solution, otherwise this is the only way to make these files as far as i can tell. I tend to not follow the rules but it leads me places others never think of going. If you disagree with that then this is not for you.
Bud



Hey guys,

  I would just like to add to this old thread and onto jeronij's astute observations concerning the resource keys related to s3d models. I want to provide two examples.
the first is the Hillside El To Subway Transition found here.http://www.simtropolis.com/stex/index.cfm?id=11413 created by Morifari. The rail props and support props in this lot are actually modified prop exemplars that point to default maxis transit models. The only issue seems to be the ever present color shift. This  could be avoided by cloning whatever model you want to use and give it unique darkened textures. Here's the lot i'm talking about.



The key to these exemplars seems to be that they use something called a "Network Model Resource Key". Just for reference this is the only item throughout the net i found on this subject and dates from 2003 at simtropolis by Teirusu.

QuoteOkay, I guess I'll start off with something I just noticed about 0x27812820 or the 'Network Model Resource Key'

I would like to argue that even though this property is closely related with network bits it CAN be used in other applications as well. For example, gizmo just recently used this property to make the 'Train Cars as Props' modd. Following this up, I just tested this property in my 'G-Mode Tree' modd, where I replaced the the normal resource key with the NMR Key.

The end result turned out very well! Not only was I still able to plop trees, not only did they get resized correctly for each zoom, but the performance of the NMR trees was actually slightly FASTER then the normal trees! Scrolling over the NMR trees was slightly faster and loading was also faster. The normal tress sometimes got blocky/pixelated when zooming and out and scrolling all around, but the NMR trees didn't!

The only problem I encountered that the S3D files I used for the NMR trees had only one side, so when I rotated the view it just showed the same side. However, I imagine if the S3D file was designed to be viewed from all sides this wouldn't occur.

Back to my point, this key can be used for FAR more things then displaying network pieces! As you guys probably already know, this key ONLY needs ONE S3D file to function correctly! No multiple files for different zooms or rotations.

Thus, as I see it. A modeler could create their building, save it as a .3ds file, import via reader, make the building as a prop using the NMR key, grab a blank lot, and presto! Insta-building!

So, what do you guys thing? Did I just hit pay-dirt? Am I crazy? ...Or should I just be shot because you guys already knew this or this is the wrong thread?

Anyways, it took me awhile to figure out that this key was in use because it only shows in the hex & text view. Also if you try to modify the exemplar using the standard method the file becomes corrupted as soon as you reconfig the exemplar in the preview window. As for network props this method could be used for integrating network models onto transit enabled lots as morifari had done. At the bottom of this post i provided a blank exemplar (Network Prop 01.dat) and another (Network Prop 02.dat) which can be used quite easily if you follow the instructions otherwise it most likely will not work. The second exeample is for making tiles intended to be placed via t21.

First Example

Ok..lets get started.... load the Network Prop 01 into reader. We only need to change the following keys. (Please create unique instances for all exemplars, models and textures you create...do not the example instances below)
1. instance of the exemplar file
2. 3rd rep of the resource key
3. the name of the file.



You may also consider changeing other values. But theres a trick to all that. Follow on.

You have to first give it a unique instance. Use the usual method by (see below)
1. highlighting the exemplar and clicking on file, then
2. edit, then
3. assign a new instance in the instance field.
4. click apply when done


Next we will change the 3d rep of the resource key by using the following method (see below)
1. highlightand right click on the exemplar file and choose Text View
2. Click Edit.
3. Change the 3rd rep to point toward the network 3ds file you want to use as a prop.
4. click apply when done



Note that all the green check marks indicate values you can alter in this view without corrupting the file. The red x's are all string and bool values and can not be altered in this view...

Further note that the "Network Model Resource Key" appears properly in this view where as in the preview it appears as "Resource Key 0"

Also make note of the "Prop Count", this value seems to have something to do with textures alphas or objects. The value of B seems to work best allowing for seamless multiple textures. Play with it to find out what i mean. For instance a texture on a s3d prop will only show under a network shadow if the value is B. Anyways.... onto the name

Next and last we want to give our prop a new name. We can do this in the "Hex Editor (decoded file)" view. A little bit about how to do that first. You only want to make alterations in the ascii column on the right hand side as illustrated below. When you click on a character you will get a blinking cursor to the right of where you clicked. You have to use the up,down,left,right arrow keys to move the cursor without altering anything. If you type you will type over what is there. Use the insert key to insert a space and the delete key to remove a space. Ok lets get to it.

1. highlight and right click on the exemplar file and this time choose "Hex Editor (decoded file)
2. This is the location of the name. All you need to do is type in a name over the XxXxX field highlighted in green between the quotes. (use the insert or delete keys if needed)
3. Shows the location of the other 3 boolean values you may want to change. Remember to Capitalize the first letter and remove or add a space as needed if you change the values.
4. Click Apply.



Thats it.... Reconfigure your dat (not the exemplar) and rebuild your directory then save and then open a lot in le and look for your prop.

Second Example

The next thing i want to add builds on jeroij's observations. The above example is provided because it relates directly with what jeronij was trying and what i did. It's essentially the same approach as morifari but uses differnt resource keys but allows us to use flippable s3d props. In the second dat i provided you will find 1 prop exemplar, 5 s3d models and 6 textures. First the exemplar.



The exemplar is identical to the initial one except i changed the resource key to 3 and added a 3xm. The reason for this was because i wanted to be able to provide for flips on t21's. This exemplar needs to treated in exactly the same manor as the example above. Also note, even thought the "resource key 3" and "3xm" both require 5 reps for model zooms only one model is needed. I only just realized this today. So for example lets say we used the first model i provided with the Instance of ff000001 and did not need a flip, the reps would look like the top of the picture below. IF i made a flipped model and gave it an instance of AA000001 it would then look like the bottom part of the picture below.



Ok lets look at the models we will use for this. I provided five separate models.

The first model is the most basic and contains only one group with two triangles and 4 points. The first thing to note is that you can assign a texture id to it. Be it a default one or a unique one. This makes for great versatility.

Vert Tab

For those that have trouble understanding the models i overlayed the orientation and point positions on the picture below. Note that by manipulating the x or z axis you can flip or rotate the model into any position. You can also do this to the texture via the uv settings but i'm still working on this.
The only info i have is as follows from Smoncrie
Quote
Buddybud, well without checking: U is the fraction of the distance across the texture and V is the fraction of the distance up the texture.  So an outer vertex should have same UV as a corner vertex of a square, (0 or 1) for U and (0 or 1) for V.  U and V should both be .5 for the vertex at the centre.

You can also add points to a group and triangles but you can only have one texture per group.



A little more about manipulating the model. This can get confusing but is simple once understood.

- to flip a model over the x axis change all the numbers in the x column from negative to posite or vis-versa.
- to flip a model over the z axis change all the numbers in the x column from negative to posite or vis-versa.
- to rotate the model 180' change all the numbers in the x and y columns from negative or postive or vis-versa.
- mirror the model change all the x values to y and all the y values to x.

you can then go through the first three steps and get the remaing positions. This can be done relatively easy with even the most complex models. The only thing to keep in mind is that for every column you change you have to flip the the triangles of that group in the Indx tab. If change two colums it cancels out and you don't have to flip them. Essentially every odd action requires a triangle flip.

This was provided thanx to Smoncrie
Quote
For coordinate rotation it may be simpler to use the formula:

Xrotated = X cos(angle) – Y sin(angle)
Yrotated = X sin(angle) + Y cos(angle)

And note that for angles that are multiples on 90 degrees sin and cos will be -1, 0, or 1.
So for 180 degrees:

Xrotated = X * -1 – Y * 0
Yrotated = X * 0 + Y * -1

Vert Tab

This is where you find your triangles as seen in the top below. So lets say we fliped the model once then the triangels in the picture below would become

2 1 0
3 0 1

If you rotate the model 180' by flipping both columns then now action needs to take place and the triangles would remain untouched.
If you mirror then flip it over the x axis that would be three changes, the x and z column switch place and then you change the plus or minus in the x axis. this again would require you to flip the triangles.

etc.
Sounds confusing but it's quite easy when you get around to it. Also note that the number entry for the triangle relates to a point on your xyz grid. If you have 4 points that is 0 through 3, then you should never have an entry for the triangle above 3 or there is a problem. Also it is not possible to have negative numbers here.



Prim Tab

Lets look at the Prim tab now. Just remember that the number of triangels must match the number of triangles on the indx tab. also the vertices's should always be 3 times the numbers of triangles.

Mat Tab

In the mat tab simply click on the the highlighted texture name and right click and choose change instance/name. Your texture will only appear if it is part of the simcity dat or present in your dat. It will still work but will be hard to figure out what your looking at if this is the case. There should only be 1 Texture for every group.

Anim Tab

As for the anim i simply removed them and replaced them with blanks. Theres a tutorial around about how to deal with that. It seems to work the way i dealt with it.

Smoncrie also provided this but i beg to differ for these models.
QuoteI recommend that you do not suggest just removing things under the Anim tab.  The information here links all the parts of the S3D together.  The S3D will not work with out it.

The other four files are set up identically but have multiple groups. 1,2,3,4,5. The reason i did this is because you can use alpha maps and group layers, being able to assign a different texture to each group. Here's a picture of the 5 group model. Make note it is just 5 stacked squares using 5 textures with alpha maps. One half of the photo shows 2 groups turned off. Also if seperate props are used for seperate textures then you need considerable distance between them. Where as on one model they can be super close together and the engine can still figure it all out.



Now a couple of observations. The exemplar in use is of the group c997c536 of which only roughly 1500 versions exist in the simcity dats. That leaves a lot of room for the props. However the crowding may occur with models. I have been developing triangles for fully slope conforming network props but worry about the number of unique instances needed for the badb57f1 model group. Also i have used network textures with appropriate alphas for all textures. Gradient alphas do not seem to work but do show in LE before the prop is released...? Would be nice to see that figured out if possible.

Anyways i thought this was relative and i hope it helps others. It seems quite promising to me anyways. As for potential i think this picture does it justice.



The one other thing that i used in this picture that i haven't talked about is cloned and patched network models. I haven't touched on that yet but have had great success in figuring out a method to export them from the simcity dat with equal amout of time and effort. I will cover this if others request. And just a word of note, that only photoshop, sc4tool, LE and the reader where used to do the sidewalk mod. No Bat, Gmax or 3dmax was used. But i wish i could have the choice...lol.

Cheers
Bud
ps. vast working examples (though already out of date and rather crude in construction) can be found in my sidewalk and ramp beta found here.  http://sc4devotion.com/forums/index.php?topic=2913.msg219675#msg219675