vengi-voxel / vengi

free and open source voxel art tools - editor, thumbnailer and format converter
http://vengi-voxel.github.io/vengi/
Other
1.05k stars 87 forks source link

VOXCONVERT: manifold geometry when converting with --surface-only to 3D modeling formats #393

Closed hkunz closed 4 months ago

hkunz commented 4 months ago

I initially believed that using the --surface-only option would generate manifold geometry without internal faces. However, upon reviewing the documentation, I discovered that the option specifically removes any non-surface voxels, which aligns with the current implementation.

However, I observed that when converting to 3D modeling object formats such as .obj, this implementation creates internal faces. This led me to wonder if there is a way to achieve actual manifold geometry without internal faces using a similar feature, perhaps also the same --surface-only option.

In this proposed implementation, the behavior of the --surface-only flag would differ based on the conversion direction. For example, when converting from a voxel format to a 3D modeling format like .obj, the flag would ensure the creation of manifold geometry without internal faces, enabling compatibility with 3D printing. On the other hand, when converting from a 3D modeling format to a voxel format, the current implementation would probably remain unchanged.

To determine the appropriate behavior, the script could analyze the output type and adjust accordingly. For instance, when converting from .obj to .vox, the script would maintain the current implementation, whereas when converting from .vox to .obj or .obj to .obj, the --surface-only flag would enforce manifold geometry without internal faces.

On second thought. Maybe it is safer to have another flag --manifold-mesh or something?

inner-faces

hkunz commented 4 months ago

On second thought. Maybe it is safer to have another flag --manifold-mesh or something?

hkunz commented 4 months ago

turns out this feature is not needed because it works as expected. there is just a bug when converting a regular UV Sphere to voxel format. Here's how to reproduce. use this .obj file uv-sphere.obj and run this command vengi-voxconvert.exe -set voxformat_scale 4.0 --input "uv-sphere.obj" --output "out.obj" --force. Notice that the out.obj has a hole in it which causes the additional faces and thus makes the object non-manifold.

uv-sphere.zip

image

hkunz commented 4 months ago

obj-50-verts-hole-bug.zip image

hkunz commented 4 months ago

Simpler reproduction object: hole-bug.zip

image

mgerhardy commented 4 months ago

Thanks a lot for the simplification of the test-case - the above mentioned commit should fix this issue. Please let me know if any problem persists.

hkunz commented 4 months ago

confirmed fixed! thank you very much!