# meshes cs418 computer graphics john c. hart. simple meshes cylinder (x,y,z) = (cos , sin , z) cone...

21
Meshes CS418 Computer Graphics John C. Hart

Post on 17-Jan-2016

222 views

Category:

## Documents

Tags:

• #### verticesnew vertex position

TRANSCRIPT

Meshes

CS418 Computer Graphics

John C. Hart

Simple Meshes

• Cylinder

(x,y,z) = (cos , sin , z)

• Cone

(x,y,z) = (|z| cos , |z| sin , z)

• Sphere

(x,y,z) = (cos cos , cos sin , sin )

• Torus

(x,y,z) = ((R + cos ) cos ,(R + cos ) sin , sin )

Good Meshes

• Manifold: 1. Every edge connectsexactly two faces2. Vertex neighborhoodis “disk-like”

• Orientable: Consistent normals

• Watertight: Orientable + Manifold

• Boundary: Some edges bound only one face

• Ordering: Vertices in CCW orderwhen viewed fromnormal

Indexed Face Set

• 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

v x1 y1 z1

v x2 y2 z2

v x3 y3 z3

v x4 y4 z4

f 1 2 3f 2 4 3

(x1,y1,z1)(x2,y2,z2)

(x3,y3,z3)(x4,y4,z4)

Other Attributes

• 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)– Not necessarily in vertex order– Contains u,v surface parameters

• Faces– Uses “/” to separate indices– Vertex “/” normal “/” texture– Normal and texture optional– Can eliminate normal with “//”

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

(x0,y0,z0) (a0,b0,c0) (u0,v0)

(x1,y1,z1)(a1,b1,c1)(u1,v1)

(x2,y2,z2)(a2,b2,c2)(u2,v2)

f 0/0/0 1/1/1 2/2/2 f 0/0/0 1/0/1 2/0/2

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)

Implementation

• Face vertex

– For each faceadd vertex at its centroid

• Edge vertex

– How do we find each edge?

• New vertex position

– For a given vertexhow do we find neighboringfaces and edges?

Face vertex = average of face’s verticesEdge vertex = average of edge’s two vertices

& adjacent face’s two verticesNew vertex position = (1/valence) x sum of…

Average of neighboring face points2 x average of neighboring edge points(valence – 3) x original vertex position

v x1 y1 z1

v x2 y2 z2

v x3 y3 z3

v x4 y4 z4

f 1 2 3 4...

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

};

HalfEdge e;

class HalfEdge {HalfEdge *opp;Vertex *end;Face *left;HalfEdge *next;

};

HalfEdge e;

Half Edge

e e->opp()

class HalfEdge {HalfEdge *opp;Vertex *end;Face *left;HalfEdge *next;

};

HalfEdge e;

class HalfEdge {HalfEdge *opp;Vertex *end;Face *left;HalfEdge *next;

};

HalfEdge e;

Half Edge

e

e->start()

e->opp()

class HalfEdge {HalfEdge *opp;Vertex *end;Face *left;HalfEdge *next;

};

HalfEdge e;

class HalfEdge {HalfEdge *opp;Vertex *end;Face *left;HalfEdge *next;

};

HalfEdge e;

e->end()

e->start() = e->opp()->end();

Half Edge

e

e->left()

e->opp()

class HalfEdge {HalfEdge *opp;Vertex *end;Face *left;HalfEdge *next;

};

HalfEdge e;

class HalfEdge {HalfEdge *opp;Vertex *end;Face *left;HalfEdge *next;

};

HalfEdge e;

e->right()

e->right() = e->opp()->left();

e->next()

Half Edge

e

class HalfEdge {HalfEdge *opp;Vertex *end;Face *left;HalfEdge *next;

};

HalfEdge e;

class HalfEdge {HalfEdge *opp;Vertex *end;Face *left;HalfEdge *next;

};

HalfEdge e;

e->next()->next()

e->opp()

e->op

p()->

next(

)

Can walk around left faceuntil e(->next)n = e

Vertex Star Query

1. e

2. e->next()

3. e->next()->opp()

4. e->next()->opp()->next()

5. e->next()->opp()->next()->opp()

6. e->next()->opp()->next()->opp()->next()

7. e->next()->opp()->next()->opp()->next()->opp()

8. e->next()->opp()->next()->opp()->next()->opp()->next()

… until e(->next()->opp())n == e

1

2

3

4

5

67 8

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 290m resolution

Edge-Face-Vertex

HalfEdge *opp;

Vertex *end;

Face *left;

HalfEdge *next;

HalfEdge *opp;

Vertex *end;

Face *left;

HalfEdge *next;

Half Edges

HalfEdge *opp;

Vertex *end;

Face *left;

HalfEdge *next;

HalfEdge *opp;

Vertex *end;

Face *left;

HalfEdge *next;

f 1 2 3 <he>

f 3 2 4 <he>

f 3 4 5 <he>

f 1 2 3 <he>

f 3 2 4 <he>

f 3 4 5 <he>

Faces

v <x1> <y1> <z1> <he>

v <x2> <y2> <z2> <he>

v <x3> <y3> <z3> <he>

v <x1> <y1> <z1> <he>

v <x2> <y2> <z2> <he>

v <x3> <y3> <z3> <he>

Vertices

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

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?

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) = (Ni ∙ v + Di)2

112

3

45

6

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) + P2

2(x) = xT (Q1 + Q2) x