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

web3d-product.vr

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


  #VRML v2.0 utf8
  

Web3D/VR

product with logo

(extern) proto


  EXTERNPROTO aelogo [
  exposedField SFVec3f  translation 
  exposedField SFVec3f  scale      
  ][
  "@vr-web3d-logo.wrl#logo"
  ]
  
  

monitor proto


  
  PROTO monitor [
  exposedField SFVec3f translation 0 0 0
  exposedField SFVec3f scale 1 1 1
  eventIn MFString string 
  ]{
  
  
  Transform {
  translation IS translation
  scale IS scale
  children [
      Shape {
      appearance Appearance {
        material Material { diffuseColor 1 1 1 }
        }
      geometry 
      ## Group { corrected by: Willem van Willigen (vr0711)
      ## children [
      DEF text Text { string [ "click me!" ] }
      ## ] } see www.cs.vu.nl/~eliens/archive/avr/ch2-26.htm#2.6.3
      }
      ]
  }
  
  
  
  Script {
  directOutput TRUE
  eventIn MFString string IS string
  field SFNode text USE text
  url "vrmlscript: 
  function string(value,time) { text.string = value; }
  "
  }## end script
  
  } ## end monitor
  
  

proto product


  
  PROTO product [
  exposedField SFVec3f translation   0 0 0
  ]{
  
  
  DEF product Transform {
  translation IS translation
  children [
      DEF touch TouchSensor { }
      Transform { translation -3 0 0 
      children [
      Inline { url "@vr-web3d-box.wrl" }
      ] }
      DEF monitor monitor {  translation 3 3 0 }
      ]
  }
  
  
  
  
  DEF script Script {
  directOutput TRUE
  eventIn SFTime touch
  field SFNode text USE monitor
  field SFInt32 toggle 0
  field MFString string1 [ "message 1:" "this is a cube" ]
  field MFString string2 [ "message 2:" "it rotates" ]
  field MFString string3 [ "message 3:" "more" "information?" ]
  field SFInt32 damage 1
  field SFString temp "damage: "
  
  
  url "vrmlscript:
  function touch(value) {
  toggle += 1;
  if (toggle == 1) text.string = string1;
  else if (toggle == 2) text.set_string = string2;
  else if (toggle == 3) text.set_string = string3;
  else if (toggle == 4) {
  //temp += ' ';
  temp += damage.toString();
  //temp += ' ';
  text.set_string = new MFString(temp);
  }
  if (toggle == 4) toggle=0;
  }"
  
  } ## end script
  
  
  
  
  ROUTE touch.touchTime TO script.touch
  } ## end proto
  
  

instance


  
  product { }
  
  
  
  
  aelogo {
  translation 6 -3 0
  scale 0.5 0.5 0.5
  }
  
  
  
  
  Viewpoint { position 0 0 10 }
  Background { skyColor 1 0.2 0.2 }
  
  
  


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