|
|
VRML Script Tutorial
Full list
VRML Interactive Tutorial
Introduction
VRML File Structure
Drawing: Shape node
Geometry Nodes:
Appearance
Let there be Light
Materials with Colored Lights
Hierarchical Node Structures
Inlining Files
Defining and Instancing Nodes
Defining Levels of Detail
Events in VRML
Interpolators
Let the Music Play
Bindable Nodes
Adding Realism to the world
Information about your world
Definition for Auxiliary Nodes
|
|
|
|
Interpolators
Interpolators define a Dictionary from a key, ranging from 0.0 to 1.0, to a keyValue, which can take several types of data depending on the Interpolator. All fields and events are equal for all Interpolators, only the data type varies.
In VRML the following interpolators are available:
ColorInterpolator
CoordinateInterpolator
NormalInterpolator
OrientationInterpolator
PositionInterpolator
ScalarInterpolator
Interpolators have an eventIn, see events, set_fraction , and an eventOut value_changed. These two events are wired together, i.e. when the node receives a set_fraction event it generates a value_changed event.
The set_fraction event specifies a key value, the value_changed event outputs the data, specified in keyValue which corresponds to the key value given.
Interpolators combined with TimeSensors can be used to create animations, color variations, morphing objects, etc.... In each of the interpolator nodes, listed at the beggining of this section, an example will be provided.
One of the events generated by the TimeSensor node is the fraction_changed event. This event can be linked to the set_fraction event from the interpolator using a ROUTE. The interpolator will in turn generate the event value_changed. This event can then be routed to an exposed field of another node, for instance the color field of the Color node. The end result of this series of ROUTES is that the color of a given shape will change over time. The following figure shows the chaining of events between the nodes (read the figure from left to right):
In the remaining of this section a short disscussion of the fields present in all interpolators, key and keyValue, is presented.
For instance consider that the following values for key and keyValue are given:
key [0 1]
keyValue [-0.5 0.5]
If the set_fraction event inputs 0 then the value_changed event outputs -0.5. Similarly when the set_fraction event inputs 1 then the value_changed event outputs 0.5.
So what happens when the set_fraction event inputs 0.3? Well, it is time to look at the title of this section. The nodes being dealt with in here are interpolators, so when 0.3 is inputed, the output will be -0.2, i.e. the value which would correspond to the key 0.3 if all possible pairs ( key, keyValue) were specified and assuming that the pairs mentioned correspond to a straight line. The following figure shows how the keyValue for key 0.3 was computed.
The above example is a very simple one, you just specify two values for the key and the interpolator node does the rest.
This is OK if you want to specify a linear relation between key and keyValue. However there are situations when the desired relation is not linear.
You can specify as many elements as desired in the key and keyValue lists, note however that the lists must have the same length.
For instance consider that the following values for key and keyValue are given:
key [0 0.5 1]
keyValue [-0.5 0.0 -0.5]
The above figure represents the line segments which define the interpolator. In this example, a key of 0.3 and a key of 0.7 correspond to the same keyValue.
By using a larger number of points you can approximate a curve.
|