Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
vox_import.hpp
Go to the documentation of this file.
1
6
7
#pragma once
8
#include <cstdint>
9
#include <glm/glm.hpp>
10
#include <optional>
11
#include <span>
12
#include <string>
13
#include <
toast/export.hpp
>
14
#include <
toast/voxel/brick_pool.hpp
>
15
#include <
toast/voxel/palette.hpp
>
16
#include <
toast/voxel/stamp.hpp
>
17
#include <
toast/voxel/voxel_volume.hpp
>
18
#include <vector>
19
20
namespace
assets {
21
22
inline
constexpr
uint32_t k_vox_max_dim = 256;
23
24
struct
VoxVoxel
{
25
uint8_t x = 0;
26
uint8_t y = 0;
27
uint8_t z = 0;
28
30
uint8_t
palette_index
= 0;
31
};
32
33
struct
VoxModel
{
34
glm::uvec3 dims {0};
35
std::vector<VoxVoxel> voxels;
36
};
37
39
struct
VoxTransform
{
40
voxel::LatticeOrientation
orientation;
41
glm::ivec3 translation {0};
42
43
[[nodiscard]]
44
auto
operator==(
const
VoxTransform
&)
const
noexcept
->
bool
=
default
;
45
};
46
47
struct
VoxNode
{
48
std::string name;
49
50
VoxTransform
local;
51
52
bool
hidden =
false
;
53
54
std::vector<uint32_t> children;
55
56
std::optional<uint32_t> model;
57
};
58
59
struct
VoxScene
{
60
std::vector<VoxModel> models;
61
63
std::vector<VoxNode>
nodes
;
64
65
voxel::Palette
palette;
66
67
std::vector<std::string> warnings;
68
};
69
71
[[nodiscard]]
72
TOAST_API
auto
voxOrientationFromByte(uint8_t rotation) -> std::optional<voxel::LatticeOrientation>;
73
74
[[nodiscard]]
75
TOAST_API
auto
voxOrientationToByte(
const
voxel::LatticeOrientation
& orientation) -> uint8_t;
76
77
[[nodiscard]]
78
TOAST_API
auto
composeVoxTransforms(
const
VoxTransform
& parent,
const
VoxTransform
& local) ->
VoxTransform
;
79
81
[[nodiscard]]
82
TOAST_API
auto
voxPlacementOf(
const
VoxTransform
& world, glm::uvec3 model_dims) ->
voxel::LatticePlacement
;
83
84
struct
VoxPlacement
{
85
uint32_t model = 0;
86
std::string name;
87
bool
hidden =
false
;
88
voxel::LatticePlacement
placement;
89
};
90
91
[[nodiscard]]
92
TOAST_API
auto
flattenVoxScene(
const
VoxScene
& scene) -> std::vector<VoxPlacement>;
93
94
[[nodiscard]]
95
TOAST_API
auto
buildVoxVolume(
const
VoxModel
& model,
voxel::BrickPool
& pool) -> std::optional<voxel::Volume>;
96
98
[[nodiscard]]
99
TOAST_API
auto
importVox(std::span<const uint8_t> data) ->
VoxScene
;
100
101
}
brick_pool.hpp
voxel::BrickPool
Definition
brick_pool.hpp:26
export.hpp
palette.hpp
stamp.hpp
assets::VoxModel
Definition
vox_import.hpp:33
assets::VoxNode
Definition
vox_import.hpp:47
assets::VoxPlacement
Definition
vox_import.hpp:84
assets::VoxScene
Definition
vox_import.hpp:59
assets::VoxScene::nodes
std::vector< VoxNode > nodes
nodes[0] is the root
Definition
vox_import.hpp:63
assets::VoxTransform
Translation positions the node centre not its corner.
Definition
vox_import.hpp:39
assets::VoxVoxel
Definition
vox_import.hpp:24
assets::VoxVoxel::palette_index
uint8_t palette_index
1-255 since a .vox never stores an empty voxel
Definition
vox_import.hpp:30
voxel::LatticeOrientation
Output axis i reads input axis source[i] negated when flip[i].
Definition
stamp.hpp:23
voxel::LatticePlacement
Definition
stamp.hpp:72
voxel::Palette
Entry 0 is the empty voxel and must stay all zero.
Definition
palette.hpp:59
voxel_volume.hpp
engine
src
toast
voxel
assets
vox_import.hpp
Generated by
1.17.0