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(authors, "Jean-Michaƫl Celerier, opengametools authors")
21 halp_meta(manual_url, "")
22 halp_meta(uuid, "a7c3e1b4-9f2d-4e8a-b6c5-1d3f7e9a2b4c")
23
24 enum VoxelMode
25 {
26 PointCloud,
27 Mesh_Simple,
28 Mesh_Greedy
29 };
30 struct ins
31 {
32 struct vox_t : halp::file_port<"Voxel file">
33 {
34 halp_meta(extensions, "Voxel files (*.vox)");
35 static std::function<void(VoxelLoader&)> process(file_type data);
36 } file;
37
38 struct : halp::combobox_t<"Mode", VoxelMode>
39 {
40 struct range
41 {
42 std::string_view values[3]{"Point Cloud", "Mesh (Simple)", "Mesh (Greedy)"};
43 int init{1};
44 };
45
46 void update(VoxelLoader& self) { self.reload(); }
47 } mode;
48
49 PositionControl position;
50 RotationControl rotation;
51 ScaleControl scale;
52 } inputs;
53
54 struct
55 {
56 struct : halp::mesh
57 {
58 halp_meta(name, "Geometry");
59 std::vector<halp::dynamic_geometry> mesh;
60 } geometry;
61 } outputs;
62
63 void reload();
64 void rebuild_geometry();
65 void operator()();
66
67 std::vector<mesh> meshinfo{};
68 float_vec complete;
69 float_vec palette;
70
71 // Cache the file data so mode changes can re-process
72 std::string cached_filename;
73
74 // Per-frame TRS matrix cache (see TransformHelper.hpp).
75 CachedTRS m_cachedTRS{};
76};
77
78}
Definition VoxelLoader.hpp:15
Definition VoxelLoader.hpp:33
Definition VoxelLoader.hpp:31
Definition MIDISync.hpp:127