#VRML V2.0 utf8 WorldInfo { title "Lavalamp" info ["Gemaakt door Pim van den Broek & Natalie Vijlbrief" "vr0208@cs.vu.nl"] } NavigationInfo{ type "EXAMINE" } ######################################## # # # PROTO print_electricity_cord # # # ######################################## PROTO print_electricity_cord [ exposedField SFVec3f translation 0 0 0 exposedField SFVec3f scale 1 1 1 exposedField SFRotation rotation 0 0 0 0 field SFFloat height 0 ] { Transform { translation IS translation scale IS scale rotation IS rotation children [ # cord Transform { children [ Shape { appearance Appearance { material Material { diffuseColor 0 0 0 } } geometry Cylinder { radius 0.075 height IS height } } ] } ] } } ######################################## # # # print_logo # # # ######################################## EXTERNPROTO print_logo [ exposedField SFVec3f translation exposedField SFVec3f scale exposedField MFString url ][ "logo.wrl#logo" ] ######################################## # # # PROTO lavalamp # # # ######################################## PROTO lavalamp [ exposedField SFVec3f translation 0 0 0 exposedField SFVec3f scale 1 1 1 exposedField SFColor content_color 0 0 1 exposedField SFRotation rotation 0 0 1 0 exposedField SFTime startTime 0 exposedField SFTime stopTime 0 field SFFloat height 2 ] { Transform { translation -2.5 1.5 5 scale 0.3 0.3 0.3 children [ print_logo {} ] } Transform { translation IS translation scale IS scale children [ # metal Transform { translation 0 -2 0 children [ Shape { appearance Appearance { material Material { ambientIntensity .137 diffuseColor .57 .58 .58 specularColor .67 .46 .44 shininess .17 } } geometry Cylinder { radius 0.7 height 2 } } ] } Transform { translation 0 -2 0 children [ Shape { appearance Appearance { material Material { ambientIntensity .137 diffuseColor .57 .58 .58 specularColor .67 .46 .44 shininess .17 } } geometry Cone { bottomRadius 1 height 2 } } ] } Transform { translation 0 2.62 0 children [ Shape { appearance Appearance { material Material { ambientIntensity .137 diffuseColor .57 .58 .58 specularColor .67 .46 .44 shininess .17 } } geometry Cone { bottomRadius 0.28 height 0.8 } } ] } # upper glass Transform { translation 0 0.125 0 children [ Shape { appearance Appearance { material Material { ambientIntensity 0 diffuseColor .29 .29 .29 specularColor 1 .94 .54 emissiveColor .4 .4 .4 shininess .83 transparency .28 } } geometry Cylinder { radius 0.7 height 1.75 top FALSE bottom FALSE } } ] } # lower glass Transform { translation 0 -0.875 0 children [ DEF CONTENTSENSOR TouchSensor {} Shape { appearance Appearance { material Material { ambientIntensity 0 diffuseColor .29 .29 .29 specularColor 1 .94 .54 emissiveColor .4 .4 .4 shininess .83 transparency .28 } } geometry Cylinder { radius 0.7 height 0.25 top FALSE bottom FALSE } } ] } Transform { translation 0 2 0 children [ Shape { appearance Appearance { material Material { ambientIntensity 0 diffuseColor .29 .29 .29 specularColor 1 .94 .54 emissiveColor .4 .4 .4 shininess .83 transparency .28 } } geometry Cone { bottomRadius 0.7 height 2 bottom FALSE } } ] } # content Transform { translation IS translation scale IS scale children [ Transform { translation 0 -0.875 0 children [ Shape { appearance Appearance { material DEF CONTENT_MATERIAL Material { } } geometry Cylinder { radius 0.699 height 0.25 } } ] } ] } # bottom Transform { translation 0 -3.001 0 children [ DEF BOTTOMSENSOR TouchSensor {} Shape { appearance Appearance { material Material { diffuseColor 0 0 0 } } geometry Cylinder { radius 0.8 height 0.05 top FALSE } } ] } ] } ######################################## # # # print_cord # # # ######################################## Transform { children [ Transform { translation 1 -2.35 0 rotation 0 0 1 0.78 children [ print_electricity_cord {height 1.3} ] } Transform { translation 2.55 -2.8 0 rotation 0 0 1 1.57 children [ print_electricity_cord {height 2.3} ] } # button box Transform { translation 2.55 -2.8 0 rotation 1 0 0 -0.5 scale 0.5 0.2 0.15 children [ Shape { appearance Appearance { material Material { diffuseColor 0 0 0 } } geometry Box { } } ] } DEF REALBUTTON Transform { translation 2.55 -2.75 0.15 rotation 0.97 0.12 -0.21 1.1 children [ DEF BUTTONSENSOR TouchSensor {} Transform { children [ Shape { appearance Appearance { material Material { diffuseColor 1 1 1 } } geometry Cylinder { radius 0.15 height 0.1 } } ] } ] } # cord Transform { translation 3.925 -2.8 -0.4 rotation 0.43 0.43 0.79 1.8 children [ print_electricity_cord {height 1} ] } # cord Transform { translation 4.18 -2.8 -1.3 rotation 1 0 0 1.57 children [ print_electricity_cord {height 1} ] } Group { children [ DEF PLUGSENSOR TouchSensor {} #stekker Transform { translation 4.18 -2.8 -1.8 rotation 1 0 0 1.57 children [ Shape { appearance Appearance { material Material { diffuseColor 0.5 0.5 0.5 } } geometry Cylinder { radius 0.3 height 0.3 } } ] } #stekker plug links Transform { translation 4.03 -2.8 -2.1 rotation 1 0 0 1.57 children [ Shape { appearance Appearance { material Material { diffuseColor .61 .61 .61 specularColor .39 .39 .39 ambientIntensity .25 shininess .11 } } geometry Cylinder { radius 0.05 height 0.3 } } ] } #stekker plug einde links Transform { translation 4.03 -2.8 -2.25 rotation 1 0 0 1.57 children [ Shape { appearance Appearance { material Material { diffuseColor .61 .61 .61 specularColor .39 .39 .39 ambientIntensity .25 shininess .11 } } geometry Sphere { radius 0.05 } } ] } #stekker plug rechts Transform { translation 4.33 -2.8 -2.1 rotation 1 0 0 1.57 children [ Shape { appearance Appearance { material Material { diffuseColor .61 .61 .61 specularColor .39 .39 .39 ambientIntensity .25 shininess .11 } } geometry Cylinder { radius 0.05 height 0.3 } } ] } #stekker plug einde rechts Transform { translation 4.33 -2.8 -2.25 rotation 1 0 0 1.57 children [ Shape { appearance Appearance { material Material { diffuseColor .61 .61 .61 specularColor .39 .39 .39 ambientIntensity .25 shininess .11 } } geometry Sphere { radius 0.05 } } ] } ] } ] } ######################################## # # # TEXT # # # ######################################## Transform { translation 3.55 1 0 children [ Shape { geometry DEF TEXT Text { fontStyle FontStyle { size 0.4 family "ARIAL" justify "MIDDLE" } } appearance Appearance { material DEF TEXT_STRING Material { diffuseColor 1 1 1 transparency 1 } } } ] } Transform { translation 3.55 1 -0.05 rotation 0 1 0 3.14 children [ Shape { geometry DEF TEXT2 Text { fontStyle FontStyle { size 0.4 family "ARIAL" justify "MIDDLE" } } appearance Appearance { material DEF TEXT_STRING2 Material { diffuseColor 1 1 1 transparency 1 } } } ] } Transform { translation 3.6 1.15 -0.01 children [ Shape { geometry Box { size 4 0.8 0.01 } appearance Appearance { material DEF TEXT_BOX Material {transparency 1} texture ImageTexture { url "text_box.gif" } } } ] } DEF LINE Transform { rotation IS rotation children [ Shape { appearance Appearance { material DEF LINE_MATERIAL Material { diffuseColor 0 0 0 transparency 1 } } geometry Cylinder { radius 0.01 height 1 } } ] } ######################################## # # # SCRIPTS ETC # # # ######################################## DEF TIMESENSOR TimeSensor { cycleInterval 1.5 } DEF TIMESENSOR2 TimeSensor { cycleInterval 1.5 } DEF TIMESCRIPT Script { eventIn SFBool isOver eventOut SFTime startTime eventOut SFTime startTime2 eventOut SFBool fadeIn url "javascript: function isOver (val,ts) { if (isOver) fadeIn = TRUE; else fadeIn = FALSE; startTime = ts; startTime2 = ts + 1; } " } DEF INVERTSCRIPT Script { eventIn SFFloat inputnumber eventIn SFBool fadeIn eventOut SFFloat outputnumber field SFBool this_fadeIn FALSE url "javascript: function fadeIn (val,ts) { if (fadeIn) this_fadeIn = TRUE; else this_fadeIn = FALSE; } function inputnumber (val,ts) { if (this_fadeIn) outputnumber = 1 - inputnumber; else outputnumber = inputnumber; } " } DEF INVERTSCRIPT2 Script { eventIn SFFloat inputnumber eventIn SFBool fadeIn eventOut SFFloat outputnumber field SFBool this_fadeIn FALSE url "javascript: function fadeIn (val,ts) { if (fadeIn) this_fadeIn = TRUE; else this_fadeIn = FALSE; } function inputnumber (val,ts) { if (this_fadeIn) outputnumber = 1 - inputnumber; else outputnumber = inputnumber * 3; } " } DEF GET_TOUCHED_PART Script { eventIn SFBool button eventIn SFBool button_on eventIn SFBool bottom eventIn SFBool plug eventIn SFBool content eventOut MFString string_out eventOut SFRotation line_rotation eventOut SFVec3f line_translation eventOut SFVec3f line_scale url "javascript: function initialize() { string_out = ''; line_rotation = '0 0 0 0'; line_translation = '0 0 0'; line_scale = '0 0 0'; } function button() { string_out = 'On / Off Switch'; line_rotation = '0 0 1 -0.27'; line_translation = '3.1 -0.9 0'; //line_scale = '1 3.2 1'; line_scale = '0 0 0'; } function button_on() { string_out = 'Yes you can turn it on'; line_rotation = '0 0 1 -0.27'; line_translation = '3.1 -0.9 0'; //line_scale = '1 3.2 1'; line_scale = '0 0 0'; } function bottom() { string_out = 'Felt bottom'; line_rotation = '0 0 1 -0.27'; line_translation = '3.1 -0.9 0'; line_scale = '0 0 0'; } function plug() { string_out = 'Electrical Plug'; line_rotation = '1 0 0 0.6'; line_translation = '3.9 -1.2 -0.4'; line_scale = '0 0 0'; } function content() { string_out = 'Blubby stuff'; line_rotation = '1 0 0 0.6'; line_translation = '3.9 -1.2 -0.4'; line_scale = '0 0 0'; } " } DEF BUTTONSCRIPT Script { eventIn SFTime touchTime field SFInt32 number 2 field SFInt32 last_number 0 eventOut SFRotation button_rotation eventOut SFColor content_color url "javascript: function initialize() { last_number = 0; button_rotation = '0.97 0.12 -0.21 1.1'; content_color = '0.8 0.8 0'; } function touchTime(value, time) { if (last_number == number - 1) { last_number = 0; button_rotation = '0.97 0.12 -0.21 1.1'; content_color = '0.8 0.8 0'; } else { ++last_number; button_rotation = '0.97 -0.12 0.21 1.1'; content_color = '1 0 0'; } } " } ######################################## # # # Add Vieuwpoints # # # ######################################## PROTO addViewpoints [] { Viewpoint { position 0 0 10 description "Start" } Viewpoint { position 0 0 20 description "Overview" } Viewpoint { position -5 0 10 description "Left" } Viewpoint { position 5 0 10 description "Right" } } ######################################## # # # Add Background # # # ######################################## PROTO addBackground [] { Background { skyColor [1 0 0, 1 1 0.79, 1 0 0, 1 1 0.79] skyAngle [0.5, 1.4, 1.8] } } ######################################## # # # ROUTES # # # ######################################## # on/off switch ROUTE BUTTONSENSOR.touchTime TO BUTTONSCRIPT.touchTime ROUTE BUTTONSENSOR.isActive TO GET_TOUCHED_PART.button_on ROUTE BUTTONSCRIPT.button_rotation TO REALBUTTON.rotation ROUTE BUTTONSCRIPT.content_color TO CONTENT_MATERIAL.diffuseColor #general for text ROUTE GET_TOUCHED_PART.string_out TO TEXT.string ROUTE GET_TOUCHED_PART.string_out TO TEXT2.string ROUTE TIMESCRIPT.startTime TO TIMESENSOR.startTime ROUTE TIMESCRIPT.startTime2 TO TIMESENSOR2.startTime ROUTE TIMESCRIPT.fadeIn TO INVERTSCRIPT.fadeIn ROUTE TIMESCRIPT.fadeIn TO INVERTSCRIPT2.fadeIn ROUTE TIMESENSOR2.fraction_changed TO INVERTSCRIPT2.inputnumber ROUTE TIMESENSOR.fraction_changed TO INVERTSCRIPT.inputnumber ROUTE INVERTSCRIPT.outputnumber TO TEXT_BOX.transparency #ROUTE GET_TOUCHED_PART.line_rotation TO LINE.rotation #ROUTE GET_TOUCHED_PART.line_translation TO LINE.translation #ROUTE GET_TOUCHED_PART.line_scale TO LINE.scale #ROUTE INVERTSCRIPT2.outputnumber TO LINE_MATERIAL.transparency ROUTE INVERTSCRIPT2.outputnumber TO TEXT_STRING.transparency ROUTE INVERTSCRIPT2.outputnumber TO TEXT_STRING2.transparency # button ROUTE BUTTONSENSOR.isOver TO GET_TOUCHED_PART.button ROUTE BUTTONSENSOR.isOver TO TIMESCRIPT.isOver # plug ROUTE PLUGSENSOR.isOver TO GET_TOUCHED_PART.plug ROUTE PLUGSENSOR.isOver TO TIMESCRIPT.isOver # bottom ROUTE BOTTOMSENSOR.isOver TO GET_TOUCHED_PART.bottom ROUTE BOTTOMSENSOR.isOver TO TIMESCRIPT.isOver # content ROUTE CONTENTSENSOR.isOver TO GET_TOUCHED_PART.content ROUTE CONTENTSENSOR.isOver TO TIMESCRIPT.isOver addViewpoints {} addBackground {} } lavalamp { content_color 0.8 0.8 0 }