3D model to volume

category: general [glöplog]

I was looking for a tool that can do the following:

Get one 3D model (3ds,obj,lw etc. no texture/materials, just geometry)
Produce a series of cross-sections as 2D images.

In other words a 3D -> Voxel space converter of sorts. Any idea ? Does such thing exist out there ?

added on the 2008-02-18 13:46:56 by Navis Navis
ask tbl :)
added on the 2008-02-18 13:49:09 by havamal havamal
We did it by rendering polygons into a 3D grid. Each polygon was rendered 3 times, parallel-projected once along each major axis. This "render each polygon 3 times" removed any holes in the rasterized triangles.
added on the 2008-02-18 13:52:23 by Kalms Kalms
I'm basically interested more in the cross-sections. So a tool to convert 3DS -> lots of images.
added on the 2008-02-18 13:58:00 by Navis Navis
I thought you did your own tools :)
You can render stuff in orthographical and export the zbuffer... you probably though about it.
added on the 2008-02-18 13:59:36 by xernobyl xernobyl
Navis: I have written one, by doing inside-mesh testing on the stencil-buffer (basically the same as shadow volumes), and I've added in a distance-transform to get a signed distance to the mesh-surface for each voxel. Interrested in the source code (it's a mess, but whatever)? My e-mail is kusmabite att gmail dotcom.
added on the 2008-02-18 14:03:17 by kusma kusma
wouldnt a scheme like this work?:

-set up parallel projection, look down a major axis (z?)
for all slices:
-set up slice rendertarget/texture
-set up clipping planes (near plane: current slice - voxelsize/2, far plane: current slice + voxelsize/2)
-render obj
end for

then build a 3d texture from the slices or whatever :)
added on the 2008-02-18 14:05:29 by gopher gopher
I have done that tool myself for something outside the demoscene, but I seem to have lost it completely (the tool :-)).

By the way, when I say 'mesh to volume' I mean that if you give it, for example, a cylinder, it will export a series of 'filled' circles ( actually, even if it is just the outline it would do, as I can 'bucket fill' later by hand).

The way I did it back then was by raycasting but now it is lost forever.

Kusma: in what language ? Does it produce an exe ? (have you got it)

thanks, lets just wait a bit maybe somebody has a better solution or something..
added on the 2008-02-18 14:09:09 by Navis Navis
so you rather want contour lines?
added on the 2008-02-18 14:11:58 by gopher gopher
Navis: It's c++ code, and uses opengl for the rasterization, and yes - it produces an exe. BUT, since I'm a lazy coder, you have to recompile it to change the mesh, so you really need the source code (and some python-scripts to re-generate the input-header files) to do anything except calculating and then spinning a voxel-duck ;)
added on the 2008-02-18 14:12:13 by kusma kusma
thanks. I'll think over that with a clear head cause I'm massively tired, sleepy and sick. The idea of clipping planes/isometric and rendering loop sounds like it would do it (probably faster than recompiling and pythons etc). I was hoping for an off the shelf solution somewhere rather than spend some hours on my own, but anyway thats life...
added on the 2008-02-18 14:14:23 by Navis Navis
Also, it produces two results - a 3d-grid of booleans (inside/outside mesh) and supersampled signed surface-distance grid (for better precision - the distance is calculated on the voxel representation, and thus gets a bit shitty without it when using low resolution grids).
added on the 2008-02-18 14:14:52 by kusma kusma
If it's a closed mesh, couldn't you just go through each (x, y) on each z plane, and do a point-inside-mesh test for each point? I seem to remember you can determine that by observing the signs of the dot product of the point and every triangle normal in the mesh.
parapete: that's what my solution is doing, and it was a lot easier and faster than trying to get a ray-triangle intersection routine or scanline-rasterizer robust.
added on the 2008-02-18 14:41:30 by kusma kusma
i think its rather the plane equation of that triangle where you need to insert the point to test. however it's only that simple for convex meshes.
added on the 2008-02-18 14:41:33 by gopher gopher
oh, yeah. my routine does the point-inside-mesh test with depth-pass stencil-testing, not any fancy dot-products. hardware acceleration ftw.
added on the 2008-02-18 14:42:48 by kusma kusma
kusma, cool, i misunderstood your description. i guess your technique would probably be feasible in real-time too...

gopher, yep i think you're right :)
Navis: an addition note, my voxelizer takes any kind of OpenGL (you can just replace a call to glDrawElements() with anything you wish) input, so you may plug in your model-loader of choice instead of using my python script to convert ASE-files to point- and index-lists. The voxelizing process itself is pretty fast, the slow part is the distance transform afterwards, but if I've understood you correctly, you don't need that part.
added on the 2008-02-18 14:49:40 by kusma kusma
www.vtk.org can also do these kinds of things. It is a pretty huge library so it can be tricky to use. I'd probably use a vtkPolyDataToImageStencil to take care of it.
added on the 2008-02-18 14:53:01 by avoozl avoozl
i guess your technique would probably be feasible in real-time too...

them nextgen peoples do it yes.
added on the 2008-02-18 15:01:24 by superplek superplek
added on the 2008-02-18 19:37:27 by Hatikvah Hatikvah
they called?
added on the 2008-02-18 19:43:15 by raer raer
Niels, did you use this technique while developing 'My Horsey & Me'? ;)
well, it only took 45 mins and a very bastardised version of 'beyond the walls of eryx' (with the isometric projection and all) to make it... So, yes, no problem now !
added on the 2008-02-18 20:05:42 by Navis Navis
Many years ago I did the same thing with 3dsMAX...

Lets say you have a head, they put a flatten box that cover the whole area (from the top view). Then you animate that box so it goes from the top of the head to the bottom, and then you apply a boolean operation between the head and the box, so what the box is doing is slicing the head as an animation from top to the bottom. The last thing you need to do is apply the caps modifier to the resulting mesh so it will put caps to the top and bottom hole of the mesh. And well, then you just have to render from the top view.

I know you found a solution already, but well, maybe for the next time :P
added on the 2008-02-18 20:22:11 by mrdoob mrdoob