media @ VU
[] readme course preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthoughts appendix references examples resources _

talk show tell print

x-ball-result-1.vr

x-ball-result-1.vr (wrl ) [ flux / bitmanagement / cortona / octaga ]


  
  #Peter Rutgers, 6-4-2006

  

  Transform {

          children [

                  Transform {

                          translation 0 -10 0

                          children [

                                  Shape {

                                  geometry Box { size 10 0.2 10 }

                                  appearance Appearance {

                                  material DEF GROUND Material {

                                  diffuseColor 1 1 1

                          }

                          }

                                  }

                          ]

                  }

                  Transform {

                          translation -5 0 0

                          children [

                                  Shape {

                                  geometry Box { size 0.2 20 10 }

                                  appearance Appearance {

                                  material DEF LEFT Material {

                                  diffuseColor 1 1 1

                          }

                          }

                                  }

                          ]

                  }

                  Transform {

                          translation 0 0 -5

                          children [

                                  Shape {

                                  geometry Box { size 10 20 0.2 }

                                  appearance Appearance {

                                  material DEF ACHTER Material {

                                  diffuseColor 1 1 1

                          }

                          }

                                  }

                          ]

                  }

                  Transform {

                          translation 0 0 5

                          children [

                                  Shape {

                                  geometry Box { size 10 20 0.2 }

                                  appearance Appearance {

                                  material DEF VOOR Material {

                                  diffuseColor 1 1 1

                                                          transparency 0.7

                          }

                          }

                                  }

                          ]

                  }

                  Transform {

                          translation 5 0 0

                          children [

                                  Shape {

                                  geometry Box { size 0.2 20 10 }

                                  appearance Appearance {

                                  material DEF RIGHT Material {

                                  diffuseColor 1 1 1

                          }

                          }

                                  }

  

                      ]

                  }

  

                  DEF OBJECT Transform {

                          translation        3 4 0

                          scale 0.5 0.5 0.5

                          children [ 

                                  Shape  {

                                  geometry Sphere { radius 1 }

                                  appearance Appearance {

                                  material DEF MATERIAL Material {

                                      diffuseColor 1 0 0

                                  }

                              }

                                  }

                          ] 

                  }

  

  

                  DEF OBJECT2 Transform {

                          translation        -2 0 0

                          scale 0.5 0.5 0.5

                          children [ 

                                  Shape  {

                                  geometry Sphere { radius 1 }

                                  appearance Appearance {

                                  material DEF MATERIAL2 Material {

                                  diffuseColor 0 0 1

                          }

                          }

                                  }

                          ] 

                  }

                  DEF OBJECT3 Transform {

                          translation        8 2 0

                          scale 0.5 0.5 0.5

                          children [ 

                                  Shape  {

                                  geometry Sphere { radius 1 }

                                  appearance Appearance {

                                  material DEF MATERIAL3 Material {

                                  diffuseColor 0 1 0

                          }

                          }

                                  }

                          ] 

                  }

          ]

  }

  

  

  

  DEF TIME TimeSensor { loop TRUE cycleInterval 5 } 

  

  

  DEF SCRIPT Script {   

      directOutput TRUE

  

      field  SFTime  tick   0

  

      field SFNode object USE OBJECT

      field SFNode object2 USE OBJECT2

      field SFNode object3 USE OBJECT3

      field SFNode material USE MATERIAL

      field SFNode material2 USE MATERIAL2

      field SFNode material3 USE MATERIAL3

      field SFNode ground USE GROUND

      field SFNode left USE LEFT

      field SFNode right USE RIGHT

      field SFNode voor USE VOOR

      field SFNode achter USE ACHTER

      field SFFloat position 2

      field SFFloat xposition -2

      field SFFloat zposition 3

      field SFFloat color 0.5

      field SFInt32 sign 1

      field SFInt32 xsign 1

      field SFInt32 zsign 1

      field SFFloat speed 1

      field SFFloat xspeed 20

      field SFFloat zspeed 20

      field SFFloat position2 4

      field SFFloat xposition2 2

      field SFFloat zposition2 -4

      field SFFloat color2 0.5

      field SFInt32 sign2 1

      field SFInt32 xsign2 1

      field SFInt32 zsign2 1

      field SFFloat speed2 1

      field SFFloat xspeed2 20

      field SFFloat zspeed2 20

      field SFFloat position3 0

      field SFFloat xposition3 0

      field SFFloat zposition3 -1

      field SFFloat color3 0.5

      field SFInt32 sign3 1

      field SFInt32 xsign3 1

      field SFInt32 zsign3 1

      field SFFloat speed3 1

      field SFFloat xspeed3 20

      field SFFloat zspeed3 20

  

      eventIn SFFloat set_fraction    

      url "javascript:

  

  

      function set_fraction(value) { 

          if (tick == 0) {

              tick = value;

              color = 0.5;

              color2 = 0.5;

              color3 = 0.5;

          }

          while (tick < value) {

              update(value);

              tick = tick + 0.05;

          }

          tick = value;

      }

  

  

      function update(value) {

                  position += 0.01 * sign * speed;

          position2 += 0.01 * sign2 * speed2;

          position3 += 0.01 * sign3 * speed3;

          xposition += 0.01 * xsign * xspeed;

          xposition2 += 0.01 * xsign2 * xspeed2;

          xposition3 += 0.01 * xsign3 * xspeed3;

          zposition += 0.01 * zsign * zspeed;

          zposition2 += 0.01 * zsign2 * zspeed2;

          zposition3 += 0.01 * zsign3 * zspeed3;

  

          color = value;

          if (value > 0.7) {color2 = value - 0.7;} else {color2 = value + 0.3;};

          if (value > 0.4) {color3 = value - 0.4;} else {color3 = value + 0.6;};

  

          speed = speed * ( 1  - sign * 0.1);

          speed2 = speed2 * ( 1  - sign2 * 0.1);

          speed3 = speed3 * ( 1  - sign3 * 0.1);

   

          object.translation.y = position;

          object2.translation.y = position2;

          object3.translation.y = position3;

          object.translation.x = xposition;

          object2.translation.x = xposition2;

          object3.translation.x = xposition3;

          object.translation.z = zposition;

          object2.translation.z = zposition2;

          object3.translation.z = zposition3;

  

                  material.diffuseColor = new SFColor(1,color,color);

                  material2.diffuseColor = new SFColor(color2,color2,1);

                  material3.diffuseColor = new SFColor(color3,1,color3);

  

          if (speed < 0.5) sign = -1; 

          if (speed2 < 0.5) sign2 = -1; 

          if (speed3 < 0.5) sign3 = -1; 

  

          if (position < -9) {

              effect(1,color,color);

                          speed = speed * 0.8;

                          if (speed < 0.4) speed = 170;

              sign = 1;

          } 

          if (position2 < -9) {

              effect(color2,color2,1);

                          speed2 = speed2 * 0.8;

                          if (speed2 < 0.4) speed2 = 170;

              sign2 = 1;

          } 

          if (position3 < -9) {

              effect(color3,1,color3);

                          speed3 = speed3 * 0.8;

                          if (speed3 < 0.4) speed3 = 170;

              sign3 = 1;

          } 

  

          if (xposition > 4.5) {

                          xsign = -1;

                          effectr(1,color,color);

                  }

          if (xposition < -4.5) {

                          xsign = -1;

                          effectl(1,color,color);

                  }

          if (xposition < -4.5) xsign = 1;

  

          if (xposition2 > 4.5) {

                          xsign2 = -1;

                          effectr(color2,color2,1);

                  }

          if (xposition2 < -4.5) {

                          xsign2 = -1;

                          effectl(color2,color2,1);

                  }

          if (xposition2 < -4.5) xsign2 = 1;

  

                  if (xposition3 > 4.5) {

                          xsign3 = -1;

                          effectr(color3,1,color3);

                  }

          if (xposition3 < -4.5) {

                          xsign3 = -1;

                          effectl(color3,1,color3);

                  }

          if (xposition3 < -4.5) xsign3 = 1;                

  

  

          if (zposition > 4.5) {

                          zsign = -1;

                          effectv(1,color,color);

                  }

          if (zposition < -4.5) {

                          zsign = -1;

                          effecta(1,color,color);

                  }

          if (zposition < -4.5) zsign = 1;

  

          if (zposition2 > 4.5) {

                          zsign2 = -1;

                          effectv(color2,color2,1);

                  }

          if (zposition2 < -4.5) {

                          zsign2 = -1;

                          effecta(color2,color2,1);

                  }

          if (zposition2 < -4.5) zsign2 = 1;

  

                  if (zposition3 > 4.5) {

                          zsign3 = -1;

                          effectv(color3,1,color3);

                  }

          if (zposition3 < -4.5) {

                          zsign3 = -1;

                          effecta(color3,1,color3);

                  }

          if (zposition3 < -4.5) zsign3 = 1;                

  

  

  

          

  

                  if  (   Math.abs(position2 - position) < 1.2 ) { 

                  if  (   Math.abs(xposition2 - xposition) < 1.2 ) {

                  if  (   Math.abs(zposition2 - zposition) < 1.2 ) {

                              xsign = - xsign;

                                  xsign2 = - xsign2;

                              zsign = - zsign;

                                  zsign2 = - zsign2;

                                  sign = - sign;

                                  sign2 = - sign2;

                      }

                  }

                  }

                  if  (   Math.abs(position3 - position) < 1.2 ) { 

                  if  (   Math.abs(xposition3 - xposition) < 1.2 ) {

                  if  (   Math.abs(zposition3 - zposition) < 1.2 ) {

                              xsign = - xsign;

                                  xsign3 = - xsign3;

                              zsign = - zsign;

                                  zsign3 = - zsign3;

                                  sign = - sign;

                                  sign3 = - sign3;

                      }

                  }

                  }

                  if  (   Math.abs(position2 - position3) < 1.2 ) { 

                  if  (   Math.abs(xposition2 - xposition3) < 1.2 ) {

                  if  (   Math.abs(zposition2 - zposition3) < 1.2 ) {

                              xsign3 = - xsign3;

                                  xsign2 = - xsign2;

                              zsign3 = - zsign3;

                                  zsign2 = - zsign2;

                                  sign3 = - sign3;

                                  sign2 = - sign2;

                              

                      }

                  }

                  }

             

                  

  

  

  

      }

  

      function effect(value1,value2,value3) {

          ground.diffuseColor = new SFColor(value1,value2,value3);

      }

      function effectl(value1,value2,value3) {

          left.diffuseColor = new SFColor(value1,value2,value3);

      }

      function effectr(value1,value2,value3) {

          right.diffuseColor = new SFColor(value1,value2,value3);

      }

      function effectv(value1,value2,value3) {

          voor.diffuseColor = new SFColor(value1,value2,value3);

      }

      function effecta(value1,value2,value3) {

          achter.diffuseColor = new SFColor(value1,value2,value3);

      }

      "

  }

  

  ROUTE TIME.fraction_changed TO SCRIPT.set_fraction

  

  

  

  PointLight { location         0 0 0  }

  Viewpoint { position 0 0 30 }

  Background { skyColor 0.2 0.2 0.4 }

  

  

  


(C) A. Eliëns 21/5/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.