PDA

View Full Version : Obtaining vertices from a NURB surface.



godhandiscen
12-08-2008, 04:24 AM
Hello. Thanks in advance for your help.

I am rendering a NURB surface:



gluBeginSurface(nurbRenderer);

gluNurbsSurface(nurbRenderer,
sKnotCount, sKnot,
tKnotCount, tKnot,
sStride, tStride,
ctlPtArray,
sOrder, tOrder,
GL_MAP2_VERTEX_3);
gluEndSurface(nurbRenderer);


What do I need to to in order to obtain the 3D coordinate points that describe this surface?

trinitrotoluene
12-08-2008, 08:20 AM
You need to call gluNurbsProperty(theNurb,GLU_NURBS_MODE,GLU_NURBS_ TESSELLATOR);. Then you have to register a callback function gluNurbsCallback(theNurb,GLU_NURBS_VERTEX,(GLvoid (*)())vertex_callback);. Here is a simple callback function:


void CALLBACK vertex_callback(GLfloat *vertex)
{
std::cout<<"("<<vertex[0]<<","<<vertex[1]<<","<<vertex[2]<<")"<<std::endl;
std::cout.flush();
}


For more information see gluNurbsProperty (http://www.opengl.org/sdk/docs/man/xhtml/gluNurbsProperty.xml) and gluNurbsCallback (http://www.opengl.org/sdk/docs/man/xhtml/gluNurbsCallback.xml).

godhandiscen
12-08-2008, 01:58 PM
Thank you. However, I cannot build the project because GLU_NURBS_MODE and GLU_NURBS_TESSELATOR are undeclared identifiers. Is there anything else I need to do?

trinitrotoluene
12-08-2008, 02:38 PM
What version of GLU you have? I think you need version 1.3 or better to be able to use the GLU nurbs tessellator. Use gluGetString (http://www.opengl.org/sdk/docs/man/xhtml/gluGetString.xml) to retrieve the version number.

godhandiscen
12-08-2008, 02:45 PM
What version of GLU you have? I think you need version 1.3 or better to be able to use the GLU nurbs tessellator. Use gluGetString (http://www.opengl.org/sdk/docs/man/xhtml/gluGetString.xml) to retrieve the version number.

It says "1.2.2.0 Microsoft Corporation". Is there any way to upgrade? Thanks for all your help.

trinitrotoluene
12-08-2008, 03:39 PM
It seem that you have the default Microsoft implementation of OpenGL. What is your video card? Try to get the latest driver release for your video card.

godhandiscen
12-08-2008, 03:51 PM
I have an ATI card 4870x2. I also have the latest driver release. Catalyst 8.11. Is there any way other way to get the vertex data out of the NURB surface? I've searched for Glu 1.3 without any luck. I can only find the spec, but I cannot find the files I need. Is there a place where I can just download the library and header files?

trinitrotoluene
12-08-2008, 04:10 PM
I think that the Mesa project include also the source code for GLU. But I don't know if it is possible to just install the glu portion of this software on a computer. Just to compare, my video card is a NVidia TnT2 (1999) an I have at least GLU 1.3 supported. It is strange that your card have a version older than mine. Can you verify that your OpenGL renderer is ATI/AMD, not the Microsoft 1.1 implementation version => check to see if your video driver is installed properly.

godhandiscen
12-08-2008, 04:18 PM
How do I check for my OpenGL renderer specifically? I know that my video driver is installed properly because of benchmarks, and the Catalyst control panel. I use a Quadro 5xx card at work, should I try that one?

trinitrotoluene
12-08-2008, 04:24 PM
Check for glGetString (http://www.opengl.org/sdk/docs/man/xhtml/glGetString.xml) with GL_VENDOR,GL_RENDERER and GL_VERSION. The Mesa (http://www.mesa3d.org/) project include the latest GLU version provided by SGI.

ZbuffeR
12-08-2008, 04:29 PM
check thos strings :
glGetString(GL_RENDERER);
glGetString(GL_VENDOR);
... etc ...

godhandiscen
12-08-2008, 05:41 PM
I am at my job. I got:
Quadro FX 550/PCI/SSE2
NVIDIA Corporation

trinitrotoluene
12-08-2008, 08:44 PM
I am at my job. I got: Quadro FX 550/PCI/SSE2 NVIDIA Corporation This one is correct and the software that come with the driver should support GLU 1.3. Now you have to check for your ATI graphic card.

godhandiscen
12-08-2008, 09:35 PM
It is still using GLU verssion 1.2.2 by Microsoft. I think it is a problem with the Visual Studio and its version of GLU. Even at work I cannot get it working. Thanks for your help.

godhandiscen
12-08-2008, 10:18 PM
I think I got it working. I downloaded the .h, .dll, and .lib files from here.

http://www.geocities.com/vmelkon/glu.html

I have not tested all the functionality I need, but so far so good.

Thanks for your help.

godhandiscen
12-08-2008, 10:35 PM
I am using the code recommended in post #2 of this thread, and I am getting this error.

Error 2 error C2664: 'gluNurbsCallback' : cannot convert parameter 3 from 'GLvoid (__cdecl *)(void)' to '_GLUfuncptr' c:\documents and settings\cen\my documents\572\nurbseditor\nurbseditor\nurbseditor. cpp 457

So the problem is with my third argument not being a _GLUfuncptr. Any suggestions?

trinitrotoluene
12-09-2008, 07:25 AM
If you pass only the function name without the cast what happen. My compiler is GCC, it seem that it have a different behavior than the Microsoft compiler.

godhandiscen
12-09-2008, 10:18 AM
If I pass it without the cast I get the following error:

Error 2 error C2664: 'gluNurbsCallback' : cannot convert parameter 3 from 'void (__stdcall *)(GLfloat *)' to '_GLUfuncptr' c:\documents and settings\cen\my documents\572\nurbseditor\nurbseditor\nurbseditor. cpp 581

trinitrotoluene
12-09-2008, 05:21 PM
Try that:


_GLUfuncptr func;
func = (GLvoid (*)()) vertex_callback;
gluNurbsCallback(theNurb,GLU_NURBS_VERTEX,func);


It work for me. In theory, _GLUfuncptr is for GLU internal purpose.

godhandiscen
12-10-2008, 03:45 AM
I got it to compile by doing this cast



gluNurbsCallback(nurbRenderer, GLU_NURBS_VERTEX, (_GLUfuncptr) vertex_callback);

Got it working on Linux (should have tried this from the begining).

Now, my problem is that when I set gluNurbsProperty and enable the gluNurbsCallback, the patch won't render. I still get the vertices dumped to the output, but I don't see the patch. If I comment out the property and callback, it will render.

trinitrotoluene
12-10-2008, 08:32 AM
Now, my problem is that when I set gluNurbsProperty and enable the gluNurbsCallback, the patch won't render. I still get the vertices dumped to the output, but I don't see the patch. If I comment out the property and callback, it will render. This is not a problem. this is the normal behavior when you enable the tessellator (http://www.opengl.org/sdk/docs/man/xhtml/gluNurbsProperty.xml).

godhandiscen
12-11-2008, 04:18 AM
Thank you. I guess I'll render quads (or tris?) from the data I got.