OpenGL VRML Shockwave 3D
Home Tutorials Books Applications Tools Docs Models Textures

Send me bugs and suggestions, please
VRML Script Tutorial
Full list

VRML Interactive Tutorial

Introduction
VRML File Structure
Drawing: Shape node
Geometry Nodes:
Box
Sphere
Cone
Cylinder
PointSet
IndexedLineSet
IndexedFaceSet
Extrusion
ElevationGrid
Example: Chessboard
Text
FontStyle
Appearance
Material
Textures
Image Texture
Movie Texture
Pixel Texture
Texture Coordinate
Texture Transform
Let there be Light
Directional Light
Point Light
Spot Light
Materials with Colored Lights
Hierarchical Node Structures
Group
Transform
Collision
Anchor
Billboard
Switch
Inlining Files
Defining and Instancing Nodes
Defining Levels of Detail
Events in VRML
Creating Paths between events: ROUTE
Generating Events based on Timers or User Actions
Timers
Touch Sensor
Visibility Sensor
Dragging Sensors
Plane Sensor
Sphere Sensor
Cylinder Sensor
Proximity Sensors
Example: Proximity sensor
Interpolators
Color
Coordinate
Normal
Orientation
Position
Scalar
Example
Let the Music Play
Sound
AudioClip
Bindable Nodes
Who Am I: NavigationInfo
Where Am I: ViewPoint
Adding Realism to the world
Background
Fog
Information about your world
WorldInfo
Definition for Auxiliary Nodes
Coordinate
Color
Normal

Switch Node


If you're not familiar to grouping nodes in VRML see the section Creating Hierarchical Node Structures for general information on grouping.

The Switch node is a grouping node with a difference. At most one of the children nodes are drawn. The whichChoice field specifies the index of which child is to be drawn. If whichChoice is -1 then none of the children are drawn.

Why do you want a grouping node which draws at most one of its children? In fact it is a very useful node as you shall see.

One possible use for this node is to have different versions of a given shape inside the Switch node. Setting whichChoice provides a quick way to change between these objects. Because this field is an exposed field it can receive events which can change the child to be drawn.

Another good use of this node is to have node definitions without drawing them, whichChoice set to -1. Using this approach the node definitions would be together in the file simplifying your life when you try to find a node's definition.

Note that the whichChoice determines only which child is drawn, however non-graphic nodes still take effect when present in a Switch node. For instance a TimeSensor node will generate events regardless of the value of whichChoice. In fact all nodes will generate and are able to receive events regardless of the whichChoice value.

Syntax:
Switch {
whichChoice -1
choice [ ]
}




Site designed and maintained by António Ramires Fernandes
Your comments, suggestions and references to further material are welcome!

Lighthouse 3D privacy statement