-
Book Overview & Buying
-
Table Of Contents
OpenSceneGraph 3.0: Beginner's Guide
By default, OSG automatically turns on the first light (GL_LIGHT0) and gives the scene a soft, directional light. However, this time we will create multiple lights by ourselves, and move them with transformation parent nodes. Be aware: only positional lights can be translated. A directional light has no origin and cannot be placed anywhere.
OpenGL and OSG both use the fourth component of the position parameter to decide if a light is a point light. That is to say, if the fourth component is 0, the light is treated as a directional source; otherwise it is positional.
Include the necessary headers:
#include <osg/MatrixTransform> #include <osg/LightSource> #include <osgDB/ReadFile> #include <osgViewer/Viewer>
We create a function to create light sources for the scene graph. A light source should have a number (ranging from 0 to 7), a translation position, and a color parameter. A point light is created because the fourth...
Change the font size
Change margin width
Change background colour