PDA

View Full Version : GL_NV_evaluators and many questions!



Diapolo
02-06-2002, 07:21 PM
Hi,

Iīm trying to look into the Extension GL_NV_evaluators, but I donīt seem to understand the whole stuff.

1. Do I have to set up control points for every Vertex Attribute (one for vertex position, one for TexCoords etc.)?

2. Is there a rule how many control points I have to use (a minium number of ctrl points)?

3. For what is the 4th value used in the ctrl points array? First three are X, Y, Z (vertex position), but the 4th?

4. Where can I find a detailed description or an REALLY easy example on how to use the glMapControlPointsNV command?

OK, currently I got the following:

1. parameter = patch type
2. parameter = vertex attribute register no.
3. parameter = GL_FLOAT or GL_DOUBLE
4. parameter = ustride
5. parameter = vstride
4 + 5 = the numbers of basic machine units (typically unsigned bytes) between control
points in the u and v directions, but WHAT does that mean?
6. parameter = uorder
7. parameter = vorder
6 + 7 = uorder and vorder have the same
meaning they do in the Map2{fd} command.
My red book sais: Finally, the order parameters uorder and vorder, can be different - allowing patches that are cubic in one direction and quadric in the other, for example. Really not a good explanation http://www.opengl.org/discussion_boards/ubb/wink.gif.
8. parameter: packed = true oder false
Guess I could teach me that on my own, IF i would understand the other missing parts of the puzzle http://www.opengl.org/discussion_boards/ubb/smile.gif.
9. parameter: pointer to the ctrl points array, OK thatīs clear

Here is the code I try to use, Vertex position works, but texture coordinates are messed (and remember I dunno the correct meanings of the glMapControlPointsNV parameter *g*):

float CPTS[4][4][4] = {{{-0.6, 0.6, 0, 1}, {-0.2, 0.6, 0, 1}, {0.2, 0.6, 0, 1}, {0.6, 0.6, 0, 1}},
{{-0.6, 0.2, 0, 1}, {-0.2, 0.2, 0, 1}, {0.2, 0.2, 0, 1}, {0.6, 0.2, 0, 1}},
{{-0.6, -0.2, 0, 1}, {-0.2, -0.2, 0, 1}, {0.2, -0.2, 0, 1}, {0.6, -0.2, 0, 1}},
{{-0.6, -0.6, 0, 1}, {-0.2, -0.6, 0, 1}, {0.2, -0.6, 0, 1}, {0.6, -0.6, 0, 1}}};

glEnable(GL_EVAL_VERTEX_ATTRIB0_NV);
glEnable(GL_EVAL_VERTEX_ATTRIB8_NV);

glMapControlPointsNV(GL_EVAL_2D_NV, 0, GL_FLOAT, (4 * sizeof(GLfloat)), (4 * 4 * sizeof(GLfloat)), 4, 4, GL_TRUE, CPTS);

glMapControlPointsNV(GL_EVAL_2D_NV, 8, GL_FLOAT, (4 * sizeof(GLfloat)), (4 * 4 * sizeof(GLfloat)), 4, 4, GL_TRUE, CPTS);

glEvalMapsNV(GL_EVAL_2D_NV, GL_FILL);

I really hope, there are people here, that are willing to help me http://www.opengl.org/discussion_boards/ubb/smile.gif.

Regards,
Diapolo

Diapolo
02-07-2002, 05:46 AM
Please help, I really get crazy http://www.opengl.org/discussion_boards/ubb/frown.gif.

Diapolo

zed
02-07-2002, 12:09 PM
>>My red book sais: Finally, the order parameters uorder and vorder, can be different - allowing patches that are cubic in one direction and quadric in the other, for example. Really not a good explanation <<

that extensions wont be in the red book perhaps u mean a similar glu.. function

