PDA

View Full Version : Dynamic Bezier Surfaces



gilrgr
03-26-2001, 03:19 AM
hi !!
I need to draw a bezer surface in opengl.
I made quite an impressive program , but my only problem is the size of the control points I use is constant 4*4*3
(the 3 is for x,y,z).
Of course I can change it to any number , but I want it to be argument dependent :
I read the control points from a file and I want to read every time any number of control points (assuming the dimension of the grid is given in the text file).
So - I wrote this

GLfloat *ctrlPoints;
static int n,m;

// Getting the n,m :
n = (int)readNumber(fIn);
m = (int)readNumber(fIn);

ctrlPoints = new GLfloat[n*m*3];
for(int i = 0; i < n ; ++i)
{
for(int j = 0; j < m ; ++j)
{
// Getting the triplets (xyz coordinates of the grid)
ctrlPoints[i*n+j*m] = readNumber(fIn);
ctrlPoints[i*n+j*m + 1] = readNumber(fIn);
ctrlPoints[i*n+j*m + 2] = readNumber(fIn);
}
}

the readNumber gets me a float number from the file.

And it works bad (the arrau do hold all the points but opengl do something wrong ?!).

So - I kept trying : I used the ctrlPoints array as a ***.
And I did all the required allocation (exactly as shown in another thread about that thing) , and nothing...
I know there my be problem with the order or stride (the numer of floats between the control points).
Can someone help me ??
Please ??

Relic
03-26-2001, 07:23 AM
Read the documentation about glMap2f, glMapGrid2f and glEvalCoord.
I assume the uorder and vorder is 4, thereby defining polynomials of degree 3 (cubic).
The rest you need is the correct calculation of strides between the 4x4 data grids.