timrighettini / CSCI_480_Assignment_2

0 stars 0 forks source link

Level 1 (spline): First, please implement your spline function and draw some splines to the screen. #1

Closed timrighettini closed 11 years ago

timrighettini commented 11 years ago

A point on a single Catmull-Rom spline segment is given by:

p(u) = [u^3 u^2 u 1] M C, (1)

where M is the Catmull-Rom spline basis matrix, C is the control matrix, and parameter u varies on the interval [0,1]. The exact form for M is given in the lecture notes, and also in Angel, p. 629 (for s=1/2). Note, however, that there is a typo in the formula in Angel: The last entry of the first row of M should be 1 instead of 0 (i.e. the first row of M should be [-1 3 -3 1] instead of [-1 3 -3 0]). Also, please do not forget to include the 1/2 factor before the matrix if you are using the formula in Angel.

Please consult the spline lecture notes (slide "How to Draw Spline Curves") for how to render a spline. You may use the simplest, "brute-force" method where you vary the parameter u by some fixed value, for example 0.001. Insert each value of u into equation (1) (above), to obtain the point location p(u). For example: u = 0.0, 0.001, 0.002, ..., 0.999, 1.0. Then, connect consecutive points with lines, for example, by using GL_LINES. You may need to set a proper line width, by using the OpenGL glLineWidth function. Note that in order to see the spline, you must setup your OpenGL camera. For a start, you can just use a stationary camera, similar to the first assignment (we recommend using gluPerspective for this assignment). You may use the keyboard/mouse to view the scene from different angles, or zoom in and out, just like in the first assignment. We provide a set of "track" files containing control points to define some simple splines, and starter code to read in a sequence of these files and convert them to sequences of control points that you can use. You can safely assume that each spline file (i.e. splines/*.sp) has at least 4 control points. You are encouraged to experiment with .sp files, creating your own spline files as needed for your personalized solution (well-documented creativity will be awarded).

timrighettini commented 11 years ago

This works for an odd number of control points, but not for an even number. I will investigate this ASAP.

timrighettini commented 11 years ago

Fixed the issue. The first control point was not being drawn. The splines draw well, but the smoothness factor for the recursive algorithm may need to be changed. Also, before closing this issue, the spline drawing results need to be stored in a display list. This display list will need to be destroyed and remade upon every transformation.

timrighettini commented 11 years ago

Done, with ONE spline only. This needs to be mentioned in the readme.