Camera
The default camera position is at the origin pointed in the -z direction. We can, however, change
this position and orientation with the command
gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz);
where eyex, eyey, and eyez are the world coo
Both user interaction and animation utilize the event driven nature of the operating
system. Fortunately, GLUT has taken care of wrapping this functionality into callback
routines that are relatively easy to implement. However, if more complicated user
in
All vertices passed into the graphics card are processed by a multi-stage graphics pipeline. The
graphics pipeline is optimized to process graphics (as opposed to a more general purpose
computing pipeline such as on the CPU) which provides a great deal of
The simplest type of projection is known as orthographic, often used in engineering drawings. In
this projection mode, the camera is assumed to be at an infinite distance, i.e. at +|infin| looking in
the -z direction. Thus all rays become parallel and obj
Defining Geometry through Vertices
All objects in OpenGL are created through a set of polygons that are defined by the coordinates
of the corner vertices. The vertices are passed to the graphics pipeline from the application (i.e.
into the vertex processo
Mouse Input
Mouse input is handled by two mouse callbacks, the mouse clicked callback and the mouse
motion callback. The mouse clicked callback is called when a mouse button is pressed or
released and is registered via
glutMouseFunc(mouse_func);
where mou
Orthographic Projection and the Reshape Callback
Often it is convienient to define the geometry of the objects in our world without having to scale
everything to fit within the default extents of [-1,1]. This will usually produce a visually poor
scene (or
Vector/Matrix Operations
Addition
Addition is done componentwise for vectors/matricies that have the same dimensions. Hence
adding two vectors
would give
Similarly, adding matrices
would give
However the computation
would be undefined since the two operan
Conceptually, translation is simply a matter of adding the desired offsets to the components of
each vertex. Unfortunately the graphics pipeline is optimized to perform multiplication and
hence would require additional circuitry to implement addition in o
Spherical Coordinates
We have already discussed in previous labs how to reset the modelview matrix
using glLoadIdentity(). However often we wish to maintain a global transformation, e.g. one
produced by positioning the camera, for all objects in the scene
Perspective Projection
Unlike orthogonal projection where parallel lines remain parallel and the size of an object is
independent of its location relative to the camera, perspective projection is more akin to actual
scenes. For example, two parallel railr
Scaling Transformations
The simplest transformations to apply are scaling transformations which simply multiply each
component of a vector by a given amount known as the scale factor. If the scale factor is the
same for all components, then the transforma