Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS418 Computer Graphics John C. Hart

Similar presentations


Presentation on theme: "CS418 Computer Graphics John C. Hart"— Presentation transcript:

1 CS418 Computer Graphics John C. Hart
Meshes CS418 Computer Graphics John C. Hart

2 Simple Meshes Cylinder (x,y,z) = (cos q, sin q, z) Cone
(x,y,z) = (|z| cos q, |z| sin q, z) Sphere (x,y,z) = (cos f cos q, cos f sin q, sin f) Torus (x,y,z) = ((R + cos f) cos q,(R + cos f) sin q, sin f)

3 Good Meshes Manifold: 1. Every edge connects exactly two faces 2. Vertex neighborhood is “disk-like” Orientable: Consistent normals Watertight: Orientable + Manifold Boundary: Some edges bound only one face Ordering: Vertices in CCW order when viewed from normal

4 Indexed Face Set Popular file format VRML, Wavefront “.obj”, etc.
(x4,y4,z4) (x3,y3,z3) Popular file format VRML, Wavefront “.obj”, etc. Ordered list of vertices Prefaced by “v” (Wavefront) Spatial coordinates x,y,z Index given by order List of polygons Prefaced by “f” (Wavefront) Ordered list of vertex indices Length = # of sides Orientation given by order (x2,y2,z2) (x1,y1,z1) v x1 y1 z1 v x2 y2 z2 v x3 y3 z3 v x4 y4 z4 f 1 2 3 f 2 4 3

5 Other Attributes Vertex normals Prefixed w/ “vn” (Wavefront)
v x0 y0 z0 v x1 y1 z1 v x2 y2 z2 vn a0 b0 c0 vn a1 b1 c1 vn a2 b2 c2 vt u0 v0 vt u1 v1 vt u2 v2 (x2,y2,z2) (a2,b2,c2) (u2,v2) Vertex normals Prefixed w/ “vn” (Wavefront) Contains x,y,z of normal Not necessarily unit length Not necessarily in vertex order Indexed as with vertices Texture coordinates Prefixed with “vt” (Wavefront) Contains u,v surface parameters Faces Uses “/” to separate indices Vertex “/” normal “/” texture Normal and texture optional Can eliminate normal with “//” (x0,y0,z0) (a0,b0,c0) (u0,v0) (x1,y1,z1) (a1,b1,c1) (u1,v1) f 0/0/0 1/1/1 2/2/2 f 0/0/0 1/0/1 2/0/2

6 Catmull Clark Subdivision
First subdivision generates quad mesh Generates B-spline patch when applied to 4x4 network of vertices Some vertices extraordinary (valence  4) Rules: Face vertex = average of face’s vertices Edge vertex = average of edge’s two vertices & adjacent face’s two vertices New vertex position = (1/valence) x sum of… Average of neighboring face points 2 x average of neighboring edge points (valence – 3) x original vertex position (boundary edge points set to edge midpoints, boundary vertices stay put)

7 Implementation Face vertex For each face add vertex at its centroid
Face vertex = average of face’s vertices Edge vertex = average of edge’s two vertices & adjacent face’s two vertices New vertex position = (1/valence) x sum of… Average of neighboring face points 2 x average of neighboring edge points (valence – 3) x original vertex position Face vertex For each face add vertex at its centroid Edge vertex How do we find each edge? New vertex position For a given vertex how do we find neighboring faces and edges? v x1 y1 z1 v x2 y2 z2 v x3 y3 z3 v x4 y4 z4 f ...

8 Half Edge class HalfEdge { HalfEdge *opp; Vertex *end; Face *left;
HalfEdge *next; }; HalfEdge e;

9 Half Edge e e->opp() class HalfEdge { HalfEdge *opp; Vertex *end;
Face *left; HalfEdge *next; }; HalfEdge e; e e->opp()

10 Half Edge e->end() e e->opp()
class HalfEdge { HalfEdge *opp; Vertex *end; Face *left; HalfEdge *next; }; HalfEdge e; e->end() e e->opp() e->start() = e->opp()->end(); e->start()

11 Half Edge e->left() e->right() e e->opp()
class HalfEdge { HalfEdge *opp; Vertex *end; Face *left; HalfEdge *next; }; HalfEdge e; e->left() e->right() e e->opp() e->right() = e->opp()->left();

12 Half Edge Can walk around left face until e(->next)n = e
class HalfEdge { HalfEdge *opp; Vertex *end; Face *left; HalfEdge *next; }; HalfEdge e; e->next() e e->opp() e->opp()->next() e->next()->next() Can walk around left face until e(->next)n = e

13 Vertex Star Query e e->next() e->next()->opp()
7 8 6 5 e e->next() e->next()->opp() e->next()->opp()->next() e->next()->opp()->next()->opp() e->next()->opp()->next()->opp()->next() e->next()->opp()->next()->opp()->next()->opp() e->next()->opp()->next()->opp()->next()->opp()->next() … until e(->next()->opp())n == e 4 3 2 1

14 Digital Michelangelo In 1998 Marc Levoy takes a sabbatical year in Florence to scan a bunch of Michelangelo sculptures David at 1mm resolution St. Matthew at 290m resolution

15 Edge-Face-Vertex Half Edges Faces Vertices HalfEdge *opp; Vertex *end;
Face *left; HalfEdge *next; f <he> f <he> f <he> v <x1> <y1> <z1> <he> v <x2> <y2> <z2> <he> v <x3> <y3> <z3> <he> HalfEdge *opp; Vertex *end; Face *left; HalfEdge *next;

16 Mesh Simplification Meshes often contain more triangles than are necessary for visual fidelity Some surface generation methods run at a fixed resolution regardless of surface detail Meshes might be used on different resolution devices, e.g. cellphone Need a method to reduce the number of triangles in a mesh Must figure out which triangles to remove while preserving visual shape and appearance 424,376 triangles 60,000 triangles

17 Edge Collapse Removing a vertex turns triangle mesh into polygon mesh
Removing an edge… Merges two vertices into one vertex Removes two faces Mesh still consists of triangles Which edges should be removed first? Where should the new vertices go?

18 QEM(v) = S (Ni ∙ v + Di)2 (for adjacent polygons i)
Vertex Importance Plane equation Pi(x,y,z) = Aix + Biy + Ciz + D Pi(x) = Ni ∙ x + D Pi(x) returns signed distance from x to plane passing through polygon i Best position of new vertex position minimizes squared distance to original planes of original polygons QEM(v) = S (Ni ∙ v + Di)2 (for adjacent polygons i) 2 1 1 3 6 4 5

19 Matrix Representation
Squared distance from point x to plane P P2(x) = (Ax + By + Cz + Dz)2 = xT Q x Sum of squared distances from point x to planes P1 and P2 P12(x) + P22(x) = xT (Q1 + Q2) x

20 Q(v) = S Qi (for adjacent polygons i)
Quadric Error Metric Find Q for each vertex v Q(v) = S Qi (for adjacent polygons i) Edge collapse edges whose vertices v1,v2 have least Q(v1) + Q(v2) New vertex v12 can be at v1 or v2 or optimally at …

21 Examples


Download ppt "CS418 Computer Graphics John C. Hart"

Similar presentations


Ads by Google