CS 543: Computer Graphics Lecture 04 Part III: 3D Modeling: Polygonal Meshes. Emmanuel Agu

Similar documents
CS 4731/543: Computer Graphics Lecture 3 (Part III): 3D Modeling: Polygonal Meshes. Emmanuel Agu

Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley

Computer Graphics. This Week. Meshes. Meshes. What is a Polygon Mesh? Meshes. Modelling Shapes with Polygon Meshes.

Computer Graphics (CS 543) Lecture 4a: Linear Algebra for Graphics (Points, Scalars, Vectors)

CS Computer Graphics: Hidden Surface Removal

Lecture 7: Building 3D Models (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Parametric description

Modeling. Simulating the Everyday World

Graphics and Visualization

COMP3421. Introduction to 3D Graphics

Chapter 4-3D Modeling

COMP3421. Introduction to 3D Graphics

3D Graphics and OpenGl. First Steps

Computer Graphics CS 543 Lecture 13a Curves, Tesselation/Geometry Shaders & Level of Detail

Filled Area Primitives. CEng 477 Introduction to Computer Graphics METU, 2007

Using GLU/GLUT Objects

CS451Real-time Rendering Pipeline

Computer Graphics 1. Chapter 2 (May 19th, 2011, 2-4pm): 3D Modeling. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2011

Graphics Pipeline : Geometric Operations

Surface and Solid Geometry. 3D Polygons

Fundamentals of Computer Graphics. Lecture 3 Generate a simple shape using OpenGL. Yong-Jin Liu

Mesh Representations & Geometry Processing

Computer Graphics CS 543 Lecture 1 (Part I) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Painter s HSR Algorithm

Lecture 7 CISC440/640 Spring 2015

CSE4030 Introduction to Computer Graphics

Transformation Hierarchies. CS 4620 Lecture 5

lecture 18 - ray tracing - environment mapping - refraction

11/1/13. Polygon Meshes and Implicit Surfaces. Shape Representations. Polygon Models in OpenGL. Modeling Complex Shapes

CHAPTER 1 Graphics Systems and Models 3

Three-Dimensional Object Representations Chapter 8

3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

CS 543: Computer Graphics Midterm review. Emmanuel Agu

Building Models. Objectives Introduce simple data structures for building polygonal models. Vertex lists Edge lists

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

Animation & Rendering

COMP3421. Introduction to 3D Graphics

Three-Dimensional Shapes

3D Modeling: Surfaces

Computer Graphics. Prof. Feng Liu. Fall /21/2016

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Building Models. Objectives. Introduce simple data structures for building polygonal models. OpenGL vertex arrays. Vertex lists Edge lists

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

Graphics and Interaction Rendering pipeline & object modelling

COMP30019 Graphics and Interaction Rendering pipeline & object modelling

Lecture outline. COMP30019 Graphics and Interaction Rendering pipeline & object modelling. Introduction to modelling

D A S O D A. Identifying and Classifying 3-D Objects. Examples

CGS 3220 Lecture 17 Subdivision Surfaces

Computer Graphics (CS 543) Lecture 9 (Part 2): Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing

Building Models. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

OBJECT ORIENTED PROGRAMMING

Computer Graphics. Prof. Feng Liu. Fall /14/2016

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

TNM079 Modeling & Animation Lecture 6 (Implicit surfaces)

Rendering Pipeline/ OpenGL

How shapes are represented in 3D Graphics. Aims and objectives By the end of the lecture you will be able to describe

Using GLU/GLUT Objects. GLU/GLUT Objects. glucylinder() glutwirecone() GLU/GLUT provides very simple object primitives

Foundations of 3D Graphics Programming

Lectures OpenGL Introduction

Scene Graphs. COMP 575/770 Fall 2010

Homework #2. Shading, Projections, Texture Mapping, Ray Tracing, and Bezier Curves

Display Lists. Conceptually similar to a graphics file. In client-server environment, display list is placed on server

PROCEDURAL OBJECT MODELING

Mach band effect. The Mach band effect increases the visual unpleasant representation of curved surface using flat shading.

Supplement to Lecture 11

A method in creating 3D models: From shape to shape, from shapes to model (October 2016)

CSCI E-74. Simulation and Gaming

Recall: Indexing into Cube Map

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

Welcome to COMP 770 (236) Introduction. Prerequisites. Prerequisites

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

Example: The following is an example of a polyhedron. Fill the blanks with the appropriate answer. Vertices:

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

Transformations in Ray Tracing. MIT EECS 6.837, Durand and Cutler

Shading Intro. Shading & Lighting. Light and Matter. Light and Matter

CS559: Computer Graphics. Lecture 23: Shape Modeling Li Zhang Spring 2010

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

CS 352: Computer Graphics. Hierarchical Graphics, Modeling, And Animation

Shading in OpenGL. Outline. Defining and Maintaining Normals. Normalization. Enabling Lighting and Lights. Outline

Development of Computer Graphics

CS 4731/543: Computer Graphics Lecture 7 (Part I): Raster Graphics: Polygons & Antialiasing. Emmanuel Agu

ECE 104 Fundamentals of Computer Graphics Project 1

Computer Graphics CS 543 Lecture 11 (Part 1) Polygon Filling & Antialiasing

L1 - Introduction. Contents. Introduction of CAD/CAM system Components of CAD/CAM systems Basic concepts of graphics programming

OUTLINE. Hierarchical Models Z-Fighting Primitives Besides Triangles Back Face Culling

? Which intermediate. Recall: Line drawing algorithm. Programmer specifies (x,y) of end pixels Need algorithm to determine pixels on line path

Polygon Filling. Can write frame buffer one word at time rather than one bit. 2/3/2000 CS 4/57101 Lecture 6 1

Computer Graphics Fundamentals. Jon Macey

CS 4204 Computer Graphics

SFU CMPT 361 Computer Graphics Fall 2017 Assignment 2. Assignment due Thursday, October 19, 11:59pm

CS 283: Assignment 1 Geometric Modeling and Mesh Simplification

Overview. Computer Graphics CS324. OpenGL. Books. Learning Resources. CS131 Notes. 30 Lectures 3hr Exam

5.2 Shading in OpenGL

Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer Graphics

Computer Graphics I Lecture 11

Chapter 2: Rhino Objects

Precept 2 Aleksey Boyko February 18, 2011

CS 563 Advanced Topics in Computer Graphics Polygonal Techniques. by Linna Ma

Transcription:

CS 543: Computer Graphics Lecture 04 Part III: 3D Modeling: Polygonal Meshes Emmanuel Agu

3D Modeling Previously Introduced 3D modeling Previously introduced GLUT models (wireframe/solid) and Scene Description Language (SDL): 3D file format Previously used GLUT calls Cylinder: glutwirecylinder( ), glutsolidcylinder( ) Cone: glutwirecone( ), glutsolidcone( ) Sphere: glutwiresphere( ), glutsolidsphere( ) Cube: glutwirecube( ), glutsolidcube( ) Newell Teapot, torus, etc

Polygonal Meshes Modeling with basic shapes (cube, cylinder, sphere, etc) too primitive Difficult to approach realism Polygonal meshes: Collection of polygons, or faces, that form skin of object More flexible Models complex surfaces better Examples: Human face Animal structures Furniture, etc

Polygonal Mesh Example

Polygonal Meshes Have become standard in CG OpenGL Good at drawing polygon Mesh = sequence of polygons, thin skin around object Simple meshes exact. (e.g barn) Complex meshes approximate (e.g. human face) Later: use shading technique to smoothen

What is a Polygonal Mesh Polygonal mesh given by: Polygon list: vertices Direction of each polygon Represent direction as normal vector Normal vector used in shading Normal light determines shading

Vertex Normal Use vertex normal instead of face normal See advantages later: Facilitates clipping Shading of smoothly curved shapes Flat surfaces: all vertices associated with same n Smoothly curved surfaces: V1, V2 with common edge share n

Newell Method for Normal Vectors Martin Newell at Utah (teapot guy) Normal vector: calculation difficult by hand Given formulae, suitable for computer Compute during mesh generation Simple approach used previously: Start with any three vertices V1, V2, V3 Form two vectors, say V1-V2, V3-V2 Normal: cross product of vectors

Defining Polygonal Mesh Three lists: Vertex list: distinct vertices (vertex number, Vx, Vy, Vz) Normal list: Normals to faces (normalized nx, ny, nz) Face list: indexes into vertex and normal lists. i.e. vertices and normals associated with each face Face list convention: Traverse vertices counter-clockwise Interior on left exterior on right

Newell Method for Normal Vectors Problems with simple approach: If two vectors are almost parallel, cross product is small Numerical inaccuracy may result Newell method: robust Formulae: Normal N = (mx, my, mz) m m m x y z N 1 i 0 N 1 i 0 N 1 i 0 y y z z i next( i) i next( i) z z x x i next( i) i next( i) x x y y i next( i) i next( i)

Newell Method Example Example: Find normal of polygon with vertices P0 = (6,1,4), P1=(7,0,9) and P2 = (1,1,2) Solution: Using simple cross product: ((7,0,9)-(6,1,4)) X ((1,1,2)-(6,1,4)) = (2,-23,-5) Using Newell method, plug in values result is the same: Normal is (2, -23, -5)

Meshes in Programs Tetrahedron example

Meshes in Programs Class Mesh Helper classes VertexID Face Mesh Object: Normal list Vertex list Face list Use arrays of pt, norm, face Dynamic allocation at runtime Array lengths: numverts, numnormals, numfaces

Meshes in Programs Face: Vertex list Normal vector associated with each face Array of index pairs Example, vth vertex of fth face: Position: pt[face[f].vert[v].vertindex] Normal vector: norm[face[f].vert[v].normindex] Organized approach, permits random access

Meshes in Programs Data structure: // ############### Vertex ID ###################### class VertexID public: int vertindex; // index of this vertex in the vertex list int normindex; // index of this vertex s normal } // ############### Face ###################### class Face public: int nverts; // number of vertices in this face VertexID *vert; // the list of vertex and normal indices Face( ){nverts = 0; vert = NULL;} // constructor -Face( ){delete[ ] vert; nverts = 0; // destructor };

Meshes in Programs // ############### Mesh ###################### class Mesh{ private: int numverts; // number of vertices in the mesh Point3 *pt; // array of 3D vertices int numnormals; // number of normal vertices for the mesh Vector3 *norm; // array of normals int numfaces; // number of faces in the mesh Face *face; // array of face data // others to be added later public: Mesh( ); // constructor ~Mesh( ); // destructor int readfile(char *filename); // to read in a filed mesh.. other methods. }

Drawing Meshes Using OpenGL Pseudo-code: for(each face f in Mesh) { glbegin(gl_polygon); for(each vertex v in face f) { glnormal3f(normal at vertex v); glvertex3f(position of vertex v); } glend( ); }

Drawing Meshes Using OpenGL Actual code: Void Mesh::draw( ) // use opengl to draw this mesh { for(int f = 0;f < numfaces;f++) { glbegin(gl_polygon); for(int v=0;v<face[f].nverts;v++) // for each one { int in = face[f].vert[v].normindex; // index of this normal int iv = face[f].vert[v].vertindex; // index of this vertex glnormal3f(norm[in].x, norm[in].y, norm[in].z); glvertex3f(pt[iv].x, pt[iv].y, pt[iv].z); } glend( ); } }

Drawing Meshes Using SDL Scene class reads SDL files Accepts keyword Mesh Example: Pawn stored in mesh file pawn.3vn Add line: Push translate 3 5 4 scale 3 3 3 mesh pawn.3vn pop

Creating Meshes Simple meshes easy by hand Complex meshes: Mathematical functions Algorithms Digitize real objects Libraries of meshes available Mesh trends: 3D scanning Mesh Simplification

3D Simplification Example Original: 424,000 triangles 60,000 triangles (14%). 1000 triangles (0.2%) (courtesy of Michael Garland and Data courtesy of Iris Development.)

References Hill, 6.1-6.2