media @ VU
[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

talk show tell print

vrml-math-PentaWeb.vr

vrml-math-PentaWeb.vr (wrl ) [ flux / bitmanagement / cortona / octaga ]


  
  
  NavigationInfo{ type "EXAMINE" }
  Viewpoint{ description "start"}
  Background{ skyColor 0 0 .75}
  DEF Clock TimeSensor { cycleInterval 15}
  DEF Animation OrientationInterpolator {
     key [ 0, .5, 1 ]
     keyValue [ 0 1 0 0, 0 1 0 1.57, 0 1 0 3.14 ]}
  
  Transform{ translation -4 -1 0 rotation 1 0 0 1.57 children[
    Shape{ appearance Appearance{ material Material{ diffuseColor 1 0 0}}
     geometry Cylinder{ height .2 radius .25}}
    DEF tsRot TouchSensor{} ]}
  Transform{ translation -4 1 0 children[
    Shape{ appearance Appearance{ material Material{ diffuseColor 1 0 0}}
     geometry Box{ size .4 .4 .2 }}
    DEF tsPlus TouchSensor{} ]}
  Transform{ translation -4 0 0 children[
    Shape{ appearance Appearance{ material Material{ diffuseColor 0 1 0}}
     geometry Box{ size .4 .4 .2 }}
    DEF tsMinus TouchSensor{} ]}
  
  DEF ROOT Transform{ rotation 0 1 0 -.25 scale 1.5 1.5 1.5
   children[]}
  
  DEF Polyhedron Script {
    eventIn SFBool Plus
    eventIn SFBool Minus
    eventOut MFNode new_f
    field SFNode ROOT USE ROOT
    directOutput TRUE
  url ["javascript:
  function initialize(){ 
    strArr = new MFString();  strArr.length = 10;
    strArr[0] =
  'DEF s0 Shape{ appearance Appearance{ material Material{ emissiveColor 1 1 1}} '+
  'geometry IndexedLineSet{ coord Coordinate{ '+
  'point[0 0 0,0 1.4 0,2 -.6 0,0 -.6 -2,-2 -.6 0,0 -.6 2]} '+
  'coordIndex[1 0 2 -1 3 0 4 -1 0 5]}}';
    for ( i= 1; i<10; i++)  strArr[i] = 
  'Transform{ translation 0 .7 0 children '+
  'DEF s'+i+' Transform{ scale .5 .5 .5 children[ '+
  strArr[i-1] +
  ']}} Transform{ translation 1 -.3 0 children USE s'+i+'} '+
  'Transform{ translation 0 -.3 -1 children USE s'+i+'} '+
  'Transform{ translation -1 -.3 0 children USE s'+i+'} '+
  'Transform{ translation 0 -.3 1 children USE s'+i+'} ';
    iter = 4;
    new_f = Browser.createVrmlFromString( strArr[iter] );
    ROOT.addChildren = new_f;
  }
  
  function Plus(value){
    if (value) {
      //ROOT.removeChildren = new_f;
      iter++; if (iter > 9) iter = 9;
      new_f = Browser.createVrmlFromString( strArr[iter] );
      ROOT.addChildren = new_f;
     }
  }
  function Minus(value){
    if (value) {
      //ROOT.removeChildren = new_f;
      iter--; if (iter<0) iter = 0;
      new_f = Browser.createVrmlFromString( strArr[iter] );
      ROOT.addChildren = new_f;
     }
  }
  "]}
  
  ROUTE tsPlus.isActive TO Polyhedron.Plus
  ROUTE tsMinus.isActive TO Polyhedron.Minus
  ROUTE tsRot.touchTime TO Clock.startTime
  ROUTE Clock.fraction_changed TO Animation.set_fraction
  ROUTE Animation.value_changed TO ROOT.rotation
  


(C) A. Eliëns 2/9/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.