2002 by Jim X. Chen:

Slides:



Advertisements
Similar presentations
Lecture Notes #11 Curves and Surfaces II
Advertisements

© University of Wisconsin, CS559 Spring 2004
2002 by Jim X. Chen: Bezier Curve Bezier Curve.
COMPUTER GRAPHICS CS 482 – FALL 2014 OCTOBER 8, 2014 SPLINES CUBIC CURVES HERMITE CURVES BÉZIER CURVES B-SPLINES BICUBIC SURFACES SUBDIVISION SURFACES.
Geometric Modeling Notes on Curve and Surface Continuity Parts of Mortenson, Farin, Angel, Hill and others.
© University of Wisconsin, CS559 Spring 2004
B-Spline Blending Functions
MAE 152 Computer Graphics for Scientists and Engineers
1 Curves and Surfaces. 2 Representation of Curves & Surfaces Polygon Meshes Parametric Cubic Curves Parametric Bi-Cubic Surfaces Quadric Surfaces Specialized.
MIT EECS 6.837, Durand and Cutler Curves & Surfaces.
Informationsteknologi Monday, December 10, 2007Computer Graphics - Class 161 Today’s class Curve fitting Evaluators Surfaces.
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Curves and Surfaces in OpenGL CS4395: Computer Graphcis 1 Mohan Sridharan Based on slides created by Edward Angel.
Modelling. Outline  Modelling methods  Editing models – adding detail  Polygonal models  Representing curves  Patched surfaces.
2003 by Jim X. Chen: Introduction to Modeling Jim X. Chen George Mason University.
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.
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Hidden Surfaces and Shading CS BSP Tree T1T1 T2T2 E if (f 1 (E) < 0) then draw T 1 draw T 2 else draw T 2 draw T 1 f 1 (p) = 0 is the.
Geometric Modeling Surfaces Mortenson Chapter 6 and Angel Chapter 9.
Curves Mortenson Chapter 2-5 and Angel Chapter 9
ENDS 375 Foundations of Visualization Geometric Representation 10/5/04.
1 Representing Curves and Surfaces. 2 Introduction We need smooth curves and surfaces in many applications: –model real world objects –computer-aided.
Parts of Mortenson Chapter 6-9,
Curve Surfaces June 4, Examples of Curve Surfaces Spheres The body of a car Almost everything in nature.
Lighting & Material. Example 1/5 #include ” glut.h ” void display(); void reshape(int, int); void lighting(); int main(int argc, char** argv) { glutInit(&argc,
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 CSE 872 Advanced Computer Graphics Charles B. Owen (Instructor) – 1138 E. B., MW 12:30-1:50pm.
Computer Graphics Lecture 13 Curves and Surfaces I.
Computer Graphics Modeling.
1 Graphics CSCI 343, Fall 2013 Lecture 20 Lighting and Shading III.
A D V A N C E D C O M P U T E R G R A P H I C S CMSC 635 January 15, 2013 Spline curves 1/23 Curves and Surfaces.
Shading in OpenGL.
CS 376 Introduction to Computer Graphics 04 / 23 / 2007 Instructor: Michael Eckmann.
V. Space Curves Types of curves Explicit Implicit Parametric.
1 Bezier Curves © Jeff Parker, Nov Goal We often wish to draw generate curves Through selection of arbitrary points Smooth (many derivatives)
CS 445 / 645 Introduction to Computer Graphics Lecture 23 Bézier Curves Lecture 23 Bézier Curves.
Computer Graphics I, Fall 2010 Shading in OpenGL.
OpenGL and Parametric Curves Advanced Multimedia Technology: Computer Graphics Yung-Yu Chuang 2005/12/21 with slides by Brian Curless, Zoran Popovic, Robin.
1 Bezier Curves and Surfaces © Jeff Parker, Nov 2011.
OpenGL Color and Lighting 2003 Spring Keng Shih-Ling.
Parametric Surfaces Define points on the surface in terms of two parameters Simplest case: bilinear interpolation s t s x(s,t)x(s,t) P 0,0 P 1,0 P 1,1.
OpenGL Lighting Jian-Liang Lin 2002 Hidden-Surface Removal -1 Original Code: while (1) { get_viewing_point_from_mouse_position(); glClear(GL_COLOR_BUFFER_BIT);
1 Bezier Curves and Surfaces © Jeff Parker, Nov 2009.
Geometric Modelling 2 INFO410 & INFO350 S Jack Pinches
CS 376 Introduction to Computer Graphics 04 / 25 / 2007 Instructor: Michael Eckmann.
Representation of Curves & Surfaces Prof. Lizhuang Ma Shanghai Jiao Tong University.
Bézier Curves & Surfaces Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, March 1, 2004.
04/18/02(c) 2002 University of Wisconsin Last Time Hermite Curves Bezier Curves.
Review CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005.
Computing & Information Sciences Kansas State University Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 32 of 42 Wednesday, 11.
11/26/02(C) University of Wisconsin Last Time BSplines.
CSCI480/582 Lecture 10 Chap.2.3 Cubic Splines – B-Splines and NURBS Feb, 13, 2009.
12/9/ :28 UML Graphics II B-Splines NURBS Session 3A.
CS 325 Computer Graphics 04 / 30 / 2010 Instructor: Michael Eckmann.
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:
Illumination CSE 410. Basic steps of lighting Enable smooth shading Set global ambient light glShadeModel(GL_SMOOTH); glEnable(GL_NORMALIZE); GLfloat.
CS559: Computer Graphics Lecture 16: Shading and OpenGL Li Zhang Spring 2008.
8. Surfaces and Surface Modeling Assoc.Prof.Dr. Ahmet Zafer Şenalp Mechanical Engineering Department.
3D MODELLING PART-3 Wikitechy.
COMPUTER GRAPHICS CHAPTERS CS 482 – Fall 2017 SPLINES
Curves and Surfaces in OpenGL
CS5500 Computer Graphics May 11, 2006
Representation of Curves & Surfaces
CS 445 / 645 Introduction to Computer Graphics
Lecture 16: Shading and OpenGL Li Zhang Spring 2008
© University of Wisconsin, CS559 Fall 2004
Shading in OpenGL Ed Angel
CSC461: Lecture 24 Lighting and Shading in OpenGL
Computer Graphics Algorithms Ying Zhu Georgia State University
Lighting – Material Properties
Three-Dimensional Object Representation
Presentation transcript:

by Jim X. Chen:

POLYGON MESHES list of vertices - polygon; list of edges - polygon list of polygons -- objects Plane equation from 3 vertices: Ax + By +Cz + D = 0 Normal: (A,B,C) = k(P 1 P 2 x P 1 P 2 ) A, B, and C are proportional to the signed areas of the projections of the polygon onto the (y, z), (x, z), and (x, y) planes. If the polygon is parallel to the (x, y) plane, then A = B = 0.

by Jim X. Chen: 3 where the operator is normal addition except that. The The area for A and B are given by similar formulae The distance d for a vertex at (x,y,z) is

by Jim X. Chen: 4

5

6 7 PARAMETRIC BICUBIC SURFACES General form of cubic curve: Q(u) = U ·M ·G where G, the geometry vector, is a constant If we allow G to vary in 3D along some path: Then, a functional description is often tesselated to produce a polygon-mesh approximation to the surface (trianglular polygon patches) For a fixed t 1, Q(s, t 1 ) is a curve because G(t 1 ) is constant. If G i (t) are cubics, the surface is said to be a parametric bicubic surface

by Jim X. Chen: 7 Hermite Surfaces Curve: and Surface: Since: we have:

by Jim X. Chen: 8 Where Where x coordinates, coordinates of the tangent vectors and twists are specified

by Jim X. Chen: 9 Just as the Hermite cubic curves, the Hermite bicubic permits C 1 and G 1 continuity from one patch to the next 1st, to have C 0 continuity, the matching curves of the two patches must be identical, which means the control points for the two surfaces must be identical along the edge To have C 1 continuity, the control points along the edge and the tangent and twist vectors across the edge be equal. To have G 1 continuity, the tangent and twist vectors across the edge be in the same direction, but do not need to have the same magnitude..

by Jim X. Chen: 10 Bezier Surfaces The Bezier bicubic formulation can be derived in exactly the same way as above. The results are: B-Spline Surfaces The B-Spline bicubic formulation can be derived in exactly the same way also. The results are: Normals to Surfaces The cross product between thes and t tangent vectors of the surface Q(s, t) results in the normal at givens andt:

by Jim X. Chen: 11 EVALUATORS AND NURBS in OpenGL One-Dimensional Evaluators Example Drawing a Bézier Curve Using Four Control Points: bezcurve.c #include 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} }; and Click Me Click Me

by Jim X. Chen: 12 void myinit(void) { glClearColor(0.0, 0.0, 0.0, 1.0); glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4,&ctrlpoints[0][0]); glEnable(GL_MAP1_VERTEX_3); glShadeModel(GL_FLAT); } GL_MAP1_VERTEX_3: Three-dimensional vertices are produced 0--Low value of parameter u 1--High value of parameter u 3--The number of floating-point values to advance in the data between one control point and the next 4--The order of the spline, which is the degree+1; &ctrlpoints[0][0]--Pointer to the first control point’s data

