Open GL Super Bible:Curves and Surfaces: What the #%@!&* Are NURBS?
To access the contents, click the chapter and section titles.
Open GL Super Bible
(Publisher: Macmillan Computer Publishing)
Author(s): Waite group Press
ISBN: 1571690735
Publication Date: 08/01/96
Previous
Table of Contents
Next
glMapGrid
Purpose
Defines a 1D or 2D mapping grid.
Include File
<gl.h>
Variations
void glMapGrid1d(GLint un, GLdouble u1, GLdouble u2);
void glMapGrid1f(GLint un, GLfloat u1, GLfloat u2);
void glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
void glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
Description
This function establishes a 1D or 2D mapping
grid. This is used with glMap and glEvalMesh to efficiently evaluate a
mapping and create a mesh of coordinates.
Parameters
un,vn
GLint: Specifies the number of grid subdivisions in the u or v direction.
u1,u2
Specifies the lower and upper grid domain values in the u direction.
v1,v2
Specifies the lower and upper grid domain values in the v direction.
Returns
None.
Example
The following code from the BEZ3D example program shows a 3D Bazier mapping being established and a mesh being created and evaluated for it.
// Sets up the Bzier
// This actually only needs to be called once and could go in
// the setup function
glMap2f(GL_MAP2_VERTEX_3, // Type of data generated
0.0f, // Lower u range
10.0f, // Upper u range
3, // Distance between points in the
data
3, // Dimension in u direction (order)
0.0f, // Lower v range
10.0f, // Upper v range
9, // Distance between points in the
data
3, // Dimension in v direction (order)
&ctrlPoints[0][0][0]); // array of control points
// Enable the evaluator
glEnable(GL_MAP2_VERTEX_3);
// Use higher level functions to map to a grid, then evaluate the
// entire thing.
// Map a grid of 10 points from 0 to 10
glMapGrid2f(10,0.0f,10.0f,10,0.0f,10.0f);
// Evaluate the grid, using lines
glEvalMesh2(GL_LINE,0,10,0,10);
See Also
glEvalCoord, glEvalMesh, glEvalPoint, glMap1,
glMap2
gluBeginCurve
Purpose
Begins a NURBS curve definition.
Include File
<glu.h>
Syntax
void gluBeginCurve(GLUnurbsObj *nObj);
Description
This function is used with gluEndCurve to
delimit a NURBS curve definition.
Parameters
nObj
GLUnurbsObj: Specifies the NURBS object.
Returns
None.
Example
The following code from the example program NURBC from the CD demonstrates this function delimiting the NURBS curve definition.
// Render the NURB
// Begin the NURB definition
gluBeginCurve(pNurb);
// Evaluate the surface
gluNurbsCurve(pNurb,
8, Knots,
4 * 3,
3,
&ctrlPoints[0][0],
4,
GL_MAP1_VERTEX_3);
// Done with surface
gluEndCurve(pNurb);
See Also
gluEndCurve
gluBeginSurface
Purpose
Begins a NURBS surface definition.
Include File
<glu.h>
Syntax
void gluBeginSurface(GLUnurbsObj *nObj);
Description
This function is used with gluEndSurface to
delimit a NURBS surface definition.
Parameters
nObj
GLUnurbsObj: Specifies the NURBS object.
Returns
None.
Example
The following code from the example program NURBS from this chapter demonstrates this function delimiting the NURBS surface definition.
// Render the NURB
// Begin the NURB definition
gluBeginSurface(pNurb);
// Evaluate the surface
gluNurbsSurface(pNurb,
8, Knots,
8, Knots,
4 * 3,
3,
&ctrlPoints[0][0][0],
4, 4,
GL_MAP2_VERTEX_3);
// Done with surface
gluEndSurface(pNurb);
See Also
gluEndSurface
gluBeginTrim
Purpose
Begins a NURBS trimming loop definition.
Include File
<glu.h>
Syntax
void gluBeginTrim(GLUnurbsObj *nObj);
Description
This function is used with gluEndTrim to delimit
a trimming curve definition. A trimming curve is a curve or set of
joined curves defined with gluNurbsCurve or gluPwlCurve. The
gluBeginTrim and gluEndTrim functions must reside inside the
gluBeginSurface/gluEndSurface delimiters. When you use trimming, the
direction of the curve specifies which portions of the surface are
trimmed. Surface area to the left of the traveling direction of the
trimming curve is left untrimmed. Thus clockwise-wound trimming curves
eliminate the area inside them, while counter clockwise-wound trimming
curves eliminate the area outside them.
Parameters
nObj
GLUnurbsObj: Specifies the NURBS object.
Returns
None.
Example
The following code from this chapterłs NURBT example program shows two trimming curves being applied to a NURBS surface. The outer trimming curve includes the entire surface area. The inner curve is actually triangular in shape and creates a cut-away section in the surface.
// Render the NURB
// Begin the NURB definition
gluBeginSurface(pNurb);
// Evaluate the surface
gluNurbsSurface(pNurb,
8, Knots,
8, Knots,
4 * 3,
3,
&ctrlPoints[0][0][0],
4, 4,
GL_MAP2_VERTEX_3);
// Outer area, include entire curve
gluBeginTrim (pNurb);
gluPwlCurve (pNurb, 5, &outsidePts[0][0], 2, GLU_MAP1_TRIM_2);
gluEndTrim (pNurb);
// Inner triangluar area
gluBeginTrim (pNurb);
gluPwlCurve (pNurb, 4, &insidePts[0][0], 2, GLU_MAP1_TRIM_2);
gluEndTrim (pNurb);
See Also
gluEndTrim
Previous
Table of Contents
Next
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.
Wyszukiwarka
Podobne podstrony:
562 pl wyklady z dnia lutego 11559 (2)557 559I CKN 562 97559,6,artykuldemo cgi 562557 562README (562)562 567559 563562 (2)562,39,artykul556 559więcej podobnych podstron