#VRML V2.0 utf8 WorldInfo { title "MMA Assignment 4" info ["Aäron Jansen" "Studentnumber: 1262602" "Studying: AI" "ajansen@few.vu.nl"] } DEF NAVIGATION_INFO NavigationInfo { headlight FALSE } Background { skyColor 0.0 0.0 0.0 } EXTERNPROTO logo [ exposedField MFString url exposedField SFVec3f translation exposedField SFVec3f scale ] ["protos.wrl#logo"] EXTERNPROTO clouds [] ["protos.wrl#clouds"] EXTERNPROTO earth [] ["protos.wrl#earth"] EXTERNPROTO glassbox [] ["protos.wrl#glassbox"] EXTERNPROTO foot [] ["protos.wrl#foot"] EXTERNPROTO floor [] ["protos.wrl#floor"] EXTERNPROTO wall [] ["protos.wrl#wall"] EXTERNPROTO infoscreen [] ["protos.wrl#infoscreen"] EXTERNPROTO infoscreen_text [ exposedField MFString string ] ["protos.wrl#infoscreen_text"] EXTERNPROTO colourcube [] ["protos.wrl#colourcube"] # Model the world objects in a group...(without the HUD objects) Group { children [ # Group all the timers together Group { children [ DEF EARTH_ROTATION_TIMER TimeSensor { cycleInterval 40 loop TRUE enabled FALSE } DEF COLOURCUBE_ROTATION_TIMER TimeSensor { cycleInterval 5 loop TRUE enabled FALSE } DEF CLOUDS_ROTATION_TIMER TimeSensor { cycleInterval 20 loop TRUE enabled FALSE } DEF EARTH_TIMER_SPLITPARTS_OPEN TimeSensor { cycleInterval 1 loop FALSE startTime -1 } DEF EARTH_TIMER_SPLITPARTS_CLOSE TimeSensor { cycleInterval 1 loop FALSE startTime -1 } DEF COLOURCUBE_TIMER_SPLITPARTS_OPEN TimeSensor { cycleInterval 1 loop FALSE startTime -1 } DEF COLOURCUBE_TIMER_SPLITPARTS_CLOSE TimeSensor { cycleInterval 1 loop FALSE startTime -1 } ] } # Group all sounds together Group { children [ Sound { minFront 10 minBack 10 maxFront 50 maxBack 50 source DEF OPENSOUND AudioClip { url "shawee.wav" } } Sound { minFront 10 minBack 10 maxFront 50 maxBack 50 source DEF CLICKSOUND AudioClip { url "click.wav" } } ] } # Build a room around the product line Transform { translation -1 -3 0 children [ Group { children [ PointLight { location 2 7 5 } floor {} Transform { rotation 0 0 1 1.57 translation 29 0 -20 children [ wall{} ] } Transform { rotation 1 0 0 1.57 translation -20 49 -15 children [ wall{} ] } ] } ] } # The colorcube part Group { children [ DEF COLOURCUBE_TOUCHSENSOR TouchSensor {} DEF COLOURCUBE_ROTATION Transform { scale 0.5 0.5 0.5 translation 3 0 0 children [ colourcube {} ] } DEF COLOURCUBE_INTERPOLATOR OrientationInterpolator { key [0, 0.25, 0.5, 0.75, 1] keyValue [ 1 1 0 0, 1 1 0 1.57, 1 1 0 3.14, 1 1 0 4.71, 1 1 0 6.28 ] } DEF COLOURCUBEPOPUP_SCRIPT Script { eventIn SFBool isOver eventOut SFInt32 output url "javascript: function isOver(value, time) { if (value == true) { output = 4; } else { output = 0; } } " } ] } # The glass box part Group { children [ DEF COLOURCUBE_GLASSTOUCHSENSOR TouchSensor {} DEF COLOURCUBE_GLASSBOX_TRANSFORM Transform { translation 3 0 0 children [ glassbox {} ] } DEF COLOURCUBE_GLASSPOSITION_INTERPOLATOR_OPEN PositionInterpolator { key [ 0, 0.6, 1 ] keyValue [ 3 0 0, 3 1.5 0, 3 3 0 ] } DEF COLOURCUBE_GLASSPOSITION_INTERPOLATOR_CLOSE PositionInterpolator { key [ 0, 0.6, 1 ] keyValue [ 3 3 0, 3 1.5 0, 3 0 0 ] } DEF COLOURCUBE_GLASSPOPUP_SCRIPT Script { eventIn SFBool isOver eventOut SFInt32 output url "javascript: function isOver(value, time) { if (value == true) { output = 1; } else { output = 0; } } " } DEF COLOURCUBE_TOGGLE_GLASSBOX Script { field SFBool open FALSE eventIn SFTime toggle eventOut SFTime startClose eventOut SFTime startOpen url "javascript: function toggle(value) { if (!open) { startOpen = value; startClose = -1; } else { startOpen = -1; startClose = value; } open = !open; } " } ] } # The foot of the colorcube in a box Group { children [ DEF COLOURCUBE_FOOTTOUCHSENSOR TouchSensor {} Transform { translation 3 -1.15 0 children [ foot {} ] } DEF COLOURCUBE_FOOTPOPUP_SCRIPT Script { eventIn SFBool isOver eventOut SFInt32 output url "javascript: function isOver(value, time) { if (value == true) { output = 3; } else { output = 0; } } " } ] } # The Earth part Group { children [ # clouds texture DEF CLOUDSROTATION Transform { children [ clouds {} ] } DEF CLOUDS_ORIENTATIONINTERPOLATOR OrientationInterpolator { key [0, 0.25, 0.5, 0.75, 1] keyValue [ 0 1 0 0, 0 1 0 1.57, 0 1 0 3.14, 0 1 0 4.71, 0 1 0 6.28 ] } DEF EARTHTOUCHSENSOR TouchSensor {} DEF EARTHROTATION Transform { children [ earth {} ] } DEF EARTH_INTERPOLATOR OrientationInterpolator { key [0, 0.25, 0.5, 0.75, 1] keyValue [ 0 1 0 0, 0 1 0 1.57, 0 1 0 3.14, 0 1 0 4.71, 0 1 0 6.28 ] } DEF EARTHPOPUP_SCRIPT Script { eventIn SFBool isOver eventOut SFInt32 output url "javascript: function isOver(value, time) { if (value == true) { output = 2; } else { output = 0; } } " } ] } # The glass box part Group { children [ DEF GLASSTOUCHSENSOR TouchSensor {} DEF GLASSBOX_TRANSFORM Transform { translation 0 0 0 children [ glassbox {} ] } DEF GLASSPOSITION_INTERPOLATOR_OPEN PositionInterpolator { key [ 0, 0.6, 1 ] keyValue [ 0 0 0, 0 1.5 0, 0 3 0 ] } DEF GLASSPOSITION_INTERPOLATOR_CLOSE PositionInterpolator { key [ 0, 0.6, 1 ] keyValue [ 0 3 0, 0 1.5 0, 0 0 0 ] } DEF GLASSPOPUP_SCRIPT Script { eventIn SFBool isOver eventOut SFInt32 output url "javascript: function isOver(value, time) { if (value == true) { output = 1; } else { output = 0; } } " } DEF EARTH_TOGGLE_GLASSBOX Script { field SFBool open FALSE eventIn SFTime toggle eventOut SFTime startClose eventOut SFTime startOpen url "javascript: function toggle(value) { if (!open) { startOpen = value; startClose = -1; } else { startOpen = -1; startClose = value; } open = !open; } " } ] } # The foot of the world in a box Group { children [ DEF FOOTTOUCHSENSOR TouchSensor {} Transform { translation 0 -1.15 0 children [ foot {} ] } DEF FOOTPOPUP_SCRIPT Script { eventIn SFBool isOver eventOut SFInt32 output url "javascript: function isOver(value, time) { if (value == true) { output = 3; } else { output = 0; } } " } ] } ] } # Also, we want a HUD(Heads Up Display) for displaying manipulation controls # Source: http://web3d.vapourtech.com/workshop/hud/ # HUD objects DEF SENSOR ProximitySensor { size 10000 10000 10000 center 0 0 10 } DEF HUD Transform { translation 0 0 10 children [ DirectionalLight { direction 0 0 -1 intensity 1 } # HUD geometry will go here Transform { translation 0 -0.073 -0.2 children [ # Display the logo at the bottom left of the screen Billboard { axisOfRotation 0 1 1 # Rotation around y/z axes is possible. children [ logo { url "../index.html" scale 0.007 0.007 0.007 translation -0.124 0.005 0 } ] } # Infoscreen Transform { translation 0.1105 0.06 0.0 children [ infoscreen {} ] } # HUD display at the bottom part of the screen. Transform { translation 0.02 0 0 children [ Shape { appearance Appearance { material Material { diffuseColor 0 0.6 1 emissiveColor 0.1 0.1 0.1 transparency 0.0 } } geometry Box { size 0.24 0.016 0.0025 } } ] } # Switch for the changing of the view Transform { translation 0.12 0 0 children [ DEF BUTTON_STARTTOUR_TOUCHSENSOR TouchSensor {} Shape { appearance Appearance { material Material { diffuseColor 1 0 1 } } geometry Sphere { radius 0.003 } } ] } Transform { translation 0 0.0015 0.01 children [ Shape { appearance Appearance { material Material { diffuseColor 1 1 1 } } geometry Text { string "Start/stop the tour by pressing/releasing the mouse button on the purple sphere" fontStyle FontStyle { size 0.006 family "SANS" style "BOLD" justify "MIDDLE" } length 0.17 } } ] } # Texts for the infoscreen Transform { translation 0.106 0.1 0.01 children [ DEF SWITCHTEXT Switch { whichChoice 0 choice [ # 0: Default text infoscreen_text { string [ "InfoScreen" "" "'Your own virtual" "world in a" "glass box'" "" "Move the mouse" "over seperate" "parts for info" ] } # 1: Text for the glass box infoscreen_text { string [ "InfoScreen" "" "The glass box" "protects the" "part inside" ] } # 2: Text for the earth part infoscreen_text { string [ "InfoScreen" "" "Earth part" "" "Your own virtual" "earth, just 4 you." "" "Keep mouse pressed" "for rotation of" "earth and clouds" ] } # 3: Text for the foot part infoscreen_text { string [ "InfoScreen" "" "The foot carries" "the object in a" "special way," "such that it" "floats in the air." ] } # 4: Text for the colourcube part infoscreen_text { string [ "InfoScreen" "" "The colourcube shows" "a large spectrum" "colours." "" "Keep mouse pressed" "for rotation of" "the cube" ] } ] } ] } ] } ] } # All viewpoints grouped together Group { children [ DEF HUDVIEW Viewpoint { description "HUD View" position 0 0 30 } DEF default Viewpoint { position 2 7 10 orientation -0.95 0.30 0.09 0.63 description "Default Entry" } DEF aerial Viewpoint { position 0 5 10 orientation 1 0 0 -0.39 description "Aerial View" } DEF aerial-side Viewpoint { position 5 5 5 orientation -0.59 0.77 0.24 0.99 description "Aerial View: Isometric" } ] } # A short flying tour around the products Group { children [ DEF SHORTTOUR_TIMER TimeSensor { loop TRUE enabled TRUE cycleInterval 60 } DEF SHORTTOUR_VIEWPOINT_ORIENTATIONINTERPOLATOR OrientationInterpolator { key [0, 0.25, 0.5, 0.75, 1] keyValue [ 0 1 0 0, 0 1 0 1.57, 0 1 0 3.14, 0 1 0 4.71, 0 1 0 6.28 ] } DEF SHORTTOUR_TRANSFORM Transform { translation 2 0 0 children [ DEF SHORTTOUR_VIEWPOINT Viewpoint { position 0 1 10 orientation -1 0 0 0.10 description "Short tour" } ] } ] } # All script routings... # Note: Toggling method had been copied and adapted from source group 0607. # Routing for earth information pop-up ROUTE EARTHTOUCHSENSOR.isOver TO EARTHPOPUP_SCRIPT.isOver ROUTE EARTHPOPUP_SCRIPT.output TO SWITCHTEXT.whichChoice # Routing for glass information pop-up ROUTE GLASSTOUCHSENSOR.isOver TO GLASSPOPUP_SCRIPT.isOver ROUTE GLASSPOPUP_SCRIPT.output TO SWITCHTEXT.whichChoice ROUTE COLOURCUBE_GLASSTOUCHSENSOR.isOver TO COLOURCUBE_GLASSPOPUP_SCRIPT.isOver ROUTE COLOURCUBE_GLASSPOPUP_SCRIPT.output TO SWITCHTEXT.whichChoice # Routing for foot information pop-up ROUTE FOOTTOUCHSENSOR.isOver TO FOOTPOPUP_SCRIPT.isOver ROUTE FOOTPOPUP_SCRIPT.output TO SWITCHTEXT.whichChoice # Routing for colourcube information pop-up ROUTE COLOURCUBE_TOUCHSENSOR.isOver TO COLOURCUBEPOPUP_SCRIPT.isOver ROUTE COLOURCUBEPOPUP_SCRIPT.output TO SWITCHTEXT.whichChoice # Routing for colourcube foot information pop-up ROUTE COLOURCUBE_FOOTTOUCHSENSOR.isOver TO COLOURCUBE_FOOTPOPUP_SCRIPT.isOver ROUTE COLOURCUBE_FOOTPOPUP_SCRIPT.output TO SWITCHTEXT.whichChoice # Routing for earth rotation ROUTE EARTH_ROTATION_TIMER.fraction_changed TO EARTH_INTERPOLATOR.set_fraction ROUTE EARTH_INTERPOLATOR.value_changed TO EARTHROTATION.set_rotation # Routing for cloud rotation ROUTE CLOUDS_ROTATION_TIMER.fraction_changed TO CLOUDS_ORIENTATIONINTERPOLATOR.set_fraction ROUTE CLOUDS_ORIENTATIONINTERPOLATOR.value_changed TO CLOUDSROTATION.set_rotation # Routing for starting and stopping of the earth rotation. ROUTE EARTHTOUCHSENSOR.isActive TO EARTH_ROTATION_TIMER.enabled ROUTE EARTHTOUCHSENSOR.isActive TO CLOUDS_ROTATION_TIMER.enabled # Routing for starting and stopping of the colorcube rotation. ROUTE COLOURCUBE_TOUCHSENSOR.isActive TO COLOURCUBE_ROTATION_TIMER.enabled ROUTE COLOURCUBE_ROTATION_TIMER.fraction_changed TO COLOURCUBE_INTERPOLATOR.set_fraction ROUTE COLOURCUBE_INTERPOLATOR.value_changed TO COLOURCUBE_ROTATION.set_rotation # Routing for the HUD to work ROUTE SENSOR.orientation_changed TO HUD.set_rotation ROUTE SENSOR.position_changed TO HUD.set_translation ROUTE SENSOR.position_changed TO SENSOR.set_center # Routing of the sound accompanying the opening/closing of the box... ROUTE GLASSTOUCHSENSOR.touchTime TO OPENSOUND.startTime ROUTE FOOTTOUCHSENSOR.touchTime TO OPENSOUND.startTime ROUTE COLOURCUBE_GLASSTOUCHSENSOR.touchTime TO OPENSOUND.startTime ROUTE COLOURCUBE_FOOTTOUCHSENSOR.touchTime TO OPENSOUND.startTime # Routing for letting a clicksound play when the earth is clicked. # However, this event is not properly detected. Sometimes it is, sometimes not. # This seems to be a problem with Cortona 4.2. In group 0607, we can see # that certain event handling has been implemented differently, because they # use the Blaxxun VRML browser. ROUTE EARTHTOUCHSENSOR.touchTime TO CLICKSOUND.startTime # Routing for the opening and closing of the glass boxes # ... for the earth ROUTE GLASSTOUCHSENSOR.touchTime TO EARTH_TOGGLE_GLASSBOX.toggle ROUTE FOOTTOUCHSENSOR.touchTime TO EARTH_TOGGLE_GLASSBOX.toggle ROUTE EARTH_TOGGLE_GLASSBOX.startOpen TO EARTH_TIMER_SPLITPARTS_OPEN.startTime ROUTE EARTH_TIMER_SPLITPARTS_OPEN.fraction_changed TO GLASSPOSITION_INTERPOLATOR_OPEN.set_fraction ROUTE GLASSPOSITION_INTERPOLATOR_OPEN.value_changed TO GLASSBOX_TRANSFORM.translation ROUTE EARTH_TOGGLE_GLASSBOX.startClose TO EARTH_TIMER_SPLITPARTS_CLOSE.startTime ROUTE EARTH_TIMER_SPLITPARTS_CLOSE.fraction_changed TO GLASSPOSITION_INTERPOLATOR_CLOSE.set_fraction ROUTE GLASSPOSITION_INTERPOLATOR_CLOSE.value_changed TO GLASSBOX_TRANSFORM.translation # ... for the colourcube ROUTE COLOURCUBE_GLASSTOUCHSENSOR.touchTime TO COLOURCUBE_TOGGLE_GLASSBOX.toggle ROUTE COLOURCUBE_FOOTTOUCHSENSOR.touchTime TO COLOURCUBE_TOGGLE_GLASSBOX.toggle ROUTE COLOURCUBE_TOGGLE_GLASSBOX.startOpen TO COLOURCUBE_TIMER_SPLITPARTS_OPEN.startTime ROUTE COLOURCUBE_TIMER_SPLITPARTS_OPEN.fraction_changed TO COLOURCUBE_GLASSPOSITION_INTERPOLATOR_OPEN.set_fraction ROUTE COLOURCUBE_GLASSPOSITION_INTERPOLATOR_OPEN.value_changed TO COLOURCUBE_GLASSBOX_TRANSFORM.translation ROUTE COLOURCUBE_TOGGLE_GLASSBOX.startClose TO COLOURCUBE_TIMER_SPLITPARTS_CLOSE.startTime ROUTE COLOURCUBE_TIMER_SPLITPARTS_CLOSE.fraction_changed TO COLOURCUBE_GLASSPOSITION_INTERPOLATOR_CLOSE.set_fraction ROUTE COLOURCUBE_GLASSPOSITION_INTERPOLATOR_CLOSE.value_changed TO COLOURCUBE_GLASSBOX_TRANSFORM.translation # Routing for the short tour around the products... ROUTE SHORTTOUR_TIMER.fraction_changed TO SHORTTOUR_VIEWPOINT_ORIENTATIONINTERPOLATOR.set_fraction ROUTE SHORTTOUR_VIEWPOINT_ORIENTATIONINTERPOLATOR.value_changed TO SHORTTOUR_TRANSFORM.rotation # ...routing to start/stop the tour ROUTE BUTTON_STARTTOUR_TOUCHSENSOR.isActive TO SHORTTOUR_VIEWPOINT.set_bind