The basic premise behind generating 3D textures from geometry in 3dsmax is similar to how a CT scan generates images from real world object: a bunch of slices. Luckily 3dsmax has the ability to boolean objects with planes, and although the materials aren't necessary accurate it is possible to set the scene up in such a way that a flat plane can be booleaned with all relevant geometry to create the depth portion of the 3d texture.
The script goes as follows:
- Check the extents of all selected objects. This is to calculate how far the slicer needs to move in total and between each iteration. Additionally, the size slice plane can be made to match the objects as well.
- Make all original objects not visible to the camera
- Start slice loop
- Find any objects that intersect the slice plane and make a copy of them. Make these copies visible to the camera.
- Create a slice plane object at Z
- Boolean (intersection method) all copies of objects
- Render the results
- Delete all sliced objects and slice plane as well
- Move to next iteration
- End of slice loop
- Make all original objects visible to the camera.
It's as simple as that :) And the nice thing is I figured out how to test the bounding box much more efficiently in this new script. This change can be propagated back to the older scripts that need it, like the convex mesh creator.
The biggest draw back of booleans in 3dsmax is that any UVW coordinates essentially get destroyed. So any object that is fully textured will not end up looking as it should. At the moment there doesn't appear to be a catch-all-quick-fix for this problem, at least not that I've seen. It's definitely worth looking into as it would be a shame to have such a handy script that can only be used with untextured geometry.
As further exercise for myself I'm writing a c++ console app that will take the existing Z axis 3d texture and resave it in another axis :) While it may not be the most useful tool seeing as renderers may not necessary care how a 3d texture is laid out, I'm learning lots about dynamic arrays and pointers.
What's inside this cheap barrel??
Lets find out!

No comments:
Post a Comment