OpenGL and Parametric Curves Advanced Multimedia Technology: Computer Graphics Yung-Yu Chuang 2005/12/21 with slides by Brian Curless, Zoran Popovic, Robin.

Slides:



Advertisements
Similar presentations
02/17/05CISC640/440 OpenGL Tutorial1 OpenGL Tutorial CISC 640/440 Computer Graphics TA: Qi Li/Mani Thomas
Advertisements

Chapter 2: Graphics Programming
Graphics Pipeline.
Slide 127 October 1999CS Computer Graphics (Top Changwatchai) Review of Spline Concepts Sections 10-6 to in Hearn & Baker Splines can be 2D.
Curves Chiew-Lan Tai. Curves 2 Reading Required Hearn & Baker, 8-8 – 8-10, 8-12 Foley, 11.2.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
Modelling: Curves Week 11, Wed Mar 23
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
OpenGL (II). How to Draw a 3-D object on Screen?
Curve Surfaces June 4, Examples of Curve Surfaces Spheres The body of a car Almost everything in nature.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
Curve Modeling Bézier Curves
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
11/19/02 (c) 2002, University of Wisconsin, CS 559 Last Time Many, many modeling techniques –Polygon meshes –Parametric instancing –Hierarchical modeling.
INTRO TO COMPUTER GRAPHICS TEXT EDWARD ANGEL: EDITION 5 CS770/870
Geometric transformations The Pipeline
CSC 461: Lecture 41 CSC461: Lecture 4 Introduction to OpenGL Objectives: Development of the OpenGL API OpenGL Architecture -- OpenGL as a state machine.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Quadratic Surfaces. SPLINE REPRESENTATIONS a spline is a flexible strip used to produce a smooth curve through a designated set of points. We.
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,
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
Intro to OpenGL Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai.
CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai.
Lecture 7 Midterm Review. OpenGL Libraries gl: Basic OpenGL library, e.g. primitives. glu: OpenGL Utility library, a set of functions to create texture.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Rendering Bezier Curves (1) Evaluate the curve at a fixed set of parameter values and join the points with straight lines Advantage: Very simple Disadvantages:
Curves University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
CS552: Computer Graphics Lecture 19: Bezier Curves.
Chapter 1 Graphics Systems and Models Models and Architectures.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
Graphics Programming. Graphics Functions We can think of the graphics system as a black box whose inputs are function calls from an application program;
OpenGL: The Open Graphics Language Technology and Historical Overview By Ricardo Veguilla.
Introduction to Parametric Curve and Surface Modeling.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
- Introduction - Graphics Pipeline
School of Computer Science
CS5500 Computer Graphics May 11, 2006
Programming with OpenGL Part 2: Complete Programs
CS451Real-time Rendering Pipeline
OpenGL API 2D Graphic Primitives
Models and Architectures
Programming with OpenGL Part 2: Complete Programs
Models and Architectures
Models and Architectures
Introduction to Computer Graphics with WebGL
Lecture 13 Clipping & Scan Conversion
Models and Architectures
Models and Architectures
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Introduction to Parametric Curve and Surface Modeling
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

OpenGL and Parametric Curves Advanced Multimedia Technology: Computer Graphics Yung-Yu Chuang 2005/12/21 with slides by Brian Curless, Zoran Popovic, Robin Chen and Doug James

Review of graphics pipeline Transformation

Review of graphics pipeline Projection & clipping

Review of graphics pipeline Rasterization Visibility

Review of graphics pipeline Shading

Hierarchical modeling: a robot arm

First implementation

Better implementation

OpenGL implementation

Hierarchical modeling

Implementation

Human with hands

Better implementation

OpenGL implementation

OpenGL A low-level OS-independent graphics API for 2D and 3D interactive graphics. Initiated by SGI (called GL at early time) Implementation, for Windows, hardware vendors provide suitable drivers for their own products; for Linux, we have Mesa.

Helper libraries OpenGL does not provide OS-dependent functions such as windowing and input –GL: core graphics functions –GLU: graphics utilities in top of GL –GLUT: input and windowing functions

How does it work? From the programmer’s view –Specify geometric properties of the objects –Describe material properties –Define viewing –Define camera and object transformations OpenGL is a state machine –States: color, material properties, line width, current viewing –States are applied to subsequent drawing commands –Input: description of geometric objects –Output: shaded pixels

How does it work From the implementer’s perspective Graphics pipeline Primitives + material properties Rotate Translate Scale Is it Visible? 3D to 2DScan conversion Visibility determination Display

