|
|
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Also See: |
Surf the VR 2.0 Wave!!
INTRODUCTIONTHE source for information, the industry bible so to speak, is the VRML 2.0 Sourcebook, Andrea L. Ames, David Nadeau, John Moreland, Wiley and Sons, N.Y. 1997, ISBN 0-471-16507-7 See http://www.wiley.com/compbooks/, get the book/CD! Other sources of info include the Annotated VRML 97 Reference,
fully online at http://www.best.com/~rikk/Book/book.shtml.
Excellent resource. FEATURES OF VRML 2.0VRML 2.0 shares many code features with VRML 1.0, (such as the code is still basic ASCII text files, with the .wrl extension), except it is completely different. At first glance it seems much more complicated, with repeating words and endless brackets, but it is also much more powerful. VRML 2.0 allows such new features such as:
Samples of code may be seen below, and simple worlds can be viewed from Scotty's VR WAVE, VRML 2.0 samples. VRML files may contain:
NOTESThis guide is intended to give examples of the codes used to create virtual worlds (.WRL) for use in VRML v2.0 browsers. It includes code snippets and default settings to assist the student in designing their worlds. Please note the following:
ROUTES AND EVENTS (Advanced)You can wire nodes in your world so that, for example, clicking on a button will turn on a light, or start an animation, or make a sound. The path between nodes is called the route, and the message that the first node sends to the second is called an event. Multiple node routes are called circuits.Most nodes have input and output jacks that you can wire. Input jacks are called eventIn, output jacks are called eventOut. Implicit input and output jacks are called exposed fields. With this ability, it is necessary to know which elements, or fields can be changed. To denote this, the fields in various nodes are noted as "exposed field". This means you can cause a change in a field parameter during the viewing of a world. At the risk of making the code look overly complex, I have noted these field parameters, as well as the field values. This will help you determine the values required in a field. (EventIns and eventOuts have to have matching field values). The field values are either SF (single field value), MF (multiple field value). Please note that anything preceding a # is a comment and not necessary in your code. Field Values
Beam me up, Scotty!
FILE INFORMATIONVRML 2.0 HEADER (req'd at top of all files)#VRML V2.0 utf8# utf-8 stands for Universal Character Set Transform Format WORLD INFORMATION (optional)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title | " " | # field SFString, used for title bar | |
| info | [" "] | # field MFString, strings of information |
Nodes such as shapes and transforms (all called children) are grouped, in nodes such as the Group node, the Shape nodes, the Transform nodes. This keeps properties and transformations contained within the group, nodes outside the group are unaffected. Groups can be nested. Children can be parents to other children nodes. The top level parent is the root.
Group
{
| children | [ enter nodes here ] | # exposedField MFNode | |
| bboxCenter | 0.0 0.0 0.0 | # field SFVec3f | |
| bboxSize | -1.0 -1.0 -1.0 | # field SFVec3f | |
| addChildren | # eventIn MFNode | ||
| removeChildren | # eventIn MFNode |
Billboard {
| children | [ enter nodes here ] | # exposedField MFNode | |
| axisOfRotation | 0.0 1.0 0.0 | # exposedField SFVec3f | |
| bboxCenter | 0.0 0.0 0.0 | # field SFVec3f | |
| bboxSize | -1.0 -1.0 -1.0 | # field SFVec3f | |
| addChildren | # eventIn MFNode | ||
| removeChildren | # eventIn MFNode |
Used to keep shapes toward viewer no matter which angle they are coming from. (Z axis always toward viewer). AxisofRotation default rotates around Y axis, like billboard sign. Value of 0.0, 0.0, 0.0 would allow rotation in any angle. Instanced defined Billboard groups act independently.
Switch {
| whichChoice | -1 | # exposedField SFInt32 | |
| choice | [ nodes for each selection ] | # exposedField MFNode |
Switch allows separate groups or nodes to be imaged. WhichChoice selects which group of nodes to image.
Anchor { # links Web pages and worlds to objects
| children | [ ] | # exposedField MFNode | |
| url | [" "] | # exposedField MFString, priority list | |
| parameter | [ ] | # exposedField MFString | |
| description | " " | # exposedField MFString, usually displayed at cursor | |
| bboxCenter | 0.0 0.0 0.0 | # field SFVec3f | |
| bboxSize | -1.0 -1.0 -1.0 | # field SFVec3f | |
| addChildren | #eventIn MFNode | ||
| removeChildren | #eventOut MFNode |
Shape #used for all shapes
{
| appearance | NULL | exposedField SFNode | |
| geometry | NULL | exposedField SFNode |
Appearance { # placed in appearance field in Shape node
| material | NULL | # see Material below | |
| texture | NULL | # see textures below | |
| textureTransform | NULL | # see TextureTransform below |
Material { # placed in material field in Appearance node
| ambientIntensity | 0.2 | # exposedField SFFloat | |
| diffuseColor | 0.8 0.8 0.8 | # exposedField SFColor, main shading color | |
| emissiveColor | 0.0 0.0 0.0 | # exposedField SFColor, glowing color | |
| specularColor | 0.0 0.0 0.0 | # exposedField SFColor, color of reflection highlight | |
| shininess | 0.2 | # exposedField SFFloat | |
| transparency | 0.0 | # exposedField SFFloat |
ImageTexture { # used in texture field in Appearance node
| url | [" "] | # exposedField MFString | |
| repeatS | TRUE | # field SFBool | |
| repeatT | TRUE | # field SFBool |
MovieTexture { # used in texture field in Appearance node
| loop | FALSE | # exposedField SFBool | |
| speed | 1.0 | # exposedField SFFloat | |
| startTime | 0.0 | # exposedField SFTime | |
| stopTime | 0.0 | # exposedField SFTime | |
| url | [" "] | # exposedField MFString | |
| repeatS | TRUE | # field SFBool | |
| repeatT | TRUE | # field SFBool | |
| duration_changed | # eventOut SFFloat | ||
| isActive | # eventOut SFBool |
PixelTexture { # used in texture field in Appearance node
| image | 0.0 0.0 0.0 | # exposedField SFImage | |
| repeatS | TRUE | # field SFBool | |
| repeatT | TRUE | # field SFBool |
TextureTransform { # used in texture field in Appearance node
| translation | 0.0 0.0 | # exposedField SFVec2f | |
| rotation | 0.0 | # exposedField SFFloat | |
| scale | 1.0 1.0 | # exposedField SFVec2f | |
| center | 0.0 0.0 | # exposedField SFVec2f |
Box {
| size | 2.0 2.0 2.0 | # field SFVec3f |
Sphere {
| radius | 1.0 | # field SFFloat | ||
Cylinder {
| radius | 1.0 | # field SFFloat | |
| height | 2.0 | # field SFFloat | |
| bottom | TRUE | # field SFBool | |
| side | TRUE | # field SFBool | |
| top | TRUE | # field SFBool |
Cone {
| height | 2.0 | # field SFFloat | |
| bottomRadius | 1.0 | # field SFFloat | |
| side | TRUE | # field SFBool | |
| bottom | TRUE | # field SFBool |
Text {
| string | [ ] | # exposedField MFString, separate strings with commas | |
| fontStyle | NULL | # exposedField SFNode | |
| maxExtent | 0.0 | # exposedField SFFloat | |
| length | [ ] | # exposedField MFFloat, lengths for each individual string |
FontStyle { # (a property node for the Text node above)
| family | "SERIF" | # field SFString | |
| horizontal | TRUE | # field SFBool | |
| justify | "BEGIN" | # field MFString | |
| language | " " | # field SFString, use of English recommended for compatibility | |
| leftToRight | TRUE | # field SFBool | |
| size | 1.0 | # field SFFloat | |
| spacing | 1.0 | # field SFFloat | |
| style | "PLAIN" | # field SFString | |
| topToBottom | TRUE | # field SFBool |
{
| translation | 0.0 0.0 0.0 | # exposedField SFVec3f | |
| rotation | 0.0 0.0 1.0 0.0 | # exposedField SFRotation | |
| center | 0.0 0.0 0.0 | # exposedField SFVec3f | |
| scale | 1.0 1.0 1.0 | # exposedField SFVec3f | |
| scaleOrientation | 0.0 0.0 1.0 0.0 | # exposedField SFRotation | |
| bboxCenter | 0.0 0.0 0.0 | # field SFVec3f, bounding box: used for render culling | |
| bboxSize | -1.0 -1.0 -1.0 | # field SFVec3f | |
| children | [ #enter nodes here ] |
Beam me up, Scotty!
Use the following sets in the geometry field of Shape node, as in:
geometry IndexFaceSet {
coord Coordinate {
| point | [ # enter XYZ coordinate list ] |
PointSet {
| color | NULL | # exposedField SFNode | |
| coord | NULL | # exposedField SFNode |
IndexedLineSet {
| color | NULL | # exposedField SFNode | |
| coord | NULL | # exposedField SFNode | |
| coordIndex | [ ] | # field MFInt32 | |
| colorIndex | [ ] | # field MFInt32 | |
| colorPerVertex | TRUE | # field SFBool | |
| set_coordIndex | # eventIn MFInt32 | ||
| set_colorIndex | # eventIn MFInt32 |
}
IndexedFaceSet {
| color | NULL | # exposedField SFNode | |
| coord | NULL | # exposedField SFNode | |
| normal | NULL | # exposedField SFNode | |
| texCoord | NULL | # exposedField SFNode | |
| ccw | TRUE | # field SFBool | |
| colorIndex | [ ] | # field MFInt32 | |
| colorPerVertex | TRUE | # field SFBool | |
| convex | TRUE | # field SFBool | |
| coordIndex | [ ] | # field MFInt32 | |
| creaseAngle | 0.0 | # field SFFloat | |
| normalIndex | [ ] | # field MFInt32 | |
| normalPerVertex | TRUE | # field SFBool | |
| solid | TRUE | # field SFBool | |
| texCoordIndex | [ ] | # field MFInt32 | |
| set_colorIndex | # eventIn MFInt32 | ||
| set_coordIndex | # eventIn MFInt32 | ||
| set_normalIndex | # eventIn MFInt32 | ||
| set_texCoordIndex | # eventIn MFInt32 |
}
ElevationGrid {
| color | NULL | # exposedField SFNode | |
| normal | NULL | # exposedField SFNode | |
| texCoord | NULL | # exposedField SFNode | |
| height | [ ] | # field MFFloat | |
| ccw | TRUE | # field SFBool | |
| colorPerVertex | TRUE | # field SFBool | |
| creaseAngle | 0.0 | # field SFFloat | |
| normalPerVertex | TRUE | # field SFBool | |
| solid | TRUE | # field SFBool | |
| xDimension | 0.0 | # field SFInt32 | |
| xSpacing | 0.0 | # field SFFloat | |
| zDimension | 0.0 | # field SFInt32 | |
| zSpacing | 0.0 | # field SFFloat | |
| set_height | # eventIn MFFloat |
}
The following are fields for the coordinate geometry nodes:
Color { # used in color field of coord geometry nodes
| color | [ ] | # exposedField MFColor (list of colors) |
}
TextureCoordinate { # used in the texCoord field in IndexFaceSet, ElevationGrid
| point | [ ] | # exposedField MFVec2f | ||
}
Normal { #used in normal field of IndexFaceSet and ElevationGrid
| vector | [ ] | # exposedField MFVec3f | ||
} #can be used with NormalInterpolator node
Extrusion {
| beginCap | TRUE | # field SFBool | |
| ccw | TRUE | # field SFBool | |
| convex | TRUE | # field SFBool | |
| creaseAngle | 0.0 | # field SFFloat | |
| crossSection | [ 1.0 1.0,1.0 -1.0, -1.0 -1.0,-1.0 1.0, 1.0 1.0 ] | # field MFVec2f | |
| endCap | TRUE | # field SFBool | |
| orientation | [ 0.0 0.0 1.0 0.0 ] | # field MFRotation | |
| scale | [ 1.0 1.0 ] | # field MFVec2f | |
| solid | TRUE | # field SFBool | |
| spine | [ 0.0 0.0 0.0, 0.0 1.0 0.0 ] | # field MFVec3f | |
| set_crossSection | # eventIn MFVec2f | ||
| set_orientation | # eventIn MFRotation | ||
| set_scale | # eventIn MFVec2f | ||
| set_spine | # eventIn MFVec3f |
}
DEF name node-type { ..}
# name can be composed of letters, numbers, underscores. Case sensitive,
cannot start with numbers.
USE name
Inlining is used for inserting separate VRML files such as furniture
in a room or rooms in a building.
Inline {
| url | [ "name.wrl" ] | # exposedField MFString | |
| bboxCenter | 0.0 0.0 0.0 | # field SFVec3f | |
| bboxSize | -1.0 -1.0 -1.0 | # field SFVec3f |
}
Background {
| skyColor | [ 0.0 0.0 0.0 ] | # exposedField MFColor | |
| skyAngle | [ ] | # exposedField MFFloat | |
| groundColor | [ ] | # exposedField MFColor | |
| groundAngle | [ ] | # exposedField MFFloat | |
| backUrl | [ ] | # exposedField MFString | |
| bottomUrl | [ ] | # exposedField MFString | |
| frontUrl | [ ] | # exposedField MFString | |
| leftUrl | [ ] | # exposedField MFString | |
| rightUrl | [ ] | # exposedField MFString | |
| topUrl | [ ] | # exposedField MFString | |
| set_bind | # eventIn SFBool | ||
| bind_changed | # eventOut SFBool |
}
Fog {
| color | 1.0 1.0 1.0 | # exposedField SFColor | |
| visibilityRange | 0.0 | # exposedField SFFloat | |
| fogType | "LINEAR" | # exposedField SFString, else EXPONENTIAL | |
| set_bind | # eventIn SFBool | ||
| bind_changed | # eventOut SFBool |
}
Beam me up, Scotty!
The ViewPoint node specifies the location of the viewer "eyes",
takes the place of cameras. NavigationInfo provides info on the viewer's
avatar, or virtual self, and how it navigates using the current viewpoint.
Viewpoint {
| position | 0.0 0.0 1.0 | # exposedField SFVec3f | |
| orientation | 0.0 0.0 1.0 0.0 | # exposedField SFRotation | |
| fieldOfView | 0.785398 | # exposedField SFFloat | |
| description | " " | # field SFString | |
| jump | TRUE | # exposedField SFBool | |
| set_bind | # eventIn SFBool | ||
| isBound | # eventOut SFBool | ||
| bindTime | # eventOut SFTime |
}
NavigationInfo {
| type | "WALK" | # exposedField MFString | |
| speed | 1.0 | # exposedField SFFloat | |
| avatarSize | [ 0.25, 1.6, 0.75 ] | # exposedField MFFloat | |
| headlight | TRUE | # exposedField SFBool | |
| visibilityLimit | 0.0 | # exposedField SFFloat | |
| set_bind | # eventIn SFBool | ||
| isBound | # eventOut SFBool |
}
DirectionLights are lights are lights aimed from infinity so that rays
are parallel, like the Sun. PointLight emanates in a radial pattern in
all directions, like a light bulb. SpotLights are light constrained in
a cone from the light source. Normal lighting is accomplished with the
headlight, a white DirectionLight that is automatic and is aimed from
your viewpoint. This can be truned off with the NavigationInfo node.
Note: In VRML, objects do not cast shadows. Faked shadows are used sometimes
for realism. Note also that there are some limitations in different browsers,
such as how a light will look and how many lights can be in any scene.
DirectionalLight {
| on | TRUE | # exposedField SFBool | |
| intensity | 1.0 | # exposedField SFFloat | |
| ambientIntensity | 0.0 | # exposedField SFFloat | |
| color | 1.0 1.0 1.0 | # exposedField SFColor | |
| direction | 0.0 0.0 -1.0 | # exposedField SFVec3f |
}
PointLight {
| on | TRUE | # exposedField SFBool | |
| location | 0.0 0.0 0.0 | # exposedField SFVec3f | |
| radius | 100 | # exposedField SFFloat | |
| intensity | 1.0 | # exposedField SFFloat | |
| ambientIntensity | 0.0 | # exposedField SFFloat | |
| color | 1.0 1.0 1.0 | # exposedField SFColor | |
| attenuation | 1.0 0.0 0.0 | # exposedField SFVec3f |
}
SpotLight {
| on | TRUE | # exposedField SFBool | |
| location | 0.0 0.0 0.0 | # exposedField SFVec3f | |
| direction | 0.0 0.0 -1.0 | # exposedField SFVec3f | |
| radius | 100 | # exposedField SFFloat | |
| intensity | 1.0 | # exposedField SFFloat | |
| ambientIntensity | 0.0 | # exposedField SFFloat | |
| color | 1.0 1.0 1.0 | # exposedField SFColor | |
| attenuation | 1.0 0.0 0.0 | # exposedField SFVec3f | |
| beamWidth | 1.570796 | # exposedField SFFloat | |
| cutOffAngle | 0.785398 | # exposedField SFFloat |
}
Sound in VRML 2.0 is 3D, the sound will seem to emanate from different
locations in the world. Sound formats include General MIDI type 1 or WAV.
Sound {
| source | NULL | # exposedField SFNode | |
| intensity | 1.0 | # exposedField SFFloat | |
| location | 0.0 0.0 0.0 | # exposedField SFVec3f | |
| direction | 0.0 0.0 1.0 | # exposedField SFVec3f | |
| minBack | 1.0 | # exposedField SFFloat | |
| minFront | 1.0 | # exposedField SFFloat | |
| maxBack | 10.0 | # exposedField SFFloat | |
| maxFront | 10.0 | # exposedField SFFloat | |
| priority | 0.0 | # exposedField SFFloat | |
| spatialize | TRUE | # field SFBool |
}
AudioClip # used in source field in Sound node
{
| url | [" "] | # exposedField MFString | |
| duration | " " | # exposedField SFString | |
| startTime | 0.0 | # exposedField SFTime | |
| stopTime | 0.0 | # exposedField SFTime | |
| pitch | 1.0 | # exposedField SFFloat | |
| loop | FALSE | # exposedField SFBool | |
| isActive | # eventOut SFBool | ||
| duration_changed | # eventOut SFFloat |
}
You can set the level of detail seen from a distance, used to speed
up rendering. Levels refer to shapes or url's of shapes, listed in order
from highest detail to lowest.
LOD {
| center | 0.0 0.0 0.0 | # field SFVec3f | |
| level | [ ] | # exposedField MFNode, shapes from high detail to low | |
| range | [ ] | # field MFFloat, distance in units, n-1 number of levels |
}
Beam me up, Scotty!
Sensors are used for animations or viewer interactions. Note that fields
without values are IMPLICIT, meaning you do not put them in your code,
they are there. See route examples to see how they are used.
TimeSensor {
| enabled | TRUE | # exposedField SFBool | |
| cycleInterval | 1.0 | # exposedField SFTime, sets cycle time | |
| loop | FALSE | # exposedField SFBool | |
| startTime | 0.0 | # exposedField SFTime, rarely used | |
| stopTime | 0.0 | # exposedField SFTime, rarely used | |
| isActive | # eventOut SFBool | ||
| time | # eventOut SFTime | ||
| cycleTime | # eventOut SFTime | ||
| fraction_changed | # eventOut SFFloat, mainly used |
}
Time Sensors are used to output to interpolators which then change a
node's position, rotation or scale. The time sensor is a clock used to
generate and control animations. Enabled turns clock on/off. CycleInterval
in seconds, is time to take fractional time from 0.0 to 1.0. This is what
you use to describe the length of animation. Loop TRUE makes continuous
loop. StartTime is absolute time in seconds to begin clock after 12:00
midnight GMT, Jan. 1, 1970 (birth of UNIX!) StopTime ends clock. Both
are used infrequently except to start/stop animations by other interpolators.
IsActive generates TRUE when sensor becomes active. Time outputs absolute
time continuously when sensor active. CycleTime outputs time whenever
cycle starts, or begins loops. Fraction_changed outputs fractional value
between 0.0 and 1.0 till end of cycleInterval, and at again at beginning
of each loop.
TouchSensor {
| enabled | TRUE | # exposedField SFBool | |
| isActive | # eventOut SFBool | ||
| isOver | # eventOut SFBool, mouse cursor overtop? | ||
| touchTime | # eventOut SFTime | ||
| hitNormal_changed | # eventOut SFVec3f | ||
| hitPoint_changed | # eventOut SFVec3f | ||
| hitTexCoord_changed | # eventOut SFVec2f |
}
TouchSensor is used to sense a viewer's mouse (or other pointer's) movement over a node, clicking on a node and/or dragging the node. A TouchSensor will affect any shape within it's group. Multiple sensors is allowable in a group. The innermost sensor in a nest of groups overrides the outer ones, (i.e. an on/off switch can be used on a movable object). Other notes:
autoOffset: when TRUE remembers last position, default.
Enabled: can be changed to start or stop animation or motion
hitPoint: the point at which the viewer points at the shape
max and minPosition: limits movement, can be used to constrain motion,
i.e. if min = max
The following three nodes act similar to the Touch Sensor, but are used to pick up and move shapes within a world:
PlaneSensor: moves shape in plane, like floor or wall
SphereSensor: moves shape around axis, like surface of ball
CylinderSensor moves shape around center axis, like record player or rolling pin
The CylinderSensor will look like a turntable if viewing from above,
like a roller viewed from side.
PlaneSensor {
| autoOffset | TRUE | # exposedField SFBool | |
| enabled | TRUE | # exposedField SFBool | |
| isActive | # eventOut SFBool | ||
| maxPosition | -1.0 -1.0 | # exposedField SFVec2f, maximum XY coordinates | |
| minPosition | 0.0 0.0 | # exposedField SFVec2f, minimum XY coordinates | |
| offset | 0.0 0.0 0.0 | # exposedField SFVec3f | |
| trackPoint_changed | # eventOut SFVec3f | ||
| translation_changed | # eventOut SFVec3f |
}
SphereSensor {
| autoOffset | TRUE | # exposedField SFBool | |
| enabled | TRUE | # exposedField SFBool | |
| isActive | # eventOut SFBool | ||
| offset | 0.0 1.0 0.0 0 | # exposedField SFRotation | |
| rotation_changed | # eventOut SFRotation | ||
| trackPoint_changed | # eventOut SFVec3f |
}
CylinderSensor {
| autoOffset | TRUE | # exposedField SFBool | |
| diskAngle | 0.262 | # exposedField SFFloat, (15 degrees) | |
| enabled | TRUE | # exposedField SFBool | |
| isActive | # eventOut SFBool | ||
| maxAngle | -1.0 | # exposedField SFFloat | |
| minAngle | 0.0 | # exposedField SFFloat | |
| offset | 0.0 | # exposedField SFFloat | |
| rotation_changed | # eventOut SFRotation | ||
| trackPoint_changed | # eventOut SFVec3f |
}
The ProximitySensor detects viewer cursor position. The Collision group
node detects when a viewer collides with an object such as a wall.
ProximitySensor {
| enabled | TRUE | # exposedField SFBool | |
| center | 0.0 0.0 0.0 | # exposedField SFVec3f | |
| size | 0.0 0.0 0.0 | # exposedField SFVec3f | |
| isActive | # eventOut SFBool | ||
| position_changed | # eventOut SFVec3f | ||
| orientation_changed | # eventOut SFRotation | ||
| enterTime | # eventOut SFTime | ||
| exitTime | # eventOut SFTime |
}
Collision {
| children | [ ] | # exposedField MFNode | |
| collide | TRUE | # exposedField SFBool | |
| bboxCenter | 0.0 0.0 0.0 | # field SFVec3f | |
| bboxSize | -1.0 -1.0 -1.0 | # field SFVec3f | |
| proxy | NULL | # field SFNode | |
| collideTime | # eventOut SFTime | ||
| addChildren | # eventIn MFNode | ||
| removeChildren | # eventIn MFNode |
}
VisibilitySensor {
| center | 0.0 0.0 0.0 | # exposedField SFVec3f | |
| enabled | TRUE | # exposedField SFBool | |
| size | 0.0 0.0 0.0 | # exposedField SFVec3f | |
| isActive | # eventOut SFBool | ||
| enterTime | # eventOut SFTime | ||
| exitTime | # eventOut SFTime |
}
Interpolators take info from sensors and route it to nodes. PositionInterpolator
sets position (translates), or scales (shrinks/enlarges), OrientationInterpolator
sets rotation angles. ColorInterpolator changes RGB colors. ScalarInterpolator
outputs a scalar value that can be used to set transparency, time values,
or anything else that requires or uses one value. Interpolators are usually
placed at end of the file, just before routing information.
PositionInterpolator {
| key | [ # enter key fields here ] | # exposedField MFFloat | |
| keyValue | [ # enter key position value fields here ] | # exposedField MFVec3f | |
| set_fraction | # eventIn SFFloat, implicit | ||
| value_change | # eventOut SFVec3f, implicit |
}
OrientationInterpolator {
| key | [ # enter key fields here ] | # exposedField MFFloat | |
| keyValue | [ # enter key rotation value fields here ] | # exposedField MFRotation | |
| set_fraction | # eventIn SFFloat | ||
| value_changed | # eventOut SFRotation |
}
ColorInterpolator { #note: interpolates HSV values for smooth color shift
| key | [ # enter keys here ] | # exposedField MFFloat | |
| keyValue | [ # enter key RGB color values here ] | # exposedField MFColor | |
| set_fraction | # eventIn SFFloat | ||
| value_changed | # eventOut SFColor |
}
ScalarInterpolator {
| key | [ # enter keys here ] | # exposedField MFFloat | |
| keyValue | [ # enter key values here ] | # exposedField MFVec3f | |
| set_fraction | # eventIn SFFloat | ||
| value_changed | # eventOut SFFloat |
}
CoordinateInterpolator {
| key | [ # enter keys here ] | # exposedField MFFloat | |
| keyValue | [ # enter key values here ] | # exposedField MFVec3f | |
| set_fraction | # eventIn SFFloat | ||
| value_changed | # eventOut MFVec3f |
}
NormalInterpolator {
| key | [ # enter keys here ] | # exposedField MFFloat | |
| keyValue | [ # enter key values here ] | # exposedField MFVec3f | |
| set_fraction | # eventIn SFFloat | ||
| value_changed | # eventOut MFVec3f |
}
Routes describe the path of action from a sensor, to interpolator (if
required), to shape node. For example, the following routes from a TimeSensor
(Clock) to the OrientationInterpolator (GlobePath), to the rotation of
a shape (Globe):
ROUTE Clock.fraction_changed TO GlobePath.set_fraction
ROUTE GlobePath.value_changed TO Globe.set_rotation
Scripts are Java or JavaScript apps used for creating more complex animations,
etc. The Script node provides a shell for the programs.
Script {
| url | [" "] | # exposedField MFString | |
| mustEvaluate | FALSE | # field SFBool | |
| directOutput | FALSE | # field SFBool |
# And any number of:
| field | # fieldType fieldName initialValue | ||
| eventIn | # eventTypeName eventName | ||
| eventOut | # eventTypeName eventName |
}
Beam me up, Scotty!
EXAMPLES
#VRML V2.0 utf8
#a simple box
Shape
{
| appearance Appearance | |
| { | |
| material Material { } | |
| } | |
| geometry Box { } |
}
#VRML V2.0 utf8
Shape {
| appearance Appearance { | |
| material Material { } | |
| } | |
| geometry Cylinder { | |
| height 2.0 | |
| radius 1.5 | |
| } |
}
#VRML V2.0 utf8
# crossed long boxes
# note commas between shape nodes
Group
{
| children | ||
| [ | ||
| Shape | { | |
| appearance DEF MyColor Appearance { | ||
| material Material { } | ||
| } | ||
| geometry Box {size 25.0 2.0 2.0} | ||
| }, | ||
| Shape | { | |
| appearance USE MyColor | ||
| geometry Box {size 2.0 25.0 2.0} | ||
| }, | ||
| Shape | { | |
| appearance USE MyColor | ||
| geometry Box {size 2.0 2.0 25.0} | ||
| } | ||
| ] |
}
#VRML V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
| children [ | ||
| # Rotating cylinder | ||
| DEF Column Transform { | ||
| rotation 0.0 0.0 1.0 0.0 | ||
| children Shape { | ||
| appearance Appearance { | ||
| material Material { } | ||
| } | ||
| geometry Cylinder { | ||
| height 1.0 | ||
| radius 0.2 | ||
| } | ||
| } | ||
| }, | ||
| # Animation clock | ||
| DEF Clock TimeSensor { | ||
| cycleInterval 4.0 | ||
| loop TRUE | ||
| }, | ||
| # Animation path | ||
| DEF ColumnPath OrientationInterpolator { | ||
| key [ 0.0, 0.50, 1.0 ] | ||
| keyValue [ | ||
| 0.0 0.0 1.0 0.0, | ||
| 0.0 0.0 1.0 3.14, | ||
| 0.0 0.0 1.0 6.28 | ||
| ] | ||
| } | ||
| ] |
}
ROUTE Clock.fraction_changed TO ColumnPath.set_fraction
ROUTE ColumnPath.value_changed TO Column.set_rotation
Beam me up, Scotty
© 2003 millenniumWAVE
technologies
Please acknowledge author
in use of any original material