I'm going to write some code for 3d blobs (metaballs). I've been
collecting some info and now I've got an algorithm. I'd like to know if
anybody can tell me where can I optimize or what can I change just
before to start coding it.
This is what I have in mind (it's called the "marching cubes
1) Position the metaballs (points with a radius) in the 3d world
2) Get the bounding rectangle
3) Divide it and obtain a 3d grid
4) For each cube in the grid, and for each vertex in the cube, compute
the value - I will call it F (based on the distances to the centers of
I guess I can precalc this value and put it in some kind of lookup...
5) With the 8 F's of the cube, go to a lookup to get the triangles
6) Calc the exact position of each vertex of the triangles with linear
7) Add the triangles to the final polygon list
I can reuse the F values for neightbour subcubes
This should be done for every frame of the animation - if the metaballs
positions change. Isn't it too SLOW??
Has anybody ever coded something similar and can tell me about the
efficiency of this?
Another problem is to calc the vertex normals... I need it in order to
do the phong shading.
I'll thank you any comment