Jump to content

Search Articles

- - - - -

Creating Custom Working Light Props


Level: Advanced Please PM STomnibus if you have any questions about this article.
This is a technical guide/tutorial on creating custom light props that actually light up in the game (at night).


The tutorial assumes the following knowledge:


  • Familiarity with iLive's Reader utility
  • Understanding of the key SC filetypes, such as FSH and S3D files
  • A strong understanding of TGI's and IID's
There are two parts to this document, a technical overview of the components involved in in game and custom light props, followed by a mini tutorial on creating custom lights. Some of this stuff is fairly complex, and there are some areas where it's easy to make mistakes, so I'd advise doing this stuff carefully and take a few backups. I had many frustrating nights trying to get it right.


Thanks to Karybdis, Pegasus and the BSC team for help with this.


Background
When looking at the props we wanted to add to the Amsterdam Centraal Station lot, I found some funky blue lightpoles in front of the real station and thought they'd be great for custom lights in the game. I know smoncrie had played around with this a bit and written a brief tutorial. Pegasus has also been playing with custom light models. In the end I was able to create the lights I wanted, but it was a long process.


Lights and LightCones, A Technical Overview
Before jumping headfirst into creating custom lights, we need to look at the technical aspects of the Maxis lights and lightcones. If you skip this section and go to the tutorial, you'll get yourself into strife, guaranteed.


Files and Relationships

The following points describe the files used by lghts and their relationships:


  • To build a custom light you're concerned with two models, the lightpole which you would build in the BAT, and the light it "produces" (such as lightcone). You can refer to the supplied ones or copy the supplied ones and tweak to your liking.
  • Each model (e.g. lightpole and lightcone) consists of two filetypes; the FSH filetype (Type = 0x7ab50e44) and S3D filetype (Type = 0x5ad0e817). These are normally in a 1:1 relationship, one FSH file per S3D, but some S3D files share a FSH file (such as the standard MAXIS lightcones).
  • Each model will have either one (1) FSH/S3D file pair or twenty (20) FSH/S3D file pairs. The BAT will produce twenty (for each of zoom 1-5 and each direction combination). Some MAXIS models only have one pair of FSH/S3D files. This is usually where the model looks exactly the same in each direction and zoom level (such as the lightcones which are basically a spherical shape and look the same in each direction).
  • Prop exemplars refer to the S3D file (either the single one if there is only one or the ****0000 IID one if there are twenty of them). This is done through the Resource Key Type 4 exemplar property. If this points to an invalid model, you will normally get the brown box.
  • Each S3D file refers to a FSH file (or "texture") through its Material ID (under the Mats tab in the reader). If this points to an invalid texture, you will get a box in Red/Blue/Green.
GID's and IID's
For the lights to work in both day and night, all models (both the lightpole and lightcone) must use a GID of BADB57F1 (0xbadb57f1). If you don't for custom lights, you may see what you're expecting during the day but at night you'll either get the brown box or an unexpected model.



Because you must use a GID of BADB57F1, and only the first four characters of the IID are used as a unique reference (the other four are used for zoom and rotation) you have to be really careful when allocating IID's. There seem to be great chunks not used by MAXIS (3***, 5***, 7***, b***, d*** and f*** based on a quick check of the simcity_*.dat files). I've been using 4DE*.


The Standard MAXIS Lightcones
MAXIS provide four lightcone models:


  • 0x5ad0e817,0xbadb57f1,2cb70000 - a large cone approx. 13m high, radius at base of 4.5m
  • 0x5ad0e817,0xbadb57f1,2cb80000 - a medium cone approx. 10m high, radius at base of 3.5m
  • 0x5ad0e817,0xbadb57f1,09c6e584 - a smaller/flatter cone approx. 6m high, radius at base of 2.5m
  • 0x5ad0e817,0xbadb57f1,29da0000 - a small globe of light as used with the $ lights
These are shown below against a 10m x 10m grid.

Posted Image



These S3D files refer to one of two textures (FSH files):



  • 0x7ab50e44,0x1abe787d,09c6e584 - lightcone; used by 2cb70000, 2cb80000 and 09c6e584
  • 0x7ab50e44,0x1abe787d,ea89e9ee - globe of light, used by 29da0000



Building Custom Lights

