The Switch Helper can be used to add complex interactivity to the scene. The Switch can contain multiple objects (pieces of geometry or lights f.i.) that can be switched between using the Switch. In order to actively use it, the Switch must be accessible.
[Image:Osgswitchdemo1.png]
First object in the Switch: a box
[Image:Osgswitchdemo2.png]
Second object in the Switch: a teapot
[Image:Osgswitchdemo3.png]
Third object in the Switch: a sphere
The example shows an implemented switch containing three objects. To view the different states of the switch you will need a viewer that supports the changing of switches. This example can be downloaded as an archive[file:dsSwitch.zip], containing the .MAX and the .OSG-files
This example shows how the Switch-node is represented in an OSG-file. This particular node ("OSG_Switch01")allows you to switch between 3 pieces of geometry, namely GeoSphere01, Pyramid01 and TeaPot01. These are children-nodes of the Switch node.
... Switch { DataVariance STATIC name "OSG_Switch01" nodeMask 0xff cullingActive TRUE NewChildDefaultValue 1 ValueList { 1 1 1 } num_children 3 MatrixTransform { DataVariance STATIC name "GeoSphere01" nodeMask 0xff cullingActive TRUE referenceFrame RELATIVE_TO_PARENTS ... } MatrixTransform { DataVariance STATIC name "Pyramid01" nodeMask 0xff cullingActive TRUE referenceFrame RELATIVE_TO_PARENTS ... } MatrixTransform { DataVariance STATIC name "Teapot01" nodeMask 0xff cullingActive TRUE referenceFrame RELATIVE_TO_PARENTS ... } }