Torque/LightingSystem/Creating Lights

From TDN

Introduction

How to create lights using the Torque Lighting System.

Contents


What is a Light?

Torque Lighting System lights consist of two components; the light datablock and the light object. In Torque's object/datablock architecture, datablocks contain static data, which is shared among multiple objects. This makes configuring and updating multiple objects extremely easy, as changes to the datablock affect all objects that reference it.

Following this model light datablocks contain common lighting information, such as color, intensity, and type (omni/spotlight), which is shared between multiple light objects. Light objects are the physical light locations placed in the scene, which provide the actual illumination.

Creating a Light Datablock

The first step in creating a light is to create its datablock (if the light will use an existing datablock then skip ahead to creating the light object) using the Torque Lighting System's Light Editor (F12 in the mission editor or alt+g in TGEA). There are two ways to create a new datablock; creating a new blank datablock using the menu item File -> New..., or selecting a similar datablock and cloning it using the menu item File -> Clone....

When creating your datablock you must not have spaces in the name. Doing so will cause your datablock to not show when searching for it to create your light object. An example is as follows:

Radio Tower Light (Wrong) RadioTowerLight (Correct)



Image:TLK-NewDB.jpg

Creating a Light Object

The next step is to create the light object that will add illumination to the scene. Light objects are created using the Torque Mission Editor's Object Creator (which is used to create most mission objects, including interiors, statics and items). Light objects are located in the Object Creator's tree of available objects under Mission Objects -> environment -> sgLightObject (sgUniversalStaticLight for TLK). When prompted select the datablock you'd like to asign the light object from the drop down list.

(Because datablocks are shared between light objects, changing the parameters of a datablock affects all the lights using that datablock. This makes editing multiple lights extremely fast and easy.)

Making a Light Unique

Occasionally a single light needs adjusted even though it shares a datablock with several other light objects. To adjust only one light, it needs to have a unique datablock. To accomplish this select the light's current datablock in the Light Editor and clone it using File -> Clone..., then using the Mission Editor's Object Inspector select the target light object and change its datablock to the newly created unique datablock.