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

web3d-x-editor.vr

web3d-x-editor.vr (wrl ) [ flux / bitmanagement / cortona / octaga ]

Web3D/VR

editor

scene


  
  NavigationInfo {
     type ["NONE"]
  }
  
  Viewpoint {
     description "Default View"
     position 0 0.5 2
  }
  
  

selector box


  
  Transform {
     translation -0.25 -0.15 0
     children [
        DEF CUBESENSOR TouchSensor {
        }
  
  
        Shape {
           appearance Appearance {
              material Material {
                 diffuseColor 1 0 0
              }
           }
           geometry Box {
              size 0.1 0.1 0.17
           }
        }
     ] } ## end
  
  

selector sphere


  Transform {
     translation 0 -0.15 0
     children [
        DEF SPHERESENSOR TouchSensor {
        }
  
  
        Shape {
           appearance Appearance {
              material Material {
                 diffuseColor 0 1 0
              }
           }
           geometry Sphere {
              radius 0.05
           }
        }
     ]
  }
  
  

selector cone


  Transform {
     translation 0.25 -0.15 0
     children [
        DEF CONESENSOR TouchSensor {
        }
  
  
        Shape {
           appearance Appearance {
              material Material {
                 diffuseColor 0 0 1
              }
           }
           geometry Cone {
              bottomRadius 0.05
              height 0.1
           }
        }
     ]
  }
  
  

(box) panel


  
  DEF TOP Transform {
     translation 0 0.5 0
     children [
        Transform {
           rotation 1 0 0 1.57   
           children [
              Shape {
                 appearance Appearance {
                    material Material {
                       diffuseColor 0.4 0.4 0.4
                    }
                 }
  
  
                 geometry Box {
                    size 1 1e-8 1
                 }
              }
           ] }
     ] } ## end TOP
  
  

script


  
  DEF CREATOR Script {
     eventIn SFTime cube_touchTime
     eventIn SFTime sphere_touchTime
     eventIn SFTime cone_touchTime
     field SFNode parentNode USE TOP
     eventOut MFNode newChildren
     mustEvaluate TRUE
     url "javascript:
  
  

cube function


  
        function cube_touchTime(value,time) {
           newVRML =  'Group {';
           newVRML += '   children [';
           newVRML += '      DEF SENSOR PlaneSensor {';
           newVRML += '         maxPosition 0.45 0.45';
           newVRML += '         minPosition -0.45 -0.45';
           newVRML += '      }';
  
  
           newVRML += '      DEF OBJECT Transform {';
           newVRML += '         children [';
           newVRML += '            Shape {';
           newVRML += '               appearance Appearance {';
           newVRML += '                  material Material {';
           newVRML += '                     diffuseColor 1 0 0';
           newVRML += '                  }';
           newVRML += '               }';
  
  
           newVRML += '               geometry Box {';
           newVRML += '                  size 0.1 0.1 0.1';
           newVRML += '               }';
           newVRML += '            }';
           newVRML += '         ]';
           newVRML += '      }';
           newVRML += '   ]';        
           newVRML += '}';
           newVRML += 'ROUTE SENSOR.translation_changed TO OBJECT.set_translation';
           newChildren = Browser.createVrmlFromString(newVRML);
        }
  

sphere function


        function sphere_touchTime(value,time) {
           newVRML =  'Group {';
           newVRML += '   children [';
           newVRML += '      DEF SENSOR PlaneSensor {';
           newVRML += '         maxPosition 0.45 0.45';
           newVRML += '         minPosition -0.45 -0.45';
           newVRML += '      }';
  
  
           newVRML += '      DEF OBJECT Transform {';
           newVRML += '         children [';
           newVRML += '            Shape {';
           newVRML += '               appearance Appearance {';
           newVRML += '                  material Material {';
           newVRML += '                     diffuseColor 0 1 0';
           newVRML += '                  }';
           newVRML += '               }';
  
  
           newVRML += '               geometry Sphere {';
           newVRML += '                  radius 0.05';
           newVRML += '               }';
           newVRML += '            }';
           newVRML += '         ]';
           newVRML += '      }';
           newVRML += '   ]';        
           newVRML += '}';
           newVRML += 'ROUTE SENSOR.translation_changed TO OBJECT.set_translation';
           newChildren = Browser.createVrmlFromString(newVRML);
        }
  

cone function


        function cone_touchTime(value,time) {
           urlString = new MFString('@vr-web3d-cone.wrl');
           Browser.createVrmlFromURL(urlString, parentNode, 'addChildren');
        }
     "
  }
  
  

event routing


  
  ROUTE CUBESENSOR.touchTime TO CREATOR.cube_touchTime
  ROUTE SPHERESENSOR.touchTime TO CREATOR.sphere_touchTime
  ROUTE CONESENSOR.touchTime TO CREATOR.cone_touchTime
  
  ROUTE CREATOR.newChildren TO TOP.addChildren
  


(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.