vengi icon indicating copy to clipboard operation
vengi copied to clipboard

VOXELFORMAT: add m3d support

Open mgerhardy opened this issue 4 years ago • 3 comments

https://bztsrc.gitlab.io/model3d/

validator: https://bztsrc.gitlab.io/model3d/validator/

mgerhardy avatar Jun 17 '20 19:06 mgerhardy

unfortunately the goxel code is released under the gpl.

Yeah, that's because goxel itself is released under the GPL, so any goxel plugins must be too. You can still read the code the see how it is done.

On the other hand the single header M3D SDK is licensed under MIT, you should use that, just like how you have used ogt_vox.h or tiny_gltf.h for example.

Here's a description with example code on how to get the voxel data with the API (scroll down a bit, voxel description comes after the triangle mesh). The voxel only description also has some example clode. Basically it is just a single function call which returns a struct array, one element for each layer with decompressed data and that's it. Saving works the same way, a single function call on the same struct array, all the details are taken care for you. The SDK also does you the favour to automatically convert voxels into a face-culled, optimized triangle-mesh when you load a model if you want. This part isn't particularly performant, but not bad either, also well-tested and known to be correct.

There's also a C++ wrapper class in the M3D SDK, but you might not like its interface or the std dependency (vector and string). Some of my users are just using extern C and the C API from C++ because of that, which works with boost too for example.

is there some validator for the format that I could run my own implementation against?

Of course. The m3dconv utility has a -D switch that dumps the parsed and uncompressed in-memory structure (the aforementioned struct array, and the -d, -dd, -ddd switches validate and dump the on-disk format). Validation is also available as a web service.

To check how a model should look like when displayed, you can use the portable m3dview utility, which is also available as a web service, but if you have simple static voxel-color-only models (no materials nor textures and no animations), then the javascript polyfill works perfectly too.

But again, I believe it's much easier to add m3d.h than implementing yourself.

Also I'll close this issue to continue in the already existing one.

Ok!

PS: if you really really don't want to use the single header SDK, then I could clean up the goxel plugin, remove the goxel specific parts and re-license under MIT for you. Let me know if this would help you!

Cheers, bzt

bztsrc avatar Sep 20 '23 16:09 bztsrc

@mgerhardy what do you say? Should I create a goxel-specific-free, MIT licensed version for you, or are you okay with using the single header SDK (which BTW supports more than just voxels)?

bztsrc avatar Sep 23 '23 18:09 bztsrc

i am totally fine with using the single header.

mgerhardy avatar Sep 23 '23 20:09 mgerhardy