Transform a 3D model into a voxel field

I need to write code to convert an array of quads into a voxel field. Making it work should be easy, but doing it quickly will not be so trivial.

Does anyone know of any libs or source code that I can use? I'm sure someone should have done this before.

change The algorithm should also fill the inside of the model with voxels. Just a shell will not do.

+7
algorithm 3d model voxel
source share
2 answers

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.

+7
source share

Mark the Marching Cubes algorithm . I think you need to flip it in the context of your problem!;)

+1
source share

All Articles