Weighting NURBS


got some problem with NURBS. I got a NURBS specification including weights for every node. I tried to tell opengl the weights as fourth parameter in the controlpoint (so every control point has 4 entries: x, y, z and w). The last parameter from gluNurbsSurface is set to GL_MAP2_VERTEX_4, which tells opengl to use rational b-splines:

gluNurbsSurface(pNurb,	// pointer to NURBS renderer
    nruKnots, uKnots,			// No. of knots and knot array u direction	
    nrvKnots, vKnots,			// No. of knots and knot array v direction
    dimV * 4,				// Distance between control points in u dir.
    4,					// Distance between control points in v dir.
    ctrlPoints, // Control points
    degreeU + 1, degreeV + 1,					// u and v order of surface
    GL_MAP2_VERTEX_4);		// Type of surface

But the result is not as it should be. The surfaces are warped. I tried it with a simple cylinder and it was not round like a circle but the 4 quaters of the cylinder was warped to the outside.

To my question: Is it possible, that the w parameter in opengl is not the weight used in NURBS? Is there any possibility to convert it?

Thanks a lot!

w is 1/z.
for homogeneous coordinate system.

I could be wrong, but think it’s that.

No I don’t think you can use it as a weighting value.

Everything looks fine Kilam. I suspect it’s something else in the code that is causing a problem; are you sure the variables all have the correct values? One other possibility pops into my head, are you sure that your control points are GLfloats?

(and to the previous poster, no, that’s not what w is in a 4-dim homogeneous coord system.)

Thanks for your replies!

But I found the problem now. OpenGL needs the weight multiplied on the coordinates of the controlpoints and additionally the weights as w-parameter. Maybe its because w is in OpenGL not the weight but the homogenous coordinate.