by Jim X. Chen: 13 void display(void) { int i; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glBegin(GL_LINE_STRIP); for (i = 0; i <= 30; i++) glEvalCoord1f((GLfloat) i/30.0); glEnd(); /* The following code displays the control points as dots. */ glPointSize(5.0); glColor3f(1.0, 1.0, 0.0); glBegin(GL_POINTS); for (i = 0; i < 4; i++) glVertex3fv(&ctrlpoints[i][0]); glEnd(); glFlush(); } Click Me Click Me

by Jim X. Chen: 14 Two-Dimensional Evaluators Mathematically, the definition of a Bézier surface patch is given by Example 11-2 Drawing a Bézier Surface: bezsurf.c GLfloat ctrlpoints[4][4][3] = { {{-1.5, -1.5, 4.0}, {-0.5, -1.5, 2.0}, {0.5, -1.5, -1.0}, {1.5, -1.5,2.0}}, {{-1.5, -0.5, 1.0}, {-0.5, -0.5, 3.0}, {0.5, -0.5, 0.0}, {1.5, -0.5,-1.0}}, {{-1.5, 0.5, 4.0}, {-0.5, 0.5, 0.0},{0.5, 0.5, 3.0}, {1.5, 0.5, 4.0}}, {{-1.5, 1.5, -2.0}, {-0.5, 1.5, -2.0}, {0.5, 1.5, 0.0}, {1.5, 1.5, -1.0}} }; void myinit(void) { glClearColor (0.0, 0.0, 0.0, 1.0); glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &ctrlpoints[0][0][0]);

