PDA

View Full Version : I need to convert quad data to triangle data!!

bansheeogl
05-14-2005, 02:00 AM
hi im loading a mesh from a file and sometimes the mesh could have a couple of quads here and there. how can i convert them to triangles? so i only call GL_TRIANGLES !! thanks!

ZbuffeR
05-14-2005, 02:46 AM
==>
triangle 1 2 3
triangle 3 4 1

Silkut
05-14-2005, 02:55 AM
Don't forget that your gfx card can only work with triangles. Your 'quad' is certainly an assembly of 2 tris.

bansheeogl
05-14-2005, 02:27 PM
um it sounds hard to implement this!
is there any example i could see and learn from?

thanks

bansheeogl
05-14-2005, 03:44 PM
i see this in a c++ example (nothing to do with the quad to tri but i dont understand something)

glVertex3fv(&model->vertices[3 * triangle->vindices[0]]);

isnt that function asking for 3 values? X Y Z ?
no commas in c++ ?

ZbuffeR
05-14-2005, 03:53 PM
you are kidding right ? :p

each time you read a quad (4 vertices), you transform it to 2 triangles using these 4 vertices as I told you...

What seem hard to you exactly ?

For glVertex (and a lot of other calls) the postfix means a lot of useful things.

3fv stands for :
3 : three elements are sent
f : each element is a float (can be i for int, b for byte, d for double, you get it)
v : data is sent as a single vector, a pointer to an array in C terminology, containing the above described information. If this 'v' is not there, then each element is in a single parameter : glVertex3f( GLfloat x, GLfloat y, GLfloat z )

You should definitely read some medium level C/C++ generic tutorials on arrays and pointers, it will help you a lot for doing anything useful.

bansheeogl
05-14-2005, 05:51 PM
oh yes i didnt see that wasnt glvertex3f!