steapf

10-13-2008, 08:57 AM

Hello!

Just, a short question ;)

Is there a Knot-count-limitation in "gluNurbsSurface"?

I can't render more then 20 knots and i can't figure out why!?

If not, i have to check my code once more... and once more...once more... :(

Thank you!

trinitrotoluene

10-13-2008, 01:33 PM

If I am not wrong, the number of knots for each s and t directions in the array depends on the numbers of control points + the order of the NURBS curve for each s and t directions. Maybe the count or the size of your arrays don't match. I did not find any limitations in documentation like GLU_MAX_KNOT_... . Can you post some code just to verify it.

steapf

10-13-2008, 11:46 PM

Thank you trinitrotoluene!

I found nothing about it, too!

My goal is to generate a plane up to 640x480 points (video - one corresponding point per videopixel)

Some Infos:

Mac OSX 10.4.11 / NVIDIA GeForce 7300 GT

XCode

Here is a simple code Example i found on INet and i used for tests.

Everything is working fine till Knots>20; ???

hmmm... is there another fast way, genrating a 640x480 dots plane with connected Quads?

Code:

GLfloat ctlpoints[10][10][3];

GLUnurbsObj *theNurb;

void nurbsinit_surface(void)

{

int u, v;

for (u = 0; u < (10); u++) {

for (v = 0; v < (10); v++) {

ctlpoints[u][v][0] = ((GLfloat)u - 1.5);

ctlpoints[u][v][1] = ((GLfloat)v - 1.5);

ctlpoints[u][v][2] = 0.0;

if ( u == 2 && v == 2){

ctlpoints[u][v][2] = 20.0;

}

if ( u == 3 && v == 3){

ctlpoints[u][v][2] = -200.0;

}

}

}

}

void nurbsknotmyinit(void)

{

GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 };

GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };

GLfloat mat_shininess[] = { 100.0 };

glClearColor (0.0, 0.0, 0.0, 1.0);

glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);

glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);

glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);

glEnable(GL_LIGHTING);

glEnable(GL_LIGHT0);

glDepthFunc(GL_LEQUAL);

glEnable(GL_DEPTH_TEST);

glEnable(GL_AUTO_NORMAL);

glEnable(GL_NORMALIZE);

nurbsinit_surface();

theNurb = gluNewNurbsRenderer();

gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0);

gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL);

}

void nurbsdisplay(void)

{

GLfloat knots[20] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};

GLfloat knotsb[26] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPushMatrix();

glRotatef(330.0, 1.,0.,0.);

glScalef (0.5, 0.5, 0.5);

gluBeginSurface(theNurb);

gluNurbsSurface(theNurb,

20, knots,

20, knots,

10 * 3,

3,

&ctlpoints[0][0][0],

10, 10,

GL_MAP2_VERTEX_3);

gluEndSurface(theNurb);

glPopMatrix();

glFlush();

}

GLfloat knots[26] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };

gluBeginSurface(theNurb);

gluNurbsSurface(theNurb,

26, knots,

26, knots,

13 * 3,

3,

&ctlpoints[0][0][0],

13, 13,

GL_MAP2_VERTEX_3);

gluEndSurface(theNurb);

26 knots do not work... but it should!! ? Empty, black Viewport!

The count and the size of the arrays match.... or am i blind?

trinitrotoluene

10-14-2008, 10:01 AM

I think the order 10 for a bezier curve may introduce floating point error due to the high exponent for each basis functions. I try the same set of control points with the knot vector

void nurbsinit_surface(void)

{

int u, v;

for (u = 0; u < (10); u++) {

for (v = 0; v < (10); v++) {

ctlpoints[u][v][0] = ((GLfloat)u - 1.5);

ctlpoints[u][v][1] = ((GLfloat)v - 1.5);

ctlpoints[u][v][2] = 0.0;

if ((u == 4 || u == 5) && (v == 4 || v == 5))

{

ctlpoints[u][v][2] = 3.0;

}

else

{

ctlpoints[u][v][2] = -3.0;

}

}

}

}

GLfloat knots2[14] = {0.0, 0.0, 0.0, 0.0, 0.25, 0.25,0.25,0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 1.0};

glPushMatrix();

glRotatef(45.0, 1.0,0.0,0.0);

glRotatef(45.0,0.0,1.0,0.0);

gluBeginSurface(theNurb);

gluNurbsSurface(theNurb,

14, knots2,

14, knots2,

10 * 3,

3,

&ctlpoints[0][0][0],

4, 4,

GL_MAP2_VERTEX_3);

gluEndSurface(theNurb);

glPopMatrix();

which reduce the order of basis functions and it work. The result is a plane with a "mountain" in the middle.

steapf

10-17-2008, 04:11 AM

Thank you very much!

Your example is working. But none of my attempts to get a larger number of Knots

I think, i misunderstand here something completely!! :(

Do you know a good explanation of "gluNurbsSurface", made for fools in the Inet?!

trinitrotoluene

10-17-2008, 08:11 AM

I found an example (http://www.edm2.com/0608/opengl.html) which use 13 order Bézier surface. I just looked at the source (http://www.edm2.com/0608/glcol12a.zip) and did not try it. But if this one work, then you will know that there is an error in your code (and hopefully where it is).

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.