CS 184: COMPUTER GRAPHICS
Lecture #7 -- We: 2/10, 1999.
PREVIOUS
< - - - - > CS
184 HOME < - - - - > CURRENT
< - - - - > NEXT
Preparation:
HAND-IN: Take-Home Quiz #1
Read Ch 3.12 "Line Clipping" (Read or Skim Cyrus Beck; Skip Liang-Barsky);
Ch 3.14 "Polygon Clipping"
Lecture Topics
Review of Hierarchical Bounding Boxes
Use of Bounding Boxes:
Effective culling, reduction of computation that needs to be done,
e.g.,
Visibility Culling: Is something sure to lie completely outside
viewing frustum ?
Collision detection: Are two objects overlapping ? - (Titanic
vs Iceberg).
Clipping: Cut away features outside display rectangle (more
next time).
An Example: Rollercoaster scene
Look at hierarchical bounding boxes.
Add windowing, culling and clipping (conceptually).
Review of Window to Viewport Transformation
Conceptuall: Window ==> NDC ==> Viewport;
in reality: a single composite transform: (Move to origin ) *
( appropriate scaling) * ( move to position of viewport)
Adjust scale factor so that the whole window fits without distortion;
i.e., based on the "more constraining" axis.
Clipping
General use:
Avoid interference outside a designated window.
Get rid of stuff that is outside field of view as early as possible.
Use hierarchy of the scene and tests of bounding boxes.
POINT Clipping (trivial)
Point (x,y) is in window if xl <= x <= xr AND if yb <= y
<= yt.
Hierarchical clipping using bounding boxes (Rollercoaster foils)
1.) Recursive bottom-up construction of BBoxes for each node of
the scene tree;
BB above any dynamic node need to be
reconstructed in every frame.
2.) Top-down testing of these BBoxes: 3-way decision:
eliminate all, render completely,
or open up box to next level and test
all BBoxes inside in same manner.
What if you have random point cloud (e.g., a rotating star cluster,
with no hierarchy ?
==> Must create some structure, e.g.
with octree or kD-tree.
Don't go too deep: 16-32 points per box are ok, for fewer, the overhead
gets expensive.
Now consider LINES: they have coherence, thus can
be treated more efficiently than random points.
Convexity of the window also helps: need to consider only endpoints
!
LINE Clipping in 2D. (Cohen-Sutherland) {Ch 3.12.3}
Do some region checks for trivial accept/reject decisions:
Whole window plane is divided into 9 regions by extending window edges.
Assign 4-bit outcode to the end vertices of the line segment.
1.) Trivial accept, if both end codes = 0000;
2.) Trivial reject if both end codes have one bit in common, e.g. "above",
both have 1xxx.
This can be done efficiently by forming
AND codes of the two endpoints ...
3.) If no trivial accept or reject, clip line against one window edge
at a time.
The clip point at window edge replaces
the outer, clipped point.
Continue on same line until obtaining a successful accept/reject
test.
This process is particularly efficient if the window is a small part
of the whole scene.
Parametric Line Representation
The individual line segments can be clipped conveniently, when they are
expressed in parameterized notation:
P(t) := A + t ( B - A ) = A ( 1 - t ) + B t
; with P(0) = A, P(1) = B
Finding t-value of x-clipping point: e= [ E - A ] / [ B - A ]:
just compare x-values !
Similarly, for a y=const-edge: just compare y-values of endpoints.
POLYGON Clipping. (Sutherland-Hodgman) {Ch 3.14}
Relevant to Homework #4 : clipped hierarchical animated scene.
Basically can clip the polygon sides that cross window frame with above
clipper,
but also need to fill in missing boundary pieces in order to close
and fill polygon.
Clip polygon against one edge at a time to produce proper corners.
Work with vertices and with conceptual rubberband between them.
Pipeline the whole process...
Simple polygon: "Arrow"
Basic concept: Walk around contour,
parametric clip of any edge that crosses to the outside,
"rubber-banding" the parts outside the window onto the window edge,
parametric clip of the edge that crosses back inside.
Do this for one window edge at a time !)
Complicated polygon "Double-Hook"
-- show what can happen: Spurious double edges !
Current Homework Assignment:
ASG#3:
"Hierarchical Fish 'n' Ships"
DUE: Saturday 2/20/99, 11:59pm.
TO BE DONE with a NEW PARTNER !
--> Next
Lecture
<-- Up to CS
184 HomePage
Page Editor: Carlo H. Séquin