by Jim X. Chen: 15 glEnable(GL_MAP2_VERTEX_3); glEnable(GL_DEPTH_TEST); glShadeModel(GL_FLAT); } void display(void) { int i, j; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glPushMatrix (); glRotatef(85.0, 1.0, 1.0, 1.0); for (j = 0; j <= 8; j++) { glBegin(GL_LINE_STRIP); for (i = 0; i <= 30; i++) glEvalCoord2f((GLfloat)i/30.0, (GLfloat)j/8.0); glEnd(); glBegin(GL_LINE_STRIP); for (i = 0; i <= 30; i++) glEvalCoord2f((GLfloat)j/8.0, (GLfloat)i/30.0); glEnd(); } glPopMatrix (); glFlush(); } CLICK ME

by Jim X. Chen: 16 GL_SHININESS, mat_shininess); Example 11-3 Drawing a Lit, Shaded Bézier Surface Using a Mesh: bezmesh.c void initlights(void) { GLfloat ambient[] = { 0.2, 0.2, 0.2, 1.0 }; GLfloat position[] = { 0.0, 0.0, 2.0, 1.0 }; GLfloat mat_diffuse[] = {0.6, 0.6, 0.6, 1.0 }; GLfloat mat_specular[] = {1.0,1.0, 1.0, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0,GL_AMBIENT, ambient); glLightfv(GL_LIGHT0,GL_POSITION, position); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT_AND_BACK, } CLICK ME

by Jim X. Chen: 17 CLICK ME void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(85.0, 1.0, 1.0, 1.0); glEvalMesh2(GL_FILL, 0, 8, 0, 8); glPopMatrix(); glFlush(); } void myinit(void) { glClearColor (0.0, 0.0, 0.0, 1.0); glEnable(GL_DEPTH_TEST); glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4,0, 1, 12, 4, &ctrlpoints[0][0][0]); glEnable(GL_MAP2_VERTEX_3); glEnable(GL_AUTO_NORMAL); glMapGrid2f(8, 0.0, 1.0, 8, 0.0, 1.0); initlights(); }

by Jim X. Chen: 18 The GLU NURBS Interface The GLU provides a NURBS (Non-Uniform Rational B-Spline) interface built on top of the OpenGL evaluator commands. Example 11-5 Drawing a NURBS Surface: surface.c GLfloat ctlpoints[4][4][3]; GLUnurbsObj *theNurb; include #include Click Here

by Jim X. Chen: 19 Click Here void init_surface(void) { int u, v; for (u = 0; u < 4; u++) { for (v = 0; v < 4; v++) { ctlpoints[u][v][0] = 2.0*((GLfloat)u - 1.5); ctlpoints[u][v][1] = 2.0*((GLfloat)v - 1.5); if ( (u == 1 || u == 2) && (v == 1 || v == 2)) ctlpoints[u][v][2] = 3.0; else ctlpoints[u][v][2] = -3.0; } } } void myinit(void) { GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 }; GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_shininess[] = { }; glClearColor (0.0, 0.0, 0.0, 1.0);

by Jim X. Chen: 20 Click Here glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT,GL_SHININESS, mat_shininess); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); init_surface(); theNurb = gluNewNurbsRenderer(); gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0); gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); }

by Jim X. Chen: 21 Click Here void display(void) { GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(330.0, 1.,0.,0.); glScalef (0.5, 0.5, 0.5); gluBeginSurface(theNurb); gluNurbsSurface(theNurb, 8, knots, 4 * 3, 3, &ctlpoints[0][0][0], 4, 4, GL_MAP2_VERTEX_3); gluEndSurface(theNurb); glPopMatrix(); glFlush(); }