Primitives: drawing a polygon // put GL into polygon drawing mode glBegin(GL_POLYGON); // define vertices glVertex2f(x0, y0); glVertex2f(x1, y1); glVertex2f(x2, y2); glEnd(); Code available at

Primitives Hardware may be more efficient on triangles; stripes require less data

Polygon restrictions In OpenGL, polygons must be simple and convex not simple not convex

Attributes Part of the state of the graphics pipeline Set before primitives are drawn. Remain in effect! Example: –Color, including transparency –Reflection properties –Shading properties

Primitives: material properties glColor3f(r,g,b); All subsequent primitives will use this color. Colors are not attached to objects. The above command only changes the system states. OpenGL uses red, green and blue color model. Each components are ranged within 0 and 1.

Primitives: material properties

Simple transformations Rotate by a given angle (in degrees) about ray from origin through (x,y,z) glRotate{fd}(angle, x, y, z); Translate by a given x, y, z values glTranslate{fd}(x, y, z); Scale with a factor in the x, y, and z directions glScale{fd}(x, y, z); glPushMatrix(); glPopMatrix();

Orthographic projection glOrtho(left, right, bottom, top, near, far);

Camera transformations gluLookAt(eyex, eyey, eyez, cx, cy, cz, upx, upy, upz);

Example: drawing a box

Example: drawing a shaded polygon

Initializing attributes

Callback functions Handle “events”, Idle, Keyboard, Mouse, Menu, Motion, Reshape The display callback is installed by glutDisplayFunc()

Actual drawing function

Results glShadeModel(GL_FLAT) glShadeModel(GL_SMOOTH)

Depth buffer in OpenGL glutInitDisplayMode(GLUT_DEPTH); glEnable(GL_DEPTH_TEST); glClear(GL_DEPTH_BUFFER_BIT);

Double buffering Flicker if drawing overlaps screen refresh Solution: use two frame buffers –Draw into one buffer –Swap and display, while drawing other buffer glutInitDisplayMode(GLUT_SINGLE) glutInitDisplayMode(GLUT_DOUBLE) glutSwapBuffers()

Example: rotate a color cube Step 1: define the vertices

Example: rotate a color cube Step 2: enable depth testing and double buffering

Example: rotate a color cube Step 3: create window and set callbacks

Example: rotate a color cube Step 4: reshape callback, enclose cube, preserve aspect ratio

Example: rotate a color cube Step 5: display callback, clear, rotate, draw, flush, swap

Example: rotate a color cube Step 6: draw cube by drawing faces, orientation consistency

Example: rotate a color cube Step 7: drawing face

Example: rotate a color cube Step 8: animation, set idle callback spinCube()

Example: rotate a color cube Step 9: change axis of rotation using mouse callback

Example: rotate a color cube Step 10: toggle rotation or exit using keyboard callback

Mathematical curve representation

Parametric polynomial curves

Cubic curves N too small → less flexibility in controlling the shape of the curve N too large → often introduce unwanted wiggles

Compact representation

Constrain the cubics Hermite: defined by two endpoints and two endpoint tangent vectors Bezier: defined by two endpoints and two other points that control the endpoint tangent vectors Spline: defined by four control points

Hermite curves

Computing Hermite basis matrix

Computing a point

Blending functions

Bezier curves

Bezier basis matrix

Bezier blending function

Alternative (de Casteljau’s algorithm)

Finding Q(u)

Bezier curve each is between 0 and 1 sum of all four is exactly 1 Curve lies within the convex Hull of its control points

Displaying Bezier curves

Testing for flatness

What do we want for a curve? Local control Interpolation Continuity

Local control One problem with Bezier curve is that every control points affect every point on the curve (except for endpoints). Moving a single control point affects the whole curve. We’d like to have local control, that is, have each control point affect some well- defined neighborhood around that point.

Interpolation Bezier curves are approximating. The curve does not necessarily pass through all the control points. We’d like to have a curve that is interpolating, that is, that always passes through every control points.

Continuity We want our curve to have continuity: there shouldn’t be any abrupt changes as we move along the curve.

Splines We will splice together a curve from individual Bezier segments. We call these curves splines. When splicing Bezier together, we need to worry about continuity.

Ensuring C 0 continuity

1 st derivatives at the endpoints

Ensuring C 1 continuity

The C 1 Bezier spline

Catmull-Rom splines

Catmull-Rom basis matrix

2 nd derivatives at the endpoints

Ensuring C 2 continuity

A-frames and continuity

B-spline