Meshing and Geometry

Similar documents
Programming with OpenGL Part 3: Three Dimensions

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Programming with OpenGL Part 1: Background

Graphics Programming

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++

Graphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction:

2D Drawing Primitives

Computer Graphics CS 543 Lecture 4 (Part 2) Building 3D Models (Part 2)

UNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 4: Three Dimensions

3D Graphics and OpenGl. First Steps

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

Getting Started. 1 st Week, Sun-Jeong Kim. Computer Graphics Applications

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

Announcement. Homework 1 has been posted in dropbox and course website. Due: 1:15 pm, Monday, September 12

Objectives. Programming with OpenGL Part 5: More GLSL. Program Object. Reading a Shader. Shader Reader. Linking Shaders with Application

Lecture 3 Advanced Computer Graphics (CS & SE )

COMPUTER GRAPHICS LAB # 3

Precept 2 Aleksey Boyko February 18, 2011

Interaction Computer Graphics I Lecture 3

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall

Cameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

Computer graphics MN1

Computer Graphics and Visualization VTU QUESTION PAPER SOLUTION UNIT -1 INTRODUCTION

Introduction to Computer Graphics with OpenGL/GLUT

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

CS 4204 Computer Graphics

Interaction. CSCI 480 Computer Graphics Lecture 3

This library uses only GL functions but contains code for creating common objects and simplifying viewing.

Graphics Hardware and OpenGL

Lectures OpenGL Introduction

Computer Graphics (Basic OpenGL)

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

Basic Graphics Programming

Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,

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

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu

COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p1/15

Drawing Primitives. OpenGL basics

Introduction to OpenGL Week 1

Objectives. Image Formation Revisited. Physical Approaches. The Programmer s Interface. Practical Approach. Introduction to OpenGL Week 1

4: Polygons and pixels

Visualizing Molecular Dynamics

OpenGL/GLUT Intro. Week 1, Fri Jan 12

1.2 Basic Graphics Programming

Programming of Graphics

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

CS Computer Graphics: Hidden Surface Removal

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

Computer graphic -- Programming with OpenGL I

Programming using OpenGL: A first Introduction

Computer Graphics. OpenGL

CSCI E-74. Simulation and Gaming

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

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

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

Simple Geometric Modeling

三維繪圖程式設計 3D Graphics Programming Design 第三章三維繪圖狀態設定和幾何元件繪製嘉大資工系盧天麒

Interaction. CSCI 420 Computer Graphics Lecture 3

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

CENG 477 Introduction to Computer Graphics. Graphics Hardware and OpenGL

CS 465 Program 4: Modeller

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Computer Graphics Introduction to OpenGL

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers

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

VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

Computer Graphics Course 2005

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

Polygonal Meshes: Representing 3D Objects

Introduction to OpenGL and 3D Graphics

Building Models. Prof. George Wolberg Dept. of Computer Science City College of New York

2/3/16. Interaction. Triangles (Clarification) Choice of Programming Language. Buffer Objects. The CPU-GPU bus. CSCI 420 Computer Graphics Lecture 3

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

Computer Graphics and Visualization. Graphics Systems and Models

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

Basic Graphics Programming

Advanced Computer Graphics

polygon meshes polygon meshes representation

PLC Papers Created For:

Intro to OpenGL III. Don Fussell Computer Science Department The University of Texas at Austin

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

OpenGL Basics I. Seoul National University Graphics & Media Lab

Chapter 3: Graphics Output Primitives. OpenGL Line Functions. OpenGL Point Functions. Line Drawing Algorithms

QUESTION 1 [10] 2 COS340-A October/November 2009

SOURCES AND URLS BIBLIOGRAPHY AND REFERENCES

API Background. Prof. George Wolberg Dept. of Computer Science City College of New York

