Loading...
Searching...
No Matches
BufferToGeometry.hpp
1#pragma once
2#include "BufferToGeometryCommon.hpp"
3
4#include <Threedim/TinyObj.hpp>
5#include <halp/buffer.hpp>
6#include <halp/controls.hpp>
7#include <halp/geometry.hpp>
8#include <halp/layout.hpp>
9#include <halp/meta.hpp>
10
11#include <climits>
12#include <cstdint>
13namespace Threedim
14{
15
17{
18public:
19 halp_meta(name, "Buffers to geometry")
20 halp_meta(category, "Visuals/Utilities")
21 halp_meta(c_name, "buffers_to_geometry")
22 halp_meta(manual_url, "https://ossia.io/score-docs/processes/buffers-to-geometry.html")
23 halp_meta(uuid, "d5dd3b9a-f57b-4546-9890-d5b5e351dcea")
24 halp_flag(deprecated);
25
26 struct ins
27 {
28 // Input buffers
29 halp::gpu_buffer_input<"Buffer 0"> buffer_0;
30 halp::gpu_buffer_input<"Buffer 1"> buffer_1;
31 halp::gpu_buffer_input<"Buffer 2"> buffer_2;
32 halp::gpu_buffer_input<"Buffer 3"> buffer_3;
33 halp::gpu_buffer_input<"Buffer 4"> buffer_4;
34 halp::gpu_buffer_input<"Buffer 5"> buffer_5;
35 halp::gpu_buffer_input<"Buffer 6"> buffer_6;
36 halp::gpu_buffer_input<"Buffer 7"> buffer_7;
37
38 // clang-format off
39#define ATTRIBUTE(i) \
40 halp::spinbox_i32<"Attr" #i " buffer", halp::irange{-1, 7, -1}> attribute_buffer_ ## i; \
41 halp::spinbox_i32<"Attr" #i " offset", halp::irange{0, INT32_MAX, 0}> attribute_offset_ ## i; \
42 halp::spinbox_i32<"Attr" #i " stride", halp::irange{0, 1024, 0}> attribute_stride_ ## i; \
43 halp::combobox_t<"Attr" #i " format", AttributeFormat> format_ ## i; \
44 halp::spinbox_i32<"Attr" #i " location", halp::irange{0, 15, i}> location_ ## i; \
45 halp::toggle<"Attr" #i " instanced"> instanced_ ## i;
46
47 ATTRIBUTE(0)
48 ATTRIBUTE(1)
49 ATTRIBUTE(2)
50 ATTRIBUTE(3)
51 ATTRIBUTE(4)
52 ATTRIBUTE(5)
53 ATTRIBUTE(6)
54 ATTRIBUTE(7)
55#undef ATTRIBUTE
56 // clang-format on
57
58 // Index buffer
59 halp::spinbox_i32<"Index Buffer", halp::irange{-1, 7, -1}> index_buffer;
60 halp::combobox_t<"Index Format", IndexFormat> index_format;
61 halp::spinbox_i32<"Index Offset", halp::irange{0, 1000000, 0}> index_offset;
62
63 // Geometry settings
64 halp::spinbox_i32<"Vertices", halp::irange{0, 1000000000, 0}> vertices;
65 halp::spinbox_i32<"Instances", halp::irange{1, 1000000000, 1}> instances;
66 halp::combobox_t<"Topology", PrimitiveTopology> topology;
67 halp::combobox_t<"Cull Mode", CullMode> cull_mode;
68 halp::combobox_t<"Front Face", FrontFace> front_face;
69
70 // Transform
71 PositionControl position;
72 RotationControl rotation;
73 ScaleControl scale;
74 } inputs;
75
76 struct
77 {
78 struct
79 {
80 halp_meta(name, "Geometry");
81 halp::dynamic_gpu_geometry mesh;
82 float transform[16]{};
83 bool dirty_mesh = false;
84 bool dirty_transform = false;
85 } geometry;
86 } outputs;
87
88 BuffersToGeometry();
89 void operator()();
90
91 // Cache previous state to detect changes
93 {
94 bool enabled{};
95 int32_t buffer{};
96 int32_t offset{};
97 int32_t stride{};
98 AttributeFormat format{};
99 int32_t location{};
100 bool instanced{};
101 };
102
103 std::array<AttributeState, 8> m_prevAttributes{};
104 std::array<halp::gpu_buffer, 8> m_prevBuffers;
105 int32_t m_prevUseIndexBuffer{};
106 IndexFormat m_prevIndexFormat{};
107 int32_t m_prevIndexOffset{};
108 int32_t m_prevVertices{};
109 PrimitiveTopology m_prevTopology{};
110 CullMode m_prevCullMode{};
111 FrontFace m_prevFrontFace{};
112
113 struct ui
114 {
115 halp_meta(name, "Main")
116 halp_meta(layout, halp::layouts::hbox)
117 halp_meta(background, halp::colors::background_mid)
118
119 struct T
120 {
121 halp_meta(name, "Tabs")
122 halp_meta(layout, halp::layouts::tabs)
123 halp_meta(background, halp::colors::background_darker)
124 struct G
125 {
126 halp_meta(name, "Global")
127 halp_meta(layout, halp::layouts::hbox)
128 struct A
129 {
130 halp_meta(layout, halp::layouts::vbox)
131 halp::item<&ins::vertices> vertices;
132 halp::item<&ins::instances> instances;
133 halp::item<&ins::topology> topology;
134 halp::item<&ins::cull_mode> cull_mode;
135 halp::item<&ins::front_face> front_face;
136 } a;
137
138 struct B
139 {
140 halp_meta(layout, halp::layouts::vbox)
141 halp::item<&ins::position> p;
142 halp::item<&ins::rotation> r;
143 halp::item<&ins::scale> s;
144 } b;
145 } global;
146
147 struct A1
148 {
149 halp_meta(name, "0")
150 halp_meta(layout, halp::layouts::vbox)
151 halp::item<&ins::attribute_buffer_0> buffer;
152 halp::item<&ins::attribute_offset_0> offset;
153 halp::item<&ins::attribute_stride_0> stride;
154 halp::item<&ins::format_0> format;
155 halp::item<&ins::location_0> location;
156 halp::item<&ins::instanced_0> instanced;
157 } a0;
158 struct A2
159 {
160 halp_meta(name, "1")
161 halp_meta(layout, halp::layouts::vbox)
162 halp::item<&ins::attribute_buffer_1> buffer;
163 halp::item<&ins::attribute_offset_1> offset;
164 halp::item<&ins::attribute_stride_1> stride;
165 halp::item<&ins::format_1> format;
166 halp::item<&ins::location_1> location;
167 halp::item<&ins::instanced_1> instanced;
168 } a1;
169 struct
170 {
171 halp_meta(name, "2")
172 halp_meta(layout, halp::layouts::vbox)
173 halp::item<&ins::attribute_buffer_2> buffer;
174 halp::item<&ins::attribute_offset_2> offset;
175 halp::item<&ins::attribute_stride_2> stride;
176 halp::item<&ins::format_2> format;
177 halp::item<&ins::location_2> location;
178 halp::item<&ins::instanced_2> instanced;
179 } a2;
180 struct A3
181 {
182 halp_meta(name, "3")
183 halp_meta(layout, halp::layouts::vbox)
184 halp::item<&ins::attribute_buffer_3> buffer;
185 halp::item<&ins::attribute_offset_3> offset;
186 halp::item<&ins::attribute_stride_3> stride;
187 halp::item<&ins::format_3> format;
188 halp::item<&ins::location_3> location;
189 halp::item<&ins::instanced_3> instanced;
190 } a3;
191 struct A4
192 {
193 halp_meta(name, "4")
194 halp_meta(layout, halp::layouts::vbox)
195 halp::item<&ins::attribute_buffer_4> buffer;
196 halp::item<&ins::attribute_offset_4> offset;
197 halp::item<&ins::attribute_stride_4> stride;
198 halp::item<&ins::format_4> format;
199 halp::item<&ins::location_4> location;
200 halp::item<&ins::instanced_4> instanced;
201 } a4;
202 struct A5
203 {
204 halp_meta(name, "5")
205 halp_meta(layout, halp::layouts::vbox)
206 halp::item<&ins::attribute_buffer_5> buffer;
207 halp::item<&ins::attribute_offset_5> offset;
208 halp::item<&ins::attribute_stride_5> stride;
209 halp::item<&ins::format_5> format;
210 halp::item<&ins::location_5> location;
211 halp::item<&ins::instanced_5> instanced;
212 } a5;
213 struct A6
214 {
215 halp_meta(name, "6")
216 halp_meta(layout, halp::layouts::vbox)
217 halp::item<&ins::attribute_buffer_6> buffer;
218 halp::item<&ins::attribute_offset_6> offset;
219 halp::item<&ins::attribute_stride_6> stride;
220 halp::item<&ins::format_6> format;
221 halp::item<&ins::location_6> location;
222 halp::item<&ins::instanced_6> instanced;
223 } a6;
224 struct A7
225 {
226 halp_meta(name, "7")
227 halp_meta(layout, halp::layouts::vbox)
228 halp::item<&ins::attribute_buffer_7> buffer;
229 halp::item<&ins::attribute_offset_7> offset;
230 halp::item<&ins::attribute_stride_7> stride;
231 halp::item<&ins::format_7> format;
232 halp::item<&ins::location_7> location;
233 halp::item<&ins::instanced_7> instanced;
234 } a7;
235 struct
236 {
237 halp_meta(name, "Index")
238 halp_meta(layout, halp::layouts::vbox)
239 halp::item<&ins::index_buffer> buffer;
240 halp::item<&ins::index_offset> offset;
241 halp::item<&ins::index_format> format;
242 } index;
243 } tabs;
244 };
245};
246
247} // namespace Threedim
Definition BufferToGeometry.hpp:17
Definition BufferToGeometry.hpp:93
Definition BufferToGeometry.hpp:27
Definition BufferToGeometry.hpp:114
Definition TinyObj.hpp:74
Definition TinyObj.hpp:79
Definition TinyObj.hpp:83
Definition TinyObj.hpp:27