#
#ex-route.wrl # example of use of sensors and route (and DEF for internal reuse) # by Fabiana March, 97 # In this example when you touch the ball (mouse right button) # the text will move in the horizontal direction. When you touch # the box the text will move in the vertical direction # see more details in [details] #VRML V2.0 utf8 Viewpoint { position 0 0 50} Group { children [ Transform{ translation -4 8 0 children [ Shape{ geometry Sphere{radius 1.5} appearance Appearance{ material Material{ diffuseColor .73 .56 .56} } } DEF STOUCH TouchSensor{} ] } Transform{ translation 4 8 0 children [ Shape{ geometry Box {size 2 2 2} appearance Appearance{ material Material{ diffuseColor 0 1 0} } } DEF BTOUCH TouchSensor{} ] } DEF XTIMERH TimeSensor{ cycleInterval 2} DEF XTIMERV TimeSensor{ cycleInterval 2} DEF ANIMAH PositionInterpolator{ keys [ 0, .25, .5, .75, 1] values[ 0 0 0, 8 0 0, 16 0 0, -8 0 0, 0 0 0]} DEF ANIMAV PositionInterpolator{ keys [ 0, .25, .5, .75, 1] values[ 0 0 0, 0 -8 0, 0 -16 0, 0 -8 0, 0 0 0]} DEF SFORM Transform{ children Shape{ geometry Text{ string["Virtual"] fontStyle FontStyle{ style "BOLD" justify "MIDDLE" } length[7] maxExtent 20 } } } ] } ROUTE STOUCH.touchTime TO XTIMERH.set_startTime ROUTE XTIMERH.fraction TO ANIMAH.set_fraction ROUTE ANIMAH.value_changed TO SFORM.set_translation ROUTE BTOUCH.touchTime TO XTIMERV.set_startTime ROUTE XTIMERV.fraction TO ANIMAV.set_fraction ROUTE ANIMAV.value_changed TO SFORM.set_translation