There are three stages to creating custom lights; create your own lightcone models (optional, you can use the supplied ones), create your own lighpole models, and putting them together.


Creating your own LightCone Models
Theoretically it's possible to create your own complete lightcone model (i.e. create the S3D + FSH files) but it would be a lot of work. The simplest way is to use the existing MAXIS lightcone models and tweak the FSH file.


You will need custom light models if you want different light colours (as Peg has done with his Peglites). Also if you are going to use multiple lightcones on a single light that will intersect, you might want to reduce the brightness of the light (otherwise you'll burn your eyes out looking at the intersection of the lightcones).


You will need to copy both the MAXIS S3D and FSH files into your own .dat file (reader). You need the S3D file as it refers to the FSH file. You use the normal FiSHman and image editing tools to change the FSH file and upload it.


You will need to ensure you set the GID of your custom files to BADB57F1, the IID's to something unique (within the BADB57F1 set) and that the Material ID points to your custom FSH file.


Creating you own Lightpole Models
This is just standard BAT work. Two things to remember:


  • You should make your poles equivalent to the light model sizes (i.e. approx. 11-12m tall, approx. 8-9m tall or 6-7m tall).
  • If you are going to have multiple lightcones hanging off a single pole, you will need to know the X,Y co-ordinates of the light sources (bulbs) in your model.
Once you have exported the model from the BAT and created the model as a Prop in the Plugin Manager, you will need to go through every S3D file and FSH file in your .desc file and change the GID to BADB57F1 and the IID to a unique value (same unique value for all files). You will also need to go through the S3D files and set the Material ID to be the unique ID you have set for these files. This is a critical step and it must be done correctly.


Putting it all Together
The key to putting it all together is the prop exemplar file. There are two properties you must have:


  • Nighttime State Change - 0x01 means "change to state 1"
  • Resource Key Type 4 - this replaces the Resource Key Type 0/1 that is the default for single state/single model props. Resource Key Type 4xm is used to tie changing props to game activity (such as traffic lights). I've removed it and the props seem to function ok.
The resource key type 4 contains a variable number of sets of values. Each set contains eight Uint32 values. Each set of values represents one model (such as lightpole or lightcone) and state (daytime = 0, nighttime = 1) combination. For example a light with three lightcones would have five sets of values (i.e. fourty all up):


  • SET1 - reps 1 - 8 - nighttime model for lightpole
  • SET2 - reps 9 - 16 - nighttime model for lightcone #1
  • SET3 - reps 17 - 24 - nighttime model for lightcone #2
  • SET4 - reps 25 - 32 - nighttime model for lightcone #3
  • SET5 - reps 33 - 40 - daytime model for lightpole
An example of this is shown below:



Posted Image




Each set of eight values contains:


  • the first REP is day (0) or night (1), although I think the values can be different things, because there is the Nighttime State Change property that say's "at night time use state A" (where A is normally "1" corresponding to the value of the first rep).
  • the second, third and fourth reps are the X,Z,Y represent the offset from the centre of the prop.
  • the fifth rep will be either:
    • 0x27812820 if there is a single S3D file for the prop/lightcone etc. which corresponds to Resource Key Type 0, or
    • 0x27812821 if there are 20 S3D files (for combinations of N/S/E/W at zoom 1 - 5) which corresponds to Resource Key Type 1.
  • the sixth, seventh and eigth reps are the T,G and I values for the prop/lightcone.
To work out the X,Z and Y values, you need to convert from Hex to Decimal and then divide the number by 16^4 (i.e. 65536). For example, the $StreetlightDiagonalAVE_2CC1 uses two lighcones (5ad0e817,badb57f1,2cb70000) with the following dimensions:

Posted Image



From what I've seen the Z value refers to the height of the cone base above the ground.


So my example above using the custom lightcone of 4DE00000 has the following X,Z,Y values for the lightcones (rep #2, #3 and #4):


  • #2 .63m, -1.5m, 1.12m
  • #3 .63m, -1.5m, -1.12m
  • #4 -1.3m, -1.5m, 0m
Here are three lights I created for the Amsterdam Centraal Station lot (day and night views). There are actually three light cones per light pole.

Posted Image

Posted Image




That's pretty much it. If you have any questions, PM deadwoods or email at st_deadwoods@optusnet.com.au.


If you have any further questions about this article, please PM STomnibus.


0 Comments