19.4 Lights

19.4 Lights

An important aspect of any 3D scene is lighting. OGRE supports lights of different kinds, and each performs much the same role as natural and artificial light in our real world. Their primary purpose is to illuminate the scene, but they can also be used to achieve various kinds of special effects related to light. Lights are also valuable for the computation of shadows.

There are four kinds of lights in OGRE: ambient light, spotlight, directional light, and point light. All of these light types can be included in the scene and each affects how a scene is rendered to the display.

19.4.1 Ambient Light

Ambient light is a special kind of light, primarily because it has no position or direction. With this type of lighting, the light is evenly dispersed throughout a scene. Ambient light can be set to different colors and have a variation of brightness. The code at the end of this section sets the ambient light of a scene.

19.4.2 Point Light

A point light has a position in the scene and emits light of any color, equally in all directions.

19.4.3 Spotlight

A spotlight has both position and direction, and it works much like a spotlight in the real world.

19.4.4 Directional Light

Directional light is useful for creating very large light sources, like the sun. For the purposes of OGRE, these lights have no position and only direction.

Consider the following code to create a sample scene light:

      // Create a light with a name to identify it      Light* myLight = mSceneMgr->createLight("Light0");      myLight->setType(Light::LT_POINT);      myLight->setPosition(0, 40, 0);      myLight->setDiffuseColour(1, 1, 1);      myLight->setSpecularColour(1, 1, 1); 

Introduction to Game Programming with C++
Introduction to Game Programming with C++ (Wordware Game Developers Library)
ISBN: 1598220322
EAN: 2147483647
Year: 2007
Pages: 225
Authors: Alan Thorn

Similar book on Amazon
Beginning C++ Through Game Programming
Beginning C++ Through Game Programming
Beginning Game Programming
Beginning Game Programming
The Ultimate Guide to Video Game Writing and Design
The Ultimate Guide to Video Game Writing and Design

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net