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