Loading...
Searching...
No Matches
VoxelLoader.hpp
1#pragma once
2#include "TransformHelper.hpp"
3
4#include <Threedim/TinyObj.hpp>
5#include <Threedim/Vox.hpp>
6#include <halp/controls.hpp>
7#include <halp/file_port.hpp>
8#include <halp/geometry.hpp>
9#include <halp/meta.hpp>
10
11namespace Threedim
12{
13
15{
16public:
17 halp_meta(name, "Voxel loader")
18 halp_meta(category, "Visuals/Meshes")
19 halp_meta(c_name, "voxel_loader")
20 halp_meta(description, "Load a VOX voxel file as a point cloud or a simple or greedy mesh.")
21 halp_meta(authors, "Jean-Michaƫl Celerier, opengametools authors")
22 halp_meta(manual_url, "")
23 halp_meta(uuid, "a7c3e1b4-9f2d-4e8a-b6c5-1d3f7e9a2b4c")
24
25 enum VoxelMode
26 {
27 PointCloud,
28 Mesh_Simple,
29 Mesh_Greedy
30 };
31 struct ins
32 {
33 struct vox_t : halp::file_port<"Voxel file">
34 {
35 halp_meta(extensions, "Voxel files (*.vox)");
36 static std::function<void(VoxelLoader&)> process(file_type data);
37 } file;
38
39 struct : halp::combobox_t<"Mode", VoxelMode>
40 {
41 struct range
42 {
43 std::string_view values[3]{"Point Cloud", "Mesh (Simple)", "Mesh (Greedy)"};
44 int init{1};
45 };
46
47 void update(VoxelLoader& self) { self.reload(); }
48 } mode;
49
50 PositionControl position;
51 RotationControl rotation;
52 ScaleControl scale;
53 } inputs;
54
55 struct
56 {
57 struct : halp::mesh
58 {
59 halp_meta(name, "Geometry");
60 std::vector<halp::dynamic_geometry> mesh;
61 } geometry;
62 } outputs;
63
64 void reload();
65 void rebuild_geometry();
66 void operator()();
67
68 std::vector<mesh> meshinfo{};
69 float_vec complete;
70 float_vec palette;
71
72 // Cache the file data so mode changes can re-process
73 std::string cached_filename;
74
75 // Per-frame TRS matrix cache (see TransformHelper.hpp).
76 CachedTRS m_cachedTRS{};
77};
78
79}
Definition VoxelLoader.hpp:15
Definition VoxelLoader.hpp:34
Definition VoxelLoader.hpp:32
Definition MIDISync.hpp:149