Thread: how to build a surface........(help......)

1. how to build a surface........(help......)

i have a list of 3d points(in a array),i want to use these points to bulid a sruface,i have read some discussion about this subject, but i still don't know how to do....i am a new programmer,please help me!
ps: i need a example.........

thanks a lot!

2. Re: how to build a surface........(help......)

Hi !

It all depends.....

If the points are ordered nicely, either clockwise or counterclockwise it's pretty easy.

Please notice that this example only works with convex surfaces, if you have more complex surfaces then you need to use the tesselator included with glu, it's pretty much the same thing as the example below you just feed to points through the teseelator that breaks it down into triangles.

Convex means that if you have all the points in counterclockwise order, then the angle between any point and the next one must be turning "left", a triangle, quad, a circle and so on are convex, an L shaped surface is NOT convex.

Lets make a rectangular surface (a quad):

glBegin( GL_POLYGON);
glVertex3d( 0,0,0);
glVertex3d( 1,0,0);
glVertex3d( 1,1,0);
glVertex3d( 0,1,0);
glEnd();

This will render a rectangle in the X/Y plane, GL_POLYGON is used to create a convex polygon, if you know that you want to render a rectangle, then it's possible that GL_QUADS would be a little faster.

The idea is that you feed it the first point of the surface, then the next one and so on, OpenGL will close it for you so you don't need to specify the first point at the end again.

I hope that was what you was asking for ?

Mikael

3. Re: how to build a surface........(help......)

yes...it is very useful for me........
thank you very much!

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•