Triangulation Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast.

Slides:



Advertisements
Similar presentations
1Computer Graphics Building Models John Shearer Culture Lab – space 2
Advertisements

OpenGL: Simple Use Open a window and attach OpenGL to it Set projection parameters (e.g., field of view) Setup lighting, if any Main rendering loop –Set.
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Building Models modified by Ray Wisman Ed Angel Professor of Computer Science,
1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
 The success of GL lead to OpenGL (1992), a platform-independent API that was  Easy to use  Close enough to the hardware to get excellent performance.
Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 21 Today’s class Graphics programming Color.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
Drawing Geometric Objects
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
1 GLUT Callback functions Event-driven: Programs that use windows  Input/Output  Wait until an event happens and then execute some pre-defined functions.
Drawing Basic Graphics Primitives Lecture 4 Wed, Sep 3, 2003.
Texturing A picture is worth a thousand words. Texturing Texturing is the art of doing this with any picture to any model.  (This is Opus the Penguin.
Interactive Computer Graphics CS 418 – Spring 2015 Mesh Rendering, Transformation, Camera Viewing and Projection in OpenGL TA: Zhicheng Yan Sushma S Kini.
State Management and Drawing Geometry Objects
Ch 2 Graphics Programming page 1 CSC 367 Coordinate Systems (2.1.2) Device coordinates, or screen coordinates (pixels) put limitations on programmers and.
1. OpenGL/GLU/GLUT  OpenGL v4.0 (latest) is the “core” library that is platform independent  GLUT v3.7 is an auxiliary library that handles window creation,
Object Representation Rama C Hoetzlein, 2010 Univ. of California Santa Barbara Lecture Notes.
Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition Chapter 2.
1 Graphics CSCI 343, Fall 2015 Lecture 2 Introduction to HTML, JavaScript and WebGL.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
CAP4730: Computational Structures in Computer Graphics
Introduction to OpenGL  OpenGL is a graphics API  Software library  Layer between programmer and graphics hardware (and software)  OpenGL can fit in.
Computer Graphics Bing-Yu Chen National Taiwan University.
Lecture 2: Some definitions of terms 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Introduction to OpenGL. OpenGL is a low-level graphics library specification. It makes available to the programmer  a small set of geometric primitives.
On to OpenGL Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast.
Image Synthesis Rabie A. Ramadan, PhD 4. 2 Review Questions Q1: What are the two principal tasks required to create an image of a three-dimensional scene?
UniS CS297 Graphics with Java and OpenGL State Management and Drawing Primative Geometric Objects.
Solid Figures Vocabulary.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.
Computer Graphics I, Fall 2010 Building Models.
On to 3D Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast.
OpenGL Objects Finalised. Debugging Tip For Debugging your applications remember: glGetError(); gluErrorString(); Don’t use these in release code (the.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
CSC Graphics Programming
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Computer Graphics Implementation II
Transformations Introduction to Computer Graphics and Animation
Programming with OpenGL Part 2: Complete Programs
Materi Anatomi OpenGL Fungsi GLUT Posisi Kamera Proyeksi
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
Class 17 front and back lighting convex sets, convex hull
Starting to draw dealing with Windows which libraries? clipping
Class 1: First Program.
Building Models Ed Angel
Implementation II Ed Angel Professor Emeritus of Computer Science
Isaac Gang University of Mary Hardin-Baylor
Introduction to OpenGL
Primitive Objects Lecture 6 Wed, Sep 5, 2007.
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Starting to draw dealing with Windows which libraries? clipping
Programming with OpenGL Part 2: Complete Programs
Implementation II Ed Angel Professor Emeritus of Computer Science
Class 18 front and back lighting convex sets, convex hull
Presentation transcript:

Triangulation Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast

Triangulations A valid triangulation of a figure X is a collection of triangles (T) satisfying the following two properties: 1. The collection T together exactly covers X. 2. Any given two triangles t 1 and t 2 in the collection are either (a) disjoint (ie., do not intersect at all), or (b) intersect exactly in a vertex of both, or (c) intersect exactly in an edge (side) of both.

Examples Triangulation is not a unique process and the same object may have multiple triangulations.

Exercise 5.1 Draw a square identical to the one in square.cpp, but using triangulation. –Use TRIANGLE_STRIP –Use TRIANGLE_FAN Draw a square and a triangle using triangulation with Steiner vertices. Draw a circle using triangulation –Without a Steiner vertex –With a Steiner vertex

Why should we care? If the collection satisfies the properties of a triangulation, then the image is independent of the order in which the triangles are rendered.

Experiment 5.1 Run invalidTriangulation.cpp, press space bar to interchange the order of drawn vertices. Experiment with glutKeyboardFunc(keyInput) and keyInput(unsigned char key, int x, int y).

Quality of Triangulation Good triangulation –Few slivers –Most triangles being of nearly equal size –And each relatively small with respect to the entire object

Quality of Triangulation C B A D P

Triangulation by OpenGL and the Trouble with Non-Convexity Do the Experiment 4.16 again. When OpenGL is asked to draw a filled polygon, it creates a fan around the first vertex. Make sure to use GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON with convex shape.

Experiment 5.2 Replace the polygon declaration part of square.cpp with glBegin(GL_POLYGON); glColor3f(1.0,1.0,1.0); glVertex3f(80.0, 20.0, 0.0); glColor3f(1.0,0.0,0.0); glVertex3f(40.0, 40.0, 0.0); glColor3f(1.0,1.0,1.0); glVertex3f(20.0, 80.0, 0.0); glVertex3f(20.0, 20.0, 0.0); glEnd(); The rendered ‘triangle’ is all white with no sign of red at all. Why?

Experiment 5.2 Replace the polygon declaration part of square.cpp with glBegin(GL_POLYGON); glVertex3f(50.0, 10.0, 0.0); glVertex3f(40.0, 50.0, 0.0); glVertex3f(10.0, 60.0, 0.0); glVertex3f(90.0, 60.0, 0.0); glVertex3f(60.0, 50.0, 0.0); glEnd(); Predict the filled output each time as you rotate the vertices cyclically.

Experiment 5.2 Replace the polygon declaration part of square.cpp with glBegin(GL_POLYGON); glColor3f(1.0,1.0,1.0); glVertex3f(20.0, 20.0, 0.0); glColor3f(1.0,1.0,1.0); glVertex3f(50.0, 20.0, 0.0); glColor3f(1.0,1.0,1.0); glVertex3f(80.0, 50.0, 0.0); glColor3f(1.0,1.0,1.0); glVertex3f(80.0, 80.0, 0.0); glColor3f(1.0,0.0,0.0); glVertex3f(20.0, 80.0, 0.0); glEnd(); Rotate the vertices by putting the first vertex (with its color) to the end of the list. Explain the difference in the rendering between the two listings?

Recommendation Avoid using GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON. Use only the points, lines (including strip or loop) and triangles (including strip and fan) primitives –Convexity of individual piece is guaranteed –You control the quality of triangulation rather than trusting the OpenGL’s fan-maker.

Vertex Array glVertex3fv(*pointer) glColor3fv(*pointer) Separate data and code –Reduce redundancy and errors –Improve memory usage efficiency –Easy to modularize and debug

Experiment 5.3 Run squareAnnulus1.cpp. Press the space bar to see the wireframe. Run squareAnnulus2.cpp. Compare the code with the previous experiment. Run squareAnnulus3.cpp. Compare the code with the previous experiments.

Initializing Vertex Array Vertex arrays are enabled with calls to glEnableClientState( array ) The data for the arrays are specified with calls to glVertexPointer( size, type, stride, *pointer ) and glColorPointer( size, type, stride, *pointer )

Experiment 5.3 Run squareAnnulus4.cpp. Compare the code with the previous experiments. glDrawElements( primitive, count, type, *indices ) glBegin( primitive ) for (i=0 ; i < count ; i++) glArrayElement( indices [i]); glEnd;

Assignment 2 1. Draw a face as in the picture. It need not be an exact replica but should be similar. –Head and ears are circular –The user should be able to toggle between the filled rendering and a wireframe via keyboard interaction. –You can paint your face in any colors. A rainbow, if you like.

Assignment 2 2. Triangulate the figure "8". The "8" is thick. Color the figure as creatively as you like.

Assignment 2 Note on assignment 2 –Make sure you have your shapes valid triangulation –Allow the user to toggle between the filled rendering and wireframe by pressing the space bar. –You are free to color objects as you like. –Instructions for user interaction should always be output to the main C++ Window and also be written as comments at the top of your program file.