# Cut outs

I am trying to acheive the appearance of cut outs or holes in solid objects. Can anyone tell me a good way to approach this? I have considered using alpha blending but without much success.
I would like my "cut-out object" to be transparent when in front of my "solid object".
Where the "cut-out object" intersects my "solid object", I would like the intersection to be visible.
Is this acheivable?

## Comment viewing options

### Re: Cut outs

Do you have any screenshots of the geometry? It would help find a solution.

One possible approach is to use alpha testing. Turn depth writes off, leave depth testing on and draw the object last (after rendering all other geometry). You can also do this with shaders (texkill).

### Re: Cut outs

I will try to get a screenshot to you, but it would be just like drilling a hole in, or snipping the corners of, a 3D shape such as a cube or piece of plate metal.

### Re: Cut outs

Are your objects infinitely thin (like GL quads are) or do they have a thickness?

### Re: Cut outs

Since Alpha Testing appears not to be the answer, do you want this result?
http://en.wikipedia.org/wiki/Constructive_Solid_Geometry

### Re: Cut outs

The objects are 3D so do have a thickness, the procedure in Inertia's link is exactly what I want to acheive. Is this possible in OpenGL?

### Re: Cut outs

@Soundbomber

OpenGL provides low-level primitives drawing, that is you can draw triangles, lines, polygons and so on. So any _graphics_ is possible with OpenGL (which means Open Graphics Library).

Now about the mathematics of constructive solid geometry, you need another library for such, or build one yourself.

### Re: Cut outs

Looks like a pretty daunting subject! Any resources with examples would be greatly appreciated.

### Re: Cut outs

The wikipedia article contains a number of links, you should also try searching the web for 'metaballs' and 'marching cubes'. Those are the general approaches for boolean operations I know of, besides using a model editor to do it for you.
You're not verbose what exactly you're trying to do.

### Re: Cut outs

Thanks all for your replies. I am trying to create a 3d model of some simple(ish) geometric shapes (structural steel sections such as universal beams, channels tee's etc). I then want to apply c.s.g. (or any other process to achieve the same effect) to these shapes to give the impression of notching and stripping (creating areas of fresh air!). I feel this would be a better more flexible approach than, say, modelling the objects with the notches in place. I have the original unchanged objects in interleaved array format and am rendering using OpenTK DrawArrays subroutine. I have read articles on c.s.g. but putting it into practical use seems daunting. This DOES, however, seem like exactly what I need.
Oh, and just to throw another spanner in the works I am working in VB.NET, and I am new to OpenGL, but I am an engineer with a sound mathematical background.

### Re: Cut outs

Implementing CSG from scratch is daunting. However, there are many unmanaged, open-source libraries that implement CSG -check out the wikipedia links at the bottom. If you don't mind the dependency, you could use DllImports and let the unmanaged library do the work for you.

As long as it is written in C, or exposes a C API (C++ interop is more complicated and is not portable), has a compatible license and actually does what you want, you should be able to use it from VB.Net.