Curves and Surfaces in OpenGL

Curves and Surfaces in OpenGL 1 Objectives • Introduce OpenGL evaluators • Learn to render polynomial curves and surfaces • Discuss quadrics in Open...
Author: Beverly Hodge
6 downloads 3 Views 274KB Size
Curves and Surfaces in OpenGL

1

Objectives • Introduce OpenGL evaluators • Learn to render polynomial curves and surfaces • Discuss quadrics in OpenGL -  GLUT Quadrics -  GLU Quadrics

2

1

What Does OpenGL Support? • Evaluators: general mechanism for working with Bernstein polynomials -  Can use any degree polynomials -  Can use in 1-4 dimensions -  Automatic generation of normals and texture coordinates -  NURBS supported in GLU • Quadrics -  GLU and GLUT contain polynomial approximations of quadrics 3

One-Dimensional Evaluators • Evaluate Bernstein polynomial of any degree at set of specified values • Can evaluate variety of variables -  Points along 2-, 3- or 4-D curve -  Colors -  Normals -  Texture Coordinates

• Can set up multiple evaluators -  all evaluated for same value 4

2

Setting Up an Evaluator what we want to evaluate

max and min of u

glMap1f(type,u_min,u_max,stride, order, pointer_to_array) separation between data points pointer to control data

1+degree of polynomial

Each type must be enabled by glEnable(type) 5

Example Consider evaluator for cubic Bezier curve over (0,1) point data[ ]={…………..}; * /3d data /* glMap1f(GL_MAP_VERTEX_3, 0.0, 1.0, 3, 4, data);

data are 3D vertices

cubic

data arranged as x,y,z,x,y,z…… three floats between data points in array glEnable(GL_MAP_VERTEX_3); 6

3

Evaluating • glEvalCoord1f(u) causes all enabled

evaluators to be evaluated for specified u -  Can replace glVertex, glNormal, glTexCoord

• values of u need not be equally spaced

7

Example •  Consider previous evaluator set up for cubic Bezier over (0,1) •  Suppose want to approximate curve with 100 point polyline glBegin(GL_LINE_STRIP) for(i=0; i

Suggest Documents