A static picture of a yellow cone
#VRML V2.0 utf8 #----------------------------------------------------------------------------- # yellowcone.wrl # # A really simple VRML world consisting of a yellow cone lit from above. #----------------------------------------------------------------------------- # A directional light source, shining down from above. DirectionalLight { direction 0 -1 0 } # A yellow cone rotated about 57 degrees from vertical. Transform { rotation 0 0 -1 1 children [ Shape { appearance Appearance { material Material {diffuseColor 1 1 0} } geometry Cone { bottomRadius 2 height 8.1 } } ] }
Illustration of textures and anchors
#VRML V2.0 utf8 #----------------------------------------------------------------------------- # boxandsphere.wrl # # A really simple VRML world consisting of a ellipsoid and a box. The # ellipsoid has a marble texture mapped on to it and the box is anchored # to LMU's main web page. #----------------------------------------------------------------------------- # A light DirectionalLight { direction 1 0 -1 } # A camera PerspectiveCamera { position -8.6 2.1 5.6 orientation -0.14 -1 -0.12 1.142 focalDistance 10.84 } # A marble ellipsoid Transform { translation 3 0 1 scale 1.5 1 0.75 children [ Shape { appearance Appearance { material Material {diffuseColor 1 1 0} texture ImageTexture {url "marble.jpg"} } geometry Sphere { radius 2.3 } } ] } # A box with a hyperlink Transform { rotation 0 0 1 3.1 translation 2 2.5 1.25 children [ Anchor { url "http://www.lmu.edu" description "Loyola Marymount" children [ Shape { appearance Appearance { material Material {emissiveColor 1 1 0} } geometry Box {} } ] } ] }
Naive way to make axes
#VRML V2.0 utf8 #----------------------------------------------------------------------------- # axes1.wrl # # Draws the X, Y and Z coordinate axes, each 10 meters long: X red, Y green # and Z blue, as cylinders with radius 0.1m. # # This is a very ugly document because each axis is constructed separately # and transforms are used to scale the cylinder. #----------------------------------------------------------------------------- # Red X-axis Transform { scale 0.1 5 0.1 rotation 0 0 1 -1.57080 translation 5 0 0 children [ Shape { appearance Appearance {material Material {diffuseColor 1 0 0}} geometry Cylinder {} } ] } # Green X-axis Transform { scale 0.1 5 0.1 translation 0 5 0 children [ Shape { appearance Appearance {material Material {diffuseColor 0 1 0}} geometry Cylinder {} } ] } # Blue Z-axis Transform { scale 0.1 5 0.1 rotation 1 0 0 1.57080 translation 0 0 5 children [ Shape { appearance Appearance {material Material {diffuseColor 0 0 1}} geometry Cylinder {} } ] } # Spere at origin Shape {geometry Sphere{}} # Sphere at end of X-axis Transform { translation 10 0 0 children [Shape {geometry Sphere{}}] } # Sphere at end of Y-axis Transform { translation 0 10 0 children [Shape {geometry Sphere{}}] } # Sphere at end of Z-axis Transform { translation 0 0 10 children [Shape {geometry Sphere{}}] }
Slightly better way to make axes, but still stupid
#VRML V2.0 utf8 # ---------------------------------------------------------------------------- # axes2.wrl # # Draws the X, Y and Z coordinate axes, each 10 meters long: X red, Y green # and Z blue, as cylinders with radius 0.1m. # # Each axis is constructed separately in a rather brute force manner. At # least the fields of the Cylinder node are used. # ---------------------------------------------------------------------------- # Red X-axis Transform { rotation 0 0 1 -1.57080 translation 5 0 0 children [ Shape { appearance Appearance {material Material {diffuseColor 1 0 0}} geometry Cylinder {radius 0.1 height 10 top FALSE bottom FALSE} } ] } # Green X-axis Transform { translation 0 5 0 children [ Shape { appearance Appearance {material Material {diffuseColor 0 1 0}} geometry Cylinder {radius 0.1 height 10 top FALSE bottom FALSE} } ] } # Blue Z-axis Transform { rotation 1 0 0 1.57080 translation 0 0 5 children [ Shape { appearance Appearance {material Material {diffuseColor 0 0 1}} geometry Cylinder {radius 0.1 height 10 top FALSE bottom FALSE} } ] } # Spere at origin Shape {geometry Sphere{}} # Sphere at end of X-axis Transform { translation 10 0 0 children [Shape {geometry Sphere{}}] } # Sphere at end of Y-axis Transform { translation 0 10 0 children [Shape {geometry Sphere{}}] } # Sphere at end of Z-axis Transform { translation 0 0 10 children [Shape {geometry Sphere{}}] }
Smart way to make axes, using PROTO
#VRML V2.0 utf8 # ---------------------------------------------------------------------------- # axes3.wrl # # Draws the X, Y and Z coordinate axes, each 10 meters long: X red, Y green # and Z blue, as cylinders with radius 0.1m. # # This document illstrates using PROTO to make a new SimpleAxis node, which # is the combination of a cylinder and cone, parameterized by its appearance. # ---------------------------------------------------------------------------- # Define a new node called SimpleAxis with one parameter, its appearance. # A SimpleAxis is basically a cylinder of base radius 0.1 and height 10 # resting on the xz plane pointing upward. Sitting on top of the cylinder # is a cone of base radius 0.25 and height 1. PROTO SimpleAxis [field SFNode axisAppearance NULL] { Transform { translation 0 5 0 children [ Shape { appearance IS axisAppearance geometry Cylinder {radius 0.1 height 10} } Transform { translation 0 5.5 0 children [ Shape { appearance IS axisAppearance geometry Cone {bottomRadius 0.25 height 1} } ] } ] } } # Red X-axis Transform { rotation 0 0 1 -1.57080 children [ SimpleAxis { axisAppearance Appearance {material Material {diffuseColor 1 0 0}} } ] } # Green X-axis Transform { children [ SimpleAxis { axisAppearance Appearance {material Material {diffuseColor 0 1 0}} } ] } # Blue Z-axis Transform { rotation 1 0 0 1.57080 children [ SimpleAxis { axisAppearance Appearance {material Material {diffuseColor 0 0 1}} } ] } # Sphere at origin Shape {geometry Sphere{}}
Example of using IndexedFaceSet to make a polyhedron
#VRML V2.0 utf8 #----------------------------------------------------------------------------- # house.wrl # # A very basic "house". #----------------------------------------------------------------------------- Shape { appearance Appearance { material Material {diffuseColor 1 1 0} } geometry IndexedFaceSet { coord Coordinate { point [ # define the ten points -1 0 2, -1 0 -2, 1 0 -2, 1 0 2, -1 1 2, -1 1 -2, 1 1 -2, 1 1 2, 0 2 2, 0 2 -2 ] } coordIndex [ # define the seven faces 0, 1, 2, 3, -1, 0, 3, 7, 8, 4, -1, 1, 5, 9, 6, 2, -1, 2, 6, 7, 3, -1, 0, 4, 5, 1, -1, 7, 6, 9, 8, -1, 4, 8, 9, 5, -1 ] } }
A ball that rolls down a cone when you click on it
#VRML V2.0 utf8 Transform { children Shape { appearance DEF SolidYellow Appearance { material Material { diffuseColor 1 1 0 } } geometry Cone { } } } Group { children [ DEF TheTouchSensor TouchSensor {} DEF LittleSphere Transform { translation 0 1.2 0 children Shape { appearance USE SolidYellow geometry Sphere {radius 0.2} } } ] } DEF TheTimeSensor TimeSensor {cycleInterval 10} DEF TheInterpolator PositionInterpolator { key [ 0, 1 ] keyValue [ 0 1.2 0, 1.2 -1 0 ] } ROUTE TheTouchSensor.touchTime TO TheTimeSensor.startTime ROUTE TheTimeSensor.fraction_changed TO TheInterpolator.set_fraction ROUTE TheInterpolator.value_changed TO LittleSphere.set_translation
An elevator that goes up when you walk into it
#VRML V2.0 utf8 # Stolen from the VRML 97 Final Specification Transform { translation 0 0 -3.5 children Shape { appearance Appearance { material Material { diffuseColor 0 1 0 } } geometry Cone { } } } Transform { translation 0 4 -3.5 children Shape { appearance Appearance { material Material { diffuseColor 1 0 0 } } geometry Cone { } } } Transform { translation 0 8 -3.5 children Shape { appearance Appearance { material Material { diffuseColor 0 0 1 } } geometry Cone { } } } Group { children [ DEF ETransform Transform { children [ DEF EViewpoint Viewpoint { jump FALSE } DEF EProximity ProximitySensor { size 2 5 5 } Transform { translation 0 -1 0 children Shape { appearance Appearance { material Material { } } geometry Box { size 2 0.2 5 } } } ] } ] } DEF ElevatorPI PositionInterpolator { key [ 0, 1 ] keyValue [ 0 0 0, 0 8 0 ] # a floor is 4 meters high } DEF TS TimeSensor { cycleInterval 10 } # 10 second travel time ROUTE EProximity.enterTime TO TS.startTime ROUTE TS.isActive TO EViewpoint.set_bind ROUTE TS.fraction_changed TO ElevatorPI.set_fraction ROUTE ElevatorPI.value_changed TO ETransform.set_translation