Results 1 to 9 of 9

Thread: NURBS again!

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Salisbury,Wilts,UK
    Posts
    16

    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

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2000
    Location
    Oxford, England
    Posts
    472

    Re: NURBS again!

    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

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Salisbury,Wilts,UK
    Posts
    16

    Re: NURBS again!

    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:
    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

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Salisbury,Wilts,UK
    Posts
    16

    Re: NURBS again!

    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:
    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?



  5. #5
    Junior Member Newbie
    Join Date
    Aug 2002
    Posts
    5

    Re: NURBS again!

    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
    {0*w, 0*w, 1*w, w},
    {1, 0, 1, 1},
    {2*w, 0*w, 1*w, w},
    {2, 1, 1, 1},
    {2*w, 2*w, 1*w, w},
    {1, 2, 1, 1},
    {0*w, 2*w, 1*w, 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);

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Salisbury,Wilts,UK
    Posts
    16

    Re: NURBS again!

    Thank very much! It worked! Great!
    Originally posted by Pete:
    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
    {0*w, 0*w, 1*w, w},
    {1, 0, 1, 1},
    {2*w, 0*w, 1*w, w},
    {2, 1, 1, 1},
    {2*w, 2*w, 1*w, w},
    {1, 2, 1, 1},
    {0*w, 2*w, 1*w, 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);

  7. #7
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Salisbury,Wilts,UK
    Posts
    16

    Re: NURBS again!

    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.

  8. #8
    Junior Member Newbie
    Join Date
    Aug 2002
    Posts
    5

    Re: NURBS again!

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

  9. #9
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Salisbury,Wilts,UK
    Posts
    16

    Re: NURBS again!

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

Similar Threads

  1. Last one on nurbs... sweeping a nurbs curve to draw a nurbs surface?
    By BigShooter in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-04-2003, 09:54 AM
  2. NURBS
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-07-2002, 01:00 AM
  3. NURBS
    By J_Ramone in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-23-2002, 09:48 PM
  4. NURBS help
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-25-2001, 12:49 PM
  5. D-NURBS
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-29-2000, 11:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean