randychou

06-26-2002, 12:56 AM

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!

mikael_aronsson

06-26-2002, 01:48 AM

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

randychou

06-27-2002, 02:55 AM

yes...it is very useful for me........

thank you very much!

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.