dust-engine / dot_vox

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

Model Relative Positions? #32

Closed stinkytoe closed 1 year ago

stinkytoe commented 1 year ago

First off I want to thank you guys, I want to do some experimentation in the near future with voxels and marching cubes.

I made a simple .vox file in MagicaVoxel 0.99.6.4 with two adjacent 'models.' My intent is for them to represent static terrain data, and to be considered different 'chunks.' The problem is, I don't know how to find their coordinates relative to each other. I.E. one of the models is immediately to the 'right' of the other, but neither model lists their world space coordinates, and all the voxels inside each model are relative to the model's space.

Am I just missing something obvious about how I can find the world relative locations of all the voxels in each model?

Neo-Zhixing commented 1 year ago

The scene graph is what you're looking for. https://github.com/dust-engine/dot_vox/blob/9d2138beb5fd3ad79c48de697901bb299804c234/src/dot_vox_data.rs#L16

https://github.com/ephtracy/voxel-model/blob/95fae4a529626fd03c77b8ada6b89547c2e731b9/MagicaVoxel-file-format-vox-extension.txt#L44

You will have to traverse this DAG and transform the models from your own application.

Feel free to reopen if you have any additional follow up questions!