Loading...
Searching...
No Matches
StructureSynth.hpp
1#pragma once
2
3#include <Threedim/TinyObj.hpp>
4#include <boost/container/vector.hpp>
5#include <halp/controls.hpp>
6#include <halp/geometry.hpp>
7#include <halp/meta.hpp>
8#include <ossia/detail/mutex.hpp>
9#include <ossia/detail/pod_vector.hpp>
10
11#include <cstdint>
12#include <functional>
13#include <string>
14#include <string_view>
15
16namespace Threedim
17{
18
20{
21public:
22 halp_meta(name, "Structure Synth")
23 halp_meta(category, "Visuals/Meshes")
24 halp_meta(c_name, "structure_synth")
25 halp_meta(description, "Generate procedural mesh geometry from an EisenScript program.")
26 halp_meta(manual_url, "https://ossia.io/score-docs/processes/structure-synth.html")
27 halp_meta(uuid, "bb8f3d77-4cfd-44ce-9c43-b64c54a748ab")
28
29 struct ins
30 {
31 struct : halp::lineedit<"Program", "">
32 {
33 halp_meta(language, "eisenscript")
34 void update(StrucSynth& g) { g.requestBuild(); }
35 } program;
36
37 PositionControl position;
38 RotationControl rotation;
39 ScaleControl scale;
40 struct : halp::impulse_button<"Regenerate">
41 {
42 void update(StrucSynth& g) { g.requestBuild(); }
43 } regen;
44 } inputs;
45
46 struct
47 {
48 struct : halp::mesh
49 {
50 halp_meta(name, "Geometry");
51 halp::position_normals_geometry mesh;
52 } geometry;
53 } outputs;
54
55 void operator()();
56
57 // Programs are built on the worker, one at a time (libssynth's random
58 // streams are global). Builds are numbered: the mesh of a program that was
59 // replaced while it built is dropped, and the current mesh stays until the
60 // latest program's arrives. A program that does not build leaves it too.
61 struct worker
62 {
63 std::function<void(std::string, uint32_t)> request;
64
65 static std::function<void(StrucSynth&)> work(std::string_view s, uint32_t request);
66 } worker;
67
68 void requestBuild();
69
70 using float_vec = boost::container::vector<float, ossia::pod_allocator<float>>;
71 float_vec m_vertexData;
72 uint32_t m_request{};
73};
74
75}
Definition StructureSynth.hpp:20
Definition TinyObj.hpp:98
Definition TinyObj.hpp:103
Definition TinyObj.hpp:107
Definition StructureSynth.hpp:30
Definition StructureSynth.hpp:62
Definition TinyObj.hpp:27