OpenGL Curves & Surfaces. Where u varies in some domain (say [0,1]). A Bezier surface patch is a vector-valued function of two variables Evaluators A.

Slides:



Advertisements
Similar presentations
Line and Curve Drawing Algorithms. Line Drawing x0x0 y0y0 x end y end.
Advertisements

Chapter 2: Graphics Programming
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.
MAE 152 Computer Graphics for Scientists and Engineers
© 2004, Tom Duff and George Ledin Jr1 Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma.
CHAPTER 10 Curves and Surfaces Vivian by Richard S. Wright Jr.
2002 by Jim X. Chen:
Curves and Surfaces in OpenGL CS4395: Computer Graphcis 1 Mohan Sridharan Based on slides created by Edward Angel.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
Curves and Surfaces in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
19/13/ :20 UML Graphics II Parametric Curves and Surfaces Session 3.
Modeling. Geometric Models  2D and 3D objects  Triangles, quadrilaterals, polygons  Spheres, cones, boxes  Surface characteristics  Color  Texture.
Drawing Basic Graphics Primitives Lecture 4 Wed, Sep 3, 2003.
1 Bezier Curves © Jeff Parker, Nov Goal We often wish to draw generate curves Through selection of arbitrary points Smooth (many derivatives)
Picking and Curves Week 6 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico CS 480/680.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
Bézier Algorithms & Properties Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, March 3, 2004.
Computer Graphics CS 385 January 31, Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of.
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 Figures are extracted from Angel's book (ISBN x) The Human Visual System vs The Pinhole camera Human Visual System Visible Spectrum Pinhole.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
Texture Mapping Drawing Pictures on Polygons. Texture Mapping.
Introduction to OpenGL  OpenGL is a graphics API  Software library  Layer between programmer and graphics hardware (and software)  OpenGL can fit in.
MAE152 Computer Graphics for Scientists and Engineers Fall 03 Display Lists.
1 Bezier Curves and Surfaces © Jeff Parker, Nov 2009.
Bézier Curves & Surfaces Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, March 1, 2004.
OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla.
Parametric Curves & Surfaces
NoufNaief.net 1 TA: Nouf Al-Harbi.
Doç. Dr. Cemil Öz SAÜ Bilgisayar Mühendisliği Dr. Cemil Öz.
CSCI480/582 Lecture 10 Chap.2.3 Cubic Splines – B-Splines and NURBS Feb, 13, 2009.
OpenGL Vertex Arrays OpenGL vertex arrays store vertex properties such as coordinates, normal vectors, color values and texture coordinates. These properties.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Chapter 4 -- Color1 Color Open GL Chapter 4. Chapter 4 -- Color2 n The goal of almost all OpenGL applications is to draw color pictures in a window on.
Computer Graphics I, Fall 2010 Building Models.
OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 17 Animations, Loops.
Introduction to Graphics Programming. Graphics API.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL Based on GL (graphics library) by Silicon Graphics Inc. (SGI) Advantages: Runs on everything, including.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
UMBC GDC Programming Tutorial
CSC Graphics Programming
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Curves and Surfaces in OpenGL
Draw a Simple Object.
Programming with OpenGL Part 2: Complete Programs
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
Building Models Ed Angel
Isaac Gang University of Mary Hardin-Baylor
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Introduction to OpenGL
Computer Graphics Algorithms Ying Zhu Georgia State University
OpenGL program.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
MAE 152 Computer Graphics for Scientists and Engineers
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

OpenGL Curves & Surfaces

Where u varies in some domain (say [0,1]). A Bezier surface patch is a vector-valued function of two variables Evaluators A Bezier curve is a vector-valued function of 1 variable

OpenGL Evaluator Define the function C( ) or S( ) Enable it Use glEvalCoord1( ) or glEvalCoord2( ) instead of glVertex*( ) The curve or surface is used just as any other vertices are used.

