Animation is the creation of time-varying models. Alpha_1 has some loosely organized tools for animation which fall under two main categories. The simpler and more readily usable method is animated transformation. The more complicated and more powerful method is animated dependency graphs.
Animated transformations are based on instances of objects. Remember that an instance is an object transformed by an associated transformation. If that transformation changes over time, the instance will change as well. To create changing transformations, matDescrs, such as tx, rx, sx, accept curves as well as numbers. So whereas a static instance may look like this:
staticpt = instance( pt( 0,0 ), ty( 1.0 ) );a changing instance can be constructed like this:
motion_curve = profile( pt( 0,0 ), pt( 0.5,1 ), pt( 1,0.5 ) ); movept = instance( pt( 0,0 ), ty( motion_curve ) );Now, it may seem a little odd that
motion_curve
is a 2D curve but
ty needs a 1D (scalar) value. This is because motion curves can be thought of
representing time along their x-axis and the scalar value at that time along
the y-axis. To find the value of
ty( motion_curve )
at time t, we draw a
vertical line at x = t, find where it intersects the curve, and use that y
value as the scalar value for the matDescr.
Once a time-varying instance has been created, use one of the viewers and the Preview Animation selection under the View menu to view the animation.
This will tell you about rendering animations.
When designing an animation using animated transformations, it is important to keep in mind the limitations of the method. The only kind of animations possible are those you can specify with translations, rotations and scales. So most of the animations will be rigid bodies moving and rotating through space, with some cleverly chosen scaling to give the illusion of changing shape.
The other method of creating animations is through animated dependency graphs. This method only works with motif3d and c_shape_edit together. The idea here is to take advantage of the dependency propagation in c_shape_edit.
A keyword time
is defined in c_shape_edit (initially set to zero).
If that value is changed, any model that depends on time as part of
its construction will be updated. By setting the
Send time to shape_edit option in the Preview
Animation panel, the value of time in c_shape_edit will change to reflect the
value in the animation. Any model depending on time will change to reflect the
new value, and if it is currently being viewed in motif3d, it will be
updated.
Here is an example of a warped plane that changes over time. Time is used to control the cutoff distance for the warp, so as time gets larger, the warp gets larger as well. This type of changing model is impossible with the animated transformations described above.
flat = flatsrf( 3, 3, 12, 12 ); dir_vec = vec(0.0, 0.0, 1.0 ); center_pt = pt( 0, 0 ); warp_factor = 1.0; cutoff_dist = time; norm_int = 2; warp_srf = warp( flat, dir_vec, center_pt, warp_factor, cutoff_dist, norm_int ); show( warp_srf );
It is important to note that the time variable can also be used as part of
a formula, such as time * 50.0
, or sin( time )
.
There is also a handy c_shape_edit constructor to help stick animation
curves anywhere you want, not just in transformations, by using the time
variable. The constructor animnum( motion_curve )
can be used anywhere a
number can be used, but it changes its value based on the value of time.
So if you wanted the warp above to change its shape in a way that couldn't
be defined functionally, you could set
motion_curve = uniopcrv(3, {pt(0,0), pt(.1,1), pt(.2,5), pt(1,2) } ); cutoff_dist = animnum( motion_curve );And the warp distance would take on the y value of the motion curve at an x distance equal to time along the curve.
This will tell you about rendering animations.