CS 184: COMPUTER GRAPHICS
PREVIOUS
< - - - - > CS
184 HOME < - - - - > CURRENT
< - - - - > NEXT
Lecture #7 -- We: 9/18, 2002.
COLLECT QUIZ #1
Review of Sutherland-Hodgman Polygon Clipping
GOAL: Clip polygon in such a way that it can be filled (painted) properly.
We need to clip away all polygon pieces that extend beyond window frame.
But we still need to maintain a properly oriented, closed polygon;
thus we need to maintain
the topology of the contour with respect to the window,
i.e., its winding number around the corners. This can be tricky.
To make things easier, we clip the polygon against one one window
edge (half-space) at a time .
This is much easier; the contour pieces extending beyond that straight
clipping edge
can just be rubber-banded into a straight line segment between the
exit and entry points of the contour piece that we cut off.
This whole process can then be pipelined, sending the polygon vertices
through four subsequent clippers, one for each window edge.
Example #1: simple polygon: "Arrow"
Basic algorithm: 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. Pipeline all four stages.
Review of Cohen-Sutherland Line Clipping in 2D
Do some region checks for trivial accept/reject decisions:
Use the 4 window edges to define 4 halfspace pairs, and set proper
bit in outcode equal to one.
Form the Boolean AND function for the outcodes of the endpoints of
a line,
to see whether the line can trivially be characterized as lying outside
the window.
Determine the parameter value for the crossing of the line with the
clipping boundary,
and move outer point to become the new endpoint of the line lying on
the boundary.
Outcodes work for bounding boxes too !
If all four corners are in a particular outside half-space, then the
whole Bbox is outside.
Polygon clipping is relevant to:
How to deal with hierarchical and dynamic scenes.
Dynamical bounding boxes; dynamical clipping.
Attend discussion session !
Study
on-line documentation !
LOD flag can be attached to any node: objects, instances, groups, or render
statements.
LOD flag limits the maximum detail shown anywhere in the whole subtree
below the flag.
SLF_FULL (show all) > SLF_EDGES (wireframe) >
SLF_BOUND (BBoxes) > SLF_OFF (nothing).
Note, this is not really a "level of detail" system in the sense that
it is used in complex models;
there you would have actual geometrical
models with different numbers of polygons;
but it is good enough to teach you the logic and mechanics of such
a system.
This has different inheritance rules !
Colors cannot readily be hierarchically ranked.
Applying paint to a subtree should not destroy detail work done at a lower
node.
==> Color is applied downward -- but only to un-colored nodes or
geometry !
This allows to color the upholstered seats of chairs differently, but
leave the metal frames untouched.
Cyrus-Beck and Liang -Barsky Line Clipping {F:
Ch 3.12.4}
Based on a parameterized line representation.
Avoids unnecessery clipping operations, uses a more efficient decision
tree !
(==> General Principle in Graphics: Don't do any unnecessary work !)
Input and output = sequence of vertices, ordered by their parameter
values t;
calculate the t-values of important events and do some "ordering"
comparison;
then do only the relevant clipping operations:
avoid multiple, redundant clips;
avoid unnecessary coordinate computations
(1-dimensional parameter computations are simpler/cheaper than 2- or
3-dimensional coordinate calculations).
Basic idea: A point can be in the window only if it is simultaneously
in x-strip and in y-strip;
==> two entry events must occur before the first exit
event occurs.
If you are clever, you don't even have to calculate all four parameter
values ...
e.g., if you find an exit point before the 2nd entry point (Liang-Barsky).
DOF: Degrees of Freedom -- another important concept.
Suppose, you want to make a randomized generator that produces line segments
to test the above algorithm.
All possible line segments should have a chance of being generated.
How many variables need to be randomized ?
Or, if you want to make an interactive generator in SLIDE,
how many individual (one-parameter) sliders would you need ?
Or, if you wanted to sample a given "world" with all possible camera
"windows",
-- How many parameters does this require ? -- Or how many DOFs does
this have ?
Similarly, how many DOFs are there for the specification of all possible
...
line segments in 2D: (4)
rectangles in 2D: ( )
infinitely long lines in 2D: ( )
spheres in 3D: ( )
planes in 3D: ( )
-- how could each of these systems be implemented ?
Another Semantic View of Transformations:
Re-interpretation of given coordinates in a new coordinate system
CASE 1: Ship (at SW) hits rock, gets Hole (H) in
known location of Ship's hull: HS = RS;
==> determineRock (R) position: RW = RS ( )S->W
; {R, H = row vectors! }
This is really just as before: We place the Hole hierarchically in
the World via Ship.
CASE 2: Now we ask a different question:
Given the Ship position (SW), and the Rock position (RW),
both in the World,
==> determine where the Hole will occur in the Ship's hull: RS=HS
==> or: what vector RS together with ( )S->W
will give the proper RW ?
We want: RW = RS * ( )S->W
To solve this: OUTSIDE-multiply both sides with [ ( )S->W)
]-1
==> RW * [ ( )S->W ]-1 = RS
* ( )S->W * [ ( )S->W ]-1
Thus: HS = RS = RW * [ ( )S->W
]-1
==> Hole position = Rock in S coord. = Rock in W coord. * [ (
)S->W ]-1
This has a geometric representation:
Conceptually, fix Hole in Shiphull (in yet unknown location),
move Ship (red) back to origin [ ( )S->W ]-1
,
and in that position read off the Hole location in Ship=World coordinates.
Interpretation with a modified scene hierarchy:
GENERALIZATION:
Relative positions between objects in different subtrees in hierarchical
scene trees.
Reading Assignment:
Study: 2ndEd: Ch 7.3-7.5,
Study: 3rdEd: Ch 8.4-8.6,
Current Homework Assignment:
ASG#3:
"Hierarchical Fish 'n' Ships"
TO BE DONE with a NEW PARTNER !
PREVIOUS
< - - - - > CS
184 HOME < - - - - > CURRENT
< - - - - > NEXT
Page Editor: Carlo H. Séquin