Switch nodes
The osg::Switch
node is able to render or skip specific children conditionally. It inherits the methods of osg::Group
super class and attaches a Boolean value to each child node. It has a few useful public methods:
The overloaded
addChild()
method is able to have a Boolean parameter in addition to theosg::Node
pointer. When the Boolean parameter is set to false, the added node will be invisible to the viewer.The
setValue()
method will set the visibility value of the child node at the specified index. It has two parameters: the zero-based index and the Boolean value. AndgetValue()
can get the value of child node at the input index.The
setNewChildDefaultValue()
method sets the default visibility for new children. If a child is simply added without specifying a value, its value will be decided bysetNewChildDefaultValue()
, for instance:switchNode->setNewChildDefaultValue( false ); switchNode->addChild( childNode ); // Turned off by default now!