3D model to volume
category: general [glöplog]
Hi,
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 ?
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 ?
ask tbl :)
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.
I'm basically interested more in the cross-sections. So a tool to convert 3DS -> lots of images.
I thought you did your own tools :)
You can render stuff in orthographical and export the zbuffer... you probably though about it.
You can render stuff in orthographical and export the zbuffer... you probably though about it.
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.
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 :)
-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 :)
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..
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..
so you rather want contour lines?
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 ;)
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...
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).
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.
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.
oh, yeah. my routine does the point-inside-mesh test with depth-pass stencil-testing, not any fancy dot-products. hardware acceleration ftw.
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 :)
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.
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.
Quote:
i guess your technique would probably be feasible in real-time too...
them nextgen peoples do it yes.
1998
they called?
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 !
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
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