Numenor
15th Nov 2005, 12:38 AM
>>> Modding InfoCenter <<<
LIGHTS AND "LGHT" FILES
Some (uncomplete) working notes
:new: MAJOR UPDATED 30 NOV 2005: PLEASE READ AGAIN :new:
:alarm: All creators please read Paragraph 7! :alarm:
DISCLAIMER: The "Modding InfoCenter" threads are NOT tutorials: they are intended to help average-experienced object creators performing specific tasks, or to give users a deeper in-sight on specific modding-related subjects. So, don't expect to find step-by-step explanations, to be performed "blindly".
Please DO NOT REPOST the following info, or part of them, on other sites.
All the "Modding InfoCenter" threads are created and mantained by Numenor and JWoods. Everyone is welcome to post his own questions or additional information about the specific thread subject.
-------------------------------------------------------------------------------------
SUMMARY
This InfoCenter articles has the purpose to explain how the lights are managed by the game, and what is the meaning and function of the LGHT files.
First off, let me state clearly that these notes are far from being complete; the LGHT file format hasn't been decoded completely, yet and some information are still missing or unknown. Every contribute is more than welcome! :)
:deal: This tutorial is also provided in PDF format. To view it, we strongly suggest to download the Foxisoft PFD Viewer (http://www.foxitsoftware.com/pdf/rd_intro.php): it's free and small, less than 1Mb!
http://thumbs.modthesims2.com/getimage.php?file=163363 (http://thumbs.modthesims2.com/getimage.php?file=163363)
1 - INTRODUCTION
In the game there are two types of lights: direct light, that hits the objects and the sims around the light source, and diffusion light, that is the ambient light and is reflected by walls and floors, and bleeds through windows.
Every lamp in the game emits both types of light, and therefore people often don't realize that they are managed in a different way by the game.
Infact, every object can emit direct light, but only lamps (i.e. objects that use the LampGlobals) can emit diffusion light.
:new: CORRECTION: all the objects can cast any light; only, the LampGlobals are always needed in order to turn the light on and off: some BHAVs from the LampGlobals must be manually imported in non-lamp objects, and they need to be adjusted, too. My suggestion is to clone a lamp, whenever possible.
:new: The light is defined and created within the game by means of four different, connected elements: the Lighting.txt file (located in the gamedir), the LGHT file, the TextList 0x8E and the Resource Node.
We'll see more in detail the purpose of each of them later on; let's start with an overwiew about the relations between the 4 elements.
The Lighting.txt (or better, the custom .nlo file: see part 2) is where both the direct and the ambient lights are created and defined; the settings contained in it will override any other setting. If a light is not defined in the .nlo file, or the definition doesn't set all the needed parameters, the game falls back on the LGHT file contained in the package; but the LGHT file can only define a direct light, and therefore, a missing definition in the .nlo file always prevents the object from casting diffusion light.
The Resource Node is where the object is associated with its light definition; in the CRES there is a cLightRefBlock that holds the reference to the light name, as defined into the .nlo file; the cLightRefNode is also used to translate and rotate the light.
Lastly, there's the TextList 0x8E. I'm not sure what is its purpose: in my experiments, if an object has a working light, putting a wrong reference in STR# 0x8E doesn't prevent the light from working. Probably it's just another fall-back value, i.e. is used by the game when the primary references to the light can't be found.
2 - THE "LIGHTING.TXT" AND THE ".NLO" FILES
As explained above, the Lighting.txt file defines all the lights, in both their "direct" and "diffuse" components. It is located in [GameDir]\EA Games\The Sims 2\Res\Lights. NOTE: there is a "lighting.txt" file for each EP gamedir: all of them are read when the game starts.
The "lighting.txt" file can instruct the game to load other external text files. These external files, in turn, can load more files.
This is done by specifying in the lighting.txt (or in the external file called by the lighting.txt) an "include" instruction, that can have one of these forms:
include "filename" -> This includes a specific file (that can have any extension, as long as it is a text file).
wildInclude "*.nlo" -> This includes all the text file with .nlo extension (again, the extension is irrelevant: you can use *.txt if you like).
sinclude "filename" -> The leading "s" stands probably for "single" or "standard"; I couldn't find any difference with the normal "include" command: it loads a specific text file (with any extension).
:here: NOTE - The game takes the "Lights" folder as root folder; the additional files specified in the various "include" commands can be located in a subfolder nested into the Lights forder, but not outside the Lights folder. (I've run a test with the downloads folder: unfortunately, the "include" commands can't find a file located there...). Please note that the paths defined in the "include" commands use the normal slash ("/") as separator, and not the backslash ("\").
In order to create a custom light, we need to create a text file (conventionally, the additional light definitions have extension .nlo, "New Light Override"). In this file, we need to define our light, by assigning specific values to some attributes.
The basic syntax is: lightAttribOverride customLightName_light Attribute Value. The "customLightName" is whatever we decide to call the light; to avoid confusions, I suggest to use the CRES name. The "Attribute" and the "Value" are contained in the following table, that contains all the attributes used in the game light definitions, and the values that Maxis used for them.
Parameter Name Min Max
------------------------------------------------
intensity n 0 12
color (R,G,B) 0 1
falloffRate n 0 5
coneAngle n 0 150 (degrees)
conePenumbra n 0 55 (degrees)
range n 1000 1000
diffusionSourceIntensity n 0 3.5
diffusionSourceColor (R,G,B) 0 1
diffusionSourceFalloff n 0.5 15
diffusionSourceMin (x, y) -0.5 0.2
diffusionSourceMax (x, y) 0 2
diffusionSourceFloorIntensityScale n 0.5 1
diffusionSourceWallIntensityScale n 0.9 1.5
diffusionSourceIsDirectional n 0 1 (boolean)
diffusionSourceDirectionalFalloff n 0 1 (boolean)
As you can see, some attributes define direct light and some others define the diffusion light. The purpose of some attributes is still unknown to me: here is explained what I could understand.
Intensity / DiffusionSourceIntensity - Self-explanatory; usually this value ranges from 0 (= no light) to 1 (= normal light); in some rare cases is 5 or even 12.
Color / DiffusionSourceColor - Self-explanatory; these parameters are useful to tweak the intensity, too: a value of 0.5,0.5,0.5 will produce a white light, but less bright than 1,1,1.
FallOffRate / diffusionSourceFalloff - Define how quickly the light will stop being visible; normal value = 0.5; (0 = infinite: the light will hit even extremely distant objects; high values = the light will hit only close objects).
ConeAngle / ConePenumbra - These values (expressed in degrees) represent the ray of the light cone, and the ray of the additional penumbra cone that surrounds the light cone. The sum of the two rays must be less than, or equal to, 180°.
DiffusionSourceFloorIntensityScale / DiffusionSourceWallIntensityScale - These are multipliers that define how much walls and floors reflect the light; usually, their value is 1 (= normal reflectivity); values less than 1 attenuate the reflectivity.
(All the remaning attributes are unknown to me)
3 - THE "LGHT" FILE
First off, let's clear up is that there are four different "LGHT" filetypes in the game: Ambient Light and Directional Light (mostly used in CAS screen), Spot Light (used for doors and windows), and Point Light (used for lamps and other objects that lit up).
All the information provided in this article refer to the "Point Lights", though they probably apply to other LGHT types, too (untested).
As explained in the Introduction, the LGHT file defines the direct light, but is used only if there isn't a correct definition into the Lighting.txt.
The attributes set in the LGHT file are partly coincident with the LightAttributeOverrides that we have examined in the previous paragraph; as far as I could see, only some of the attributes related to the direct light are included in the LGHT file, not all. But again, there are some unknown values in the LGHT, too; so, I can't be sure if some attrivùbutes are really missing from the LGHT file...
Opening the LGHT in SimPE we can find (and edit) the following values:
Val1 = "Intensity": see explanation above; usually set to 1.
Val2 = (Unknown); normal value = 1; known range = 0.5 -- 1.0.
Val6 = "FallOffRate": see explanation above.
Val7 = (Unknown); normal value = 20; known range = 0 -- 20.
R, G, B = "Colour": see explanation above.
There are several name reference within the LGHT file; though some of them seem only explanatory (i.e. don't have to match the names in the Lighting.txt, or the CRES, or the STR# 0x8E), it's a good habit to follow a strict naming convention:
Filename - It's the scenegraphic name of the file: it should be in the form cresName_customLightName_light_lght (where "customLightName" is the name defined in the .nlo text file).
"cPointLight" tab, "Name" field - Put here the name of the light only, i.e. customLightName_light.
"cLightT" tab, "Name" field - Put here the full LGHT filename: cresName_customLightName_light_lght.
"cObjectGraphNode" tab, "Filename" field - You can leave this empty.
4 - THE TEXT LIST 0x8E
This file holds the reference to the light name, as defined in the .nlo file (i.e. customLightName_light). As said, I'm not sure about the purpose of this TextList: if the reference is wrong, the light will work anyway...
5 - THE RESOURCE NODE
In order for the LGHT file to be seen by the game, it must be linked to the Resource Node (CRES): a link to the LGHT file must be added to the CRES, "Reference" tab.
:here: NOTE: the Reference list within the CRES relies on the TGI of the various files linked: if you rename the LGHT file, you have to click "Fix TGI", and then change the reference in the CRES.
Then, a cLightRefNode block must be added to the CRES hierarchy, and attached it to an existing branch (see example in paragraph 6).
The name of the cLightRefNode has to be set in the "cObjectGraph" tab: it must match the light name defined in the .nlo file, i.e. customLightName_light. If multiple cLightRefNodes are added to the CRES, and all of them are related to the same light definition, then all of them must have the same name.
Once the LGHT file is properly linked to the CRES, it may be used by the object. You might need to adjust the light position, by editing the translation values into the "cTransformNode" tab of the cLightRefNode block.
6 - AN EXAMPLE: ADDING A DIRECT LIGHT TO AN OBJECT - ***UNFINISHED!***
1) First off, we need a LGHT (Point Light) file: you can extract it from any lamp, or directly from the Objects01.package, located in the GameDir.
You can choose any LGHT file, as long as it is a "Point Light": we'll adjust its parameters to match our needs.
2) Import the LGHT file into your package and rename it; the structure of the LGHT filename is the following: CRESname_DiffusionLightName_light_lght. You just have to replace the first part (before the first underscore) with the CRES name of your object. Do this either in the main "Filename" field and in the "Name" field under the "cLightT" tab. Then FIX TGI and commit.
http://thumbs.modthesims2.com/getimage.php?file=163362 (http://thumbs.modthesims2.com/getimage.php?file=163362)
3) Open the CRES, "Reference" tab, and add a reference to the LGHT file: use the Package Selector Form as shown in picture to drag-and-drop the reference into the list. Take note of the position of the added reference in the list; in this example, the Lighting is in position #2 (the positions start from zero).
http://thumbs.modthesims2.com/getimage.php?file=163371 (http://thumbs.modthesims2.com/getimage.php?file=163371)
4) Add one "cObjectGraphNode (cLightRefNode)" block into the CRES ("Edit Blocks" tab). Take note of the number of the added block.
http://thumbs.modthesims2.com/getimage.php?file=163372 (http://thumbs.modthesims2.com/getimage.php?file=163372)
5) Include the newly added block in the CRES Hierarchy, by adding a "Child Node" into one of the existing branches (usually, main Shape, like in picture).
Note: while adding the Child Node, the "Unknown 1" value is always "1", and the "Child Index" is the number of the added block, that you have written down in previous step 4.
Optionally, adjust the translation (i.e. the relative position of the light compared to the Shape). COMMIT, then CLOSE and RE-OPEN the CRES (so to update the Hierarchy).
http://thumbs.modthesims2.com/getimage.php?file=163409 (http://thumbs.modthesims2.com/getimage.php?file=163409)
6) Select again the CRES Hierarchy and select the (now shown) new light block. Open the "Unknown2" block and set the values as shown in picture (I don't know the meaning of all these values, but they seems identical in all the cLightRefNodes...). In particular, the value [7] must be set to the position numeber of the LGHT file in the CRES Reference list (the one that you have noted down in step 3).
http://thumbs.modthesims2.com/getimage.php?file=163416 (http://thumbs.modthesims2.com/getimage.php?file=163416)
6b) (Added thanks to the info provided by Calidan)
In the same tab, just above the "Unknown1" value, there is a "String[] Array" (the name may change according to the localized version of your .NET environment): open it by clicking on the little grey button with the three dots and write Practical in the text field. We are not sure why this is necessary, but probably the "Practical" value is needed to define the type of the block, and to instruct the game on how to manage it.
http://thumbs.modthesims2.com/getimage.php?file=174626 (http://thumbs.modthesims2.com/getimage.php?file=174626)
7) The object is now ready to work. We only need to adjust the parameters in the LGHT file: as explained, you have to set the RGB values for the light colour, the VAL1 for the intensity and the VAL7 for the Attenuation.
NOTE - As explained, the object of this example will not cast any "diffusion" light, because we only have added a LGHT file (a "direct" light).
In order for the object to cast a diffusion light, we have to import in the package a Text List 0x8E, extracted from a lamp that casts a light that we'd like for our object, too. But the Diffusion light will work only if your object uses the LampGlobals (i.e. it was cloned from a lamp); on the contrary, the Direct light works in every type of object.
:alarm: 7 - CREATORS GUIDELINE FOR A UNIFORM MODDING TECNIQUE :alarm
When creating a custom object that is intended to emit light, first off you should consider the following:
1) Does the object really need a diffusion light? If you are creating a candle, or a small, "intimate" lamp table, you don't need a diffusion light at all, and therefore a suitable LGHT file contained into the package is more than enough to create the direct light alone.
2) Does your object need a custom diffusion light? The game already contains definitions for a lot of nice diffusion lights: high lights, low lights, coloured lights... You can re-use one of the already defined lights: just clone a lamp that has a light that you like, read the value from the Text List 0x8E and paste it in your package (use that reference also as name for the cLightRefNodes in the CRES!).
3) OK, your object really needs a custom diffusion light. In this case you need to do the following:
install the CEP v.3.3 or newer: it enables support for custom light in the game, by adding a "wildInclude" command to the Lighting.txt; also, the CEP3.3 creates a folder called "CEP3_CustomLights" within the main Lights folder: all the custom .nlo files should be installed there, if you want the game to read them;
create a blank text file, rename it like the .package that contains your object and change the extension to .nlo;
edit the .nlo file, defining all the light attributes, as explained in paragraph 2;
put both the .package and .nlo in the same ZIP and upload it;
warn the users that - in order to use your object - they have to install the CEP 3.3, and then put the .nlo file in the folder: [gamedir]\EA Games\The Sims 2\TSData\Res\Lights\CEP3_CustomLights[/B].
:here: NOTE - Some older posts and threads, as well some older coloured light posted here on MTS2 used a different approach, that I strongly discourage: modifying the light definition of an existing (Maxis) light. I discourage it because this way you'll modify the behaviour of all the Maxis lamps that use that light definition. For example, if I create a red wall lamp, and modify the "lightingwallvalue_light", giving it a red tint, every Maxis cheap wall lamp in the game will emit a red light!
-------------------------------------------------------------------------------------
OTHER USEFUL RESOURCES
Modding Infocenter Index (http://www.modthesims2.com/search.php?titleonly=1&showposts=0&do=process&query=InfoCenter) - Comprehensive list of all the InfoCenter threads
Object Creation Workshop and Repair Center (http://www.modthesims2.com/showthread.php?t=82084) - If your object doesn't work, no matter what you try
The CRES File (http://www.modthesims2.com/showthread.php?t=84487) - To better understand the structure of the Resource Node.
-------------------------------------------------------------------------------------
LIGHTS AND "LGHT" FILES
Some (uncomplete) working notes
:new: MAJOR UPDATED 30 NOV 2005: PLEASE READ AGAIN :new:
:alarm: All creators please read Paragraph 7! :alarm:
DISCLAIMER: The "Modding InfoCenter" threads are NOT tutorials: they are intended to help average-experienced object creators performing specific tasks, or to give users a deeper in-sight on specific modding-related subjects. So, don't expect to find step-by-step explanations, to be performed "blindly".
Please DO NOT REPOST the following info, or part of them, on other sites.
All the "Modding InfoCenter" threads are created and mantained by Numenor and JWoods. Everyone is welcome to post his own questions or additional information about the specific thread subject.
-------------------------------------------------------------------------------------
SUMMARY
This InfoCenter articles has the purpose to explain how the lights are managed by the game, and what is the meaning and function of the LGHT files.
First off, let me state clearly that these notes are far from being complete; the LGHT file format hasn't been decoded completely, yet and some information are still missing or unknown. Every contribute is more than welcome! :)
:deal: This tutorial is also provided in PDF format. To view it, we strongly suggest to download the Foxisoft PFD Viewer (http://www.foxitsoftware.com/pdf/rd_intro.php): it's free and small, less than 1Mb!
http://thumbs.modthesims2.com/getimage.php?file=163363 (http://thumbs.modthesims2.com/getimage.php?file=163363)
1 - INTRODUCTION
In the game there are two types of lights: direct light, that hits the objects and the sims around the light source, and diffusion light, that is the ambient light and is reflected by walls and floors, and bleeds through windows.
Every lamp in the game emits both types of light, and therefore people often don't realize that they are managed in a different way by the game.
Infact, every object can emit direct light, but only lamps (i.e. objects that use the LampGlobals) can emit diffusion light.
:new: CORRECTION: all the objects can cast any light; only, the LampGlobals are always needed in order to turn the light on and off: some BHAVs from the LampGlobals must be manually imported in non-lamp objects, and they need to be adjusted, too. My suggestion is to clone a lamp, whenever possible.
:new: The light is defined and created within the game by means of four different, connected elements: the Lighting.txt file (located in the gamedir), the LGHT file, the TextList 0x8E and the Resource Node.
We'll see more in detail the purpose of each of them later on; let's start with an overwiew about the relations between the 4 elements.
The Lighting.txt (or better, the custom .nlo file: see part 2) is where both the direct and the ambient lights are created and defined; the settings contained in it will override any other setting. If a light is not defined in the .nlo file, or the definition doesn't set all the needed parameters, the game falls back on the LGHT file contained in the package; but the LGHT file can only define a direct light, and therefore, a missing definition in the .nlo file always prevents the object from casting diffusion light.
The Resource Node is where the object is associated with its light definition; in the CRES there is a cLightRefBlock that holds the reference to the light name, as defined into the .nlo file; the cLightRefNode is also used to translate and rotate the light.
Lastly, there's the TextList 0x8E. I'm not sure what is its purpose: in my experiments, if an object has a working light, putting a wrong reference in STR# 0x8E doesn't prevent the light from working. Probably it's just another fall-back value, i.e. is used by the game when the primary references to the light can't be found.
2 - THE "LIGHTING.TXT" AND THE ".NLO" FILES
As explained above, the Lighting.txt file defines all the lights, in both their "direct" and "diffuse" components. It is located in [GameDir]\EA Games\The Sims 2\Res\Lights. NOTE: there is a "lighting.txt" file for each EP gamedir: all of them are read when the game starts.
The "lighting.txt" file can instruct the game to load other external text files. These external files, in turn, can load more files.
This is done by specifying in the lighting.txt (or in the external file called by the lighting.txt) an "include" instruction, that can have one of these forms:
include "filename" -> This includes a specific file (that can have any extension, as long as it is a text file).
wildInclude "*.nlo" -> This includes all the text file with .nlo extension (again, the extension is irrelevant: you can use *.txt if you like).
sinclude "filename" -> The leading "s" stands probably for "single" or "standard"; I couldn't find any difference with the normal "include" command: it loads a specific text file (with any extension).
:here: NOTE - The game takes the "Lights" folder as root folder; the additional files specified in the various "include" commands can be located in a subfolder nested into the Lights forder, but not outside the Lights folder. (I've run a test with the downloads folder: unfortunately, the "include" commands can't find a file located there...). Please note that the paths defined in the "include" commands use the normal slash ("/") as separator, and not the backslash ("\").
In order to create a custom light, we need to create a text file (conventionally, the additional light definitions have extension .nlo, "New Light Override"). In this file, we need to define our light, by assigning specific values to some attributes.
The basic syntax is: lightAttribOverride customLightName_light Attribute Value. The "customLightName" is whatever we decide to call the light; to avoid confusions, I suggest to use the CRES name. The "Attribute" and the "Value" are contained in the following table, that contains all the attributes used in the game light definitions, and the values that Maxis used for them.
Parameter Name Min Max
------------------------------------------------
intensity n 0 12
color (R,G,B) 0 1
falloffRate n 0 5
coneAngle n 0 150 (degrees)
conePenumbra n 0 55 (degrees)
range n 1000 1000
diffusionSourceIntensity n 0 3.5
diffusionSourceColor (R,G,B) 0 1
diffusionSourceFalloff n 0.5 15
diffusionSourceMin (x, y) -0.5 0.2
diffusionSourceMax (x, y) 0 2
diffusionSourceFloorIntensityScale n 0.5 1
diffusionSourceWallIntensityScale n 0.9 1.5
diffusionSourceIsDirectional n 0 1 (boolean)
diffusionSourceDirectionalFalloff n 0 1 (boolean)
As you can see, some attributes define direct light and some others define the diffusion light. The purpose of some attributes is still unknown to me: here is explained what I could understand.
Intensity / DiffusionSourceIntensity - Self-explanatory; usually this value ranges from 0 (= no light) to 1 (= normal light); in some rare cases is 5 or even 12.
Color / DiffusionSourceColor - Self-explanatory; these parameters are useful to tweak the intensity, too: a value of 0.5,0.5,0.5 will produce a white light, but less bright than 1,1,1.
FallOffRate / diffusionSourceFalloff - Define how quickly the light will stop being visible; normal value = 0.5; (0 = infinite: the light will hit even extremely distant objects; high values = the light will hit only close objects).
ConeAngle / ConePenumbra - These values (expressed in degrees) represent the ray of the light cone, and the ray of the additional penumbra cone that surrounds the light cone. The sum of the two rays must be less than, or equal to, 180°.
DiffusionSourceFloorIntensityScale / DiffusionSourceWallIntensityScale - These are multipliers that define how much walls and floors reflect the light; usually, their value is 1 (= normal reflectivity); values less than 1 attenuate the reflectivity.
(All the remaning attributes are unknown to me)
3 - THE "LGHT" FILE
First off, let's clear up is that there are four different "LGHT" filetypes in the game: Ambient Light and Directional Light (mostly used in CAS screen), Spot Light (used for doors and windows), and Point Light (used for lamps and other objects that lit up).
All the information provided in this article refer to the "Point Lights", though they probably apply to other LGHT types, too (untested).
As explained in the Introduction, the LGHT file defines the direct light, but is used only if there isn't a correct definition into the Lighting.txt.
The attributes set in the LGHT file are partly coincident with the LightAttributeOverrides that we have examined in the previous paragraph; as far as I could see, only some of the attributes related to the direct light are included in the LGHT file, not all. But again, there are some unknown values in the LGHT, too; so, I can't be sure if some attrivùbutes are really missing from the LGHT file...
Opening the LGHT in SimPE we can find (and edit) the following values:
Val1 = "Intensity": see explanation above; usually set to 1.
Val2 = (Unknown); normal value = 1; known range = 0.5 -- 1.0.
Val6 = "FallOffRate": see explanation above.
Val7 = (Unknown); normal value = 20; known range = 0 -- 20.
R, G, B = "Colour": see explanation above.
There are several name reference within the LGHT file; though some of them seem only explanatory (i.e. don't have to match the names in the Lighting.txt, or the CRES, or the STR# 0x8E), it's a good habit to follow a strict naming convention:
Filename - It's the scenegraphic name of the file: it should be in the form cresName_customLightName_light_lght (where "customLightName" is the name defined in the .nlo text file).
"cPointLight" tab, "Name" field - Put here the name of the light only, i.e. customLightName_light.
"cLightT" tab, "Name" field - Put here the full LGHT filename: cresName_customLightName_light_lght.
"cObjectGraphNode" tab, "Filename" field - You can leave this empty.
4 - THE TEXT LIST 0x8E
This file holds the reference to the light name, as defined in the .nlo file (i.e. customLightName_light). As said, I'm not sure about the purpose of this TextList: if the reference is wrong, the light will work anyway...
5 - THE RESOURCE NODE
In order for the LGHT file to be seen by the game, it must be linked to the Resource Node (CRES): a link to the LGHT file must be added to the CRES, "Reference" tab.
:here: NOTE: the Reference list within the CRES relies on the TGI of the various files linked: if you rename the LGHT file, you have to click "Fix TGI", and then change the reference in the CRES.
Then, a cLightRefNode block must be added to the CRES hierarchy, and attached it to an existing branch (see example in paragraph 6).
The name of the cLightRefNode has to be set in the "cObjectGraph" tab: it must match the light name defined in the .nlo file, i.e. customLightName_light. If multiple cLightRefNodes are added to the CRES, and all of them are related to the same light definition, then all of them must have the same name.
Once the LGHT file is properly linked to the CRES, it may be used by the object. You might need to adjust the light position, by editing the translation values into the "cTransformNode" tab of the cLightRefNode block.
6 - AN EXAMPLE: ADDING A DIRECT LIGHT TO AN OBJECT - ***UNFINISHED!***
1) First off, we need a LGHT (Point Light) file: you can extract it from any lamp, or directly from the Objects01.package, located in the GameDir.
You can choose any LGHT file, as long as it is a "Point Light": we'll adjust its parameters to match our needs.
2) Import the LGHT file into your package and rename it; the structure of the LGHT filename is the following: CRESname_DiffusionLightName_light_lght. You just have to replace the first part (before the first underscore) with the CRES name of your object. Do this either in the main "Filename" field and in the "Name" field under the "cLightT" tab. Then FIX TGI and commit.
http://thumbs.modthesims2.com/getimage.php?file=163362 (http://thumbs.modthesims2.com/getimage.php?file=163362)
3) Open the CRES, "Reference" tab, and add a reference to the LGHT file: use the Package Selector Form as shown in picture to drag-and-drop the reference into the list. Take note of the position of the added reference in the list; in this example, the Lighting is in position #2 (the positions start from zero).
http://thumbs.modthesims2.com/getimage.php?file=163371 (http://thumbs.modthesims2.com/getimage.php?file=163371)
4) Add one "cObjectGraphNode (cLightRefNode)" block into the CRES ("Edit Blocks" tab). Take note of the number of the added block.
http://thumbs.modthesims2.com/getimage.php?file=163372 (http://thumbs.modthesims2.com/getimage.php?file=163372)
5) Include the newly added block in the CRES Hierarchy, by adding a "Child Node" into one of the existing branches (usually, main Shape, like in picture).
Note: while adding the Child Node, the "Unknown 1" value is always "1", and the "Child Index" is the number of the added block, that you have written down in previous step 4.
Optionally, adjust the translation (i.e. the relative position of the light compared to the Shape). COMMIT, then CLOSE and RE-OPEN the CRES (so to update the Hierarchy).
http://thumbs.modthesims2.com/getimage.php?file=163409 (http://thumbs.modthesims2.com/getimage.php?file=163409)
6) Select again the CRES Hierarchy and select the (now shown) new light block. Open the "Unknown2" block and set the values as shown in picture (I don't know the meaning of all these values, but they seems identical in all the cLightRefNodes...). In particular, the value [7] must be set to the position numeber of the LGHT file in the CRES Reference list (the one that you have noted down in step 3).
http://thumbs.modthesims2.com/getimage.php?file=163416 (http://thumbs.modthesims2.com/getimage.php?file=163416)
6b) (Added thanks to the info provided by Calidan)
In the same tab, just above the "Unknown1" value, there is a "String[] Array" (the name may change according to the localized version of your .NET environment): open it by clicking on the little grey button with the three dots and write Practical in the text field. We are not sure why this is necessary, but probably the "Practical" value is needed to define the type of the block, and to instruct the game on how to manage it.
http://thumbs.modthesims2.com/getimage.php?file=174626 (http://thumbs.modthesims2.com/getimage.php?file=174626)
7) The object is now ready to work. We only need to adjust the parameters in the LGHT file: as explained, you have to set the RGB values for the light colour, the VAL1 for the intensity and the VAL7 for the Attenuation.
NOTE - As explained, the object of this example will not cast any "diffusion" light, because we only have added a LGHT file (a "direct" light).
In order for the object to cast a diffusion light, we have to import in the package a Text List 0x8E, extracted from a lamp that casts a light that we'd like for our object, too. But the Diffusion light will work only if your object uses the LampGlobals (i.e. it was cloned from a lamp); on the contrary, the Direct light works in every type of object.
:alarm: 7 - CREATORS GUIDELINE FOR A UNIFORM MODDING TECNIQUE :alarm
When creating a custom object that is intended to emit light, first off you should consider the following:
1) Does the object really need a diffusion light? If you are creating a candle, or a small, "intimate" lamp table, you don't need a diffusion light at all, and therefore a suitable LGHT file contained into the package is more than enough to create the direct light alone.
2) Does your object need a custom diffusion light? The game already contains definitions for a lot of nice diffusion lights: high lights, low lights, coloured lights... You can re-use one of the already defined lights: just clone a lamp that has a light that you like, read the value from the Text List 0x8E and paste it in your package (use that reference also as name for the cLightRefNodes in the CRES!).
3) OK, your object really needs a custom diffusion light. In this case you need to do the following:
install the CEP v.3.3 or newer: it enables support for custom light in the game, by adding a "wildInclude" command to the Lighting.txt; also, the CEP3.3 creates a folder called "CEP3_CustomLights" within the main Lights folder: all the custom .nlo files should be installed there, if you want the game to read them;
create a blank text file, rename it like the .package that contains your object and change the extension to .nlo;
edit the .nlo file, defining all the light attributes, as explained in paragraph 2;
put both the .package and .nlo in the same ZIP and upload it;
warn the users that - in order to use your object - they have to install the CEP 3.3, and then put the .nlo file in the folder: [gamedir]\EA Games\The Sims 2\TSData\Res\Lights\CEP3_CustomLights[/B].
:here: NOTE - Some older posts and threads, as well some older coloured light posted here on MTS2 used a different approach, that I strongly discourage: modifying the light definition of an existing (Maxis) light. I discourage it because this way you'll modify the behaviour of all the Maxis lamps that use that light definition. For example, if I create a red wall lamp, and modify the "lightingwallvalue_light", giving it a red tint, every Maxis cheap wall lamp in the game will emit a red light!
-------------------------------------------------------------------------------------
OTHER USEFUL RESOURCES
Modding Infocenter Index (http://www.modthesims2.com/search.php?titleonly=1&showposts=0&do=process&query=InfoCenter) - Comprehensive list of all the InfoCenter threads
Object Creation Workshop and Repair Center (http://www.modthesims2.com/showthread.php?t=82084) - If your object doesn't work, no matter what you try
The CRES File (http://www.modthesims2.com/showthread.php?t=84487) - To better understand the structure of the Resource Node.
-------------------------------------------------------------------------------------