CloneDeath / MagicaVoxel-Importer-with-Extensions

A Godot plugin to import MagicaVoxel .vox files as meshes.
21 stars 6 forks source link

Y offset fix for resized grids #3

Closed bamyazi closed 5 years ago

bamyazi commented 5 years ago

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

CloneDeath commented 5 years ago

This is a screen shot before applying your fix. image

And this is a comparison after: image

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: image

And here is what the comparison looks like after doing that: image

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?

CloneDeath commented 5 years ago

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..'"

image

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.

bamyazi commented 5 years ago

This is wierd - what version of MagicaVoxel are you using ? image

is what i see (and no ground option in the edit menu)

bamyazi commented 5 years ago

Now i look more the offset IS visible when i switch to the 'world' view. image 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.

bamyazi commented 5 years ago

Just noticed your 'Snap to ground' idea - that sounds like a good option - i'd be happy to look at that if you want

bamyazi commented 5 years ago

Ok - it's done - closing this request