Docsity

Polygon Models: Construction, Rendering, and Optimization, Study notes of Computer Graphics

Toggle sidebar
bg1
Today: Polygon Models (or Meshes)
This is what we’ve been using so far
• today we’ll fill in some details
Evaluating polygon model representation
• ease of construction: Good
• ease of manipulation: Fair
• rendering efficiency: Excellent — direct hardware support
• compact description: Fair
Recall What Polygon Meshes Are
Explicit mesh description
• a list of polygonal faces F= ( f
1
, f
2
, …, f
n
)
• each polygon f
i
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= ( p
1
, p
2
, …, p
m
)
• 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
Some Sample Triangle Meshes 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();
pf3
pf4
pf5

Partial preview of the text

Download Polygon Models: Construction, Rendering, and Optimization and more Study notes Computer Graphics in PDF only on Docsity!

Today: Polygon Models (or Meshes) This is what we’ve been using so far

• today we’ll fill in some details

Evaluating polygon model representation

• ease of construction: Good• ease of manipulation: Fair• rendering efficiency: Excellent — direct hardware support• compact description: Fair

Recall What Polygon Meshes Are Explicit mesh description

• a list of polygonal faces

F

= ( f

, f 1

, …, f 2

n^

• each polygon

f

is a list of points i

• this is sometimes called a “polygon soup” model• vertices will be duplicated several times

Indexed mesh description

• a list of vertices

V

= ( p

, p 1

, …, p 2

m

• 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

Some Sample Triangle Meshes

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

Two Ways to Shade Triangles Flat shading

• one (constant) color per triangle

Smooth shading

• one color per corner• linear interpolation

Drawing Polygons: Fixed Shading Hard-coded colors on surface of model

  • maybe from pre-computed illumination (e.g., radiosity)• explicitly specify 1 color per face/vertex Flat Shaded: glBegin(GL_TRIANGLES);

for(int j=0; j<n; j++){

glColor3fv(c);glVertex3fv(v1);glVertex3fv(v2);glVertex3fv(v3); } glEnd();

Smooth Shaded: 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 Flat Shaded: glBegin(GL_TRIANGLES);

for(int j=0; j<n; j++){

glNormal3fv(n);glVertex3fv(v1);glVertex3fv(v2);glVertex3fv(v3); } glEnd();

Smooth Shaded: glBegin(GL_TRIANGLES);

for(int j=0; j<n; j++){

glNormal3fv(n1);glVertex3fv(v1);glNormal3fv(n2);glVertex3fv(v2);glNormal3fv(n3);glVertex3fv(v3); }

Optimizing Drawing: Triangle Fans

A lot like triangle strips

  • but start with a central point• build triangles around it Also 1 vertex per triangle - if the loop is sufficiently large• but it usually won’t be

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

v^1

v

2

v

3

v

4

v

5

v

6

A

B C

D

Where Do Meshes Come From? Manual construction

• write out polygons• or maybe write some code to generate them• or manually move vertices around in space

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

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

Optimizing Drawing: Level of Detail Control Don’t always need all the detail in models

• as objects move further away, can see less and less

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 Pick the right model for the current viewing distance

The Problems of Polygons 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