View Full Version : subtracting objects
02-18-2003, 06:02 AM
Does anybody knows how I can subtract one object from another?
Like making a hole in a cube.
02-18-2003, 06:11 AM
Subtracting objects is rather difficult, but there's nice trick with stencil buffer that lets you do it at speed linearly dependent from complexity of your objects (real cutting objects can take up to n^2 in worst case so forget about any realtime).
You should find it somewhere in demo section on this nice page http://www.delphi3d.net/
[This message has been edited by MickeyMouse (edited 02-18-2003).]
02-18-2003, 06:12 AM
It depends what you mean. Given a mesh representing a cube and a mesh representing a sphere, you could calculate the resulting mesh. Alternatively, you might be able to use a rendering trick (such as the stencil buffer) to leave the meshes unaffected but render them as though one had been subtracted from the other.
Unfortunatly, i don't really know how either method is done...
02-18-2003, 06:18 AM
There is an example of the stencil buffer method here called "Composite solid geometry using the stencil buffer."
I think you donīt want to do this in realtime, but once in an editor-like program, donīt you?
Well than you should search for CSG (Constructive Solid Geometry). This is an operation which is performed on BSP-Trees (Binary Space Partitioning Trees).
So you should first check out some tutorials on BSP-Trees and implement them. If you are new to them, it will take some days to get familiar to them.
When you have understood and implemented BSP-Trees you can check out the CSG algorithm. It isnīt really hard, but it is a bit of work.
BSP-Demo at: http://nate.scuzzy.net/
Infos on CSG: http://www.cfxweb.net/~aggrav8d/tutorials/csg.html
On BSP-Trees you will find lots of tutorials with google. Finding information about CSG is a bit harder.
Hope that helps you.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.