Example bezcurve.c (Note: the one I handed out is slightly different than this one.) Control Points Bézier Curve

bezcurve.c (part 1) GLfloat ctrlpoints[4][3] = { {-4.0, -4.0, 0.0}, {-2.0, 4.0, 0.0}, {2.0, -4.0, 0.0}, {4.0, 4.0, 0.0 }}; void init(void){ glClearColor(0.0, 0.0, 0.0,, 0.0); glShadeModel(GL_FLAT); glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]); glEnable(GL_MAP1_VERTEX_3);}

glMap1{fd} ( … ) GLenum target (see next slide) TYPE u1 – starting value of u TYPE u2 – ending value of u GLint stride – number of single or double precision values in each block of storage. GLint order – degree plus 1 (should agree with the number of control points) const TYPE * points – pointer to control points

glMap1 target parameter GL_MAP1_VERTEX_3 : x,y,z vertex coordinates GL_MAP1_VERTEX_4 : x,y,z,w vertex coordinates GL_MAP1_INDEX : color index GL_MAP1_COLOR_4 : R,G,B,A GL_MAP1_NORMAL : normal coordinates GL_MAP1_TEXTURE_COORD_1 : s texture coordinate GL_MAP1_TEXTURE_COOR D_2 : s,t texture coordinates GL_MAP1_TEXTURE_COOR D_3 : s,t,r texture coordinates GL_MAP1_TEXTURE_COOR D_4 : s,t,r,q texture coordinates

glEnable(GL_MAP1_VERTEX_3) Enables the one-dimensional evaluator for three dimensional vertices.

bezcurve.c (part 2) display function void display(void) { int i; glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); // set color to white glBegin(GL_LINE_STRIP); for(i=0; i<=30; i++) // loop 31 times glEvalCoord1f((GLfloat) i/30.0); // call evaluator glEnd( );

bezcurve.c (part 3) /* the following code displays the control points as dots */ glPointSize(5.0); glColor3f(1.0, 1.0, 0.0); // set color to yellow glBegin(GL_POINTS); for(i=0; i<4; i++) glVertex3fv(&ctrloints[i][0]); // Draw a point glEnd( ); glFlush( );

Bezcurve.c (part 4) A reshape function that uses glOrtho for orthographic projections and an identity matrix for model view. A normal main function like all other examples.

Modification for hand-out I changed the color of the bezier curve to red and added another bezier curve with different parameters. Only 4 steps in the evaluator loop. (This new curve is drawn in white) Note the lack of smoothness. Note the same start and end points.

Additional code glClear(GL_COLOR_BUFFER_BIT); // clear screen glColor3f(1.0, 1.0, 1.0); // set color to white glBegin(GL_LINE_STRIP); // start a line strip for(i=0; i<=4; i++); // loop FIVE times glEvalCoord1f((GLfloat)i/4.0); // calc a point glEnd( ); glColor3f(1.0, 0.0, 0.0); // set color to red glBegin(GL_LINE_STRIP); // start a line strip for(i=0; i<=30; i++); // loop 31 times glEvalCoord1f((GLfloat)i/30.0); // calc a point glEnd( );

0 : 0.0/4.0 = : 2.0/4.0 = : 1.0/4.0 = : 3.0/4.0 = : 4.0/4.0 = : 15.0/30.0=0.50

Calculated Points

DEMOS Bezier /wwwf2003/examples/class Curves /wwwf2003/public/curves

Another way to do even spacing void glMapGrid1{fd}(GLint n, TYPE u1, TYPE u2); Void glEvalMesh1(GLenum mode, GLint p1, GLint p2); (equivalent to following) glBegin(GL_POINTS); // or glBegin(GL_LINE_STRIP); for (i=p1; i<=p2; i++) glEvalCoord1(u1+i*(u2-u1)/n); glEnd();

2D Bezier Surfaces

Code is bezmeshnolight.c

bezmesh.c with lighting

bezsurf.c