View Full Version : Mapping surface to non-continuous vertices
01-27-2004, 07:17 AM
I'm working on a program that has to read in a bunch of data from a file and displays the output. When I render it using GL_POINTS it works like it is supposed to. Unfortunately the vertices are not continuous, so when I try to render with GL_POLYGONS or GL_LINE_STRIP I get polygons or lines that cut through the object every which way. I can't change the way the data sets are made because they are generated by another program I didnt write.
I've tried everything I can think of, including glMap functions, and nothing works like I want it too. In my mind I can visualize mapping the surface like dropping a blanket over the outside of the points, but opengl doesnt seem to want to cooperate.
Does anyone have any suggestions on how to make this work efficiently? (the program uses very large data sets, so performance is an issue)
01-27-2004, 08:12 AM
There's no way to do this inside OpenGL.
If the polygonal data is not ok, OpenGL can't fix it for you.
If you can correct it with a shrink-wrap like algorithm, there are many polygonalization algorithm possible for such point clouds.
Seach for "Tetrahedralization" for example.
I'm not sure what you're trying to achieve here, but it sounds to me like you have X/Y or maybe X/Y/Z coordinates for every measurement.
If you try to fix that using a 3D rendering library, you're going about it the wrong way, if performance is important.
I would say, sort the data using a tree or something, so you have to sort it only once per dataset, instead of every frame.
01-28-2004, 07:52 AM
What the best way to sort the points? Sorting for only one dimension wont help because the surface is almost spherical so each individual x,y,z coord will have 4 corresponding points. Do you know of a way to run a quick 3d distance formula while keeping track of which points have been read and ones still need to be rendered? And whats the best data structure to store all the points...right now im using a 2d array, would something from the STL, or my own struct be better?
01-28-2004, 10:49 AM
The only thing related to the OpenGL API is you should be using indexed drawing (e.g., glDrawElements). You still define your vertices in an array but supply an indexed draw order that both "fixes" the order of the raw data points and delivers them as vertices of actual triangles, multiply referenced as needed to make a closed surface.
To "sort" your points, there are various approaches you may find with a google search on "surface reconstruction from 3D points."
Whatever method you use, you generally only do that once when you load your triangles to produce your index array.
For better rendering performance, you might then want to run this data through a tool like NVTriStirp (NVidia site) which re-orders your triangles to make better use of vertex caching.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.