Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

Inverse PolyVox?
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=687
Page 1 of 1

Author:  mgumley [ Wed Nov 09, 2016 6:04 pm ]
Post subject:  Inverse PolyVox?

PolyVox is working really well for me, for converting an array of voxels into a smooth mesh.

I'd like to manipulate imported an imported mesh. The UE4 engine has a tool called "procedural mesh slicing", but it's very limited.

I have a feature request for David:

Would it be possible to start with an enclosed mesh, and then build a Voxel Volume from that? Essentially importing a shape into the voxel database. This would be really useful for example, turning a tree into a voxel database, manipulating it, then generating a new mesh.

If you don't have the time to implement this feature, do you have an outline of a strategy I could use to implement this import feature?

Maxwell Gumley

Author:  David Williams [ Sat Nov 12, 2016 7:21 pm ]
Post subject:  Re: Inverse PolyVox?

Hi,

The process you describe is known as 'Voxelization'. Searching on that term (also on this forum) should throw up some interesting leads.

You basically need a way to determine whether a given point is inside your mesh and there are a few ways to do this. One approach is to cast a ray from a voxel to infinity and then test how many of your triangles it intersects. If this is an odd number then the voxel is inside the mesh, while an even number (or zero) means it is outside. I'm sure that some searching will lead you to some better approaches though.

Unfortunately I won't be adding it to PolyVox, partly because it is out of scope, and partly because my focus is now on developing a new version of Cubiquity instead.

Hope that helps get you started!

Author:  mgumley [ Thu Nov 17, 2016 1:29 am ]
Post subject:  Re: Inverse PolyVox?

It looks like my question has been asked before quite a few times lol. I did some searching around and it looks like that it wouldn't be too hard to convert a cubic mesh into voxels.

I looked at binvox, and poly2vox, but it seems like they are both using cubic approximations. I dont think their voxelization output has any kind of distance field. The voxels are either on or off. Do you know of a way to get the partial voxel values for an input mesh that is not cubic?

Author:  David Williams [ Sat Nov 19, 2016 9:23 am ]
Post subject:  Re: Inverse PolyVox?

mgumley wrote:
Do you know of a way to get the partial voxel values for an input mesh that is not cubic?


I think the easiest approach would be to create a binary (cubic) volume at higher resolution than you need, and then downsample it to a smooth volume of the requred resolution. So if you wanted a smooth volume of 256^3 resolution, you might create a binary volume at 1024^3 resolution and voxelise into that. Then groups of 4^3 = 64 voxels would be summed up to give a value between 0-63, scaled to the range 0-255, and written to you smooth volume. Obviously there are performance and memory implications to this approach, which my or may not matter to you.

Alternatively, a smarter approach would be to test not only whether a voxel is inside a mesh, but also how far inside it is. If a triangle slices a voxel in two then determine what percentage of the voxel is inside. This then tells you what your density value should be. This method is probably faster and more scalable but requires more maths and thought.

In general I would research antialiasingtechniques (e.g. this one), as I think what you are describing is basically the 3D equivalent of those.

Author:  mgumley [ Mon Nov 21, 2016 4:15 pm ]
Post subject:  Re: Inverse PolyVox?

Thanks for the guidance David. I'll be looking into this.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/