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

proto-conversation.vr

proto-conversation.vr (wrl ) [ flux / bitmanagement / cortona / octaga ]


  

conversation

Web3D/VR

extern object


  
  EXTERNPROTO object {
  exposedField SFColor color
  exposedField SFFloat transparency
  exposedField SFNode node
  exposedField SFTime cycle
  ][ "@vr-proto-object.wrl#object" ]
  
  

extern bulb


  
  EXTERNPROTO bulb [
  eventIn MFString message
  exposedField SFInt32 type
  exposedField SFColor text
  exposedField SFVec3f scale
  exposedField SFVec3f translation
  exposedField MFString string
  exposedField SFColor color
  exposedField SFFloat transparency 
  exposedField SFVec3f text_scale
  exposedField SFVec3f text_translation
  ][ "@vr-proto-bulb.wrl#bulb" ]
  
  

extern repertoire


  
  EXTERNPROTO repertoire [
  eventIn SFInt32 next 
  eventOut MFString string
  exposedField SFInt32 max 
  exposedField MFString u01 
  exposedField MFString u02 
  exposedField MFString u03 
  exposedField MFString u04 
  exposedField MFString u05 
  exposedField MFString u06 
  exposedField MFString u07 
  exposedField MFString u08 
  exposedField MFString u09 
  exposedField MFString u10 
  exposedField MFString u11 
  exposedField MFString u12 
  ][ "@vr-proto-repertoire.wrl#repertoire" ]
  
  

default right bulb


  
  DEF b1 bulb {
      scale 3 1 1 
      translation -1 1 0
      color 0.7 0.2 0.2
      string [ "well" "eh" ]
      text 0 1 1 
      transparency 0.2
      text_scale 0.7 1 1
      }
  
  

default left bulb


  
  DEF b2 bulb {
      type 1
      scale 2 1 1
      translation 1 1 0
      text 1 1 0
      color 0 1 1
      string [ "hi" ]
      transparency 0.5
      text_scale 0.8 1 1
      text_translation -1 0 0
      }
  
  