void drawdot(glint x, GLint y) { glbegin(gl_points); glvertex2i(x,y); glend();

Line Drawing. Foundations of Computer Graphics Torsten Möller

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

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

Computer Graphics Primitive Attributes

Early History of APIs. PHIGS and X. SGI and GL. Programming with OpenGL Part 1: Background. Objectives

Geometry Primitives. Computer Science Department University of Malta. Sandro Spina Computer Graphics and Simulation Group. CGSG Geometry Primitives

Intro to OpenGL III. Don Fussell Computer Science Department The University of Texas at Austin

Transcription:

Meshing and Geometry

Points in OpenGL glbegin(gl_points); glvertex2fv(p0); glvertex2fv(p1); p7 p0 p1 glvertex2fv(p2); glvertex2fv(p3); p6 p2 glvertex2fv(p4); glvertex2fv(p5); p5 p3 glvertex2fv(p6); glvertex2fv(p7); p4 glend();

Lines in OpenGL (1/3) Line Segments glbegin(gl_lines); glvertex2fv(p0); glvertex2fv(p1); p7 p0 p1 glvertex2fv(p2); glvertex2fv(p3); glvertex2fv(p4); p6 p2 glvertex2fv(p5); glvertex2fv(p6); p5 p3 glvertex2fv(p7); glend(); p4

Lines in OpenGL (2/3) Polylines Line Strip glbegin(gl_line_strip); glvertex2fv(p0); glvertex2fv(p1); p7 p0 p1 glvertex2fv(p2); glvertex2fv(p3); glvertex2fv(p4); p6 p2 glvertex2fv(p5); glvertex2fv(p6); glvertex2fv(p7); glend(); p5 p4 p3

Lines in OpenGL (3/3) Polylines Line Loop glbegin(gl_line_loop); glvertex2fv(p0); glvertex2fv(p1); p7 p0 p1 glvertex2fv(p2); glvertex2fv(p3); glvertex2fv(p4); p6 p2 glvertex2fv(p5); glvertex2fv(p6); glvertex2fv(p7); glend(); p5 p4 p3

Definition Polygons (1/2) Object that is closed as a line loop, but that has an interior (Fill is guaranteed for convex polygon) Simple Polygon No pair of edges of a polygon cross each other Simple Nonsimple

Convexity Polygons (2/2) If all points on the line segment between any two points inside the object, or on its boundary, are inside the object p1 p2 Convex Objects

Polygons in OpenGL (1/6) Polygon glbegin(gl_polygon); glvertex2fv(p0); glvertex2fv(p1); p7 p0 p1 glvertex2fv(p2); glvertex2fv(p3); glvertex2fv(p4); p6 p2 glvertex2fv(p5); glvertex2fv(p6); glvertex2fv(p7); glend(); p5 p4 p3

Polygons in OpenGL (2/6) Quadrilaterals glbegin(gl_quads); glvertex2fv(p0); glvertex2fv(p1); p7 p0 p1 glvertex2fv(p2); glvertex2fv(p3); glvertex2fv(p4); p6 p2 glvertex2fv(p5); glvertex2fv(p6); glvertex2fv(p7); glend(); p5 p4 p3

Polygons in OpenGL (3/6) Quadstrip glbegin(gl_quad_strip); glvertex2fv(p1); glvertex2fv(p2); p7 p0 p1 glvertex2fv(p3); glvertex2fv(p0); glvertex2fv(p4); p6 p2 glvertex2fv(p7); glvertex2fv(p5); glvertex2fv(p6); glend(); p5 p4 p3

Polygons in OpenGL (4/6) Triangles glbegin(gl_triangles); glvertex2fv(p0); glvertex2fv(p1); p7 p0 p1 glvertex2fv(p2); glvertex2fv(p3); glvertex2fv(p4); p6 p2 glvertex2fv(p5); glvertex2fv(p6); glvertex2fv(p7); glend(); p5 p4 p3

Polygons in OpenGL (5/6) Triangle Strip glbegin(gl_triangle_strip); glvertex2fv(p0); glvertex2fv(p7); p7 p0 p1 glvertex2fv(p1); glvertex2fv(p6); glvertex2fv(p2); p6 p2 glvertex2fv(p5); glvertex2fv(p3); glvertex2fv(p4); glend(); p5 p4 p3

Polygons in OpenGL (6/6) Triangle Fan glbegin(gl_triangle_fan); glvertex2fv(p0); glvertex2fv(p1); p7 p0 p1 glvertex2fv(p2); glvertex2fv(p3); glvertex2fv(p4); p6 p2 glvertex2fv(p5); glvertex2fv(p6); glvertex2fv(p7); glend(); p5 p4 p3

triangle code void triangle( point a, point b, point c) { glbegin(gl_polygon); glvertex3fv(a); glvertex3fv(b); glvertex3fv(c); glend(); }

subdivision code void divide_triangle(point a, point b, point c, int m) { point v1, v2, v3; int j; if(m>0) { for(j=0; j<3; j++) v1[j]=(a[j]+b[j])/2; for(j=0; j<3; j++) v2[j]=(a[j]+c[j])/2; for(j=0; j<3; j++) v3[j]=(b[j]+c[j])/2; divide_triangle(a, v1, v2, m-1); divide_triangle(c, v2, v3, m-1); divide_triangle(b, v3, v1, m-1); } else(triangle(a,b,c)); }

tetrahedron code void tetrahedron( int m) { glcolor3f(1.0,0.0,0.0); divide_triangle(v[0], v[1], v[2], m); glcolor3f(0.0,1.0,0.0); divide_triangle(v[3], v[2], v[1], m); glcolor3f(0.0,0.0,1.0); divide_triangle(v[0], v[3], v[1], m); glcolor3f(0.0,0.0,0.0); divide_triangle(v[0], v[2], v[3], m); }

Almost Correct Because the triangles are drawn in the order they are defined in the program, the front triangles are not always rendered in front of triangles behind them get this want this

Hidden-Surface Removal We want to see only those surfaces in front of other surfaces OpenGL uses a hidden-surface method called the z-buffer algorithm that saves depth information as objects are rendered so that only the front objects appear in the image

Using the z-buffer algorithm The algorithm uses an extra buffer, the z-buffer, to store depth information as geometry travels down the pipeline It must be Requested in main.c -glutinitdisplaymode (GLUT_SINGLE GLUT_RGB GLUT_DEPTH) Enabled in init.c -glenable(gl_depth_test) Cleared in the display callback -glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT)

Meshlab 1. Model loading (points, edges, meshes) 2. Orthographic 3. Shader 4. Filters (Smoothing) 5. Lighting (Ctrl+shift+left mouse)

Delaunay triangulation 1. For any triangle in Delaunay triangulation, the circle passing through its three vertices has no other vertices in its interior. 2. For any edge in the Delaunay triangulation, there is no circle passing through the endpoints (vertices) of this edge that includes another vertex in its interior. 3. If we consider the set of angles of all the triangles in a triangulation, the Delaunay triangulation has the greatest minimum angle.

Delaunay triangulation

Delaunay triangulation

Delaunay triangulation - The act of flipping one edge can require the flipping of other edges - The triangulation has a O(n log n) complexity

https://www.youtube.com/watch?v=1uyi8t5dvf0 https://www.youtube.com/watch?v=_1m4t73l4ee https://www.youtube.com/watch?v=xzmg0grxhye