Asg 2: Rotate the camera in 3D perspective
Objectives
Set up a Camera
object (class) that contains the camera's
pos
(position),
ref
(refernce point), and
vup
(vertical tilt),
where each of these three are 3D vectors (a numpy.array
).
Provide GLUT callbacks to rotate the camera.
Assignment
- Use the
gldraw.py
program as the starting point,
which allows reading in of Alias Wavefront .obj
files.
- Create a
Camera
object that contains the following
data objects:
pos
position of the camera,
ref
ref point position, and
vup
the camera's tilt vector.
- Set up keyboard callbacks that adjust the camera position and reference
to rotate the camera
- pitching forward and back (rotate about x),
- panning left and right (rotate about y), and
- tilting left and right (rotate about z).
- Suggested key bindings
(if you use different ones, provide a USAGE file):
h
: pan left
j
: pitch down
k
: pitch up
l
: pan right
n
: tilt right
o
: tilt left
Details
- Your OpenGL code should set up a projection matrix with
gluPerspective(90,1.0,1.0,1000.0)
- Your OpenGL code should just use an identity matrix for the
modelview matrix, i.e.,
glLoadIdentity()
- Initialize the camera position, reference point, and tilt vector and
use them as arguments to
gluLookAt()
, starting with:
- pos:
0.0,0.0, 10.0
,
- ref:
0.0,0.0,-10.0
,
- vup:
0.0,1.0,0.0
.
- Set up keyboard callbacks so that, depending on the key pressed,
e.g.,
j
to pitch down, the camera object is
called so that "the camera rotates itself", e.g.,
the_camera.pitch(-10.0);
.
- The camera object can be made global, e.g., declared as
global the_camera
at the top of gldraw.py
just like global points
.
- For camera rotations, take a look at these
basic
rotations expressed in matrix form.
You will probably need to write these out in long form to change
to position of the camera's reference point with respect to
the camera's position or to use
numpy.array
matrices
(easier).
Requirements
- When you rotate the camera (e.g., pitch), it should eventually
make a full 360 degree rotation.
- Test your rotation code with the camera in place, e.g.,
don't translate the camera before testing rotation.
Turn in
Turn in all of your code, in one tar.gz
archive of your asg##/ directory, including:
- A
README
file containing
- Course id--section no
- Name
- Brief solution description
(e.g., program design, description of
algorithm, etc., however appropriate).
- Lessons learned, identified interesting features of your
program
- Any special usage instructions
- source code (
.py
source)
How to hand in
See handin
web page