proto conversation


  
  PROTO conversation [ ## "@vr-extern-conversation.wrl"
  
  exposedField SFInt32 switch 0
  exposedField SFColor color 0 0 1
  exposedField SFFloat transparency 0
  exposedField SFNode  node NULL
  exposedField SFTime cycle 1
  
  exposedField SFVec3f translation 0 0 0 
  exposedField SFVec3f scale 1 1 1
  exposedField SFRotation rotation 0 0 1 0
  
  exposedField MFNode children NULL
  eventIn MFNode addChildren
  eventIn MFNode removeChildren
  
  exposedField MFString scene ["@vr-box.wrl"]
  
  exposedField SFBool reverse TRUE
  
  exposedField SFNode p1 NULL
  exposedField SFNode p2 NULL
  
  exposedField SFNode b1 USE b1
  exposedField SFNode b2 USE b2
  
  exposedField SFTime speed 3
  
  
  exposedField SFInt32 round 0
  exposedField SFInt32 delay 3
  exposedField SFBool enabled FALSE
  exposedField SFBool ready FALSE
  ]{
  DEF root Group {
  children [
  Transform {
  translation IS translation
  scale IS scale
  rotation IS rotation
  children [
  
     Group {
     children IS children
     addChildren IS addChildren
     removeChildren IS removeChildren
     }
  
  DEF touch TouchSensor { }
  
  Switch {
  whichChoice IS switch
  choice [
     object { 
          color  IS color
          transparency IS transparency
          node IS node
          cycle IS cycle
          }
  
  ]
  }
  Inline { url IS scene }
  
  ] }
  ]}
  
  

time


  
  DEF time TimeSensor { enabled TRUE loop TRUE cycleInterval IS speed }
  
  

scenario


  
  DEF scenario Script {
  directOutput TRUE
  eventIn SFTime cycle
  eventIn SFTime touch
  eventIn MFString message
  field SFNode root USE root
  field SFBool reverse IS reverse
  field SFNode p1 IS p1 
  field SFNode p2 IS p2 
  field SFNode b1 IS b1 
  field SFNode b2 IS b2 
  field SFNode hold NULL
  field MFString s1 [ "... " ]
  field MFString s2 [ "... " ]
  field SFInt32 toggle 0
  field SFInt32 start 0
  field SFInt32 delay 0
  field SFInt32 round IS round
  field SFBool enabled IS enabled
  field SFBool ready IS ready
  field SFInt32 turn 1
  url "javascript:
  function initialize() {
   root.addChildren = new MFNode(b1);
   root.addChildren = new MFNode(b2);
   if (!reverse) {
   Browser.addRoute(p1,'string',b1,'message');
   Browser.addRoute(p2,'string',b2,'message');
   } else {
   Browser.addRoute(p1,'string',b2,'message');
   Browser.addRoute(p2,'string',b1,'message');
   }
   }
  function shutdown() {
   if (!reverse) {
   Browser.deleteRoute(p1,'string',b1,'message');
   Browser.deleteRoute(p2,'string',b2,'message');
   } else {
   Browser.deleteRoute(p1,'string',b2,'message');
   Browser.deleteRoute(p2,'string',b1,'message');
   }
   }
  function message(value) {
          //print('message ' + value);
          }
  

touch


  
  function touch(value) {
          if (toggle == 0) { toggle = 1; ready = TRUE; }
          else if (toggle == 1) { toggle = 0; ready = FALSE; enabled = FALSE; }
  }
  
  

taking turns


  
  function cycle(value) {
          if (enabled) {
          if (turn == 1) { 
                  round++; turn = 2; b2.string = s1;
                  p1.next = 1;
                  }
          else if (turn == 2) { 
                  turn = 1; b1.string = s1;
                  p2.next = 1;
                  
          if (round >= p1.max) {
                  enabled = FALSE;
                  ready = FALSE;
                  start = 0;
                  }
           }
          } else if (ready) {
                  start++;
                  if (start > delay) enabled = TRUE;
                  }
          }
  "
  } ## end script
  
  

event routing


  
  ROUTE touch.touchTime TO scenario.touch
  ROUTE time.cycleTime TO scenario.cycle
  
  } ## end proto
  
  

participant 1


  
  DEF p1 repertoire {
  max 12
  u01 [ "how" "are" "you?" ]
  u02 [ "tell" "me" "..." ]
  u03 [ "what do" "you think" "of" ]
  u04 [ "the 11th" "of september" "!" ]
  u05 [ "of course!" ]
  u06 [ "please" "speak out!" ]
  u07 [ "now," "what do you" "think?" ]
  u08 [ "what" "about" "terrorism?" ]
  u09 [ "yes eh" "violence ..." ]
  u10 [ "like in" "New York?" ]
  u11 [ "americans" "you mean?" ]
  u12 [ "" "what?" ]
  }
  
  

participant 2


  
  DEF p2 repertoire {
  max 12
  u01 [ "fine" "thank" "you" ]
  u02 [ "yes" "eh" "..." ]
  u03 [ "what?" "..." ]
  u04 [ "the crash" "you mean?" ]
  u05 [ "well eh" "..." ]
  u06 [ "yes eh," "I think ..." ]
  u07 [ "I think" "that" "eh terrorism" "..." ]
  u08 [ "acts" "of" "violence" ]
  u09 [ "against" "humanity" "..." ]
  u10 [ "against" "innocent" "citizens" ]
  u11 [ "right!" "and I think" "that .." ]
  u12 [ "I'll miss" "the" "skyline" ]
  }
  
  

final scene


  
  
  
  conversation {
  p1 USE p1
  p2 USE p2
  scene "@vr-box.wrl"
  speed 2.5
  }
  
  NavigationInfo { type ["WALK","ANY"] }
  
  DEF camera Viewpoint { position 0 0 10 }  
  
  Background {
    groundAngle  [1.57]
    skyAngle     [1.57]
    groundColor  [0 .3 0, .3 .4 .3]
    skyColor     [0 0 .3, .3 .3 .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.