11/16/04© University of Wisconsin, CS559 Fall 2004 Last Time Texture Anti-Aliasing Texture boundaries Modeling introduction.

Slides:



Advertisements
Similar presentations
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Building Models modified by Ray Wisman Ed Angel Professor of Computer Science,
Advertisements

1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
© University of Wisconsin, CS559 Spring 2004
Extended Gaussian Images
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
CS447/ Realistic Rendering -- Solids Modeling -- Introduction to 2D and 3D Computer Graphics.
HCI 530 : Seminar (HCI) Damian Schofield.
Modelling. Outline  Modelling methods  Editing models – adding detail  Polygonal models  Representing curves  Patched surfaces.
Polygonal Mesh – Data Structure and Smoothing
Introduction to Modeling. What is CG Modeling? Combination of Sculpting, Architecture, Drafting, and Painting. The core component of computer animation.
04/09/02(c) University of Wisconsin, CS559 Last Time Texturing in OpenGL Texturing Options Project 2 is now available. Start as soon as you can. Homework.
Modeling and representation 1 – comparative review and polygon mesh models 2.1 Introduction 2.2 Polygonal representation of three-dimensional objects 2.3.
11/30/04© University of Wisconsin, CS559 Fall 2004 Last Time More modeling: –Hierarchical modeling –Instancing and Parametric Instancing –Constructive.
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
CS-321 Dr. Mark L. Hornick 1 3-D Object Modeling.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
In the name of God Computer Graphics Modeling1. Today Introduction Modeling Polygon.
Mesh Representation, part I
11/19/02 (c) 2002, University of Wisconsin, CS 559 Last Time Many, many modeling techniques –Polygon meshes –Parametric instancing –Hierarchical modeling.
Polygon Lists & 3-D File Formats Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, February 18, 2002.
CS559: Computer Graphics Lecture 33: Shape Modeling Li Zhang Spring 2008.
4/15/04© University of Wisconsin, CS559 Spring 2004 Last Time More modeling: –Hierarchical modeling –Instancing and Parametric Instancing –Constructive.
11/11/04© University of Wisconsin, CS559 Fall 2004 Last Time Shading Interpolation Texture mapping –Barycentric coordinates for triangles.
Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Geometric Modeling using Polygonal Meshes Lecture 1: Introduction Hamid Laga Office: South.
HomeWork 2 Solution Chen Zhanqing.
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
Image Synthesis Rabie A. Ramadan, PhD 1. 2 About my self Rabie A. Ramadan My website and publications
03/24/03© 2003 University of Wisconsin Last Time Image Based Rendering from Sparse Data.
CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010.
Subdivision Schemes Basic idea: Start with something coarse, and refine it into smaller pieces for rendering –We have seen how subdivision may be used.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
Game Programming 06 The Rendering Engine
Geometric Modeling using Polygonal Meshes Lecture 3: Discrete Differential Geometry and its Application to Mesh Processing Office: South B-C Global.
GPH 338 Computer Animation Survey
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
04/18/02(c) 2002 University of Wisconsin Last Time Hermite Curves Bezier Curves.
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Subdivision Surfaces Greg Humphreys University of Virginia CS 445, Fall 2003.
In the name of God Computer Graphics. Introduction Modeling techniques modeling techniques managements Some renderings.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
CS559: Computer Graphics Final Review Li Zhang Spring 2010.
More Object Representations
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
Rendering Large Models (in real time)
Introduction to Meshes Lecture 22 Mon, Oct 20, 2003.
Modeling So far in class: –We’ve looked at images and image manipulation –We’ve looked at rendering from polygons Next major section: –Modeling You may.
Computer Graphics I, Fall 2010 Building Models.
11/12/02(c) University of Wisconsin, CS559 Last Time Texturing Details Homework 5.
Solid Modeling Dr. Scott Schaefer.
3D Object Representations. Introduction Line and circle and polygon algorithms- represented simple and smooth object. Some Natural object are neither.
CS559: Computer Graphics Lecture 33: Shape Modeling Li Zhang Spring 2008.
Introduction to Parametric Curve and Surface Modeling.

Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
POLYGON MESH Advance Computer Graphics
Lecture 33: Shape Modeling Li Zhang Spring 2008
Constructing Objects in Computer Graphics By Andries van Dam©
© University of Wisconsin, CS559 Spring 2004
© University of Wisconsin, CS559 Fall 2004
© University of Wisconsin, CS559 Fall 2004
© University of Wisconsin, CS559 Spring 2004
© University of Wisconsin, CS559 Fall 2004
© University of Wisconsin, CS559 Fall 2004
Chapter III Modeling.
Introduction to Meshes
Introduction to Parametric Curve and Surface Modeling
Introduction to Meshes
Last Time B-splines Project 3 was made available
Presentation transcript:

