Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class 18 front and back lighting convex sets, convex hull

Similar presentations


Presentation on theme: "Class 18 front and back lighting convex sets, convex hull"— Presentation transcript:

1 Class 18 front and back lighting convex sets, convex hull
triangulation why triangulation matters orientation drawing curves

2 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. front: specify vertices counterclockwise

3 litTriangle.cpp try setting glColor3f( 1, 1, 0); //yellow
try disabling lighting

4 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?

5 Convex set S

6 Convex Hull The smallest convex set containing a set S in the convex hull of S.

7 The Intersection of convex sets is convex
The Intersection of convex sets is convex. The Union of convex sets is NOT necessarily convex

8 If S={P1,P2, ... , Pk}, then the convex hull of S is the set of all convex combinations of S.

9 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

10 Examples: X X

11 What's wrong with a bad "triangulation"?

12 Answer: The rendering depends on the order you render the triangles.

13 If an object is made from a good triangulation then the image is independent of the order in which the triangles are rendered.

14 More good triangles gives better lighting

15 Trouble with non-convex polygons instead of triangles.
Makes a fan around the first vertex. Which is first vertex?

16 Make sure polygons are convex (and coplanar)!
GL_QUAD GL_POLYGON GL_QUAD_STRIP

17 Chapter 9 Orientation Front VS Back

18 THU triangle on transparency
What do you see from each side? T H U

19 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) )

20 Should the triangle be drawn red or green?

21 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

22 Consistent Orientation of a Triangulation: Any two triangles that share an edge order the edge oppositely. consistent inconsistent

23 squareOfWalls.cpp consistent

24 Run threeQuarterSphere.cpp
one hemisphere, solid outside one overlapping hemisphere, lines outside

25 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

26 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);

27 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

28 Discuss behavior under transformation
Discuss behavior under transformation. Order preserving, order reversing, glFrontFace(GL_CW)

29 curves in 2-space plane curve: x = f(t) y = g(t) t∈[a,b]
or (-∞, b], [a, ∞), (-∞, ∞) got to here

30 curveDrawerMJB.cpp run endpoints number of intervals and interval size
y = x*x

31 curveDrawerMJB.cpp modifications
y=sin(x) x=t y=sin(t) pick good a and b pick good MAX and MIN

32 curveDrawerMJB.cpp modifications
circle x=cos(t) y=sin(t) pick good a and b pick good MAX and MIN


Download ppt "Class 18 front and back lighting convex sets, convex hull"

Similar presentations


Ads by Google