载入中...
搜索中...
未找到
NodeDesc.h
浏览该文件的文档.
1#pragma once
2
3#include <string>
4#include <utility>
5#include <vector>
6
7namespace eve::scene {
8
9class SceneHost;
10
15struct NodeDesc {
16 std::string id;
18 std::string key;
19 std::string name;
21 std::string space = "3d";
22 bool visible = true;
23 std::vector<std::string> tags;
24 int layer = 0;
25 float bminX = 0.f, bminY = 0.f, bminZ = 0.f;
26 float bmaxX = 0.f, bmaxY = 0.f, bmaxZ = 0.f;
27 bool hasBounds = false;
28
29 float x = 0.f, y = 0.f, z = 0.f;
30 float yaw = 0.f, pitch = 0.f, roll = 0.f;
31 float sx = 1.f, sy = 1.f, sz = 1.f;
32
33 std::vector<NodeDesc> children;
34
35 NodeDesc &withId(std::string v) {
36 id = std::move(v);
37 return *this;
38 }
39 NodeDesc &withKey(std::string v) {
40 key = std::move(v);
41 return *this;
42 }
43 NodeDesc &withName(std::string v) {
44 name = std::move(v);
45 return *this;
46 }
47 NodeDesc &withSpace(std::string v) {
48 space = std::move(v);
49 return *this;
50 }
52 visible = v;
53 return *this;
54 }
55 NodeDesc &withTag(std::string v) {
56 tags.push_back(std::move(v));
57 return *this;
58 }
59 NodeDesc &withTags(std::vector<std::string> v) {
60 tags = std::move(v);
61 return *this;
62 }
64 layer = v;
65 return *this;
66 }
67 NodeDesc &withBounds(float minX, float minY, float minZ, float maxX, float maxY,
68 float maxZ) {
69 bminX = minX;
70 bminY = minY;
71 bminZ = minZ;
72 bmaxX = maxX;
73 bmaxY = maxY;
74 bmaxZ = maxZ;
75 hasBounds = true;
76 return *this;
77 }
78 NodeDesc &withPosition(float px, float py, float pz = 0.f) {
79 x = px;
80 y = py;
81 z = pz;
82 return *this;
83 }
84 NodeDesc &withRotation(float y_, float p = 0.f, float r = 0.f) {
85 yaw = y_;
86 pitch = p;
87 roll = r;
88 return *this;
89 }
91 sx = sy = sz = s;
92 return *this;
93 }
94 NodeDesc &withScaleXYZ(float sx_, float sy_, float sz_) {
95 sx = sx_;
96 sy = sy_;
97 sz = sz_;
98 return *this;
99 }
101 children.push_back(std::move(c));
102 return *this;
103 }
104
105 const std::string &reconcileKey() const { return key.empty() ? id : key; }
106};
107
108NodeDesc node(std::string id, std::vector<NodeDesc> children = {}, std::string name = "");
109NodeDesc group(std::vector<NodeDesc> children = {}, std::string id = "");
111NodeDesc when(bool cond, NodeDesc child);
112NodeDesc whenElse(bool cond, NodeDesc ifTrue, NodeDesc ifFalse);
113
114void applyTree(SceneHost *host, NodeDesc root);
116bool applyTreeReconcile(SceneHost *host, NodeDesc root);
117
118} // namespace eve::scene
std::vector< Colorf > px
const FusedGroup & group
uint32_t c
glm::vec4 p[6]
const char * name
Definition RockMesh.cpp:21
int v
int children
Definition TreeMesh.cpp:177
uint32_t s
Definition Weather.cpp:28
bool applyTreeReconcile(SceneHost *host, NodeDesc root)
Key-aware patch when structure matches; else full replace. Returns true if full rebuild.
Definition NodeDesc.cpp:294
NodeDesc whenElse(bool cond, NodeDesc ifTrue, NodeDesc ifFalse)
Definition NodeDesc.cpp:237
NodeDesc node(std::string id, std::vector< NodeDesc > children, std::string name)
Definition NodeDesc.cpp:214
NodeDesc when(bool cond, NodeDesc child)
Conditional: include child only when cond is true (empty group otherwise).
Definition NodeDesc.cpp:232
void applyTree(SceneHost *host, NodeDesc root)
Definition NodeDesc.cpp:241
Declarative scene-node description (build once / on dirty → flatten into SceneHost::Tree)....
Definition NodeDesc.h:15
std::string id
Definition NodeDesc.h:16
NodeDesc & withId(std::string v)
Definition NodeDesc.h:35
NodeDesc & withPosition(float px, float py, float pz=0.f)
Definition NodeDesc.h:78
NodeDesc & withName(std::string v)
Definition NodeDesc.h:43
std::string key
Reconciliation key; defaults to id when empty.
Definition NodeDesc.h:18
NodeDesc & withSpace(std::string v)
Definition NodeDesc.h:47
NodeDesc & withTags(std::vector< std::string > v)
Definition NodeDesc.h:59
NodeDesc & withTag(std::string v)
Definition NodeDesc.h:55
std::vector< NodeDesc > children
Definition NodeDesc.h:33
std::string name
Definition NodeDesc.h:19
std::string space
"2d" or "3d" (string enum per module convention).
Definition NodeDesc.h:21
NodeDesc & withRotation(float y_, float p=0.f, float r=0.f)
Definition NodeDesc.h:84
NodeDesc & withScaleXYZ(float sx_, float sy_, float sz_)
Definition NodeDesc.h:94
const std::string & reconcileKey() const
Definition NodeDesc.h:105
NodeDesc & withBounds(float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
Definition NodeDesc.h:67
NodeDesc & child(NodeDesc c)
Definition NodeDesc.h:100
NodeDesc & withScale(float s)
Definition NodeDesc.h:90
NodeDesc & withKey(std::string v)
Definition NodeDesc.h:39
NodeDesc & withLayer(int v)
Definition NodeDesc.h:63
std::vector< std::string > tags
Definition NodeDesc.h:23
NodeDesc & withVisible(bool v)
Definition NodeDesc.h:51