Unformatted text preview:

Some Sample Triangle Meshes What Polygon Meshes Are Explicit mesh description a list of polygonal faces F f1 f2 fn each polygon fi is a list of points this is sometimes called a polygon soup model vertices will be duplicated several times Indexed mesh description a list of vertices V p1 p2 pm a list of polygons each of which is a list of indices into V generally more space efficient requires random access to vertex set usually not a problem Drawing 3 D Triangle Meshes Very similar to closed curves emit a long list of vertices every triple assumed to be a face see also GL QUADS Also more efficient types fewer calls to glVertex GL TRIANGLE STRIP GL TRIANGLE FAN GL QUAD STRIP Drawing the Mesh glBegin GL TRIANGLES for int j 0 j n j glVertex3f glVertex3f glVertex3f glEnd Optimizing Drawing Triangle Strips glBegin GL TRIANGLE STRIP glVertex3fv v1 glVertex3fv v2 glVertex3fv v3 Triangle A glVertex3fv v4 Triangle B glVertex3fv v5 Triangle C glVertex3fv v6 Triangle D glEnd v2 v4 A v1 B C v3 v6 D v5 Emitting vertices costs something each must be transformed and lit fewer vertices faster drawing Take advantage of prior vertices first 3 specify triangle for each subsequent vertex take previous 2 vertices this will define the next triangle Up to a factor of 3 improvement for sufficiently long strips requires only 1 vertex triangle Trick is to generate strips usually start with just triangles Optimizing Drawing Triangle Fans glBegin GL TRIANGLE FAN glVertex3fv v1 glVertex3fv v2 glVertex3fv v3 Triangle A glVertex3fv v4 Triangle B glVertex3fv v5 Triangle C glVertex3fv v6 Triangle D glEnd v3 A lot like triangle strips but start with a central point build triangles around it Flat shading one constant color per triangle Also 1 vertex per triangle if the loop is sufficiently large but it usually won t be v2 Smooth shading one color per corner linear interpolation A B v4 Two Ways to Shade Triangles v1 C D v6 v5 Interpolation within a Triangle Drawing Polygons Fixed Shading With triangles can make good use of barycentric coordinates all points in triangle satisfy equation p2 p p0 p1 p 2 where 1 Hard coded colors on surface of model maybe from pre computed illumination e g radiosity explicitly specify 1 color per face vertex query point pc these coefficients are triangle area ratios Area pc p1 p 2 Area p0 p1 p 2 Area pc p 2 p0 Area p0 p1 p 2 Area pc p0 p1 1 Area p0 p1 p 2 p0 p1 Flat Shaded Smooth Shaded glBegin GL TRIANGLES for int j 0 j n j glColor3fv c glVertex3fv v1 glVertex3fv v2 glVertex3fv v3 glEnd glBegin GL TRIANGLES for int j 0 j n j glColor3fv c1 glVertex3fv v1 glColor3fv c2 glVertex3fv v2 glColor3fv c3 glVertex3fv v3 glEnd Flat vs Smooth Shading Drawing Polygons with Lighting We usually want OpenGL to infer colors via illumination model specify 1 normal per face vertex Computing Normals on Triangle Meshes v3 v2 a v 2 v1 b v 3 v1 Triangle defines unique plane can easily compute normal n a b a b depends on vertex orientation clockwise order gives n n v1 n4 n3 n1 n2 Vertex normals less well defined can average face normals works for smooth surfaces but not at sharp corners think of a cube Flat Shaded Smooth Shaded glBegin GL TRIANGLES for int j 0 j n j glNormal3fv n glVertex3fv v1 glVertex3fv v2 glVertex3fv v3 glEnd glBegin GL TRIANGLES for int j 0 j n j glNormal3fv n1 glVertex3fv v1 glNormal3fv n2 glVertex3fv v2 glNormal3fv n3 glVertex3fv v3 glEnd Drawing Wireframe Meshes Just draw each polygon as lines see also glPolygonMode glDisable GL LIGHTING glColor3fv black for int j 0 j n j glBegin GL LINE LOOP glVertex3fv v1 glVertex3fv v2 glVertex3fv v3 glEnd Removing Hidden Lines Where Do Meshes Come From Notice that we see all the lines even for triangles in back which can be confusing Manual construction write out polygons or maybe write some code to generate them or manually move vertices around in space There are many algorithms for this was once an important problem But OpenGL provides us a nice trick first draw all the polygons but in the background color now draw all the wireframe lines To make this look nice see glPolygonOffset make lines sit on top of polygons Acquisition from real objects via laser scanners vision systems generates set of points on surface need to build set of polygons surface reconstruction problem Awash in a Sea of Polygons Optimizing Drawing Level of Detail Control Acquisition systems often produce huge models millions of polygons per object are common billions of polygons per object are starting to happen dealing with these models is a real problem 300 million faces 3 7 GB after gzip compression Don t always need all the detail in models as objects move further away can see less and less This has led to a lot of current research compression can do much better than gzip for geometric models level of detail control don t draw what s too small to see Use models appropriate for current context maintain multiple versions of object 70 000 triangles 10 000 triangles 3000 triangles Optimizing Drawing Level of Detail Control The Problems of Polygons Pick the right model for the current viewing distance Problem 1 Not always very compact description it takes a lot of flat elements to make a smooth surface also need a lot of elements for highly detailed surfaces Problem 2 Hard to edit how do we easily edit a polygon surface don t want to just move individual vertices Most of the other representations are aimed at fixing these especially 1


View Full Document

U of I CS 418 - Polygonal Modeling

Loading Unlocking...
Login

Join to view Polygonal Modeling and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Polygonal Modeling and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?