A SERVICE OF

logo

92
Chapter 8: Lighting and Fog
Limiting the Scope of Lights
csEnvironment denes the scope of environmental effects, such as how far light from a
csLight object can travel. When you create a virtual room, the goal is to make a lamp in
the room shine in the room onlynot leak through walls into the hallway. When you
make a csLight part of the light array in csEnvironment, the lamp light stops at the walls
of the room.
Another application of csEnvironment is rendering headlights on a car. The goal is to
have the lights move with the car and extend only a couple of hundred feet in front of the
car. To do that, you add a csPointLight to the csEnvironment light array and limit the
csPointLight to several hundred feet.
The Scope of the Light Array
The csEnvironment node serves as the root node for the effects of all lights in its array.
csEnvironment uses an array of lights because you might have more than one csLight in
a room, but the light from all of the lamps should end at the walls of the room. All
csLights in the light array have the same range limitations.
csEnvironment Methods
csEnvironment contains the following method that species an array of lights:
csMFRef* light() const;
For example, if you wanted to add two lights but remove a third, you would use code
similar to the following:
// create an Environment
csEnvironment* park = new csEnvironment;
...
// find and remove light #3
csLight* badLight = park->getLight(3);
park->light()->remove(badLight);
//create two lights
csSpotLight* spot = new csSpotLight;
csPointLight* flood = new csPointLight;