Cut visualisation outside mesh

I’m a beginner on openGL. I want to find a way to change the visualization in a 3D box, so that everything outside a certain region will be invisible. An object that is made of contours in multiple parallel planes defines the region. A mesh can be build of the object.

I need this to make the inside of the mesh visible, because data outside the mesh blocks the viewing.

Has anyone got some tips on how it could be possible to solve this?

That’s quite a problem. If the issue is being able to see the scene, would playing w/ the near clipping plane offer any kind of solution. If you used gluPerspective, you could just try to calculate distance from the camera to the ‘good’ data and pass that as nearZ?

Hope that helps,
Matt

How about something along the lines of:

Draw the mesh first, writing only to the z buffer •
Draw the rest of your geometry, with an appropriate z test function to clip to the mesh •
Draw the mesh again, writing to both the colour and the z buffer, using one of the …Or_Equal modes (probably Less_Or_Equal) as the z test function •

Beyond that, you could involve the stencil buffer, doing something along the lines of stencil shadows, which essentially just use arbitrary volumes to define where an operation should take place…