Java Reference
In-Depth Information
Java 3D has provided, in the utility package, a number of interpolator classes, including
ColorInterpolator, PositionInterpolator, RotationInterpolator, ScaleInterpolator, SwitchVal-
ueInterpolator, TransparencyInterpolator and PathInterpolator classes.
Technically, each interpolator is a custom behavior with a trigger for waking each
frame along the time axis. Using the processStimulus method, an interpolator object will
check the associated alpha object for the current alpha value, carry out some appropriate
actions based on this value, and then reset its trigger to wake the next frame until the alpha
is finished.
In general, an interpolator object has two values that serve to denote the end points of
an interpolated action. For example, a RotationInterpolator object will have two angles
that specify the entire span of the rotation. As new frame come along, the object will check
the associated alpha value and make a suitable rotational adjustment to its target Trans-
formGroup object. An alpha value of 0 will result in one of the ending angle being used,
while an alpha value of 1 will lead to using the other extreme angle. On the other hand, if
the alpha value is between 0 and 1, the interpolator will linearly interpolate between the
two end point angles, and use the resulting interpolated angle to adjust the target object
appropriately.
While most interpolator objects are for carrying out an implicit interpolation function,
the SwitchValueInterpolator and PathInterpolator classes are for the purpose of branching
or switching. As an example, SwitchValueInterpolator will choose one of the target nodes
in a switch group based on the alpha value.
We will now give some illustrating examples on some of the important classes and
discuss how they can be used in practice.
positionInterpolator
The PositionInterpolator can be used to change the position of a visual object over time
in a translational manner. An example on how this can be used is illustrated in the code
segment and result in Figure 1.
In the code segment in Figure 1, a bounding sphere is defined in line 5. This specifies a
“live” region, within which changes to the position of the visual object can be made. Then,
an alpha object on how the position is changed is declared. Note that for smooth translation,
both INCREASING_ENABLE and DECREASING_ENABLE are used.
Line 14 creates the PositionInterpolator object. The input parameters are the alpha object
created earlier, the TransformGroup of the visual object, the axis of translation, and the
initial and final positions. By default, the object will be translated along the x-axis. Thus, in
order that the object moves along the y-axis, we need to rotate the axis of translation with
respect to the z-axis. This is the purpose of declaring Transform3D in the code segment.
Search WWH ::




Custom Search