#VRML V2.0 utf8 # #
#[return] #

#ex-proximitysensor.wrl
# example of ProximitySensor node
 
# based on an example written By Fabiana
# Modified by Leo - 10-Sept-97

#  in this example when the user enters the cube region (white one)
#  the sensor will  start the interpolator and interpolate a path
#  for the green cube
#  REMEMBER : to start the sensor you have to move the viewer to the
#             sensitive region
#########

# viewer initial position
Viewpoint {position 0 0 15} 

DEF PrSensor ProximitySensor {
                         center 0 0 5
                         size  8 8 8
                         enabled TRUE
                              }
# rest / move cube
DEF XBox Transform {
             translation 3 3 0
             rotation 1 1 0 -.7
             children [
                  Shape { 
                    geometry Box {
                               size 1 1 1
                                  }
                    appearance Appearance {
                               material Material { diffuseColor 0 1 0
#                                                   specularColor 0 1 0
                                                  }
                                           }
                         }
                       ]
                     }

# "image" of the sensitive region
Shape { 
       geometry Box {
                     size 1 1 1
                     }
       }
# Timer
#  parameter loop = TRUE will be set by the ProximitySensor
DEF TIMER TimeSensor {
	cycleInterval 7
	     	      }

# Trajectory for the green cube
DEF INTERP PositionInterpolator {
    key [0, 0.0833, 0.167, 0.25, 0.333, 0.417, 0.5, 0.583, 
         0.667, 0.75, 0.833, 0.917, 1]
    keyValue[-4 0 0, -3 0 0, -2 0 0, -1 0 0, 0 0 0, 2 0 0, 
	      3 0 0, 4 0 0, 5 0 0,  6 0 0,  5 0 0, 4 0 0,
	     -4 0 0]		         }
            
# initialize green box translation movement
ROUTE PrSensor.isActive TO TIMER.set_loop
ROUTE TIMER.fraction_changed TO INTERP.set_fraction
ROUTE INTERP.value_changed TO XBox.set_translation

#