#VRML V2.0 utf8 ############################################################ # compass.wrl V1.0 (01-Oct-1998) # ===================== # Idea spark : David Ott, TECFA, University of Geneva # Conception : David Ott # Copyright : David.Ott@tecfa.unige.ch # # Free for all non-commercial uses if you keep this notice # intact and share with other. # # Description : # The compass points to the center of the scene [0 0 0]. # Just inline it in your scene : Inline { url "compass.wrl" } ############################################################# ############# # DashBoard # ############# Group { children [ DEF PS ProximitySensor {size 1e25 1e25 1e25} DEF T Transform { children [ Collision { collide FALSE children [ DEF compass Transform { translation 0 -.05 -.2 #lower middle scale .02 .02 .02 children [ # uncommenting this region will show a transparent sphere around the pin # Shape { #compass sphere # appearance Appearance { # material Material { # transparency .9 # specularColor 1 1 1 # shininess .8 # diffuseColor 1 0 0 # } # } # geometry Sphere{} # } DEF pin Transform { # compass pin children [ Transform { translation 0 .85 0 children [ Anchor { url "#home" children [ Shape { # pin arrow appearance Appearance { material Material { diffuseColor 1 0 0 specularColor 1 .5 .5 shininess .8 } } geometry Cone { height .3 bottomRadius .2 } } ] } ] } Transform { children [ Shape { # pin stick appearance Appearance { material Material { specularColor 1 .5 .5 shininess .8 } } geometry Cylinder { height 1.6 radius .03 } } Shape { # pin stick axis-sphere appearance Appearance { material Material { specularColor 1 .5 .5 shininess .8 } } geometry Sphere { radius .05 } } ] } ] } ] } ] } ] } ] } #This script animates the compass & the pin of the compass... DEF pinRot Script { eventIn SFVec3f changePinOrientation field SFNode orient USE PS eventIn SFRotation changeCompassOrientation eventOut SFRotation pinOrientation eventOut SFRotation compassOrientation url [ "vrmlscript: function changeCompassOrientation(newOrientation) { newOrientation.angle = (newOrientation.angle*-1); compassOrientation = new SFRotation(newOrientation.x,newOrientation.y,newOrientation.z,newOrientation.angle); } function changePinOrientation(globalPosition) { globalPosition.x = -globalPosition.x; globalPosition.y = -globalPosition.y; globalPosition.z = -globalPosition.z; var actualVec = new SFVec3f(0,1,0); pinOrientation = new SFRotation(actualVec,globalPosition); }" ] } #dashboard routing ROUTE PS.position_changed TO T.set_translation ROUTE PS.orientation_changed TO T.set_rotation #compass routing for position_changed ROUTE PS.position_changed TO pinRot.changePinOrientation ROUTE pinRot.pinOrientation TO pin.set_rotation #compass routing for orientation_changed ROUTE PS.orientation_changed TO pinRot.changeCompassOrientation ROUTE pinRot.compassOrientation TO compass.set_rotation