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.
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.
A point light has a position in the scene and emits light of any color, equally in all directions.
A spotlight has both position and direction, and it works much like a spotlight in the real world.
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);