Switch

( tutorial )

Switch between  an empty world ,"vide.wrl" and  a non empty world .

When you arrive nothing  seems loaded , except the arrival world .

Click or have a ProxymitySensor and the right ( or rights * ) objects will be loaded .


#VRML V2.0 utf8

DEF dad_switch Transform {
children [      
DEF SWITCH Switch {
whichChoice 0
choice [   
Transform {
children [    Inline {url "http://.../vide.wrl"}]
}   
Transform {    translation    0 -2 0
children [   
Inline {url "http://.../galerieJP.wrl"}
]
}   
]}

Transform {     
children [ 
DEF    Sensor TouchSensor{}
       
Transform {     translation 1 -.5 0
children [
Shape {
appearance Appearance {

geometry Box { size .1 .1 .1  }
}
]
}
]
}
]
}
DEF SCRIPT Script {
eventIn SFBool clicked
eventOut SFInt32 which
field SFInt32 num 0
url "vrmlscript:
function clicked(val) {
if(val) {
num = (num + 1) % 2;
which = num;
}
}
"
}

ROUTE SCRIPT.which TO SWITCH.whichChoice
ROUTE Sensor.isActive TO SCRIPT.clicked

Viewpoint {position    0 0 2
description "Entry"
}

**To get several objects , put them in the  Switch and be sure to have the right number in the script :


num = (num + 1) % 2;   .... or 3 , or 4 , etc
 _________________________________________________________________________

Vrml...........................

artvrml/wrl/switchtuto.wrl
______________________________________________________________________

Sommaire.................

Intro

______________________________________________________________________



Switch

( tutorial )


_________________________________________________________________________

Vrml...........................

artvrml/wrl/switchtuto.wrl

______________________________________________________________________

Contents....................

Intro

_______________________________________________________________________