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.
- Include the necessary headers:
#include <osg/Switch> #include <osgDB/ReadFile> #include <osgViewer/Viewer>
- Declare the
AnimatingSwitch
class. This will be derived from theosg::Switch
class to take advantage of thesetValue()
method. We also ...
Get OpenSceneGraph 3.0 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.