Question

I'm writing a NURBS class that uses OpenGL's GLU extension to do rendering, but I just realized I have no idea how to set the control point weights. It's not in the Red Book or the GLU documentation, and the web doesn't mention much of it, either. Is it possible that GLU's NURBS implementation just doesn't include this feature? If so, I'm surprised they got away with calling it NURBS and not just B-splines.

Edit: Changed "knot weights" to "control point weights".

Was it helpful?

Solution

Your problem stated in NURBS terminology is that you want a rational curve instead of a non-rational.

Looking at the gluNurbsCurve prototype we have:

void gluNurbsCurve(GLUnurbsObj *nobj, // NURBS object 
                   GLint nknots,      // number of knots
                   GLfloat *knot,     // knot values
                   GLint stride,      // stride
                   GLfloat *ctlarray, // control points array
                   GLint order,       // order of data
                   GLenum type)       // data type

One of the parameters is *knot, HOWEVER it's not an array of weights. The way glu handles knot weights is a little confusion, you can read about it here.

The ctlarray and last parameter is the ones that interests you. The last parameter, type, is one of the two-dimensional evaluator types. Commonly, you might use GL_MAP2_VERTEX_3 for nonrational or GL_MAP2_VERTEX_4 for rational control points, respectively.

See the Red Book for further details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top