CS56 Computer Animation: Lab 3

In which, we build a curve editor for Catmull-Rom and Hermite splines

The goals of this lab are to


screesnhot


Get the source


This assignment has been added to your AnimationToolkit repository.

> cd cs56
> cd AnimationToolkit
> cd build
> cmake ..
> make 
> ../bin/a3-curveEditor

You should now have a new directory under assignments called a3-splines.


Assignment 3: The Catmull-Rom Com

Due September 27


In this assignment you will implement classes in the animation library. This code is in libsrc/animation. To start, look at ASpline.h and AInterpolator.h. These classes define the APIs (Application Programming Interfaces) you will work with this week. The ASpline class manages a list of keys (e.g. times and values) and can interpolate between them using an AInterpolator. How the spline interpolates between these keys will depend on what type of AInterpolator the ASpline uses.

Your base code includes three types of AInterpolator.

AInterpolator manages the list of control points for the spline. Subclasses of AInterpolator compute control points in AInterpolator::computeControlPoints and compute interpolated values in AInterpolator::interpolate.


User interface overview


The basecode includes a simple UI to help you test your splines.



The UI panel contains widgets for




Question 0: Code questions (5 points)


Please put the answers to the following questions in your readme for this week.




Question 1: Linear interpolator (5 points)


This question has two parts.

Part 1. For this question, modify the code in AInterpolator-basecode.cpp (libsrc/animation) to implement AInterpolatorLinear::computeControlPoints and AInterpolatorLinear::interpolate. The method, computeControlPoints, should set two control points for each segment. The order of the control points matter and show match the order of the user's keys.

To test your implementation, use the viewer. From the build directory, type

build> ../bin/a3-curveEditor 

Part 2. To start, the viewer should draw your keys but not the curve between them. To see your curve, implement the method ACurveeditor::drawCurve in ACurveEditor.cpp. Draw the spline similarly to how your drew your curves from the last assignment.


Question 2: Catmull-Rom interpolator (20 points)


This question has multiple parts.

Part 1 (10 points) For this part, modify the code in AInterpolator-basecode.cpp (libsrc/animation) to implement AInterpolatorCatmullRom::computeControlPoints. For each segment, you should set b0, b1, b2, and b3 (in this order). Check the output of testCatmullRom.cpp to check whether your implementation gives the same results as our example from class.

To run your program from the build directory, type

build> ../bin/a3-testCatmullRom 

Part 2 (10 points). For this part, modify the code in AInterpolator-basecode.cpp (libsrc/animation) to implement AInterpolatorCatmullRom::interpolate. You can use any method (Bernstein functions or de Casteljau's algorithm) to interpolate the segment. Check the output using the viewer.

To run from the build directory, type

build> ../bin/a3-curveEditor 




Question 3: Hermite interpolator (20 points)


This question has multiple parts.

Part 1 (10 points). Modify the code in AInterpolator-basecode.cpp (libsrc/animation) to implement AInterpolatorHermite::computeControlPoints. For each input key pi, you should set pi and p'i as control points (in that order). Check the output of testHermite.cpp to check whether your implementation gives the same results as our example from class.

To run your program from the build directory, type

build> ../bin/a3-testHermite 

Part 2 (10 points) Modify the code in AInterpolator-basecode.cpp (libsrc/animation) to implement AInterpolatorHermite::interpolate. You should use the Hermite form of the cubic bezier curve to interpolate. Check the output using the viewer.

To run from the build directory, type

build> ../bin/a3-curveEditor 




Question 4: Animate the dot (5 points)


In ACurveEditor::update(), use your spline to animate a dot so it moves along the spline. The basecode in ACurveEditor has a member variable mDot with type AVector3. Update the value of mDot.



Extra Credit (Up to 2 points)


Option 1Improve ASpline::computeSegment. This method uses linear search to find the interval containing time. Replace the implementation to use binary search.

Option 2 Now that your framework supports splines, try to make an interesting demo based on that. Some ideas



Option 3 Implement your own interpolator type!


Submission Requirements (1 points)