Upload
buituong
View
242
Download
2
Embed Size (px)
Citation preview
1
Meshes,data structures,simplification
CS 175
Meshes
82K vertices164K triangles
Simple file format?
Data structures?
4 vertices4 triangles
2
Wavefront file formatn Tetrahedron
# OBJ file format with ext .objv 1.0 0.0 0.0v 0.0 1.0 0.0v 0.0 0.0 1.0v 0.0 0.0 0.0f 2 4 3f 4 2 1f 3 1 2f 1 3 4
v x y z vertex f v1 v2 v3 face# comment
Objectsn Faces: polygons, triangles
n normal, area
n Verticesn coordinates, normal
n Edgesn creases, dihedral angles
n Boundariesn Euler formula:
n genus = 1 - (V-E+F+B)/2 n 4 - 5 + 2 + 1 = 2; 1 - 2/2 = 0
3
A factn usually for big meshes:
n F ≈ 2 Vn E ≈ 3 Vn why?
n usen average valence is sixn go through verts
n count adjacent facesn 6 V ≈ 3 F
Data structuresn Operations
n find normaln flat
n three verts of a face
n smoothn average normals: one-ring
» or
n use formula from subdivision
n given a face find verticesn given a vertex find faces
4
OpenGLn Flat shaded triangles
glBegin(GL_TRIANGLES);for(....) {
....glNormal3fv(n);glVertex3fv(v1); glVertex3fv(v2); glVertex3fv(v3);
}glEnd();
OpenGLn Smooth shaded triangles
....glNormal3fv(n1);glVertex3fv(v1);glNormal3fv(n2); glVertex3fv(v2); glNormal3fv(n3);glVertex3fv(v3);....
5
Operationsn naive procedure for smooth shaded:
n iterate through vertsn for every vertex compute normal
n need one ring of neighbors
n iterate through facesn for every face render a triangle with
normalsn face -> vertices
Face based meshn Vertex container
n vertex: 3 floats, 1 pointern coordinatesn pointer to adjacent face
n Face containern face: 6 pointers + ...
n pointers to neighbors, verticesn permutations
n no edges explicitlyn (v1, v2) or (f, side)
6
“permutations”n Useful to store orientation of the
neighboring facen a = [ A, C, B ]n b = [ C, D, B ]n a’s neighbors:
n (a, (0,1)) -> ..n (a, (1,2)) -> (b, (0,2))n (a, (2,0)) -> ..
a
b
A B
C D
02
10 1
2
Navigation: efsn Edge-face (ef)n Operations
n dest, org, facen sym, enext, fnext
n fnext(fnext(ef))==ef: fnext2 ==idn enext3==id, sym2==idn org(fnext(ef))==org(ef)n sym(org(ef))==dest(ef)
fnext(ef)
dest(ef)
ef
org(ef)
enext(ef)
7
Additional operationsn Bisection
n adds a vertexn bisect(ef, alpha)
n Edge-collapsen removes a vertex
n Edge-flipn beware of valence three
n these are useful. why?
Alternative: winged edgen Edge knows
n four edgesn two vertsn two faces
n Face knows n one edge
n Vertex knowsn one edge
8
Manifold conditionn Two kinds of vertices allowed
n inside vertexn full umbrella neighborhood
n boundary vertexn half umbrella neighborhood
n Prohibited configurations
Normalsn At a vertexn Tangent vectors
v0 v4
v3
v2
v1
)2cos(0
Nipt
N
ii
u π∑=
=
)2sin(0
Nipt
N
ii
v π∑=
=
vu ttn ×= tu
tv
n
9
Normals IIn Indeed for valence four
1
-1
00
0
0
1-1
Mean curvaturen Surface locally is like
n mean curvature is
n another way:
n Desbrun et al. ‘99:
221 κκ
κ+
=
22
21 yxz κκ +=
AA∇=⋅nκ
nppj ⋅−+−= ∑−
=
))(cot(cot41 1
0j
N
jjA
βακ
v0 v4
v3v2
v1
p
pj
pj+1
pj-1αj
βj
10
n Why do we need curvature?
Programming Assignment 1n Implement a mesh class
n Read/write .obj filen Show it in the viewer
n compute normals n flat and smooth shading
n compute curvatures
n OpenGL code providedn Keep in mind:
n p.a. #2 is mesh simplificationn p.a. #3 is subdivision
11
Mesh simplification
num of verts: 81457num of faces: 162910
60K verts 17K verts 400 verts
Clearly very importantn Laser scan is too finen Large planar areasn Rendering performancen Base for multires algorithms
n parameterizationn filteringn editingn progressive compression/transmission
12
Edge contractionn Hoppe and others ...
n need order in which to remove pointsn suggestions?
Polyline simplificationn How to simplify?n What is our goal?n pause.
13
Size vs error
number of vertices
error
Performancen Rate distortion curve
n compare different methods
n order defines performance
number of verticesarchive size -- rate
error
14
Choicesn Error from original
n usually too slown Local criteria
n fastern many small errors add upn each face responsible for region of the
original geometryn Need to accumulate error
n quadrics by Garland & Heckbert ‘97n programming assignment 2
Errorn Distance from a plane
n <n,p> = d
15
Error IIn Distance from several planes
n maxn mean
n advantages