CS 184: COMPUTER GRAPHICS
Lecture #11 -- Mo: 3/1, 1999.
PREVIOUS
< - - - - > CS
184 HOME < - - - - > CURRENT
< - - - - > NEXT
Preparation:
Read: Ch 5.6 "3D Transformations"; Ch 11.1.3, "Plane Equations";
Ch 15.2.4, "Backface Culling"
Lecture Topics
Review: Modeling in 3D
We have all the primitives we need, vertices, edges, faces,
and ways to put them together into groups using instance calls and
3D
transformations,
to form polyhedral scenes of arbitrary complexity.
Review: Rendering a 3D Scene
Simplest case to obtain 2D image from 3D scene:
Parallel Projection along z-axis ==> just ignore z
coordinate.
Set SLIDE: projectionflag to 0.
Other techniques used on assignments 3 and 4 readily carry over from
2D to 3D:
Formulate outcodes with 6 bits in 27 spatial partitions.
Check all 8 corners of a (transformed) bounding box against these outcodes.
Form AND function to look for trivial rejects -- work is done !
Form OR function for full acceptance for rendering -- no further BB
checks or clipping !
To save work, remove the polygons facing away from the viewer from the
rendering pipeline.
Check whether the scalar product between face normal and viewing direction
is positive !
For the special case of parallel projection down the z-axis, just check
wheter face normal has negative z-component.
(Later in the course this test will be done in a canonical view volume,
where it is also very simple).
Clipping in 3D
Polygon clipping is again done on the parameterized line segments (edges)
of the contour, but now against 4 or 6 clipping planes in 3-space.
This is not really different from before. For each line segment in the
polygon contour, just solve for the parameter value that gives the intersection
with the clipping boundary along that coordinate axis that is perpendicular
to the clipping boundary. To obtain the modified contour, Sutherland Hodgman
can be used again.
Cameras
The key parameters of a camera are: position (3 DOF), orientation (3 DOF)
== rigid body in 3D !
Furthermore: focal length --> determines opening angle of viewing pyramid;
possibly positioning and size of imaging plane ("film").
Look_at Transformation
This is convenient way to place and orient the camera (or any other object/group,
e.g. a gun) toward a part of the scene that is of interest. It consists
of specifications for the placement (eye), the viewing direction (target),
and the rotation around the viewing direction (up-vector). Even though
there are nine parameters in this specifications,
some of them are redundant, since there are only 6 DOF.
VRCS
In the case of a general camera position, we need to know what can be seen
from that camera position.
To make things simple, we make a coordinate system anchored at the
camera as a reference frame,
the View Reference Coordinate System (VRCS),
and transform the parts of the world to be rendered into this new reference
frame.
Reverse Camera Path
The desired transform into the VRCS can most easily be computed by modifying
the scene hierarchy so that the camera becomes its root, i.e., inverting
the matrices that lead from the world to the camera. Now every instanced
polygon in the scene can be described in the framework of the camera with
one compound matrix, and we can easily determine whether it can be seen
and how it would appear to the camera.
A similar technique will be used when we will have to deal with the
individual illuminations produced by one or more light sources: We will
make each one in turn temporarily the root of the hierarchy and determine
how each polygon appears in that special reference coordinate system for
a particular light.
Provide a convenient "user-centric" way to twiddle an object around for
inspection.
The basic approach keeps the various actions fairly separate and has
the following functionality:
RIGHT MOUSE: z-rotation
MIDDLE MOUSE: "zoom" = uniform scaling of object
LEFT MOUSE: Crystal ball interface = "simultaneous rotations around
x & y axes.
Enhanced ways
Mix in some amount of z-rotation into the dragging operation with
the LEFT MOUSE button:
The further the stroke passes away from the center of the screen, the more
the crystal ball responds with a pure z-rotation.
There are several different ways as to how exactly this can be achieved
(see
notes).
Rotation around arbitrary 3D axis
For the implementation of the crystal ball, we need a robust, efficient way to
turn an object around an arbitrary axis in 3-space.
We want to make many small, incremental rotations and continuously
form the composite transformation.
All these rotations need to be performed around axes that lie in 3-space
in a general direction.
In principle such a rotation around an arbitrary axis in space can be composed
from several rotations around the coordinate axes, for instance:
- rotate axis vector about z-axis until it falls into x-z-plane (angle aa);
- rotate axis vector about y-axis until it falls into z-axis (angle bb);
- do desired rotation around axis now parallel with z-axis;
- undo rotation about y-axis (angle -bb);
- undo rotation about z-axis (angle -aa);
[FIG: Rotation around arbitrary axis in 3D (Composite Matrix)]
A more powerful and elegant, but more abstract formalisms will be presented
in Discussion Session.:
Rodrigues Formula
Putting it all together
Soon we will build rather complex worlds with one or more cameras and lights,
all of which may be moving themselves. We need to find out how to coordinate
all this ... , for instance, where does Crystral ball transformation go
?
We create suitable compound matrices and their inverses for cameras,
lights, ... to deal with all objects into the coordinate system that make
the necessary computations most efficient and/or easiest to understand.
We also need to think about the exact order in which we want to do all
the necessary operations: culling, clipping ...
Remarks on Assignment #5
Based on a couple of short visits to the lab, I advise:
Don't be too timid in your transformations. Make big moves in your
scenes !
If you want to test clipping -- make sure there is lots of stuff to
clipp.
It is fine if the ship with all its attached contents moves back and
forth through scene!
Almost half the work in rendering is finding the right transformations
to make the task as easy and as efficient as possible.
Make sure you are comfortable with transformations !
New Homework Assignment:
ASG#5:
"Crystal Ball Interface"
DUE: Saturday 3/6/99, 11:59pm.
TO BE DONE with a NEW PARTNER !
--> Next
Lecture
<-- Up to CS
184 HomePage
Page Editor: Carlo H. Séquin