Next, we will see how to manage lights.
Clear the scene graph.
Add a GNode to the root node and name it "Dragon".
Add an OglModel to the Dragon node, and set the Path to the model to /Sofa/share/mesh/dragon.obj.
By default, a (positional) light is present in the OpenGL Viewer, for those who do not want to mess with it. But if you want to tweak your scene, you may want to modify this light or add other lights.
In order to do that, first you need to add a LightManager, without any kind of parameters (We will see later why we need it). After that, you can add up to the maximum number of lights permitted by OpenGL, which is 8 on most common systems.
Add a LightManager component to the root node. Rename it "lightManager".
There are 3 kinds of lights in SOFA. They are basically the same as in OpenGL :
color is a common parameter for all these 3 lights.
SpotLight has other non-essential parameters : cutoff and exponent (default value may suffice).
Add three Spotlight components to the root node. Name one "redLight", one "greenLight", and one "blueLight".
In the redLight, set the color of the light to (1 0 0) and the position to (-5 -2.5 20).
In the greenLight, set the color of the light to (0 1 0) and the position to (0 2.5 20).
In the blueLight, set the color of the light to (0 0 1) and the position to (5 -2.5 20).
Run in SOFA
LightManager and *Light must be in the root node if you want your whole scene to be lighted.