heres code i ripped out of a demo of mine from about a year ago (it works with texture coordinates on 2 texture units) perhaps its of use, perhaps not i sorta gave up on the extension cause its done in software on my vanta from then (also just checked its also in software for my gf2mx) + is pretty slow
glMapControlPointsNV( GL_EVAL_2D_NV, 0, GL_FLOAT, 16*sizeof(GLubyte), (PATCHSIZE*16)*sizeof(GLubyte), PATCHSIZE, PATCHSIZE, GL_TRUE, patch[i].points ); // degree + 1
glMapControlPointsNV( GL_EVAL_2D_NV, 8, GL_FLOAT, 16*sizeof(GLubyte), (2*16)*sizeof(GLubyte), 2, 2, GL_TRUE, patch[i].texcoords ); // degree + 1
glMapControlPointsNV( GL_EVAL_2D_NV, 9, GL_FLOAT, 16*sizeof(GLubyte), (2*16)*sizeof(GLubyte), 2, 2, GL_TRUE, texcoords ); // degree + 1

mcraighead
02-07-2002, 01:08 PM
You need to specify a bilinear patch with texture coordinates.

The fourth coordinate is the W coordinate.

- Matt

Diapolo
02-07-2002, 03:00 PM
OK, I see that I have to specify an array, that contains the vertex position in format X, Y, Z and W and an array, that contains the texture coordinates in format S and T.

Now is there a rule, how many control points I have to use as minimum, or should it be possible with only 4?

And still the question on how to set the glMapControlPointsNV parameters the right way.

ustride and vstride:

ustride: the numbers of basic machine units (typically unsigned bytes) between control
points in the u direction.
vstride: the numbers of basic machine units (typically unsigned bytes) between control
points in the v direction.

But how do i get the correct value for that parameters?
If I have got an GLfloat array with 16 control points (GLfloat CPTS[4][4][4]), how could I get the values for ustride and vstride?

uorder and vorder:

Has this got something to do with the layout of the array? Zed, you used the variable PATCHSIZE, could you perhaps post how you defined your array or can you help me in understanding these parameters?
By the way, the extension specification says about uorder and vorder itīs the same as for the Map2{fd} command and what I wrote in my first post was for the Map2{fd} in my Red book http://www.opengl.org/discussion_boards/ubb/smile.gif.

Diapolo

[This message has been edited by Diapolo (edited 02-07-2002).]

Tom Nuydens
02-07-2002, 11:57 PM
ustride and vstride:

Your control points are a 2D array of XYZW vectors. The "U direction" corresponds to the horizontal index in that array (X), the V direction is the vertical index (Y). To get one control point, it's CPTS[U][V].

The ustride parameter is the number of bytes between control points in the horizontal direction. Assuming you only have your control points in there, it will equal the size of one XYZW vector, which is four floats or 16 bytes. If you decide to add some extra information to each control point (e.g. for animation), you will need to add the size of this information to your ustride.

The vstride parameter is the distance between control points in the vertical direction. There is an entire row of control points between consecutive elements, so for a 4x4 array of control points, the size of one row is four times that of one element, which is 64 bytes (again, unless you add extra data).

-- Tom

Diapolo
02-08-2002, 04:35 AM
Thanks for your reply Tom http://www.opengl.org/discussion_boards/ubb/smile.gif.

But still one problem left and that is Texture coordinates.
If you look at your demo Tom, you will see that you canīt use the XYZW array as texture coordinates.
Change the clamping mode to GL_CLAMP and you will see what I mean.
I tried to create an array of texture coordinates in the form GLfloat CPTS_tex[4][4][2], but I guess I did it wrong.

Any good idea, how I could compute the right Tex coord values for the array?

Best Regards,
Diapolo

zed
02-08-2002, 12:03 PM
Diapolo i emailed u a small glut demo u will need 3 textures colour/detail + heightmap for it to run (check the source code)

Diapolo
02-08-2002, 05:07 PM
Great, thank you VERY much Zed http://www.opengl.org/discussion_boards/ubb/smile.gif.
I found my error ... I specified TexCoords with only s and t, instead of s, t, r and q.

But one small problem is left, if I call this command:

glEnable(GL_EVAL_FRACTIONAL_TESSELLATION_NV);

Then I get an divide by zero error, if that line is called:

glEvalMapsNV(GL_EVAL_2D_NV, GL_FILL);

And ideas?
Perhaps a driver issue (using 27.20)?

Diapolo