2020-09-12 13:10:05 -07:00
|
|
|
#ifndef VOX_LOADER_H
|
|
|
|
#define VOX_LOADER_H
|
|
|
|
|
2020-09-14 11:33:02 -07:00
|
|
|
#include "../math/vector3i.h"
|
2020-09-12 18:17:11 -07:00
|
|
|
#include "../meshers/cubes/voxel_color_palette.h"
|
2020-09-14 11:33:02 -07:00
|
|
|
|
|
|
|
class VoxelBuffer;
|
2020-09-12 13:10:05 -07:00
|
|
|
|
|
|
|
namespace vox {
|
|
|
|
|
|
|
|
struct Data {
|
|
|
|
Vector3i size;
|
|
|
|
std::vector<uint8_t> color_indexes;
|
|
|
|
FixedArray<Color8, 256> palette;
|
|
|
|
bool has_palette;
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO Eventually, will need specialized loaders, because data structures may vary and memory shouldn't be wasted
|
|
|
|
Error load_vox(const String &fpath, Data &data);
|
|
|
|
|
|
|
|
} // namespace vox
|
|
|
|
|
|
|
|
// Simple loader for MagicaVoxel
|
|
|
|
class VoxelVoxLoader : public Reference {
|
|
|
|
GDCLASS(VoxelVoxLoader, Reference);
|
|
|
|
|
|
|
|
public:
|
2020-09-12 18:17:11 -07:00
|
|
|
Error load_from_file(String fpath, Ref<VoxelBuffer> voxels, Ref<VoxelColorPalette> palette);
|
2020-12-18 13:20:00 -08:00
|
|
|
// TODO Have chunked loading for better memory usage
|
2020-09-12 13:10:05 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
vox::Data _data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VOX_LOADER_H
|