Lighthouse3d.com

uW(.JUMLO-O)ͭKLSW(L)ɰU7TWHL(3RRl bJP< 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

Z6y ];CƼ.YN%s*[Tlש-Ϭ "AcBёd<)Hu)n4ݛ0cյ~\׷B [튂OX(<~X1C]Kl:/e}ݝ8y6K9fԏu{jS[@O4t<^UմGiׯiZ¹[_Dk- Wf8{PF{F/*T  b ,n[tfQҖñA$xs1 y̧w2B1o5WzN{Ubߦ(avώ\C I5x)&gA{lJċ&cd12h@S=\7K(sRQ`EF@IN ~Ur]mohV(ƷyRL }|dJ!lvKO܁d,^M ’&^z!K0lɆB0I0;crUuq)gYЁTh+Qb$m%鬩,80Ds m2cc=3ϜG㠍E3u8! (IӗOxzVng_(uNIA.D7Q@x'b U'[\?I^{͵у28R~L|qXwSEN#zs;hf=g"^yKϷ@QT.EH?`nVv m?s! U٤0j-BH?6^Y",Ry0C)sg,k;WWļgQ`]F-E_߿o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ǘp}㥬b|Lbw>}:_?HI ڨ{:1ػ_^Û˫7H]q_)BՃR]`y0_|E%|SJָ8_ԔtwI$uבA!7k:}fvUuu?Z;,I󤐇Τ(qFw:ɎY-~b<0sVaxTzԗ'?*W$ߕ>
ColorInterpolator

The ColorInterpolator node is an interpolator which takes a list of RGB values in the field keyValue.

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

Syntax:
ColorInterpolator {
key [ ]
keyValue[ ]
}




Example:

Using this interpolator to set an initial red color, and gradually change it to blue.

ColorInterpolator {
key [0 1 ]
keyValue[1 0 0, 0 0 1 ]
}

Using this interpolator to set an initial red color, change it to blue and afterwards change it to green.

ColorInterpolator {
key [0 0.5 1 ]
keyValue[1 0 0, 0 0 1, 0 1 0 ]
}

A complete example is now presented. A Shape is drawn with a default black diffuse color. The ColorInterpolator will set an initial red diffuseColor, and gradually change it to blue. After that the Shape will remain with a blue diffuse color.

First one needs the to define a Group with a Shape, a TimeSensor, and a ColorInterpolator.

#VRML V2.0 utf8

Group {
children [
Shape {
appearance Appearance {
material DEF mat Material { diffuseColor 0 0 0 }
}
geometry Sphere {}
}
DEF ci ColorInterpolator {
key [ 0 1 ]
keyValue [ 1 0 0, 0 0 1]
}
DEF ts TimeSensor {
cycleInterval 2
loop FALSE
}
]
}


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 ColorInterpolator by routing the fraction_changed eventOut from the TimeSensor to the set_fraction eventIn from the ColorInterpolator.

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 ColorInterpolator, this event outputs a RGB value.

Finally we use this eventOut to set a color in the Material node. Note that the color that we want to change is the diffuse color. Because the diffuseColor is an exposed field of the Material node we can use the eventIn set_diffuseColor to change the color. To do this we route the fraction_changed eventOut of the ColorInterpolator to the set_diffuseColor eventIn of the Material node.

The ROUTE statements to do this are:
ROUTE ts.fraction_changed TO ci.set_fraction
ROUTE ci.value_changed TO mat.set_diffuseColor
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.