Runtime voxel conversion of 3d models

0
VoxelUser posted this 23 November 2016

Hello,

Two questions:

1) I thought I could convert 3d meshes to voxels at run time but couldn't find any related functionality. I want to convert my 3d meshes which are procedurally generated to voxels at runtime. I don't need to edit them but I need them converted. Is it possible? If yes, where should I look.

2) Voxels generated from 3d meshes do not have inner voxels, I need those inner voxels to do some calculations, is there any setting I missed that creates those inner voxels?

Best regards

Last edited 23 November 2016

3 Comments
Order By: Standard | Newest | Votes
0
GarethIW posted this 23 November 2016

Doing mesh scanning at runtime is possible but not included out of the box. You will need to copy and modify the editor code that does the mesh scanning to allow it to work at runtime.

In more detail:

You will need to examine the code in Scrtipts/Editor/MeshScanner.cs and create a runtime version of that code by removing all the editor specific parts of it. Begin by copying the cs file and moving it out of the Editor folder and renaming the class. Then remove the using UnityEditor;, and you will see which parts of the code you will need to fix to make it runtime compatible.

For example, there's an Editor.Instantiate call in there to create a new PicaVoxel object that you would need to replace with a normal instantiate on a blank prefab of a PicaVoxel volume (which you will need to create). You will also need to remove the editor progress bar code as well. Possibly some other stuff, but this is off the top of my head as I don't have Unity in front of me at the moment.

To answer your second question: The mesh scanner should absolutely fill the inside of the mesh as well, but it will depend on the mesh. The scan does two passes: the first pass lays voxels on the mesh edges, the second pass does the fill.

If you're not getting filled meshes then there is probably something with the mesh that is causing the fill to fail. This might be flipped normals or perhaps too small or too complicated a mesh.

0
VoxelUser posted this 23 November 2016

Hello,

Thanks for the quick reply. With regards to, voxels inside mesh, I'm testing with a default sphere from Unity. I add the sphere to scene(Gameobject->3d object->sphere), select scan from picavoxel menu, use 0.05 as voxel size. When I move one of the chunks away, I can see that mesh is empty inside. Same with some other meshes I tried.

I unfortunately do not have the time to make necessary adjustments that you mentioned with regards to runtime voxel conversion. While it looks like Picavoxel is really awsome, it doesn't seem to satisfy my particular needs unfortunately. I'd like to request a refund if it's OK with you. My order number is OR302814199

Best regards

0
GarethIW posted this 23 November 2016

When you look inside the volume in the editor, you won't see the voxels that are "inside" the meshed volume - that's not how meshed voxels work :) When you generate a mesh over a voxel volume, you only see the polygons that make up the outside (or rather, the visible parts) of the volume. This will be the same for any voxel engine that will run with any kind of performance.

If you were to run the project and then use (for example) the PicaVoxel exploder script on your volume to destroy voxels on the outside, you would find that there are indeed voxels that fill the inside of the volume as well.

Just thought I'd explain so that you know what to look for with any other assets you might try, and for anyone else browsing the forum. I'll happily request your refund now - it usually takes up to 10 days for the refund to hit your account.


Our 102 members have posted 428 times in 103 discussions