|
Use OpenGL to create an
orthographic camera.
Use glut to track the
position of the user’s mouse.
If the user depresses the
left mouse button in the OpenGL window, attach a new control point
to the user’s mouse and interactively render the uniform,
nonrational B-spline
that results from the current position of the user’s mouse (note
the point should be added to the end of the current spline).
When the user releases the left mouse button, deposit the
control point.
If the user presses down
with the middle mouse button, select the closest point (draw it
differently to indicate it is selected) and allow the user to drag
it someplace else. The
B-spline should be updated as the user drags.
If the mouse is far from any points when the middle button is
pressed, do nothing. When
the user releases the mouse button, deposit the control point in its
new position. Please
consider alternative editing techniques and include your thoughts in
the write up. For
example, if the user is close, but not quite touching a control
point, should the control point immediately snap to the user’s
mouse or remain an offset distance from the mouse?
If the users clicks the 'd'
key while they have selected a point with the middle mouse button,
delete the point.
If the user right clicks,
place a new control point at the location of the user’s mouse and
insert this control point between the two closest control points.
Note that this insertion method won’t allow the user to
create a new first point (and instead the first point must be moved
and a second point inserted). How
do you decide when the user desires to insert a new first point?
Include your thoughts in the write up.
Use a recursive subdivision
method to render spline as a piecewise linear curve (at most 100
control points will be entered). Many textbooks describe
adaptive subdivision methods for Bezier splines; the de Casteljau algorithm (p. 508 in Foley and van Dam and p. 353 in
Hearn and Baker). You may want to convert your B-spline to a Bezier
spline for subdivision (FvD p. 510 and H&B p. 349). If you have other
ways to accomplish the basic goal, to create a simple and intuitive spline editing program, then you should do as you
wish, however, I recommend you model the curve as a series of piecewise cubic
B-splines and convert to Bezier splines for subdivision.
(Extra credit) Integrate
your OpenGL/glut application with FLTK to add buttons to your
application. The
buttons should be used to select the interaction mode: add, move,
insert. Only the left
mouse button should be used for these operations.
|