NURBS § Non-Uniform Rational Basis Splines § They are generalizations of B-Splines - are defined by some control points and a knot vector, § Rational – ratio of two polynomials (spline functions) § Non-Uniform – Use knot multiplicity to produce variations in curve § Control points are specified in homogeneous coordinates. § NURBS rendering is part of the OpenGL Utilities library of functions (prefixed with “glu”).
Definition § They reduce the memory consumption when storing shapes (compared to simpler methods). They can be evaluated reasonably quickly by numerically stable and accurate algorithms.
Point calculate(float u, float v) { Point temp[4]; // calculate each point on our final v curve temp[0] = CalculateU(u, 0); temp[1] = CalculateU(u, 1); temp[2] = CalculateU(u, 2); temp[3] = CalculateU(u, 3); // integrate curves as a surface (in columns) return CalculateV(v, temp); }
void gluBeginCurve(GLUnurbsObj * nobj) Start NURBS curve rendering. void gluEndCurve(GLUnurbsObj * nobj) Stop NURBS curve rendering. void gluNurbsCurve(GLUnurbsObj * nobj, GLint nknots, GLfloat * knot, GLint stride, GLfloat * ctlpoints, GLint order, GLenum type) nobj: Pointer to NURBS object nknots: Number of knot values knot: Array of knot values stride: Offset between consecutive control point data in ctlpoints ctlpoints: Array of control point coordinates order: Blending function degree plus one. type: Any valid one-dimensional evaluator types. Such as GL_MAP1_VERTEX_3, GL_MAP1_COLOR_4, etc. gluBeginCurve, gluNurbsCurve, gluEndCurve
void gluNurbsProperty( GLUnurbsObj *nobj, GLenum property, TYPE value) property = GLU_DISPLAY_MODE Specify how NURBS surface is rendered. value Meaning GLU_FILL The surface is rendered as filled polygons. (Default value) GLU_OUTLINE_POLYGON Only render outlines of the polygons. GLU_OUTLINE_PATCH Only render outlines of patches and trimming curves. gluNurbsProperty property = GLU_SAMPLING_METHOD Specify how NURBS surface is tessellated. Value Meaning GLU_PATH_LENGTH Specify the maximum length, in pixels, of the edges of the tessellated polygons. (Default value) GLU_PARAMETRIC_ERROR Specify the maximum distance, in pixels, between the tessellated polygons and the true NURBS surface. GLU_DOMAIN_DISTANCE Specify, in parametric coordinates, how many sample points per unit length in u and v directions.
property = GLU_SAMPLING_TOLERANCE Specify the maximum length, in pixels, to be used when the sampling method is set to GLU_PATH_LENGTH. Default value is 50.0. property = GLU_PARAMETRIC_TOLERANCE Specify the maximum length, in pixels, to be used when the sampling method is set to GLU_PARAMETRIC_ERROR. Default value is 0.5. property = GLU_U_STEP Specify the number of sample points per unit length in u direction when sampling method is set to GLU_DOMAIN_DISTANCE. Default value is 100. property = GLU_V_STEP Specify the number of sample points per unit length in v direction when sampling method is set to GLU_DOMAIN_DISTANCE. Default value is 100.
void gluBeginSurface(GLUnurbsObj * nobj) Start NURBS surface rendering. void gluEndSurface(GLUnurbsObj * nobj) Stop NURBS surface rendering. gluBeginCurve, gluNurbsCurve, gluEndCurve nobj: Pointer to NURBS object uknot_count: Number of knot values in u direction uknot: Array of knot values in u direction vknot_count: Number of knot values in v direction vknot: Array of knot values in v direction ustride: Offset between consecutive control point data in ctlpoints in u direction vstride: Offset between consecutive control point data in ctlpoints in v direction ctlpoints: 2D Array of control point coordinates uorder: Blending function degree plus one for u direction. vorder: Blending function degree plus one for v direction. type: Any valid two-dimensional evaluator types. void gluNurbsSurface(GLUnurbsObj * nobj, GLint uknot_count, GLfloat * uknot, GLint vknot_count, GLfloat * vknot, GLint ustride, GLint vstride, GLfloat * ctlpoints, GLint uorder, GLint vorder, GLenum type)