Model Clipping / Subtracting

I’m trying to port a faux-3d visualization tool into JOGL and Java3D. One of the last remaining features that I have not been able to implement involves subtracting out areas of certain geometries. The only two occurrences of this are with Cones and Spheres. With Spheres you can set the maximum/minimum angles for two different dimensions of the Sphere.

To start with I have a sphere:
faux-3d:

http://www.gamelizard.com/images/osp/org.opensourcephysics.display3d.testingFactory.CircleAppScreen002.png

java3d:

http://www.gamelizard.com/images/osp/org.opensourcephysics.display3d.testingFactory.CircleAppScreen001.png

jogl:

http://www.gamelizard.com/images/osp/org.opensourcephysics.display3d.testingFactory.CircleAppScreen003.png

faux-3d with maximum angle U set to 70:

http://www.gamelizard.com/images/osp/org.opensourcephysics.display3d.testingFactory.CircleAppScreen004.png

faux-3d with maximum angle U set to 70 and maximum angle V set to 30:

http://www.gamelizard.com/images/osp/org.opensourcephysics.display3d.testingFactory.CircleAppScreen005.png

What this looks like to me is just taking boxes/wedges and subtracting out the geometries from a Sphere. I know in Java3D there is a class called ModelClip which probably will help me do this, however it’ll take me a while to figure out since there aren’t any good examples to go by (key word = good). As far as JOGL goes, I have no idea where to start. Usually Nehe is my savior, but this time even he didn’t have anything to offer me. Google hasn’t been much better. Where can I go to learn how to do something like this?

Thanks!

Assuming that the parameters you can modify are fairly simple, like the minimum and maximum angles of the sphere, then you can just manually generate the geometry for only that portion of the sphere. You’d need to evaluate the function for a sphere for only a certain range of the horizontal and vertical angles, and generate the triangles to connect that back to the vertical axis at the center of the sphere (based on looking at your faux 3D view). You can look at GLUquadricImpl.java in the JOGL source base for an idea of what’s needed.

Doing general purpose subtraction and intersection of 3D models is much more complicated and lies in the field of Constructive Solid Geometry (CSG).

Depending on what you want to clip exactly using clipping planes can be the solution with a little computations to find planes coordinates…
But you may already have analysed and rejected this solution.

If it’s enough to slice straight through the spheres and cilinders, the solution might be relatively simple, as they are both convex.

  • First create a plane (origin, normal)
  • Now determine which triangles are fully above it (remove those)
  • Then determine which triangles are intersecting it (store those for later use, but remove them from the geometry for now)
  • Calculate the ‘lower part’ of the stored triangles in the last part and add them to the geometry.
  • Follow the highest line of the ‘half’ triangles, these will be on the plane, and will be a convex shape.
  • Now fill the convex polyon with geometry (like a triangle-fan, but then with triangles)

Now you got yourself a sliced model, that has its ‘gap’ filled and looks solid.

The model is still convex, so you can slice through it with any number of planes.