This assignment is not highly coupled with the previous assignments. We are giving you a significant new code base (the curve_editor). You'll just use your OpenGL previsualization (from assignment 3) to view the triangle meshes you create.
In order to get your code to compile, you'll have to create some temporarily empty procedures in your Spline class. (Each is described below). Some of these may be pure virtual, depending on your implementation.
// FOR VISUALIZATION virtual void Spline::Paint(ArgParser *args); // FOR CONVERTING BETWEEN SPLINE TYPES virtual void Spline::OutputBezier(FILE *file); virtual void Spline::OutputBSpline(FILE *file); // FOR CONTROL POINT PICKING virtual int Spline::getNumVertices(); virtual Vec3f Spline::getVertex(int i); // FOR EDITING OPERATIONS virtual void Spline::moveControlPoint(int selectedPoint, float x, float y); virtual void Spline::addControlPoint(int selectedPoint, float x, float y); virtual void Spline::deleteControlPoint(int selectedPoint); // FOR GENERATING TRIANGLES virtual TriangleMesh* Spline::OutputTriangles(ArgParser *args);
For the first part of the assignment you may want to assume that your Bezier & BSpline curves have exactly 4 control points.
Q(t) = GbezierBbezierT = GbsplineBbsplineT
Remember, Q is the curve, parameterized by t. T is the power basis, a vector of all the powers of t up to the degree of our curve (for this assignment [t3 t2 t 1]T). Bbezier and Bbspline are the spline basis matrix functions which are constant for each type of spline. And finally Gbezier and Gbspline represent the control point geometry. Each control point is a column in the G matrix.
The test cases below will help you verify that you've correctly solved the matrix equation to convert between these two types of splines. The command line option -output_bezier <filename> or -output_bspline <filename> will indicate which representation you should use when you save the splines. Implement the OutputBezier(FILE *file) and OutputBSpline(FILE *file) functions.
You're only required to implement the Bezier to BSpline and BSpline to Bezier conversion for curves with exactly 4 control points. Converting curves with > 4 control points is worth extra credit. (There are different ways to do it.)
Implement the moveControlPoint(...), addControlPoint(...) and deleteControlPoint(...) functions to complete the curve editing implementation. Notice that by adding or deleting a control point, you will not have a round number of Bezier control point windows. You may choose to disallow adding or deleting control points on Bezier curves, or implement a control point duplication strategy to compensate. Also you may wish to disallow deletions if there are exactly 4 control points.
Once completed, the left mouse button is used to move a control point (the mouse down click must be within 10 pixels of a control point), the middle mouse button adds a control point on an edge (if the mouse down click is within 10 pixels of an edge) and the right mouse button deletes a control point (again if there is one within 10 pixels of the down click). Hitting the 's' key will save the geometry both in the spline format and the triangle mesh format (as specified on the command line).
You'll probably find the TriangleMesh::Merge(const TriangleMesh &m) function useful for combining multiple meshes into a single file.
You do not need to implement 3 dimensional editing of the control point grid for either the SurfaceOfRevolution or BezierPatch. (This is mostly a user interface issue, and has no "good" solution).
curve_editor -input spline8_01_bezier.txt -gui -curve_tessellation 30 curve_editor -input spline8_02_bspline.txt -gui -curve_tessellation 30
curve_editor -input spline8_01_bezier.txt -output_bezier output8_01_bezier.txt curve_editor -input spline8_01_bezier.txt -output_bspline output8_01_bspline.txt curve_editor -input spline8_02_bspline.txt -output_bezier output8_02_bezier.txt curve_editor -input spline8_02_bspline.txt -output_bspline output8_02_bspline.txt curve_editor -input output8_01_bezier.txt -gui -curve_tessellation 30 curve_editor -input output8_01_bspline.txt -gui -curve_tessellation 30 curve_editor -input output8_02_bezier.txt -gui -curve_tessellation 30 curve_editor -input output8_02_bspline.txt -gui -curve_tessellation 30
curve_editor -input spline8_03_bezier.txt -gui -curve_tessellation 30 curve_editor -input spline8_04_bspline.txt -gui -curve_tessellation 30 curve_editor -input spline8_05_bspline_dups.txt -gui -curve_tessellation 30
curve_editor -input spline8_06_torus.txt -curve_tessellation 4 -gui curve_editor -input spline8_06_torus.txt -curve_tessellation 4 -revolution_tessellation 10 -output torus_low.obj curve_editor -input spline8_06_torus.txt -curve_tessellation 30 -revolution_tessellation 60 -output torus_high.obj raytracer -input scene8_06_torus_low.txt -gui -size 300 300 raytracer -input scene8_06_torus_high.txt -gui -size 300 300
curve_editor -input spline8_07_vase.txt -curve_tessellation 4 -output_bspline output8_07_edit.txt -gui curve_editor -input output8_07_edit.txt -curve_tessellation 4 -revolution_tessellation 10 -output vase_low.obj curve_editor -input output8_07_edit.txt -curve_tessellation 10 -revolution_tessellation 60 -output vase_high.obj raytracer -input scene8_07_vase_low.txt -gui -size 300 300 raytracer -input scene8_07_vase_high.txt -gui -size 300 300
curve_editor -input spline8_08_bezier_patch.txt -gui curve_editor -input spline8_08_bezier_patch.txt -patch_tessellation 4 -output patch_low.obj curve_editor -input spline8_08_bezier_patch.txt -patch_tessellation 10 -output patch_med.obj curve_editor -input spline8_08_bezier_patch.txt -patch_tessellation 40 -output patch_high.obj raytracer -input scene8_08_bezier_patch_low.txt -gui -size 300 300 raytracer -input scene8_08_bezier_patch_med.txt -gui -size 300 300 raytracer -input scene8_08_bezier_patch_high.txt -gui -size 300 300
curve_editor -input spline8_09_teapot.txt -curve_tessellation 4 -gui curve_editor -input spline8_09_teapot.txt -patch_tessellation 4 -curve_tessellation 4 -revolution_tessellation 10 -output teapot_low.obj curve_editor -input spline8_09_teapot.txt -patch_tessellation 30 -curve_tessellation 30 -revolution_tessellation 100 -output teapot_high.obj raytracer -input scene8_09_teapot_low.txt -gui -size 300 300 raytracer -input scene8_09_teapot_high.txt -gui -size 300 300
curve_editor -input output8_07_edit.txt -curve_tessellation 20 -revolution_tessellation 100 -output vase_very_high.obj raytracer -input scene8_10_transparent_vase.txt -output output8_10.tga -grid 30 30 30 -size 300 300 -bounces 4 -shade_back -jittered_samples 9 -tent_filter 1.0 -shadows raytracer -input scene8_11_reflective_teapot.txt -output output8_11.tga -grid 50 30 30 -size 300 300 -bounces 4 -shade_back -jittered_samples 9 -tent_filter 1.0 -shadows
See the main Assignments Page for submission information.