|
Please note that this document is no longer up-to-date. (Though it is still valid.)
Please note that a more up-to-date document is available. A paper has been published that
covers the topic in a more comprehensive way. It proposes besides the Damper nodes also the
group of Chaser nodes that are usefull in cases where the Dampers fail.
To the paper: Linear Filters - Animating Objects in a Flexible and Pleasing Way
If you decide to continue reading this document, please keep in mind that now some fields on
the Damper nodes have
changed their name.
|
The Damper nodes are behavioral nodes that process
or generate animation data. They are comparable with the Interpolator
nodes. Their most important fields are an eventIn set_input
and an eventOut output_changed.
If they receive a value on set_input their
output_changed eventOut generates a
smooth animation from the current value to the one received.
The smoothness and speed of that animation can be controlled with the
tau and order parameters.
|
See the Damper Howto for scenarios where Dampers are
usefull and how to use them.
|
There are multiple *Damper PROTOs for different field types, like there
are multiple *Interpolator nodes. They all look similar:
EXTERNPROTO XxxxxDamper
[
eventIn SF<Type> set_input
field SF<Type> initial_input
eventOut SF<Type> output_changed
field SF<Type> initial_output
eventIn SF<Type> set_output
exposedField SFFloat tau # 1
field SFInt32 order # 1
field SFFloat eps # .001
eventOut SFBool isActive
eventOut SFBool isLoaded
]
"Dampers.wrl#XxxxxDamper"
|
|
|
The *Damper PROTOs can be used as simple animation creators, or as smoothers
for existing animations. They are behavioral nodes and don't have any
visible geometry.
The following data types can be animated by these nodes:
Use as Animation Creators:
If you want an object to go at a certain location, use a
PositionDamper and
send it the destination position everytime you want the object
to go to another place. The PositionDamper
will then create an animation from the objects current position
to the desired destination.
E.g. if you have a door and two buttons for opening and closing,
then use a PositionDamper
and route its output_changed
to the Transform containing
the door geometry. Send the door-open-position to the
set_input eventIn of the
PositionDamper when the
user clicks on the opening button and send it the door-close-position
when the user clicks on the close button. The
PositionDamper will do the
rest, even if user clicks on a button while the door is mooving.
This works as well for SFVec3f
as for SFRotation,
SFColor,
SFVec2f,
MFVec3f and
MFVec2f.
The duration of the animation can be controlled by the tau
parameter.
The *Damper nodes implement exponential approximation:
After a period of tau seconds 63 % of the distance to the destination
value have been reached. After another period of tau seconds 63 % of
the remaining distance have been reached, and so on. Therefore the
destination value is never reached perfectly, but practically the
animation stops very smoothly after a short number of tau periods.
The smoothness of the animations can be controlled with the
order parameter.
order specifies the
number of such filters to be used. When you set
order to one, the
object immediately starts moving when the *Damper
receives a new destination position. If the object is already
moving, it immediately changes the direction and speed of movement
in order to reach the new position.
When you set order to two, the
object also starts immediately, but it first accelerates
from zero speed, or its current speed, respectively. The acceleration
gets more efective if you further increase the value of
order.
Use as Animation Smoothers:
PositionInterpolator and
OrientationInterpolator create
linear animations that look somewhat computerish because the
animations they generate start immediately, stop immediately and
change speed immediately. There's no sense of heaviness in the objects movement.
If you put a *Damper
between an *Interpolator
and the animated object, you get a smoother movement that also features
some weight in the object. The animations become more continuous or consistent.
This principle also works for other data types than
SFVec3f and
SFRotation.
When you design the animation for the *Interpolator
node, take into account that the object will shorten its way through the world when you increase
tau or order.
You can also put a *Damper node between
a *Sensor
and the object it drives. With a value around .07 for
tau you create subjectively immediate
response but with the smooth movement of a weightfull object.
With a higher value you can generate the effect of inertia.
Explanation of the fields:
Thes are the main fields. Data that you send to to the set_input
eventIn is filtered and output on the output_changed
eventOut.
tau controls the time constant of one filter
and order determines how many
such filters are applied to the input before it is sent to the output.
tau must have positive values or
be 0.
If tau is 0, the
*Damper node directly copies input to the
output. If tau is positive,
it determines the time the output of a filter needs to reach 63 %
of its distance to the input of the filter. order must be in the range 1..5 .
More filters are not supported.
These fields allow to set initial values for input and output.
After loading the PROTO output_changed
assumes the value assigned to initial_output
and animates to the value assigned to initial_input.
You can acheive two effects with these fields: playing an animation at
world start time if you set them to different values and have the output start
at a nonzero value if you give both fields the same value.
This allows you to set the output directly. When set_output
receives a value, output_changed jumps to
that value and animates back to the value of set_input.
If you send a value to both, the set_output
and set_input eventIns, the
output_changed eventOut jumps
to that value and stays there.
See the demo of the
Position2fDamper and click
on the buttons surrounding the square to see how sending a value to
set_output works.
This field allows you to specify a tolerance that ends an animation.
If there were no such value the *Damper
nodes would forever output values on output_changed
that only minimally change. To avoid this you can specify a distance
and if the difference between input and output is less than this difference
output_changed is set to
the value of set_input and
stops sending values.
The eps is not present on
all *Damper nodes because
for some of them a reasonable value for eps
can automatically be found.
This indicates when a *Damper
outputs values. If isActive
outputs TRUE
output_changed differs from
the value of set_input and
animates to that value. If isActive
outputs FALSE
output_changed has just reached
the value of set_input and
will no longer output values.
This is just a field that allows you to get noticed when the
EXTERNPROTO has
loaded and is ready to respond to eventIns. It outputs
TRUE right
after the node has loaded and after that does not output
anything.
|