#VRML V2.0 utf8 # Protos needed for multi-user connections # PROTO BlaxxunZone [ exposedField MFNode events [] ] { } PROTO SharedEvent [ exposedField SFString name "event" eventIn SFColor colorFromServer eventIn SFRotation rotationFromServer eventOut SFColor colorToServer eventOut SFRotation rotationToServer eventIn SFString stringFromServer eventOut SFString stringToServer eventIn SFString set_string eventOut SFString string_changed eventIn SFColor set_color eventIn SFRotation set_rotation eventOut SFColor color_changed eventOut SFRotation rotation_changed eventOut SFVec3f position_changed eventOut SFBool initialized ] { Script { eventIn SFColor colorFromServer IS colorFromServer eventIn SFRotation rotationFromServer IS rotationFromServer eventOut SFColor colorToServer IS colorToServer eventOut SFRotation rotationToServer IS rotationToServer eventIn SFColor set_color IS set_color eventIn SFRotation set_rotation IS set_rotation eventOut SFColor color_changed IS color_changed eventOut SFRotation rotation_changed IS rotation_changed eventOut SFVec3f position_changed IS position_changed eventIn SFString stringFromServer IS stringFromServer eventOut SFString stringToServer IS stringToServer eventIn SFString set_string IS set_string eventOut SFString string_changed IS string_changed eventOut SFBool initialized IS initialized field SFVec3f pos 0 0.5 0 url "vrmlscript: function initialize( time ) { initialized = TRUE;} function stringFromServer (value, time) { string_changed = value; } function set_string (value, time) { stringToServer = value; } function colorFromServer (value, time) { color_changed = value; } function rotationFromServer (value, time) {Browser.print('received rotation from server '+value); rotation_changed = value; position_changed = pos; } function set_color (value, time) { colorToServer = value; } function set_rotation (value, time) { Browser.print('send rotation to server '+value); rotationToServer = value; } " } } DEF SharedZone BlaxxunZone { events [ DEF SharedColor SharedEvent { } DEF SharedRotation SharedEvent { } ] } DEF BoxRotation Transform { translation 0 1 0 rotation 0 1 0 0.5 children [ Shape { # the red box appearance Appearance { material DEF BoxColor Material { diffuseColor 1 0 0 } } geometry Box { } } ] } # the sphere is used to change the color Transform { translation -4 0 0 children [ Shape { appearance Appearance { material Material { diffuseColor 0 0 1 } } geometry Sphere {} }, DEF ColorSensor TouchSensor {}, DEF ColorScript Script { eventIn SFTime clicked eventOut SFColor color_changed url "vrmlscript: function clicked (value, time) { color_changed = new SFColor(Math.random(),Math.random(),Math.random()); } " } ] } # the cone is used to change the rotation Transform { translation 4 0 0 children [ Shape { appearance Appearance { material Material { diffuseColor 0 0 1 } } geometry Cone {} }, DEF RotSensor TouchSensor {}, DEF RotationScript Script { eventIn SFTime clicked eventOut SFRotation rotation_changed url "vrmlscript: function clicked (value, time) { angle = Math.random()*6.283; rotation_changed = new SFRotation(0,1,0,angle); } " } ] } ROUTE RotSensor.touchTime TO RotationScript.clicked ROUTE RotationScript.rotation_changed TO SharedRotation.set_rotation ROUTE SharedRotation.rotation_changed TO BoxRotation.set_rotation ROUTE SharedRotation.position_changed TO BoxRotation.set_translation ROUTE ColorSensor.touchTime TO ColorScript.clicked ROUTE ColorScript.color_changed TO SharedColor.set_color ROUTE SharedColor.color_changed TO BoxColor.set_diffuseColor