Loading...
Searching...
No Matches
SceneSelector.hpp
1#pragma once
2#include <halp/controls.hpp>
3#include <halp/meta.hpp>
4
5#include <ossia/dataflow/geometry_port.hpp>
6
7#include <cstdint>
8#include <memory>
9#include <string>
10
11namespace Threedim
12{
13
14// Extracts a subtree from an incoming scene and emits it as a fresh
15// scene_spec. Where SceneGraphFilter prunes (keeps the tree shape, drops
16// non-matches), SceneSelector extracts: it gathers the matches and forgets
17// the ancestors.
18//
19// Use case: pull out the camera, a light rig, or a character subtree
20// so it can be re-transformed / re-materialized and then merged back
21// in via SceneGroup.
22//
23// Rebase modes:
24// Preserve : emit the subtree root as-is, so its transform
25// remains in its original parent frame (the
26// ancestors are gone but the transform still
27// matches where it was).
28// ZeroOut : drop the subtree's own TRS so it renders at the
29// world origin, for re-placing the extracted subtree
30// via an upstream Transform3D / SceneGroup.
32{
33public:
34 halp_meta(name, "Scene Selector")
35 halp_meta(category, "Visuals/3D/Scene")
36 halp_meta(c_name, "scene_selector")
37 halp_meta(authors, "ossia team")
38 halp_meta(
39 manual_url,
40 "https://ossia.io/score-docs/processes/scene-selector.html")
41 halp_meta(uuid, "6c4d8b3f-5e2a-4d1f-9c7b-8a3e5f0d7b4c")
42
43 enum Mode
44 {
45 ByPath,
46 ByName,
47 ByIndex // index into the root list (0 = first root)
48 };
49
50 enum Rebase
51 {
52 Preserve,
53 ZeroOut
54 };
55
56 struct ins
57 {
58 struct
59 {
60 halp_meta(name, "Scene In");
61 ossia::scene_spec scene;
62 uint8_t dirty{0};
63 } scene_in;
64
65 // Port-driven rebuild: controls trigger rebuild(); upstream
66 // scene_in changes detected in operator()().
67 struct : halp::combobox_t<"Mode", Mode>
68 {
69 struct range
70 {
71 std::string_view values[3]{"By path", "By name", "By index"};
72 int init{0};
73 };
74 void update(SceneSelector& n) { n.rebuild(); }
75 } mode;
76
77 struct : halp::lineedit<"Path / Name", "">
78 { void update(SceneSelector& n) { n.rebuild(); } } path;
79 struct : halp::spinbox_i32<"Index", halp::irange{0, 1024, 0}>
80 { void update(SceneSelector& n) { n.rebuild(); } } index;
81
82 struct : halp::combobox_t<"Rebase", Rebase>
83 {
84 struct range
85 {
86 std::string_view values[2]{"Preserve transform", "Zero out"};
87 int init{0};
88 };
89 void update(SceneSelector& n) { n.rebuild(); }
90 } rebase;
91 } inputs;
92
93 struct outs
94 {
95 struct
96 {
97 halp_meta(name, "Scene Out");
98 ossia::scene_spec scene;
99 uint8_t dirty{0};
100 } scene_out;
101 } outputs;
102
103 void rebuild();
104 void operator()();
105
106 std::shared_ptr<const ossia::scene_state> m_cached_out;
107 uint8_t m_pending_dirty{0xFF};
108 const ossia::scene_state* m_cached_in_state{};
109 int64_t m_cached_in_version{-1};
110 int64_t m_version_counter{0};
111};
112
113}
Definition SceneSelector.hpp:32
Definition SceneSelector.hpp:57
Definition SceneSelector.hpp:94
Definition MIDISync.hpp:126