NURBS again!

Hello,
So far no one has answered this question on nurbs:
If I use GL_MAP1_VERTEX4 for the type in the function gluNurbsCurve() it should allow you to draw rational b spline curves by specifying the homogenious weighting factors in the fourth coordinate of the each control point. Unfortunately all this does is gives you a distorted curve for homogenious weighting factors different from 1.0. Could I be doing something wrong?

Sky-raven

err, more info; the curve should be distorted when using wieghts, that’s kinda the point…

specifying the curve with all weights at 1 should give you the same as when using no weights at all.

If something is different then have a look at the stride value between points and make sure it matches the vertex data you are passing it

Sky-raven reply:
Since I am using x,y,z,w for each control pt I set my stride at 4, but it still draws curve incorrectly, in that if i set all w to a new value it is drawn in the same way as glvertex4f() say would draw it. Therefore gluNurbsCurve() so far cannot give a true rational bspline. Where I am going wrong?

Originally posted by Rob The Bloke:
[b]err, more info; the curve should be distorted when using wieghts, that’s kinda the point…

specifying the curve with all weights at 1 should give you the same as when using no weights at all.

If something is different then have a look at the stride value between points and make sure it matches the vertex data you are passing it
[/b]

I have checked the stride which in this case is 4, since x,y,z,w coords for each control pt vertex. Now I put this to you.
If you try writing a programme to draw a circle using gluNurbsCurve() function with a
X of 000112233444 for the knot vector and
homogeneous weighting factors of
w of 1.0, 0.707,1.0,0.707,1.0,0.707,1.0,0.707,1.0
this should give a circular curve. Unfortunately it does not!The order should be an order of 3 with 9 control p.ts in the form of a box. Where I am going wrong?

Originally posted by sky-raven:
[b]Sky-raven reply:
Since I am using x,y,z,w for each control pt I set my stride at 4, but it still draws curve incorrectly, in that if i set all w to a new value it is drawn in the same way as glvertex4f() say would draw it. Therefore gluNurbsCurve() so far cannot give a true rational bspline. Where I am going wrong?

[/b]

Hi, I am new in Nurbs, and I had this same problem. In the case, you use a GL_MAP1_VERTEX_4, you must apply w parameter to your x, y, and z coordinate (simply multiply each of them by w).

example:
double w = 0.707;
GLfloat ctrlpt[9][4] = {
{0, 1, 1, 1}, // here is w = 1
{0w, 0w, 1w, w},
{1, 0, 1, 1},
{2
w, 0w, 1w, w},
{2, 1, 1, 1},
{2w, 2w, 1w, w},
{1, 2, 1, 1},
{0
w, 2w, 1w, w},
{0, 1, 1, 1},
};

GLfloat knots[12] = { 0.0, 0.0, 0.0, 0.25,
0.25, 0.5, 0.5, 0.75,
0.75, 1.0, 1.0, 1.0};

gluNurbsCurve(theNurb,
12, knots,
4, &ctrlpt [0][0],
3, GL_MAP1_VERTEX_4);

Thank very much! It worked! Great!

Originally posted by Pete:
[b]Hi, I am new in Nurbs, and I had this same problem. In the case, you use a GL_MAP1_VERTEX_4, you must apply w parameter to your x, y, and z coordinate (simply multiply each of them by w).

example:
double w = 0.707;
GLfloat ctrlpt[9][4] = {
{0, 1, 1, 1}, // here is w = 1
{0w, 0w, 1w, w},
{1, 0, 1, 1},
{2
w, 0w, 1w, w},
{2, 1, 1, 1},
{2w, 2w, 1w, w},
{1, 2, 1, 1},
{0
w, 2w, 1w, w},
{0, 1, 1, 1},
};

GLfloat knots[12] = { 0.0, 0.0, 0.0, 0.25,
0.25, 0.5, 0.5, 0.75,
0.75, 1.0, 1.0, 1.0};

gluNurbsCurve(theNurb,
12, knots,
4, &ctrlpt [0][0],
3, GL_MAP1_VERTEX_4);
[/b]

I would just like to finish this topic by asking anyone how they would best handle the situation of w approaching zero? Otherwise any w value will work by this method to produce rational curves.

In the case, w is zero, use w = 1

But if w should equal 1 then the particular control p.t will be left with 0,0,0,1. Is that right?