Class 17 front and back lighting convex sets, convex hull triangulation why triangulation matters orientation drawing curves
Lighting: front, back, or both litTriangle.cpp glLightModel*(GL_LIGHT_MODEL_TWO_SIDED, GL_TRUE); a) use the GL_BACK (or GL_FRONT_AND_BACK) parameter values to color back-facing polygons b) reverse the specified vertex normal for back-facing polygons.
litTriangle.cpp try setting glColor3f( 1, 1, 0); //yellow try disabling lighting
Chapter 7 Convex set S If P and Q are points of S, then the segment connecting P and Q is also in S Does a triangle have to be convex? Does a quadrilateral have to be convex? got to here
Convex set S
Convex Hull The smallest convex set containing a set S in the convex hull of S.
The Intersection of convex sets is convex The Intersection of convex sets is convex. The Union of convex sets is NOT necessarily convex
If S={P1,P2, ... , Pk}, then the convex hull of S is the set of all convex combinations of S.
Chapter 8 Triangulation Suppose T is a collection of triangles and an object X is the union of these triangles. Let s and t be any two triangles from this collection. Good: s & t don't intersect s & t intersect at a vertex of each s & t intersect at a whole edge of each got to here
Examples: ✓ ✓ X ✓ X
What's wrong with a bad "triangulation"?
Answer: The rendering depends on the order you render the triangles.
If an object is made from a good triangulation then the image is independent of the order in which the triangles are rendered.
More good triangles gives better lighting
Trouble with non-convex polygons instead of triangles. Makes a fan around the first vertex. Which is first vertex?
Make sure polygons are convex (and coplanar)! GL_QUAD GL_POLYGON GL_QUAD_STRIP
Chapter 9 Orientation Front VS Back
THU triangle on transparency What do you see from each side? T H U
What does the viewer see? For each primitive, does the viewer see the vertices : CCW - counter clockwise: FRONT facing CW - clockwise: BACK facing (CCW is default FRONT, can be changed with glFrontFace(GL_CW) )
Should the triangle be drawn red or green?
Orientation of P,Q,R as viewed from the origin D = det PX QX RX PY QY RY PZ QZ RZ If D>0 then PQR looks Clockwise If D<0 then PQR looks Counter Clockwise
Consistent Orientation of a Triangulation: Any two triangles that share an edge order the edge oppositely. consistent inconsistent
squareOfWalls.cpp consistent
Run threeQuarterSphere.cpp one hemisphere, solid outside one overlapping hemisphere, lines outside
Culling Inside a closed sphere see one side of triangles only Outside, see the other side, only. culling - don't draw those we can't see Need to tell OpenGL
glCullFace(face) face GL_FRONT, GL_BACK, GL_FRONT_AND_BACK face says which are NOT to be rendered. Also need glEnable(GL_CULL_FACE);
sphereInBox1.cpp Note what happens when box is opened. Show where the culling code is. cull some other faces – have them try – with ball, box, lid, front or back do experiment
Discuss behavior under transformation Discuss behavior under transformation. Order preserving, order reversing, glFrontFace(GL_CW)
curves in 2-space plane curve: x = f(t) y = g(t) t∈[a,b] or (-∞, b], [a, ∞), (-∞, ∞) got to here
curveDrawerMJB.cpp run endpoints number of intervals and interval size y = x*x
curveDrawerMJB.cpp modifications y=sin(x) x=t y=sin(t) pick good a and b pick good MAX and MIN
curveDrawerMJB.cpp modifications circle x=cos(t) y=sin(t) pick good a and b pick good MAX and MIN