载入中...
搜索中...
未找到
NodeDesc.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Identity.h"
6
7#include <string>
8#include <utility>
9#include <vector>
10
11namespace eve::scene {
12
13class SceneHost;
14
19struct NodeDesc {
20 std::string id;
30 std::string key;
31 std::string name;
33 std::string space = "3d";
34 bool visible = true;
35 std::vector<std::string> tags;
36 int layer = 0;
37 float bminX = 0.f, bminY = 0.f, bminZ = 0.f;
38 float bmaxX = 0.f, bmaxY = 0.f, bmaxZ = 0.f;
39 bool hasBounds = false;
40
41 float x = 0.f, y = 0.f, z = 0.f;
42 float yaw = 0.f, pitch = 0.f, roll = 0.f;
43 float sx = 1.f, sy = 1.f, sz = 1.f;
44
45 std::vector<NodeDesc> children;
46
48 NodeDesc &withId(std::string v) {
49 id = std::move(v);
50 return *this;
51 }
58 NodeDesc &withKey(std::string v) {
59 key = std::move(v);
60 return *this;
61 }
63 NodeDesc &withName(std::string v) {
64 name = std::move(v);
65 return *this;
66 }
68 NodeDesc &withSpace(std::string v) {
69 space = std::move(v);
70 return *this;
71 }
74 visible = v;
75 return *this;
76 }
78 NodeDesc &withTag(std::string v) {
79 tags.push_back(std::move(v));
80 return *this;
81 }
83 NodeDesc &withTags(std::vector<std::string> v) {
84 tags = std::move(v);
85 return *this;
86 }
89 layer = v;
90 return *this;
91 }
93 NodeDesc &withBounds(float minX, float minY, float minZ, float maxX, float maxY,
94 float maxZ) {
95 bminX = minX;
96 bminY = minY;
97 bminZ = minZ;
98 bmaxX = maxX;
99 bmaxY = maxY;
100 bmaxZ = maxZ;
101 hasBounds = true;
102 return *this;
103 }
105 NodeDesc &withPosition(float px, float py, float pz = 0.f) {
106 x = px;
107 y = py;
108 z = pz;
109 return *this;
110 }
112 NodeDesc &withRotation(float y_, float p = 0.f, float r = 0.f) {
113 yaw = y_;
114 pitch = p;
115 roll = r;
116 return *this;
117 }
120 sx = sy = sz = s;
121 return *this;
122 }
124 NodeDesc &withScaleXYZ(float sx_, float sy_, float sz_) {
125 sx = sx_;
126 sy = sy_;
127 sz = sz_;
128 return *this;
129 }
132 children.push_back(std::move(c));
133 return *this;
134 }
135
137 const std::string &reconcileKey() const { return key.empty() ? id : key; }
138};
139
141EVENGINE_API_PLATFORM NodeDesc node(std::string id, std::vector<NodeDesc> children = {}, std::string name = "");
143EVENGINE_API_PLATFORM NodeDesc group(std::vector<NodeDesc> children = {}, std::string id = "");
145EVENGINE_API_PLATFORM NodeDesc when(bool cond, NodeDesc child);
147EVENGINE_API_PLATFORM NodeDesc whenElse(bool cond, NodeDesc ifTrue, NodeDesc ifFalse);
148
150void applyTree(SceneHost *host, NodeDesc root);
152bool applyTreeReconcile(SceneHost *host, NodeDesc root);
153
154} // namespace eve::scene
int root
Definition AnimSmr.cpp:119
const std::string & s
building::EdgeCurveGroup group
float py
float pz
glm::vec4 p[6]
#define EVENGINE_API_PLATFORM
Definition Export.h:107
double r
float v
std::int32_t c
Strong identity values shared by persistence, content and logical-name APIs.
std::vector< Colorf > px
std::string name
const RoadNode * node
int children
Definition TreeMesh.cpp:295
UIHostHandle host
Id128 public API.
Definition Identity.h:112
bool applyTreeReconcile(SceneHost *host, NodeDesc root)
Key-aware patch when structure matches; else full replace. Returns true if full rebuild.
Definition NodeDesc.cpp:323
NodeDesc when(bool cond, NodeDesc child)
Conditional: include child only when cond is true (empty group otherwise).
Definition NodeDesc.cpp:234
void applyTree(SceneHost *host, NodeDesc root)
Applies tree.
Definition NodeDesc.cpp:243
NodeDesc whenElse(bool cond, NodeDesc ifTrue, NodeDesc ifFalse)
When else.
Definition NodeDesc.cpp:239
Declarative scene-node description (build once / on dirty → flatten into SceneHost::Tree)....
Definition NodeDesc.h:19
std::string id
Definition NodeDesc.h:20
NodeDesc & withId(std::string v)
With id.
Definition NodeDesc.h:48
NodeDesc & withPosition(float px, float py, float pz=0.f)
With position.
Definition NodeDesc.h:105
NodeDesc & withName(std::string v)
With name.
Definition NodeDesc.h:63
eve::SceneObjectId persistentId
Optional persisted object identity.
Definition NodeDesc.h:28
std::string key
Reconciliation key; defaults to id when empty.
Definition NodeDesc.h:30
NodeDesc & withSpace(std::string v)
With space.
Definition NodeDesc.h:68
NodeDesc & withTags(std::vector< std::string > v)
With tags.
Definition NodeDesc.h:83
NodeDesc & withTag(std::string v)
With tag.
Definition NodeDesc.h:78
std::vector< NodeDesc > children
Definition NodeDesc.h:45
std::string name
Definition NodeDesc.h:31
std::string space
"2d" or "3d" (string enum per module convention).
Definition NodeDesc.h:33
NodeDesc & withRotation(float y_, float p=0.f, float r=0.f)
With rotation.
Definition NodeDesc.h:112
NodeDesc & withScaleXYZ(float sx_, float sy_, float sz_)
With scale xyz.
Definition NodeDesc.h:124
const std::string & reconcileKey() const
Reconcile key.
Definition NodeDesc.h:137
NodeDesc & withBounds(float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
With bounds.
Definition NodeDesc.h:93
NodeDesc & child(NodeDesc c)
Child.
Definition NodeDesc.h:131
NodeDesc & withScale(float s)
With scale.
Definition NodeDesc.h:119
NodeDesc & withKey(std::string v)
With key.
Definition NodeDesc.h:58
NodeDesc & withPersistentId(eve::SceneObjectId v)
Assign a stable persisted scene-object UUID.
Definition NodeDesc.h:53
NodeDesc & withLayer(int v)
With layer.
Definition NodeDesc.h:88
std::vector< std::string > tags
Definition NodeDesc.h:35
NodeDesc & withVisible(bool v)
With visible.
Definition NodeDesc.h:73