-
Book Overview & Buying
-
Table Of Contents
OpenSceneGraph 3.0: Beginner's Guide
Do you remember that we have designed an animated switch node in Chapter 5, Managing Scene Graph? It is derived from osg::Switch, but will automatically change the states of its first two children according to an internal counter, through overriding the traverse() virtual method.
Now we would like to redo the same task, but this time using the update callback mechanism. This requires customizing a new class derived from the osg::NodeCallback base class, and overriding the operator() to perform the execution in the callback implementaton.
Include the necessary headers:
#include <osg/Switch> #include <osgDB/ReadFile> #include <osgViewer/Viewer>
Declare the SwitchingCallback class. It is an osg::NodeCallback based class, which can soon be used as update, event, or cull callbacks of scene nodes. The only important virtual method to implement is operator(). This is automatically called during the update, event, or cull traversal...
Change the font size
Change margin width
Change background colour