dust-engine / dot_vox

Rust parser for MagicaVoxel .vox files.
MIT License
51 stars 20 forks source link

Clarify that palette IDs are off by one #11

Closed expenses closed 6 years ago

expenses commented 6 years ago

According to the spec,

* <NOTICE>
* color [0-254] are mapped to palette index [1-255], e.g : 

the palette IDs are off by one, so you need to minus one from them to get to the right colour, e.g:

let voxel = &vox.models[0].voxels[0];
let colour = vox.pallete[voxel.i - 1];

I'm sure i'm not the only one that will get tripped up by this. Do you think you could clarify it in the documentation?

davidedmonds commented 6 years ago

Hi there! Sorry for the delay in replying. I'll try and get that added to the documentation when I get a chance (will sadly be a couple of weeks before I get some time), but if you fancy making a PR to address it I'll happily merge it!

davidedmonds commented 6 years ago

Finally managed to get some to address this.

Having had a think on this, I've decided that expecting users to -1 from color palette indices is pretty poor on my part, so instead of documenting this, I've made the indices match the in-memory representation of the palette. This has also affected materials as the id field maps to a color palette entry.

As this is a breaking change, I've taken this opportunity to also fix the spelling of palette throughout the library, and bumped the version to v1.0.0.

Should be published to cargo momentarily.

Thanks again for the report.

davidedmonds commented 6 years ago

... add a few hours onto when its published to cargo, ran out of time this morning :( Aim to publish it this afternoon, somewhere around 5pm UTC.

davidedmonds commented 6 years ago

Now published. https://crates.io/crates/dot_vox

expenses commented 6 years ago

Thank you!