#VRML V2.0 utf8 # #
#return :[colorInt], [positionInt], [orientationInt] #

# ex-interpolators.wrl
# Written By Leo
# Last Modified May, 14 /97

# this example introduces the use of interpolation to :
#  . modify the position of a sphere (PositionInterpolator)
#  . modify the color of a cube (ColorInterpolation)
#  . rotate a cube (OrientationInterpolator)
# the node TimeSensor is the animation clock
# (see at the end the ROUTE associations)

# Camera
Viewpoint {
   position    0 5 18
   orientation 1 0 0 -0.24
   fieldOfView 0.785398
}

Group {
  children [
     DEF CON Transform { 
          translation 1 0 0
          children Shape { 
#            geometry Cone {bottomRadius 2
#                           height 3 } 
             geometry Box {}
               appearance Appearance { 
                 material Material { diffuseColor 1 0 0 } 
                                      } 
                           } 
                        } 
     Transform {
         translation -3.4 .2 1
         rotation 0 1 1 .9
           children [	
                 Shape { 
                   geometry Box {}
                   appearance Appearance {
                       material DEF MATERIAL Material {} 	
                                          }
                        }
                    ]
                }
     DEF MOV_OBJ Transform {
         translation -8 0 0
	 children [
		Shape{
		  geometry Sphere { radius 0.7 }
		  appearance Appearance {
			 material Material {
				      diffuseColor 1 1 0
				            }
				         }
		      }	
	           ] 
			    }

             ]
       }


# Timer
DEF TIMER TimeSensor {
	loop TRUE
	cycleInterval 7
	     	      }

# Trajectories for the sphere
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[-8 0 0, -7 -4 0, -4 -6 0, 0 -7 0, 2.75 -5 0, 4 -3 0, 
	      5 0 0, 4 3 0, 2.75 5 0,  0 7 0,  -4 6 0, -7 4 0,
	     -8 0 0]		         }
# Colours for the Cube
DEF myColor ColorInterpolator {
                 key [0.0, 0.3, 0.6, 1.0 ]
                 keyValue [1 0 0 , 0 1 0, 1 0 0, 0 0 1]
                               }
# Rotate Cone
DEF ENGINE OrientationInterpolator {
                 key [ 0, .5, 1]
                 keyValue [ 0 1 0 0, 0 1 0 3.14, 0 1 0 6.28]
                                    }

#run interpolators : INTERP , ENGINE, myColor
ROUTE TIMER.fraction_changed TO INTERP.set_fraction
ROUTE TIMER.fraction_changed TO ENGINE.set_fraction
ROUTE TIMER.fraction_changed TO myColor.set_fraction


#associate interpolators and geometry : 
# cone rotation, cube color, sphere trajectory

ROUTE ENGINE.value_changed TO CON.set_rotation
ROUTE myColor.value_changed TO MATERIAL.diffuseColor
ROUTE INTERP.value_changed TO MOV_OBJ.translation

#