Lighthouse3d.com

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

ZF~ 4 Xy,ox³rXRlL{E@\O66 MjbFB^WYݛ0KիkU¯ok 3=ӱHC{Qx 08K8|>\bI}(-$qҙlcFX'&1E,DCsUu˺^ͺuu%,|Ϳ6k$Z[o1XUz5y}ݫDg%4?Ou|{Q,^8(usZߛY%p`"m-\ Iԧw2Be#?j̯}"Y*xv2%H6H ? Pb3/Nهg3U0 h'fz.#1!tӱҧT $'_*H-I@Ƿ,Dir+ƷyR\ƌ>zt> bJI?yt%ҧ_ @4^C ’&^zaʼ0lɆB0I0;cru qijQЁ6Wܲ4!yx$&Ƴ4ć)BЦ Bv:yu3AO) IJ5BCR#$/x:*7E#JS :]& (d[삡jT>{J7?O h}44Ma,, IGb-t#9nv4Ck=g"nyKϷ@Ql*"&!zg*|HgU!f^#e,qﮅ S>) )B.yJ(/ "%Qh=.)[gxdq ɐ*@Jx(t. e}Jj@i_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lk4;|sA"YT`+orV1x vagM~OШV7:F%&mqAMp]1t N?s0 v\L(Vbf!B%7BZ,vyXZV$=A) Wh/HXT 5 ɾ2aD^h״ܥԔav7u! 5YkJ:+Xu8,^.@c`yǷZٍ9ՙH2P8^TUZt2%s&AN\"LSj6C}tWp{(b 64S^*㢤!|$1 M+]ҿG%0{2R5 F^"`? KoqCF8)0RT[wl\|ڏP_ % v Tt~=k 1 K1PqDBsړ?ϣJ#Kp4C{'YKb`*ⅲmMAVڻXPwXLL[XH7 *īd j_O%R,ݲʍtbmox,>֋wb 7cIۡ :\ޤҽdUlak.ާ}H=eGZQN^ hYsS a˅r /nFH]P-]O ̿A;r3).O
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.