A Marching Cubes Voxel Renderer

I created this a few weeks ago, when experimenting with the technology to use for my new project, although I eventually decided against it, for reasons I will detail below.

It is a voxel renderer, which essentially means it creates a environment from a 3 dimensional grid of density values, it does so using a load of complicated stuff I won’t bother to try and explain – its probably easier to work it out from the code. The algorithm used here is based on code and lookup tables from Paul Bourkes Polygonise. A similar article can be found in nvidia’s GPU Gems 3 which is available freely online.

The code is in c# using the XNA framework, which means it is essentially limited to Windows, but I suppose it will be possible to get it working on other systems with some trickery. The code is all running on the CPU as the XNA framework is based on DirectX9, meaning it doesn’t have access to fancy geometry shaders. This does leave the code with some severe limitations; processes like this are extremely slow on the CPU, which means this code can take a long time to generate the triangles so its not really suited to real time generation or environments which can change.

The actual code I hope is fairly self explanatory, I have gone through and properly commented everything, all the classes are included in the file that are needed to generate, construct, and draw your voxel environment – assuming you have the XNA framework installed of course. The code for generating your environments is very bare, but there are some interesting techniques in detail in the GPU Gems article I linked above.

The source code for just the core classes can be found here. A full program that you can run and expand from can be found here (recommended if you have trouble using the former link).

World, Hello!

Welcome to Strikelimit! This is the second third, incarnation of this site, its second incarnation in WordPress powered blog form. If for some reason you happened to chance upon this blog before, you will notice that, for now, I am using the same theme, but the tag line has changed – to nothing, this is because I am not exactly sure where this blog will go in the long term, so I am leaving it open!

At this point I envisage the blog as mostly being used for my adventures in programming, but other random things of choice will probably find there way in here. At the moment I program in the C#, using the the very slick XNA framework, so far I haven’t really created anything major, but I will be posting the details of the main project I am working on later today, as well as something interesting I made a few weeks back.