#VRML V2.0 utf8 # VRML/Java Seminar WS 1997/98 # Jetzt mit Spotlight. Dem Untergrund wurde ein ElevationGrid # verpasst, damit das Licht der Scheinwerfer einigermassen # realistisch reflektiert wird. # *** Hier definieren wir uns ein Auto! ******************************** PROTO Auto [ exposedField SFVec3f pos 0 0 0, # die Position, exposedField SFRotation rot 1 0 0 0, # Orientierung, exposedField SFColor col 1 0 0 # Farbe und field SFString name "Auto"] { # ein Name Transform { translation IS pos rotation IS rot children [ Shape { # die Karosserie appearance Appearance { material Material { diffuseColor IS col } } geometry IndexedFaceSet { convex FALSE coord Coordinate { point [ 2.0 0.2 -0.8, -2.0 0.2 -0.8, -2.0 0.8 -0.8, -1.5 0.8 -0.8, -1.0 1.4 -0.8, 0.5 1.4 -0.8, 1.0 0.8 -0.8, 2.0 0.8 -0.8, 2.0 0.2 0.8, -2.0 0.2 0.8, -2.0 0.8 0.8, -1.5 0.8 0.8, -1.0 1.4 0.8, 0.5 1.4 0.8, 1.0 0.8 0.8, 2.0 0.8 0.8 ] } coordIndex [ 0 7 15 8 -1, 7 6 14 15 -1, 6 5 13 14 -1, 5 4 12 13 -1, 4 3 11 12 -1, 3 2 10 11 -1, 2 1 9 10 -1, 1 0 8 9 -1, 0 1 2 3 4 5 6 7 -1, 15 14 13 12 11 10 9 8, -1 ] } } Transform { rotation 1 0 0 -1.57 translation 1.3 0.3 0.7 children [ DEF rad Shape { # Ein Rad... appearance Appearance { material Material { diffuseColor 0.2 0.2 0.2 } } geometry Cylinder { radius 0.3, height 0.28 } } ] } Transform { # ...und noch drei rotation 1 0 0 -1.57 # R=E4der. Da ver- translation 1.3 0.3 -0.7 # wenden wir doch children USE rad # gleich noch mal } # das erste Rad! Transform { rotation 1 0 0 -1.57 translation -1.3 0.3 0.7 children USE rad } Transform { rotation 1 0 0 -1.57 translation -1.3 0.3 -0.7 children USE rad } Transform { rotation 0 0 1 -1.57 translation 2.0 0.5 0.6 children [ DEF Schein Shape { appearance Appearance { material Material { diffuseColor 1.0 1.0 1.0 } } geometry Cylinder { radius 0.15, height 0.05 } } ] } Transform { rotation 0 0 3.14 -1.57 translation 2.0 0.5 -0.6 children USE Schein } SpotLight { ambientIntensity 0 # exposedField SFFloat attenuation 1 0 0 # exposedField SFVec3f beamWidth 2 # exposedField SFFloat color 1 1 1 # exposedField SFColor cutOffAngle 0.785398 # exposedField SFFloat direction 1 0.1 0.2 # exposedField SFVec3f intensity 1 # exposedField SFFloat location 2.5 0.5 0.6 # exposedField SFVec3f on TRUE # exposedField SFBool radius 40 # exposedField SFFloat } SpotLight { ambientIntensity 0 # exposedField SFFloat attenuation 1 0 0 # exposedField SFVec3f beamWidth 2 # exposedField SFFloat color 1 1 1 # exposedField SFColor cutOffAngle 0.785398 # exposedField SFFloat direction 1 0.1 -0.2 # exposedField SFVec3f intensity 1 # exposedField SFFloat location 2.5 0.5 -0.6 # exposedField SFVec3f on TRUE # exposedField SFBool radius 40 # exposedField SFFloat } Viewpoint { # Mittendrin statt orientation 0 1 0 -1.57 # nur dabei - so position 0.2 1.2 0.0 # sieht der Fahrer description IS name # die Sache! } ] } } # *** auch die Pfosten konstruieren wir als Prototyp ******************* # Zunaechst die Zylinder-Stuecke, aus der # wir die Pfosten zusammensetzen: PROTO Segment [ exposedField SFVec3f pos 0 0 0, # Position exposedField SFColor col 1 0 0 ] { # und Farbe Transform { translation IS pos children Shape { appearance Appearance { material Material { diffuseColor IS col } } geometry Cylinder { radius 0.1, height 0.2 } } } } PROTO Pfosten [ exposedField SFVec3f pos 0 0 0 ] { Transform { translation IS pos children [ Segment { pos 0.0 0.1 0.0, col 1.0 0.0 0.0 } # rot, Segment { pos 0.0 0.3 0.0, col 1.0 1.0 1.0 } # weiss, Segment { pos 0.0 0.5 0.0, col 1.0 0.0 0.0 } # rot, Segment { pos 0.0 0.7 0.0, col 1.0 1.0 1.0 } # weiss und Segment { pos 0.0 0.9 0.0, col 1.0 0.0 0.0 } # nochmal rot ] } } # *** so, jetzt koennen wir die Welt zusammensetzen ******************** Background { skyColor 0.7 0.8 1 } # Himmel Viewpoint { # zunaechst sieht orientation 0.26 -0.93 -0.25 -1.63 # man die VRML-Welt position 13.8 6.3 0.0 # aus der Vogel- description "Uebersicht" # perspektive } Viewpoint { orientation -0.01 -1.4 -0.6 2.9 position -4 16 -18 description "Vogel" } Transform { # eine quadratische translation -9.5 0 -9.5 # Flaeche als Rennstrecke. children [ # ElevationGrid Shape { appearance Appearance { material Material { diffuseColor 0.9 0.6 0.2 } } geometry ElevationGrid { xDimension 20 zDimension 20 xSpacing 1 zSpacing 1 solid FALSE creaseAngle 0.1 height [0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, 0.01, 0.00, ] } } ] } Transform { # Ein Klotz im Weg; wird zwar rotation 0 1 0 0.6 # angestrahlt und reflektiert, translation 4.5 0 1 # wirft aber keinen Schatten! children [ Shape { appearance Appearance { material Material { diffuseColor 0.2 0.3 0.2 } }, geometry Box { size 1.5 2 0.7 } } ] } Pfosten { pos -9.0 0.0 0.0 } # Einige Pfosten Pfosten { pos -8.9 0.0 1.6 } # bringen etwas Pfosten { pos -8.5 0.0 3.0 } # Perspektive in Pfosten { pos -7.8 0.0 4.5 } # die VRML-Welt. Pfosten { pos -6.9 0.0 5.8 } Pfosten { pos -5.8 0.0 6.9 } Pfosten { pos -4.5 0.0 7.8 } # (links aussen) Pfosten { pos -3.0 0.0 8.5 } Pfosten { pos -1.6 0.0 8.9 } Pfosten { pos 0.0 0.0 9.0 } Pfosten { pos -6.0 0.0 0.0 } # (links innen) Pfosten { pos -5.7 0.0 1.9 } Pfosten { pos -4.9 0.0 3.5 } Pfosten { pos -3.5 0.0 4.9 } Pfosten { pos -1.9 0.0 5.7 } Pfosten { pos 0.0 0.0 6.0 } Pfosten { pos -6.0 0.0 -1.2 } # (Parkplatz) Pfosten { pos -4.8 0.0 -2.4 } Pfosten { pos -3.6 0.0 -3.6 } Pfosten { pos -2.4 0.0 -4.8 } Pfosten { pos -1.2 0.0 -6.0 } Pfosten { pos 0.0 0.0 -4.8 } Pfosten { pos 1.2 0.0 -3.6 } Pfosten { pos 9 0 0 } # (rechts aussen) Pfosten { pos 8.9 0.0 -1.6 } Pfosten { pos 8.5 0.0 -3.0 } Pfosten { pos 7.8 0.0 -4.5 } Pfosten { pos 6.9 0.0 -5.8 } Pfosten { pos 5.8 0.0 -6.9 } Pfosten { pos 4.5 0.0 -7.8 } Pfosten { pos 3.0 0.0 -8.5 } Pfosten { pos 1.6 0.0 -8.9 } Pfosten { pos 0 0 -9 } # Pfosten { pos 0 2.0 1 } # Pfosten { pos 1 2.0 0 } # Pfosten { pos 1 2.0 1 } Pfosten { pos 6 0 0 } # (rechts innen) Pfosten { pos 5.7 0 -1.9 } Pfosten { pos 4.9 0 -3.5 } Pfosten { pos 3.5 0 -4.9 } Pfosten { pos 1.9 0 -5.7 } Pfosten { pos 0 0 -6.0 } Pfosten { pos 9 0 0 } # (vorne aussen) Pfosten { pos 8.9 0.0 1.6 } Pfosten { pos 8.5 0.0 3.0 } Pfosten { pos 7.8 0.0 4.5 } Pfosten { pos 6.9 0.0 5.8 } Pfosten { pos 5.8 0.0 6.9 } Pfosten { pos 4.5 0.0 7.8 } Pfosten { pos 3.0 0.0 8.5 } Pfosten { pos 1.6 0.0 8.9 } Pfosten { pos 5.7 0 1.9 } # (vorne innen) # Pfosten { pos 4.9 0 3.5 } # (Ausfahrt) # Pfosten { pos 3.5 0 4.9 } Pfosten { pos 1.9 0 5.7 } Auto { # Hier parkt das pos -0.4 0.0 -3.4 # blaue Auto... rot 0 1 0 -0.79 col 0 0 1 name "Blaues Auto" } Auto { # ...und hier pos -1.9 0.0 -1.9 # das gelbe. rot 0 1 0 -0.79 col 1 1 0 name "Gelbes Auto" } Auto { # ...und hier pos -3.4 0.0 -0.4 # das gruene. rot 0 1 0 -0.79 col 0 1 0 name "Gruenes Auto" } DEF rotesAuto Transform { # Das rote Auto children Auto { pos 0.0 0.0 7.5 name "Rote Auto"} # erhaelt einen } # Transform-Node... DEF rotInt OrientationInterpolator { # ...damit es auf key [ 0.00 0.33 0.66 1.00 ] # diesem Rundkurs keyValue [ 0 1 0 0.00, 0 1 0 2.09, # fahren kann. 0 1 0 4.19, 0 1 0 0.00 ] } DEF timer TimeSensor { # Hier tickt die loop TRUE # Uhr, die unsere cycleInterval 20 # Animation } # steuert. # So, jetzt muessen wir noch alles richtig verdrahten, damit sich # auch etwas bewegt: # die Zeit vom Timer zum Interpolator ROUTE timer.fraction_changed TO rotInt.set_fraction # und die Rotation vom Interpolatior zum Transform-Node ROUTE rotInt.value_changed TO rotesAuto.set_rotation # Fertig!