11/16/04© University of Wisconsin, CS559 Fall 2004 Last Time Texture Anti-Aliasing Texture boundaries Modeling introduction

11/16/04© University of Wisconsin, CS559 Fall 2004 Today Modeling with triangle meshes Homework 5 due No class Thursday Nov 18 But, homework 6 available, due Nov 30

11/16/04© University of Wisconsin, CS559 Fall 2004 Issues in Modeling There are many ways to represent the shape of an object What are some things to think about when choosing a representation?

11/16/04© University of Wisconsin, CS559 Fall 2004 Choosing a Representation How well does it represents the objects of interest? How easy is it to render (or convert to polygons)? How compact is it (how cheap to store and transmit)? How easy is it to create? –By hand, procedurally, by fitting to measurements, … How easy is it to interact with? –Modifying it, animating it How easy is it to perform geometric computations? –Distance, intersection, normal vectors, curvature, …

11/16/04© University of Wisconsin, CS559 Fall 2004 Boundary vs. Solid Representations B-rep: boundary representation –Sometimes we only care about the surface –Rendering opaque objects and geometric computations Solid modeling –Some representations are best thought of defining the space filled, rather than the surface around the space –Medical data with information attached to the space –Transparent objects with internal structure –Taking cuts out of an object; “What will I see if I break this object?”

11/16/04© University of Wisconsin, CS559 Fall 2004 Parametric vs. Implicit vs. Procedural Parametric generates all the points on a surface (volume) by “plugging in a parameter” –eg Implicit models use an equation that is 0 if the point is on the surface –Essentially a function to test the status of a point –eg Procedural: a procedure is used to answer any question you might have about the surface –eg Where does a given ray hit the surface?

11/16/04© University of Wisconsin, CS559 Fall 2004 Parameterization Parameterization is the process of associating a set of parameters with every point on an object –For instance, a line is easily parameterized by a single value –Triangles in 2D can be parameterized by their barycentric coordinates –Triangles in 3D can be parameterized by 3 vertices and the barycentric coordinates (need both to locate a point in 3D space) Several properties of a parameterization are important: –The smoothness of the mapping from parameter space to 3D points –The ease with which the parameter mapping can be inverted –Many more We care about parameterizations for several reasons –Texture mapping is the most obvious one you have seen so far; require (s,t) parameters for every point in a triangle

11/16/04© University of Wisconsin, CS559 Fall 2004 Techniques We Will Examine Polygon meshes –Surface representation, Parametric representation Prototype instancing and hierarchical modeling –Surface or Volume, Parametric Volume enumeration schemes –Volume, Parametric or Implicit Parametric curves and surfaces –Surface, Parametric Subdivision curves and surfaces Procedural models

11/16/04© University of Wisconsin, CS559 Fall 2004 Polygon Modeling Polygons are the dominant force in modeling for real-time graphics Why?

11/16/04© University of Wisconsin, CS559 Fall 2004 Polygons Dominate Everything can be turned into polygons (almost everything) –Normally an error associated with the conversion, but with time and space it may be possible to reduce this error We know how to render polygons quickly Many operations are easy to do with polygons Memory and disk space is cheap Simplicity and inertia

11/16/04© University of Wisconsin, CS559 Fall 2004 What’s Bad About Polygons? What are some disadvantages of polygonal representations?

11/16/04© University of Wisconsin, CS559 Fall 2004 Polygons Aren’t Great They are always an approximation to curved surfaces –But can be as good as you want, if you are willing to pay in size –Normal vectors are approximate –They throw away information –Most real-world surfaces are curved, particularly natural surfaces They can be very unstructured They are hard to globally parameterize (complex concept) –How do we parameterize them for texture mapping? It is difficult to perform many geometric operations –Results can be unduly complex, for instance

