A Switch
is a special grouping node in VRML which allows you to switch between between
a number of objects or groups of objects. A Switch node is activated
when it receives an integer from a script into its whichChoice field.
So if it receives the number 3 it will display the 4th child object or group
of objects (numbering starts from 0).
Switches are most often used for turning things on and off or switching between a number of alternatives eg. a user could click a sofa to see how different designs look in a living room.
In this exercise we will be using switches for the flash texture and the LCD screen on the back of the camera. In the scripting exercise to follow we will connect the necessary routes to make these switches operate.
back to top | return to Complex Interations
Download and unzip the following file (using WinZip) into the relevant folder of your working directory.
camera_sensored.zip (47Kb)
This file contains:
- camera_sensored.wrl
all_textures.zip (158Kb)
This file contains:
- battery.png*
- camera.png*
- flash.png
- icon1.png*
- icon2.png*
- icon3.png*
- icon4.png*
- lcd_image_record.jpg
- lcd_mpeg_record.jpg
- lcd_playback.jpg
- lcd_startup.jpg
- lens.jpg*
- logos.png*
- memory_stick.png*
* indicates this texture not used in this part of the tutorial.
back to top | return to Complex Interations
![]() |
|
| Ensure Interactive Paste Placement is off (remove the tick if necessary). | ![]() |
| Select the LCD screen on the back of the camera and name it screen1. | ![]() |
|
Name the copies screen2, screen3 and blankScreen. Select each of the screens in turn and apply a different LCD texture to each. On the last screen named blankScreen remove the texture altogether. |
![]() |
| Select all 4 screens in the Outline Editor and click the Switch
node grouping icon |
![]() |
| Drill-down into the whichChoice field and change the value to 0 (this is our default value - screen1). | ![]() |
|
Now for the flash. Create a new face |
![]() |
|
Create a Switch This makes the flash invisible by default and the control script will simply toggle briefly to 0 to display the flash. |
![]() |
| The last thing we need to do is move this newly created object up the scene graph until it is in the lens group, otherwise rotating the lens will result in the flash being left behind. | ![]() |
| Note: neither of the 2 switches we have set up will do anything until the control script is wired up. | |
back to top | return to Complex Interations