Animated Robot Arm

Project 4: Animator

Assigned: Monday, 17 May 1999
Due: Wednesday, 2 June 1999
Artifact: Friday, 4 June 1999


Project Objectives

This project is designed to introduce you to splines and how they are used for animation. There are two parts to this assignment. The first is to complete a keyframe animation system which is based on the project 2 modeler code. This system lets you assign a time-varying curve to the variables of your model that were controlled with sliders. The system currently only supports piecewise linear curves; your job is to extend it with several types of splines.

The second part, due shortly after the implementation is due, is to use your system to produce an animation based on the character you developed in project 2.

Using models with animator

The skeleton code contains the sample executable (a modeler.dll file) which has all the required curve types implemented, so you can see how they behave. It also contains the source for this extended modeler DLL, minus all the spline implementations.

Models from project 3 should require no changes for use with the animator. If you have models from project 2 that have not had the minor changes needed for project 3, you should make those changes to use them with the animator. You will need to recompile your models to link them against the new modeler, but no source changes should be required (unless your models are doing something exotic).

Note that in addition to modeler.tcl there is a new file curve.tcl. It is loaded by the modeler, and must be in the same directory as the modeler DLL (where your MODELER environment variable is set to).

There is a new control type called curve. This works just like scale, but does not create a slider in controls mode. Use this type if you want to animate a variable but don't want to clutter up the control panel with a slider for it. The arguments are the same as for scale, omitting the res argument.

Animator interface

When you first load a model, the UI will like just like it did in project 2. To create an animation, select Edit > Curve mode. This will replace your controls panel with something that looks like this (without the blue curve):

The x axis represents time; 20 seconds by default but this can be changed via the global parameters dialog. Every slider or curve control now appears in the animation variables menu. You can turn the display of individual curves on and off using this menu. At most one of the curves displayed can be selected. When a curve is selected, its control points are drawn with circles and can be edited. Create a new control point by clicking on the background. Control points can be dragged around, and deleted by control-clicking.

You can select any displayed curve by clicking it. Turning display of a curve on via the animation variables menu automatically selects it. Note that if a curve has 0 control points, nothing will be drawn (even if it is checked in the animation variables menu).

Clicking the right mouse button in the edit window will set the current time to correspond to that point. A vertical blue line will appear across the graph to indicate the time.

The curve settings menu changes how the control points are interpreted. Use this menu to change the type of spline used for a particular curve. The skeleton code has only the type linear; your job is to implement Bézier curves, B-splines, C2-interpolating splines, and Catmull-Rom splines. Other curve types may be added for extra credit.

Each curve type must support accept a wrapping flag, indicating whether the curve should continuously wrap around from the end of the animation back to the beginning.

Animations can be saved and reloaded. If you change the model, when you load an animation the system will match curves to saved values in the file based on the name of the control. Any name in the file that no longer exists in the model will be discarded, and any named control in the model with no corresponding curve in the file will be initialized to have zero control points.

Adding curve types

For each curve type you must write a function called curvetype_generate(). It takes the minimum and maximum x-extents ("x" in this case represents time in the animation, "y" represents the parameter value), a boolean flag indicating whether the curve is supposed to wrap around, and an array of control points. It should return an array of new points which are endpoints of segments approximating the curve.

For Bezier curves (and the splines based on them), it is sufficient to sample the curve at fixed intervals of time. The recursive subdivision algorithm presented in class may be implemented for an extra bell.

C2-interpolating splines have an extra two degrees of freedom that are unspecified by the control points. You should implement what will be referred to in class as "natural" C2-interpolating splines, that is, let the derivatives at the two endpoints be equal to zero. There are other valid ways to handle this, see the bells and whistles section.

Since the x-values for the points you return represent time, they need to be monotonically increasing. It doesn't make sense to have something moving backwards in time. Note that for interpolating curves (Catmull-Rom or C2-Interpolating splines), the fact that the control points are given to you sorted by x does not ensure that the curve itself will also monotonically increase in x. You should recognize and handle this case appropriately.

Animation Artifact

You will eventually use the curve editor to produce an animated artifact for this project. Each person must turn in their own artifact. We may give extra credit to those that are exceptionally clever or aesthetically pleasing. Try to use the ideas discussed in the John Lasseter article distributed in class. These include anticipation, follow-through, squash and stretch, and secondary motion.

Bells and Whistles

Many of these extra credit options require changing the user interface, which is written in Tcl/Tk. For information on Tcl/Tk, including links to tutorials and reference documentation, visit the Tcl resource page at Scriptics.

[bell] Use a recursive subdivision algorithm to produce Bézier curves, rather than just sampling them at some arbitrary interval. For an extra whistle, let the user control the flatness parameter. The number of points generated for each curve is displayed at the bottom right, so you can see how well your adaptive algorithm is working.


[whistle] Enhance the requred spline options. Some of these will require alterations to the user interface. Some suggestions:


[bell] Implement a "general" subdivision curve, so the user can specify an arbitrary averaging mask.


[bell+whistle] If you find something you don't like about the interface, or something you think you could do better, change it! Any really good changes will be incorporated into Animator 2.0.