Learn and apply 3D transformations.
More exercise with FLTK and direct
manipulation interface.
To Do:
Write a program that displays a 3D object in wireframe.
Allow the user to manipulate the object using
(a) FLTK sliders and (b) directly using the mouse.
You can do this task in stages.
Stage 1:
Create a 3D unit cube object.
The vertices go from (0,0,0) to (1,1,1).
The colors of the vertices are from a color cube going
from black (0,0,0) to white (1,1,1).
The cube is to be rendered in wireframe.
Place this cube so that it's centered at the
origin of the world frame i.e. coordinates of +/- 1/2.
Create the XYZ axes of the world frame.
Allow the display of these axes to be toggled on/off with
an FLTK button.
Note:
for simplicity, use orthographic projection with glOrtho.
Stage 2:
Add transformations using FLTK sliders.
All the transformations are relative to the cube's center!
Note: the world axes stays put and does not get transformed
like the cube. This will help give you a frame of reference.
Add sliders for translating the object.
Set bounds on the sliders so that the object
doesn't fly off the screen.
Add sliders for rotating the object.
If the cube has previously been translated,
then it will be rotated about its new position.
Add sliders for scaling the object.
Again, scaling is relative to the object's center.
Add a reset button to bring the cube back to the origin
of the world with the original size and orientation --
+/- 1/2.
Stage 3:
Add translation and rotation using mouse over the image.
Instead of using the slider to move the cube around,
use the right mouse instead.
Click down anywhere in the OpenGL window (no need to do picking
since there's only one object),
move the cube in the direction that the mouse is moving.
Translations need only be done for X and Y.
You will need to convert viewport (pixel) coordinates from
the amount of mouse movement to world coordinates to determine
how far to move the cube. Use some reasonable scaling term (similar
to mouse sensitivity adjustment).
Implement a virtual trackball to rotate the cube.
The rotation is again with respect to the cube's center.
There's a description of this in the text, and a number of
other places e.g. Graphics Gems.
You can also look at the following
Java3D
example.
Adjust the FLTK sliders as you're doing the translation and rotations.
Grading.
We must be able to compile/test your code.
For this program,
we'll accept code and accompanying make/project files, etc.
for any platform that we (the course assistants) can get
their hands on to compile/run/test your program.
Be sure to include a README in your submission
as to which platform to use.
Also be sure to confirm with the course assistants that
the platform you're planning to submit is going to work out
for them or not.
Submission.
Submission must be done using the submit or xsubmit utility from CATS.
Run "quickhelp submit" on a CATS machine to find out more info.
Create and submit a subdirectory called "prog3". It should
contain all the files you have in make your program compile/run.
Remember that 20% of the grade is towards documentation/readability/style.
Last modified
Wednesday, 11-Apr-2001 22:27:21 PDT.