OpenGL VRML Shockwave 3D
Home Tutorials Books Applications Tools Docs Models Textures

Send me bugs and suggestions, please
VRML Script Tutorial
Full list

VRML Interactive Tutorial

Introduction
VRML File Structure
Drawing: Shape node
Geometry Nodes:
Box
Sphere
Cone
Cylinder
PointSet
IndexedLineSet
IndexedFaceSet
Extrusion
ElevationGrid
Example: Chessboard
Text
FontStyle
Appearance
Material
Textures
Image Texture
Movie Texture
Pixel Texture
Texture Coordinate
Texture Transform
Let there be Light
Directional Light
Point Light
Spot Light
Materials with Colored Lights
Hierarchical Node Structures
Group
Transform
Collision
Anchor
Billboard
Switch
Inlining Files
Defining and Instancing Nodes
Defining Levels of Detail
Events in VRML
Creating Paths between events: ROUTE
Generating Events based on Timers or User Actions
Timers
Touch Sensor
Visibility Sensor
Dragging Sensors
Plane Sensor
Sphere Sensor
Cylinder Sensor
Proximity Sensors
Example: Proximity sensor
Interpolators
Color
Coordinate
Normal
Orientation
Position
Scalar
Example
Let the Music Play
Sound
AudioClip
Bindable Nodes
Who Am I: NavigationInfo
Where Am I: ViewPoint
Adding Realism to the world
Background
Fog
Information about your world
WorldInfo
Definition for Auxiliary Nodes
Coordinate
Color
Normal

OrientationInterpolator


The OrientationInterpolator node is an interpolator which takes a list of rotation values, i.e. a 3D coordinate plus an angle, in the field keyValue. See the Transform node for a brief explanation on rotations.

For a list of the events of this node see interpolator.

Syntax:
OrientationInterpolator {
key [ ]
keyValue[ ]
}


This interpolator is used to animate objects, rotating them according to the values in the keyValue field.

A complete example is now presented. A Shape is drawn at the origin. The OrientationInterpolator will rotate the shape to the right by 180 degrees and down again by 180 degrees. The cycle is repeated forever.

First one needs the to define a Transform with a Shape, a TimeSensor, and an OrientationInterpolator.

Example:
#VRML V2.0 utf8

DEF tr Transform {
children [
Shape {
appearance Appearance {
material DEF mat Material { diffuseColor 1 0 0 }
}
geometry Sphere {}
}
DEF oi OrientationInterpolator {
key [ 0 1 ]
keyValue [ 0 1 0 0,
0 1 0 3.14, # rotate right
0 0 1 3.14] # rotate down
}
DEF ts TimeSensor {
cycleInterval 2
loop TRUE
}
]
}


Note that whereas in the first two keyValues the interpolation is done in the angle, in the last two the interpolation is done in the vector which defines the interpolation.

Now the only thing which is missing is routing the events.

We need to get the eventOut fraction_changed generated by the TimeSensor. This event outputs a value between 0 and 1. We can use this value to set a key for the OrientationInterpolator by routing the fraction_changed eventOut from the TimeSensor to the set_fraction eventIn from the OrientationInterpolator.

A new fraction being set in an interpolator causes the keyValue to be changed. As a consequence the interpolator will generate the fraction_changed eventOut. Because the interpolator used is a OrientationInterpolator, this event outputs a rotation value.

Finally we use this eventOut to set a rotation in the Transform node. Because the rotation is an exposed field of the Transform node we can use the eventIn set_rotation to change it. To do this we route the fraction_changed eventOut of the OrientationInterpolator to the set_rotation eventIn of the Transform node.

The ROUTE statements to do this are:
ROUTE ts.fraction_changed TO oi.set_fraction
ROUTE oi.value_changed TO tr.set_rotation
Note that the nodes being routed are given a name using the DEF statement. This is because a name is required in a ROUTE statement.



Site designed and maintained by António Ramires Fernandes
Your comments, suggestions and references to further material are welcome!

Lighthouse 3D privacy statement