Closed bamyazi closed 5 years ago
This is a screen shot before applying your fix.
And this is a comparison after:
It looks like you're just moving the Model to the ground, based on the bounds of the model, which isn't exactly desired by default. It looks like you just need to move your vox model to the floor, and it'll import just like you want.
There's a button in MagicaVoxel to do that for you:
And here is what the comparison looks like after doing that:
NOW, don't be discouraged, because I think you're close. The library I forked from originally centered the model over the origin, and moved it to the ground. The fact that both he AND you want that, means something to me. You just also have to understand that some people (like me) don't want this behavior, and wasn't expecting it like you were.
How about we add an option to the import dialog (with default false) to "snap model to ground"? Then, if it's checked, we apply your offset calculation?
P.S. Also, if you don't like it being default false, you can always make it the default in your Godot project, in case you didn't know.
Just set the import options how you want, click "Preset..." then "Set as Default for 'MagicaVoxel Mesh..'"
If you already know that, then awesome. I used to hate having to change like 2 or 3 fields for EVERY texture when I made a pixel art game, and when someone showed me that "Set as Default..." for resources, my workflow got a LOT less annoying.
This is wierd - what version of MagicaVoxel are you using ?
is what i see (and no ground option in the edit menu)
Now i look more the offset IS visible when i switch to the 'world' view.
which i never use - this looks more like a bug/feature in the way MagicaVoxel handles resizing the grid..I started witha 40 40 40 grid, resized it to 16 16 16 modelled and exported. No worries with not merging it, i'll leave this as a fork in case anyone wants the alternate behavior since that's my workflow.
Just noticed your 'Snap to ground' idea - that sounds like a good option - i'd be happy to look at that if you want
Ok - it's done - closing this request
If you resize the magicavoxel grid from 40 40 40 to say 16 16 16 the resulting vox file will have blocks which are not indexed from 0, when this is imported into godot the model will then be offset from it's origin.
This fix uses the minimum y bound to offset the generated vertices
The attached model generated with the latest version of MagicaVoxel shows this issue
example.zip
I've updated my original fix to also support the CulledMeshGenerator