11/16/04© University of Wisconsin, CS559 Fall 2004 Polygon Meshes A mesh is a set of polygons connected to form an object A mesh has several components, or geometric entities: –Faces –Edges, the boundary between faces –Vertices, the boundaries between edges, or where three or more faces meet –Normals, Texture coordinates, colors, shading coefficients, etc Some components are implicit, given the others –For instance, given faces and vertices can determine edges –Euler’s formula: #Faces + #Vertices – #Edges = 2 - 2Genus, for closed polygon meshes

11/16/04© University of Wisconsin, CS559 Fall 2004 Polygonal Data Structures Polygon mesh data structures are application dependent Different applications require different operations to be fast –Find the neighbor of a given face –Find the faces that surround a vertex –Intersect two polygon meshes You typically choose: –Which features to store explicitly (vertices, faces, normals, etc) –Which relationships you want to be explicit (vertices belonging to faces, neighbors, faces at a vertex, etc)

11/16/04© University of Wisconsin, CS559 Fall 2004 Polygon Soup struct Vertex { float coords[3]; } struct Triangle { struct Vertex verts[3]; } struct Triangle mesh[n]; glBegin(GL_TRIANGLES) for ( i = 0 ; i < n ; i++ ) { glVertex3fv(mesh[i].verts[0]); glVertex3fv(mesh[i].verts[1]); glVertex3fv(mesh[i].verts[2]); } glEnd(); Important Point: OpenGL, and almost everything else, assumes a constant vertex ordering: clockwise or counter-clockwise. Default, and slightly more standard, is counter-clockwise Many polygon models are just lists of polygons

11/16/04© University of Wisconsin, CS559 Fall 2004 Cube Soup struct Triangle Cube[12] = {{{1,1,1},{1,0,0},{1,1,0}}, {{1,1,1},{1,0,1},{1,0,0}}, {{0,1,1},{1,1,1},{0,1,0}}, {{1,1,1},{1,1,0},{0,1,0}}, … }; (1,1,1) (0,0,0) (1,0,0)(1,1,0) (0,1,0) (0,1,1) (0,0,1) (1,0,1)

11/16/04© University of Wisconsin, CS559 Fall 2004 Polygon Soup Evaluation What are the advantages? What are the disadvantages?

11/16/04© University of Wisconsin, CS559 Fall 2004 Polygon Soup Evaluation What are the advantages? –It’s very simple to read, write, transmit, etc. –A common output format from CAD modelers –The format required for OpenGL BIG disadvantage: No higher order information –No information about neighbors –No open/closed information –No guarantees on degeneracies

11/16/04© University of Wisconsin, CS559 Fall 2004 Vertex Indirection There are reasons not to store the vertices explicitly at each polygon –Wastes memory - each vertex repeated many times –Very messy to find neighboring polygons –Difficult to ensure that polygons meet correctly Solution: Indirection –Put all the vertices in a list –Each face stores the indices of its vertices Advantages? Disadvantages? v0 v2 v1 v4 v3 v0v2v3v4v1vertices faces

11/16/04© University of Wisconsin, CS559 Fall 2004 Cube with Indirection struct Vertex CubeVerts[8] = {{0,0,0},{1,0,0},{1,1,0},{0,1,0}, {0,0,1},{1,0,1},{1,1,1},{0,1,1}}; struct Triangle CubeTriangles[12] = {{6,1,2},{6,5,1},{6,2,3},{6,3,7}, {4,7,3},{4,3,0},{4,0,1},{4,1,5}, {6,4,5},{6,7,4},{1,2,3},{1,3,0}};

11/16/04© University of Wisconsin, CS559 Fall 2004 Indirection Evaluation Advantages: –Connectivity information is easier to evaluate because vertex equality is obvious –Saving in storage: Vertex index might be only 2 bytes, and a vertex is probably 12 bytes Each vertex gets used at least 3 and generally 4-6 times, but is only stored once –Normals, texture coordinates, colors etc. can all be stored the same way Disadvantages: –Connectivity information is not explicit

