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
gluNurbsSurface
Purpose
Defines the shape of a NURBS surface.
Include File
<glu.h>
Syntax
void gluNurbsSurface(GLUnurbsObj *nObj, GLint uknotCount, GLfloat *uknot, GLint vknotCount, GLfloat *vknot, GLint uStride, GLint vStride, GLfloat *ctlArray, GLint uorder, GLint vorder, GLenum type);
Description
This function defines the shape of a NURBS
surface. Must be delimited by gluBeginSurface and gluEndSurface. The
shape of the surface is defined before any trimming takes place. A NURBS
surface can be trimmed by using the gluBeginTrim/gluEndTrim and
gluNurbsCurve and/or gluPwlCurve to do the trimming.
Parameters
nObj
GLUnurbsObj*: Pointer to the NURBS object (created with gluNewNurbsRenderer).
uknotCount
GLint: The number of knots in the parametric u direction.
uknot
GLfloat*: An array of knot values that represent the knots in the u direction. These values must be nondescending. The length of the array is specified in uknotCount.
vknotCount
GLint: The number of knots in the parametric v direction.
vknot
GLfloat*: An array of knot values that represent the knots in the v direction. These values must be nondescending. The length of the array is specified in vknotCount.
uStride
GLint: Specifies the offset, as a number of single-precision, floating point values, between successive control points in the parametric u direction in ctlarray.
vStride
GLint: Specifies the offset, as a number of single-precision, floating point values, between successive control points in the parametric v direction in ctlarray.
ctlArray
GLfloat*: Pointer to an array containing the control points for the NURBS surface. The offsets between successive control points in the parametric u and v directions are given by uStride and vStride.
uorder
GLint: The order of the NURBS surface in the parametric u direction. The order is 1 more than the degree; hence a surface that is cubic in u has a u order of 4.
vorder
GLint: The order of the NURBS surface in the parametric v direction. The order is 1 more than the degree; hence a surface that is cubic in v has a v order of 4.
type
GLenum: The type of surface. This can be any of the 2D evaluator types: GL_MAP2_VERTEX_3, GL_MAP2_VERTEX_4, GL_MAP2_INDEX, GL_MAP2_COLOR_4, GL_MAP2_NORMAL, GL_MAP2_TEXTURE_COORD_1, GL_MAP2_TEXTURE_COORD_2, GL_MAP2_TEXTURE_COORD_3, and GL_MAP2_TEXTURE_COORD_4.
Returns
None.
Example
See the example for gluBeginSurface.
See Also
gluBeginSurface, gluBeginTrim,
gluNewNurbsRenderer, gluNurbsCurve, gluPwlCurve
gluPwlCurve
Purpose
Specifies a piecewise NURBS trimming curve.
Include File
<glu.h>
Syntax
void gluPwlCurve(GLUnurbsObj *nObj, GLint count, GLfloat *array, GLint stride, GLenum type);
Description
This function defines a piecewise linear
trimming curve for a NURBS surface. The array of points are in terms of
the parametric u and v coordinate space. This space is a unit square
exactly 1 unit in length along both axes. Clockwise-wound trimming
curves eliminate the enclosed area; counterclockwise trimming curves
discard the exterior area. Typically, a trimming region is first
established around the entire surface area that trims away all points
not on the surface. Then smaller trimming areas wound clockwise are
placed within it to cut away sections of the curve. Trimming curves can
be piecewise. This means one or more calls to gluPwlCurve or
gluNurbsCurve can be called to define a trimming region as long as they
share endpoints and define a close region in u/v space.
Parameters
nObj
GLUnurbsObj*: Specifies the NURBS object being trimmed.
count
GLint: Specifies the number of points on the curve listed in *array.
array
GLfloat*: Specifies the array of boundary points for this curve.
stride
GLint: Specifies the offset between points on the curve.
type
GLenum: Specifies the type of curve. May be GLU_MAP1_TRIM_2, used when the trimming curve is specified in terms of u and v coordinates; or GLU_MAP1_TRIM_3, used when a w (scaling) coordinate is also specified.
Returns
None.
Example
The following code from this chapterłs program NURBT shows a NURBS curve being trimmed with a triangular shaped region. A large trimming area encloses the surface that includes all the area within it. A secondary trimming area defines a triangle and discards any surface area within it.
// Outside trimming points to include entire surface
GLfloat outsidePts[5][2] = /* counter clockwise */
{{0.0f, 0.0f};, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}, {0.0f, 0.0f}};
// Inside trimming points to create triangle shaped hole in surface
GLfloat insidePts[4][2] = /* clockwise */
{{0.25f, 0.25f}, {0.5f, 0.5f}, {0.75f, 0.25f}, { 0.25f, 0.25f}};
...
...
// 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);
// Done with surface
gluEndSurface(pNurb);
See Also
gluBeginTrim, gluEndTrim, gluNurbsCurve
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:
571 573571 (2)rozporzadzenie ke 574 20102015 01 11 ZUSO Wykład 07id(571574 659phe 2014 3 574569 571574 576571 42015 10 09 3b2 SPR 2id(5742015 10 09 3b2 SPR 2id(574więcej podobnych podstron