I am trying to write some code that takes some data, puts it into a 3-dimensional array, and then generates a 3D mesh for rendering. The data is a list of tiles with fields for defining the tile's type, etc. I am using Irrlicht for graphics right now and it has ways to manipulate the vertices/indices of a mesh but I can't come up with a fast, efficient way to do it. Are there any libraries or examples of how to do this that anyone knows of?
views:
79answers:
3You want Delaunay triangulation. There are some links at the end of the wikipedia entry. I have used CGAL once for this, but it was quite painful. Note that the problem is particularly ill-conditioned, and you do need a library: CGAL uses some exact arithmetic tricks, hence its cumbersomeness.
Don't do this yourself.
In case you want mesh generation of the convex hull, CGAL provides it too (cumbersome too).
It's unclear what exactly you mean by a 3D array of data, but I guess that you're searching for marching cubes algorithm. It's pretty easy to implement yourself but probably you can find an open-source implementation.
If it's a fully 3D (with internal volumes and intersecting faces) then you need marching cubes or marching tetrahedra
But if it's 2.5D (ie xy and depth/height) then it's much quicker to do a 2D delauney triangulation on the XY - the best and fastest implementation is triangle but it's not free for commercial use