PDA

View Full Version : Nurbs Surface in OpenGL



snupinokio
07-17-2003, 10:36 PM
I have a program that receives from the user control points of two B-Spline curves (de Boor points) and draws the surface with these curves as edges, connecting in a straight line between each two control points in different curves (ruled surface).
My problem is the gluNurbsSurface method doesn't work correctly when the control points array is dynamically allocated (two or three dimentions array), where it works correctly when it is statically allocated. i didn't find how to operate it right.

I would be grateful for any help anyone can give me with this.
Thanks

Naerbnic
07-17-2003, 10:57 PM
How do you allocate the two dimensional array? If you create an array of pointers, then individually malloc the elements of the array, then it will not work. This is because a statically declared array (i.e. int array[5][5]) is actually represented as 25-element flat array. The latter is understood by the Nurbs generator. The former is not. I'm not sure of this, but the easiest way to create something it will understand would be:

new float[dimX * dimY * dimZ];

Then use the following equation to access it:

float[(z * dimY + y) * dimX + x]

for x = 0...dimX, etc. Hope this helps