Being pretty new to OpenGL, I’ve run into a bit of a snag on a project I’m working on. I’m actually using JOGL (Java bindings for OpenGL), since I need to run this as an applet, but the code should look about the same.
What I’ve got is a polyhedral mesh - specifically, it’s a 3D model that’s entirely filled with tetrahedra and octahedra.
What I’d like to be able to do is to paint a 2D cross-section of this model, where the “cutting plane” can be adjusted in realtime. So far, I’ve been able to use a clipping plane to slice the model, but that just gives me a halved 3D model… I realize that I could check each component of the model against the clipping plane, and paint the cross-sections of each component that intersects, but the problem here as that my model has ~10,000 components, and I can’t afford to check them all.
Is there any way, if the components are stored individually in named display lists, to retrieve the indexes of the components that are clipped, so that I can just calculate cross-sections for those components?
Another option I’ve thought of would be to turn off shading in the model, fill the faces in solid colors, and only draw lines along edges that are generated by clipping the model. (So that when you look directly at the cutting-plane, it looks like a 2D cross-section). But I’m not sure how to tell OpenGL to paint those edges but not the other edges of the model, since painting interior edges as well wouldn’t look correct.
Thanks in advance for any ideas or advice!
For reference, here’s an example of a model I’d use:
Here’s what I’m currently getting with the clipping plane:
And here’s what I’d like to get (albeit this is from a different model, and I’d like to preserve the original coloring)