11/16/04© University of Wisconsin, CS559 Fall 2004 OpenGL and Vertex Indirection struct Vertex { float coords[3]; } struct Triangle { GLuint verts[3]; } struct Mesh { struct Vertex vertices[m]; struct Triangle triangles[n]; } Continued…

11/16/04© University of Wisconsin, CS559 Fall 2004 OpenGL and Vertex Indirection (v1) glEnableClientState(GL_VERTEX_ARRAY) glVertexPointer(3, GL_FLOAT, sizeof(struct Vertex), mesh.vertices); glBegin(GL_TRIANGLES) for ( i = 0 ; i < n ; i++ ) { glArrayElement(mesh.triangles[i].verts[0]); glArrayElement(mesh.triangles[i].verts[1]); glArrayElement(mesh.triangles[i].verts[2]); } glEnd();

11/16/04© University of Wisconsin, CS559 Fall 2004 OpenGL and Vertex Indirection (v2) glEnableClientState(GL_VERTEX_ARRAY) glVertexPointer(3, GL_FLOAT, sizeof(struct Vertex), mesh.vertices); for ( i = 0 ; i < n ; i++ ) glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, mesh.triangles[i].verts); Minimizes amount of data sent to the renderer Fewer function calls Faster! Another variant restricts the range of indices that can be used - even faster because vertices may be cached Can even interleave arrays to pack more data in a smaller space

11/16/04© University of Wisconsin, CS559 Fall 2004 Yet More Variants Many algorithms can take advantage of neighbor information –Faces store pointers to their neighbors –Edges may be explicitly stored –Helpful for: Building strips and fans for rendering Collision detection Mesh decimation (combines faces) Slicing and chopping Many other things –Information can be extracted or explicitly saved/loaded

11/16/04© University of Wisconsin, CS559 Fall 2004 Normal Vectors Normal vectors give information about the true surface shape Per-Face normals: –One normal vector for each face, stored as part of face –Flat shading Per-Vertex normals: –A normal specified for every vertex (smooth shading) –Can keep an array of normals analogous to array of vertices –Faces store vertex indices and normal indices separately –Allows for normal sharing independent of vertex sharing

11/16/04© University of Wisconsin, CS559 Fall 2004 Cube with Indirection and Normals Vertices: (1,1,1) (-1,1,1) (-1,-1,1) (1,-1,1) (1,1,-1) (-1,1,-1) (-1,-1,-1) (1,-1,-1) Normals: (1,0,0) (-1,0,0) (0,1,0) (0,-1,0) (0,0,1) (0,0,-1) Faces ((vert,norm), …): ((0,4),(1,4),(2,4),(3,4)) ((0,0),(3,0),(7,0),(4,0)) ((0,2),(4,2),(5,2),(1,2)) ((2,1),(1,1),(5,1),(6,1)) ((3,3),(2,3),(6,3),(7,3)) ((7,5),(6,5),(5,5),(4,5))

11/16/04© University of Wisconsin, CS559 Fall 2004 Storing Other Information Colors, Texture coordinates and so on can all be treated like vertices or normals Lighting/Shading coefficients may be per-face, per-object, or per-vertex

11/16/04© University of Wisconsin, CS559 Fall 2004 Indexed Lists vs. Pointers Previous example have faces storing indices of vertices –Access a face vertex with: mesh.vertices[mesh.faces[i].vertices[j]] –Lots of address computations –Works with OpenGL’s vertex arrays Can store pointers directly –Access a face vertex with: *(mesh.faces[i].vertices[j]) –Probably faster because it requires fewer address computations –Easier to write –Doesn’t work directly with OpenGL –Messy to save/load (pointer arithmetic) –Messy to copy (more pointer arithmetic)

11/16/04© University of Wisconsin, CS559 Fall 2004 Vertex Pointers struct Vertex { float coords[3]; } struct Triangle { struct Vertex *verts[3]; } struct Mesh { struct Vertex vertices[m]; struct Triangle faces[n]; } glBegin(GL_TRIANGLES) for ( i = 0 ; i < n ; i++ ) { glVertex3fv(*(mesh.faces[i].verts[0])); glVertex3fv(*(mesh.faces[i].verts[1])); glVertex3fv(*(mesh.faces[i].verts[2])); } glEnd();