|
|
VRML Nodes
Prefined VRML ShapesShape
Shape {
appearance NULL
geometry NULL
}
Box
geometry Box { size 2.0 2.0 2.0 }
Cylinder
geometry Cylinder {
radius 1.0
height 2.0
}
Cone
geometry Cone {
bottomRadius 1.0
height 2.0
}
Sphere
geometry Sphere { radius 1.0 }
Text
geometry Text {
string "3D Text"
fontStyle FontStyle {
family "SERIF"
style "BOLD"
}
}
Complex VRML shapesSets
Elevation Grids
Extruded Shapes
TransformationA Transformation node is a kind of grouping node that is used to translate, rotate and scale its children Translation
VRML Translation Example
#VRML V2.0 utf8
Group {
children [
...
Transform {
translation 2.0 2.0 0.0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1.0 0.0 0.0
}
}
geometry Box {
size 2.0 2.0 2.0
}
}
]
}
]
}
Rotation
VRML Rotation Example
#VRML V2.0 utf8
Group {
children [
...
Transform {
rotation 0.0 1.0 0.0 0.785
translation 2.0 2.0 0.0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1.0 0.0 0.0
}
}
geometry Box {
size 2.0 2.0 2.0
}
}
]
}
]
}
Scaling
VRML Scaling Example
#VRML V2.0 utf8
Group {
children [
...
Transform {
scale 0.5 0.5 0.5
translation 0.0 1.5 0.0
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 1.0 0.0 0.0
}
}
geometry Box {
size 2.0 2.0 2.0
}
}
]
}
]
}
AppearanceThe appearance of a surface is defined by setting properties that define the material from which it is made. A texture can also be defined to improve the appearance of a surface.
VRML Material Example
#VRML V2.0 utf8
Group {
children [
...
Shape {
appearance Appearance {
material Material {
diffuseColor 0.22 0.15 0.0
specularColor 0.71 0.70 0.56
emissiveColor 0.0 0.0 0.0
ambientIntensity 0.4
shininess 0.16
transparency 0.0
}
}
geometry Box {
size 2.0 2.0 2.0
}
}
]
}
VRML Texture Example
#VRML V2.0 utf8
Group {
children [
...
Shape {
appearance Appearance {
material Material {}
texture ImageTexture {
url "surface.gif"
}
}
geometry Box {
size 2.0 2.0 2.0
}
}
]
}
Without textures
With textures
LightingLight can be...
VRML Lighting Example
#VRML V2.0 utf8
Group {
children [
...
DirectionalLight {
on TRUE
intensity 0.6
ambientIntensity 0.0
color 0.0 1.0 0.0
direction 0.0 0.5 -1.0
},
PointLight {
on TRUE
intensity 0.8
color 0.0 0.0 1.0
location 5.0 5.0 0.0
},
SpotLight {
on TRUE
intensity 0.6
color 1.0 0.0 0.0
location 5.0 -2.0 0.0
direction -1.0 0.0 0.0
cutOffAngle 0.5
}
]
}
FogFog can be used to provide a depth cue, add atmosphere, and increase realism. VRML Fog Example
#VRML V2.0 utf8
Group {
children [
...
Fog {
color 1.0 1.0 1.0
fogType "EXPONENTIAL"
visibilityRange 30.0
}
]
}
Without fog
With fog
Animation
VRML animation using an OrientationInterpolatorThis is a rotating box. VRML Animation example
#VRML V2.0 utf8
Group {
...
DEF GreenBox Transform {
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0.0 1.0 0.0
}
}
geometry Box {
size 2.0 2.0 2.0
}
}
]
},
DEF Clock TimeSensor {
enabled TRUE
cycleInterval 5.0
loop TRUE
},
DEF Path OrientationInterpolator {
key [ 0.0 0.5 1.0 ]
keyValue [
0.0 1.0 1.0 0.0,
0.0 1.0 1.0 3.14,
0.0 1.0 1.0 6.28
]
}
]
}
ROUTE Clock.fraction_changed TO Path.set_fraction
ROUTE Path.value_changed TO GreenBox.set_rotation
Interaction
VRML Interaction using a SphereSensorThis is a box that that the user can rotate by dragging it. VRML Interaction example
#VRML V2.0 utf8
Group {
children [
...
DEF GreenBox Transform {
children [
Shape {
appearance Appearance {
material Material {
diffuseColor 0.0 1.0 0.0
}
}
geometry Box {
size 2.0 2.0 2.0
}
}
]
},
DEF Drag SphereSensor { },
]
}
ROUTE Drag.rotation_changed TO GreenBox.rotation
AnchorsIn VRML, objects can represent links that can be used to access other virtual worlds or Net resources such as Web pages. VRML Anchor example
#VRML V2.0 utf8
Group {
children [
...
Anchor {
url "../index.html"
description "Return to lecture"
children [
Shape {
geometry Text {
string ["Go back to", "Web3D Lecture" ]
fontStyle FontStyle {
justify "MIDDLE"
}
}
}
]
}
]
}
Inline nodesInline nodes are used to reference other VRML files, enabling their contents to be included in a virtual environment. The basic syntax is simply Inline { url "url_goes_here" } Inlined nodes are loaded after the main file has been loaded. |
|
|
Michael Louka, October 10, 2001 |