Time for action - animating the switch node

The osg::Switch class can display specified child nodes while hiding others. It could be used to represent the animation states of various objects, for instance, traffic lights. However, a typical osg::Switch node is not able to automatically switch between children at different times. Based on this idea, we will develop a new AnimatingSwitch node, which will display its children at one time, and reverse the switch states according to a user-defined internal counter.

  1. Include the necessary headers:
    #include <osg/Switch>
    #include <osgDB/ReadFile>
    #include <osgViewer/Viewer>
    
  2. Declare the AnimatingSwitch class. This will be derived from the osg::Switch class to take advantage of the setValue() method. We also ...

Get OpenSceneGraph 3.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.