cutout of object

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?

how about using clip planes for cut out of objects?

i dont know about stencil buffer thingy.

Satish.

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

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
possible?

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).

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?
Thanks

Here is some sample code which does what you want. Granted, it only shows a single object but it should get you started.

-JasonM @ ATI

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?

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).]

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?
Thanks