# Subtracting objects

I succeeded subtracting one object from another, but now I want to subtract a third object from this result!
How can I do this?
Can anybody send me code on that topic?

If you are using stencil for displaying subtraction result, you can look at
“Linear-time CSG Rendering of Intersected Convex Objects” by Nigel Stewart, Geoff Leach and Sabu John
(get pdf from http://www.nigels.com/research/ ).

Originally posted by fobru:
I succeeded subtracting one object from another, but now I want to subtract a third object from this result!
How can I do this?
Can anybody send me code on that topic?

So you have A - B = C and now you want C - D = E? Is it really that difficult? Does it have anything to do with Opengl? Just do the same thing you did to get A - B only use C & D. Or is that too obvious?

What method are u using? More details please…

What I want is to do A-(B+C) or A-B-C

Now I have A-B, thats in the colorbuffer

In my routine I first clear the colorbuffer,
and then put in the result of A-B so if I repeat my routine the firts result is gone!
Do I have to store my first result in another buffer? AND than subtract C from this buffer???

My code is in VB, I can send it if required

I think you need to properly define what you mean by subtracting objects. Are you subtracting a 3D object from another 3D object or are you doing some kind of 2D operation? Perhaps some links to some screen shots might clear things up.

For those interested I have received some images that identify what it is that fobru is doing. It is the subtraction of one 3D object from another (a small cube from a larger one). So my answer remains the same - just do what you did when subtracting the small cube from the large one, only do it with the result from your first subtraction and subtract the third object from it.

I would suggest you do some reading on CSG operations (Constructive Solid Geometry). There should be any difference between doing the operation with different objects (ie. A - B should be done in the same manner as B - C)

That was also my idea, but the reust of A-B is in the colorbuffer and in my routine the first things I do is clearing the colorbuffer! So, I loose my first result.
Do I have to store my first result in another buffer? so I can recover it at any time in the second operation?
Maybe some source would make everything clear.
I could send more pictures with the almost good result I became. I think I’m not so far away from the answer!!
Does anybody did this before?? In VB??

Thanks Mr. Rgpc for your interest and help