tags:

views:

244

answers:

1

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".

+2  A: 

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.

Kornel Kisielewicz
I'm not concerned with how to set know spacing, but rather how to set weights. I think I may have confused the issue by referring to the "knot weights", when I should have referred to the control point weights (fixed now). I didn't find an answer to the weights issue at your link. Can you elaborate?
redmoskito
I assume I found a solution to your problem. I edited my answer.
Kornel Kisielewicz
Homogenous coordinates! Of course! Much thanks for your answer
redmoskito
It's my pleasure :)
Kornel Kisielewicz