Loading...
Searching...
No Matches
Vox.hpp
1#pragma once
2#include <Threedim/TinyObj.hpp>
3
4namespace Threedim
5{
6// Palette buffer layout (std430-compatible):
7// 256 entries × 8 floats = 2048 floats = 8192 bytes
8// Each entry: [r, g, b, a, metallic, roughness, emissive, ior]
9static constexpr int vox_palette_entries = 256;
10static constexpr int vox_palette_floats_per_entry = 8;
11static constexpr int vox_palette_total_floats
12 = vox_palette_entries * vox_palette_floats_per_entry;
13static constexpr int64_t vox_palette_byte_size
14 = vox_palette_total_floats * sizeof(float);
15
16// Loads a MagicaVoxel .vox file as a point cloud.
17// Per-voxel output: position (float3) + material_id (float1).
18// Palette output: 256 × {rgba, metallic, roughness, emissive, ior}.
19std::vector<mesh> VoxPointCloudFromFile(std::string_view filename, float_vec& data, float_vec& palette);
20
21// Loads a MagicaVoxel .vox file as a pre-built mesh with neighbor-culled faces.
22// Uses ogt_voxel_meshify for face culling.
23// Per-vertex output: position (float3) + normal (float3) + material_id (float1).
24// mode: 0 = simple (per-voxel quads), 1 = greedy (merged same-color regions)
25std::vector<mesh> VoxMeshFromFile(std::string_view filename, float_vec& data, float_vec& palette, int mode);
26}