PDA

View Full Version : How to get the vertex information of each Bezier patch from Control points???



Phiphy
01-16-2005, 10:05 PM
I've known the control points, and by the code below I can surely draw a curve surface by Bezier patches, but here I do want to get each Bezier patches' details such as each vertex information, normal, and the such. Can you tell me How to obtain these parameters in OpenGL? Thanks a lot!!!
My code :
glEnable(GL_MAP2_VERTEX_3);
glMap2f( GL_MAP2_VERTEX_3, 0.0, 1.0, 4, 4, 0.0, 1.0, 16, 4, @ControlPoints[0][0][0]);
glMapGrid2f(4, 0.0, 1.0, 4, 0.0, 1.0);
glEvalMesh2( FillMode, 0, 4, 0, 4);
How can I get each Bezier patch's vertex information??? :confused:

mikael_aronsson
01-17-2005, 09:54 PM
Hi !

glu is pretty crappy if you want to do anything but render your beziers, it does not have any callback support so that you cannot get the vertex information.

You could download the SGI OpenGL sample implementation or Mesa and use the GLU code from there and modify it for your own needs though.

I do not think there is any way to get normal/vertex information from the standard GLU functions.

Mikael

Aeluned
01-18-2005, 05:53 AM
you're going to have to evaluate the parametric equation yourself given the control points.

There's no way to obtain the info from OpenGL.

maybe this will give you a glimpse into what's going on under the hood:
http://www.gamedev.net/reference/articles/article1584.asp

plasmonster
01-18-2005, 03:37 PM
Hello Phiphy,

While there's no way to get vertex normals directly, you can get vertex positions, colors, and texture coordinates via OpenGL's feedback mechanism. From the vertex positions, along with the GL_POLYGON_TOKEN grouping, you could derive the vertex normals as you would for any mesh.

Here's the rub on feedback:
http://fly.cc.fer.hr/~unreal/theredbook/chapter12.html

You may find it more convenient/efficient in the end to generate the mesh yourself, as mentioned, or in advance using feedback, then render it with triangles/tri-strips. That is, if the mesh is static, there's no need to evaluate it continuously.

I thought this was worth mentioning.

By the way, you should use GL_MAP2_VERTEX_4 if you're sending 4 component vertex positions ;)