Time for action - animating the switch node
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.
- Include the necessary headers:
#include <osg/Switch> #include <osgDB/ReadFile> #include <osgViewer/Viewer>
- Declare the
AnimatingSwitchclass. This will be derived from the
osg::Switchclass to take advantage of the
setValue()method. We also ...