Asg 1: Translate 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 translate 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.
- Note that you will need to use
numpy.array([0.0,0.0,0.0])
for each of the pos
, ref
, vup
instead of basic tuples (basic tuples are non-mutable).
- You can
import numpy as np
to make the typing easier
- Set up keyboard callbacks that adjust the camera position and reference
to move (translate) the camera
- left and right (crab),
- up and down (pedestal), and
- forward and back (dolly)
- Suggested key bindings
(if you use different ones, provide a USAGE file):
a
: crab left
z
: pedestal down
q
: pedestal up
d
: crab right
w
: dolly forward
s
: dolly back
Details
- Your code should set up a projection matrix with
gluPerspective(90,1.0,1.0,1000.0)
- Your 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,0.0
,
- vup:
0.0,1.0,0.0
.
- Set up keyboard callbacks so that, depending on the key pressed,
e.g.,
a
to translate left, the camera object is
called so that "the camera moves itself", e.g.,
the_camera.crab(-0.1)
.
- The camera object can be made global, e.g., declared as
global the_camera
at the top of gldraw.py
just like global points
.
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