View Full Version : cutout of object

10-20-2002, 07:38 AM
I would like to cut through an object in a scene (with a plane) and cap the object with some colored surface.

The red book says that this can be done using the stencil buffer. but the method seems to fail if the object intersects with other object in the scene. Does anybody know how to do it?

10-20-2002, 07:49 AM
how about using clip planes for cut out of objects?

i dont know about stencil buffer thingy.


10-20-2002, 08:26 AM
If you cut an object, you will see it's inside. You can use the stencil buffer to fill the hole so that it appears solid. You know, if you cut an apple in half, you don't see the inside of an empty shell, but the actual fruit http://www.opengl.org/discussion_boards/ubb/smile.gif

10-20-2002, 08:30 AM
Thanks.! Now an extra problem. It seems by reading the read book that a clipping plane will cut everything bellow the infinite clip plane. However I want my clip plane to be finite and
clipping to occur only for the object cut by the plane. Is this

10-20-2002, 08:45 AM
You can enable the clip plane when you draw the object you want clipped, and then disable it when you draw the other objects.

You can also do clipping with alpha test, object linear TexGen, and a suitable two-pixel texture (opaque vs transparent).

10-20-2002, 08:50 AM
The problem is I have a scene with 10 objects and somewhere lies my plane. It might or not cut one (or more) of the objects. But I dont know which. Do I need to do some intersection test, or I dont need it?

JasonM [ATI]
10-20-2002, 10:31 PM
Here is some sample code (http://www.ati.com/developer/sdk/rage128sdk/OpenGL/Samples/Rage128StencilCap.html) which does what you want. Granted, it only shows a single object but it should get you started.

-JasonM @ ATI

10-21-2002, 02:30 AM
Thanks. Yet another question. Suppose the object I am clipping is drawn in wireframe but without hidden lines. After I clip the object I would like to draw the hidden lines that are exposed by the clipping plane. How to do that?

10-21-2002, 04:20 AM
Yey another question: Suppose I want to clip all objects inside a cube (I know the vertex coordinates of the cube). How do I specify the viewing volume to be this cube?

[This message has been edited by mikemor (edited 10-21-2002).]

10-21-2002, 05:45 AM
Let me rephrase my question:

I draw a cube in the screen by 6 faces each rendered as a set of 4 vertices(the cube can move) and I would like to define the viewing volume to be the interior of this volume. (so that as the cube moves, the viewing volume also moves)
Any clue on how to set the viewing volume?