#VRML V2.0 utf8 # VRML/Java Seminar WS 1997/98 # Nikolai Kiesel # *** Hier definieren wir uns ein Auto! # ******************************** PROTO Auto [ exposedField SFVec3f pos 0 0 0, =20 exposedField SFRotation rot 1 0 0 0,=20 exposedField SFColor col 1 0 0 =20 field SFString name "Auto" ]=20 { Transform { translation IS pos rotation IS rot children [ Shape { # die Karosserie appearance DEF farb Appearance { material Material { diffuseColor IS col } } geometry IndexedFaceSet { convex FALSE coord DEF points Coordinate { point [ 2.0 0.2 -0.8, -2.0 0.2 -0.8,=20 -2.0 0.8 -0.8, -1.5 0.8 -0.8, -1.0 1.4 -0.8, 0.5 1.4 -0.8,=20 1.0 0.8 -0.8, 2.0 0.8 -0.8, 2.0 0.2 0.8, -2.0 0.2 0.8,=20 -2.0 0.8 0.8, -1.5 0.8 0.8, -1.0 1.4 0.8, 0.5 1.4 0.8, =20 1.0 0.8 0.8, 2.0 0.8 0.8 ] } coordIndex [ 0 7 15 8 -1, 8 15 7 0 -1 7 6 14 15 -1, 15 14 6 7 -1, 5 4 12 13 -1, 13 12 4 5 -1, 3 2 10 11 -1, 11 10 3 2 -1, 2 1 9 10 -1, 10 9 1 2 -1, 1 0 8 9 -1, 9 8 0 1 -1, 0 1 2 7 -1, 7 2 1 0 -1, 15 10 9 8 -1, 8 9 10 15 -1 ] } } Transform { translation 0.74 1.025 0.75 children [ DEF schief Transform { rotation 0 0 1 0.70 scale 1 1.5 1 children [ DEF holm Shape { appearance USE farb geometry Box { size 0.1 0.6 0.1 } } ] } ] } Transform { scale 0.99 1 0.99 children [ Shape { appearance Appearance { material Material { transparency 0.6 emissiveColor 0 0 0.3 diffuseColor 0.7 0.7 1 } } geometry IndexedFaceSet { convex FALSE coord USE points coordIndex [ 14 13 12 11 -1, 3 4 5 6 -1, 13 14 6 5 -1, 4 3 11 12 -1 ] } } ] } Transform { translation 0.74 1.025 -0.75 children USE schief } Transform { translation -1.26 1.025 -0.75 rotation 0 0 1 -1.4 children USE schief } Transform { translation -1.26 1.025 0.75 rotation 0 0 1 -1.4 children USE schief } Transform { translation -0.2 1.1 0.75 children USE holm } Transform { translation -0.2 1.1 -0.75 children USE holm } DEF langs Transform { translation -0.25 1.35 -0.75 children [ Shape { appearance USE farb geometry Box { size 1.5 0.1 0.1 } } ] } Transform { translation 0 0 1.5 children USE langs} DEF sitz Transform { translation -1 0.35 0 children [ Shape { appearance DEF sebl Appearance { material Material { diffuseColor 0.2 0.2 0.2 } } geometry Box { size 0.7 0.3 1.55 } } Transform { translation -0.2 0.2 0 children [ Shape { appearance USE sebl geometry Box { size 0.3 0.7 1.55} } ] } =20 ]} Transform { translation 1.3 0.4 0 rotation 0 0 1 0.78 children [ Shape { appearance Appearance { material Material { diffuseColor 0.2 0.2 0.2 } } geometry Box { size 0.5 0.5 1.55 } } Transform { translation -0.2 0.45 -0.4 rotation 1 1 0 -1.57 scale 0.07 0.07 0.07 children [ Shape { appearance DEF bot Appearance { material Material { emissiveColor 0.8 0.8 0.8 } } geometry Text { string ["LIGHTS"] fontStyle DEF bot2 FontStyle { justify "MIDDLE" =20 } } } ] } Transform { translation -0.2 0.45 0.4 rotation 1 1 0 -1.57 scale 0.07 0.07 0.07 children [ Shape { appearance USE bot geometry Text { string ["HORN"] fontStyle USE bot2 } } ] } Transform { translation -0.2 0.4 0 children [ Shape { appearance USE farb geometry Cylinder { height 0.3 radius 0.04 } } Transform { translation 0 0.15 0 rotation 0 0 1 0.2 children [ Shape { appearance USE farb geometry Cylinder { height 0.02 radius 0.25} } ] } ] } ]} Transform { translation 1.1 0 0 children USE sitz } =20 =20 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 # Raeder. 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 } Viewpoint { # Mittendrin statt orientation 0.08 1 0.08 -1.57 # nur dabei - so position -0.3 1.2 0.0 # sieht der Fahrer description IS name # die Sache! } ] } } Background { skyColor 1 1 1 } # weisser 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 } # *** 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 1 1 1 } # weisser 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 } Shape { # eine quadratische appearance Appearance { # Fl=3D3DE4che als material Material { diffuseColor 0.8 0.8 0.8 } # Strasse } geometry Box { size 20.0 0.01 20.0 } } 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 } 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 } 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 } 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 } 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 { # Hier parkt das pos -1.9 0.0 -1.9 # gelbe Auto... rot 0 1 0 -0.79 col 1 1 0.2 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 rot 0 1 0 3.14 name "rotes Auto"} # erhaelt einen=20 } # Transform-Node... DEF rotInt OrientationInterpolator { #DAMIT ES AUF =20 key [ 0.00 0.33 0.66 1.00 ] # diesem Rundkurs keyValue [ 0 1 0 0.00, 0 1 0 4.19, # fahren kann. 0 1 0 2.09, 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!