I have an application that draws a nice shape (a molecule). This is accomplished through calls to gluSphere for each atom in the molecule. Some of the spheres are completely culled, as they are in the “interior” of the molecule. In other views, I draw certain aspects of the molecule in “schematic” form, with 3-D arrows and coils representing certain molecular features.
I would like to generate a surface shape (a mesh) that defines the exterior of the molecule, whether it’s been drawn exclusively with spheres or whether I’ve included some schematic representations as well. A triangle mesh would be ideal, as I will eventually ship the triangles off to another application. (I can get the triangles that are generated through any OpenGL primative by using the feedback buffer, so defining the mesh as triangles during the algorithm is not absolutely necessary – if I can draw the mesh through any means, then I can get OpenGL to give me the tesselated triangles).
Is there an algorithm that is suited for someone starting where I am (already have tons of code that draws the molecular structures) and needing to get where I’m going (a surface mesh)? Or will I have to write tons of additional code to compose the mesh instead of drawing the spheres/schematic structures?
If my code looks like this:
for each atom a
draw a sphere at a.x, a.y. a.z
And OpenGL culls all the internal faces, etc., when thousands of atoms are drawn, then it would seem that I should be able to
benefit from the culling etc. that OpenGL does. Otherwise my code becomes much more sophisticated (read “more work for me”):
for each atom a
if sphere is not already completly culled
convert sphere to triangles
determine which triangles contribute to surface
add them to the surface
determine which previous triangles from surface no longer belong there
blah, blah, blah…
Alternativley, this algorithm could start with a list of triangles (and normals) – the input would be a list of triangles, some of which are “interior” and should be culled. The output would be a (much smaller!) list of triangles that describes the surface of solid implied by the original list, with all its interior triangles removed.
Your help, as always, is most appreciated …
[This message has been edited by ghassett (edited 01-18-2002).]