The voxelation link posted by @Alexandre C. looks good.
Here is a brief overview of how we solved this problem when converting the correct quadrants / triangles models into a cubic array of refractive index / epsilon indices for modeling photons / EMs.
- Create a BSP tree for your scene. (Yes indeed)
- Go through X, Y, Z periodically through your model or solution space. (The spacing in each axis should be equal to the desired voxel sizes.)
At each point in your x / y / z cycle, check a point on the BSP tree. If it is inside an object, create a voxel at this point and set its attributes (color, texture coordinates, etc.) Based on the original model (as indicated on your BSP node). ( Optimization tip ). If your inner loop is on the Y axis (vertical axis), and you are creating a terrain or XZ-oriented surface, you can exit the Y loop whenever you create a voxel.)
Save
- Profit!
Building a BSP is the only semi-arid part (and it's a lot simpler than it looks at first), but it has been documented by ying-yang all over the Internet. This will work for almost any form of model, and it will also give you a good tree that you can use to detect collisions and determine visibility, among other things.
Also note that this entire process must be performed at compile time or using a special tool (which will obviously create a file containing a tree and voxel field that you will use at run time). If you're using XNA, it's pretty easy to import anything into the content pipeline.
David Lively
source share