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!
06-26-2002, 01:48 AM
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):
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 ?
06-27-2002, 02:55 AM
yes...it is very useful for me........
thank you very much!
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.