Version 1 (modified by martin, 7 years ago)

--

OSG Switch

General

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.

Possible usage

  • Multiple design alternatives can be added to a scene and alternately shown in real-time.
  • Change the way furniture is placed in the scene by providing several alternatives.
  • Make things (dis)appear by providing a very small piece of geometry for them (such as a 1x1mm plane).
  • Switch through the different options using the mouse wheel.

To create a Switch in MAX

  • Create some geometry;
  • Add a Switch Helper object to the scene;
  • Use the Add-button on the Modfy Pane to add the geometry to the Switch;

Other options

  1. Add: add an object to the switch. The order in which objects are added is the order in which they will appear in the Switch
  2. Remove: remove the selected object from the Switch
  3. Add multiple: lets you add more then one object

Demonstration

First object in the Switch: a box

Second object in the Switch: a teapot

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, containing the .MAX and the .OSG-files

Code Example

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 GeoSphere?01, Pyramid01 and TeaPot?01. 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
      ...
    }
 }

More information

Attachments