PDA

View Full Version : could I access one NURBS surface triangle information



lilyli
05-04-2004, 07:07 PM
Hi,
I am programming in VC++ environment. I am going to do some further operations in one NURBS surface triangle model. Could I use OpenGL to tessellate one NURBS surface and then access the triangle data structure? If yes, how can I achieve that? Thanks.

plasmonster
05-04-2004, 07:52 PM
lilyli,

you can do this with the gl feedback machanism.
For the 3D points in a NURBS surface, you could do this:


...
// setup feedback
float buffer[Max3DPoints*3];
glFeedbackBuffer( Max3DPoints*3, GL_3D, buffer );
glRenderMode( GL_FEEDBACK );

// now draw your surfaces
...


// now look at results
int size = glRenderMode( GL_RENDER );

float* ptr = &buffer[0];
while( ptr - buffer < size ){

if( *ptr++ == GL_POINT_TOKEN ){

float x = *ptr++;
float y = *ptr++;
float z = *ptr++;

// now do something with this point...

}

}edit:

I should point out that the resluting points are in window space, so you would need to setup your modelview and projection matrices accordingly.

I also recommend reading the spec on this one. You can find it here:
www.opengl.org/documentation/spec.html (http://www.opengl.org/documentation/spec.html)