1999 Autumn Quarter
Animator - Help Session Notes
Getting familiar
The animator project is basically an extended version of the modeler project you worked on for project 2.
There are a few new extensions that are worth paying attention to:
- Write Raytrace File - There is a new menu option that allows you to write a raytrace file. More
information is available here.
- Curve mode - From the "Edit" menu, there are options that allow you to choose between two modes -
Control Mode and Curve Mode.
Control Mode is essentially the same as in the original modeler project. All of the variable
parameters in your model appear as sliders or checkboxes.
Curve mode is a new mode that allows you to animate most of the controls (that were placed in
control mode) along curved paths. There are a few limitations in animating non-slider controls (like
checkboxes, etc) - you basically can't. In order to change the values of these types of elements, you have
to create a real-valued curve and then test its value, (e.g., call a positive value "true" and a negative
value "false", instead of calling get_control_b()).
- Use Curves - From the "Animate" menu, there is a checked menu option called "Use Curves".
Checking this option allows the user to view the animation using the created motion paths.
- Animation Variables - In Curve Mode, you can get a pop-up menu by left-click the curve editor.
On this menu, there is an option called "Animation Variables" that allows you to choose which animation variable's
path curve you are currently editing.
- Curve Settings - In Curve Mode, there is an option named "Curve Settings", located at the
same menu as "Animation Variables". This option allows you to choose which type of curve you are currently
using for the specified animation variable.
- Minimum Value and Maximum Value - In Curve Mode, there are two edit boxes, located below the
curve editor. These boxes are used to set the minimum and maximum y-values a curve can have.
- Scaling Factor - In Curve Mode, there is an edit box named "Scaling Factor", which is loacated
below the curve editor. This is used to scale the time axes.
- Curve Editor - You can add points to the curve window by simply right-clicking in the window.
You can move points by placing the mouse over the point, clicking and then dragging. You can remove points
by holding the [CTRL] key while clicking on a point. You can zoom in the curve by holding [SHIFT] key and
select the region that you want to zoom in.
Monotonic Curves
The handout specifies that time needs to be monotonically increasing, therefore your curves should never move in the
negative x-direction. After you get them working, you will notice that some of the curves will actually create loops or move
backwards for a short period of time when points are placed too close together. You will need to find a way to ensure that this
never happens.
STL Tips
Most of the code that you will be dealing with uses vector template. The easiest thing to think about this vector
is that it is like an array without limited size and with special methods to make your life easier.
The following methods are the most common methods that you will use to implement each curve type:
clear -- is used to clear all the content of the vector. This function does not take any input parameter.
resize -- is used to resize the vector into a certain size. It take one parameter with type integer.
push_back -- is used to insert an object (in this project, this will be a Point object) into the vector. This
method only take one parameter.
size -- to get the current size of the vector. This method does not have any parameter.
How To... in STL
How to loop through the vector
There are a couple of ways to make a loop using STl. The first one is to take the current size of the curve and then use it
to index the vector. The second one is to use STL's iter.
Example
Suppose that I have a vector of Point named foo.
int size = foo.size();
for (int i = 0; i < size; i++)
{ cout << foo[i].x << " " << foo[i].y << endl; }
OR...
for (vector<Point>::iter i = foo.begin(); i < foo.end(); i++)
{ cout << i->x << " " << i->y << endl; }
Note: there is only a single less than and greater than signs needed right and after Point. I don't know
how to display them correctly in HTML.
How to clear a vector
Just call clear method to erase all the content, i.e, foo.clear();
How to access a vector
Acessing a vector is the same as accessing the array. You should put the squared brackets. For exmple, you should have the
similar code as following: foo[2]; to access the third element of the vector. Remember that the vector is zero-based.
How to insert a new object into a vector
You should call push_back function to insert an object into a vector.
Suppose that you want to inser a point (3, 5) into a vector foo.
Your code will be like the following:
foo.pus_back(Point(3, 4));