13SceneHost *resolveHost(
const std::string &hostName) {
14 Scene *
s = Scene::create();
15 if (!
s)
return nullptr;
16 if (hostName.empty())
return s->current();
17 return s->findHost(hostName);
20SceneNode *resolveNode(
const std::string &hostName,
const std::string &nodeId) {
21 if (nodeId.empty())
return nullptr;
22 SceneHost *
h = resolveHost(hostName);
23 return h ?
h->findById(nodeId) :
nullptr;
26glm::vec3 normalizedColumn(
const glm::mat4 &
m,
int col) {
28 const float len = glm::length(
v);
29 if (len > 1e-8f)
v /= len;
41 SceneNode *
n = resolveNode(hostName_, nodeId_);
42 if (!
h || !
n)
return false;
46 h->markSubtreeDirtyById(nodeId_);
51 const SceneNode *
n = resolveNode(hostName_, nodeId_);
52 return n ?
n->x : 0.f;
56 const SceneNode *
n = resolveNode(hostName_, nodeId_);
57 return n ?
n->y : 0.f;
61 const SceneNode *
n = resolveNode(hostName_, nodeId_);
62 return n ?
n->z : 0.f;
66 const SceneNode *
n = resolveNode(hostName_, nodeId_);
67 if (!
n)
return {0.f, 0.f, 0.f};
68 return {
n->x,
n->y,
n->z};
73 SceneNode *
n = resolveNode(hostName_, nodeId_);
74 if (!
h || !
n)
return false;
78 h->markSubtreeDirtyById(nodeId_);
83 const SceneNode *
n = resolveNode(hostName_, nodeId_);
84 return n ?
n->yaw : 0.f;
88 const SceneNode *
n = resolveNode(hostName_, nodeId_);
89 return n ?
n->pitch : 0.f;
93 const SceneNode *
n = resolveNode(hostName_, nodeId_);
94 return n ?
n->roll : 0.f;
98 const SceneNode *
n = resolveNode(hostName_, nodeId_);
99 if (!
n)
return {0.f, 0.f, 0.f};
100 return {
n->yaw,
n->pitch,
n->roll};
105 SceneNode *
n = resolveNode(hostName_, nodeId_);
106 if (!
h || !
n)
return false;
110 h->markSubtreeDirtyById(nodeId_);
115 const SceneNode *
n = resolveNode(hostName_, nodeId_);
116 return n ?
n->sx : 0.f;
120 const SceneNode *
n = resolveNode(hostName_, nodeId_);
121 return n ?
n->sy : 0.f;
125 const SceneNode *
n = resolveNode(hostName_, nodeId_);
126 return n ?
n->sz : 0.f;
130 const SceneNode *
n = resolveNode(hostName_, nodeId_);
131 if (!
n)
return {0.f, 0.f, 0.f};
132 return {
n->sx,
n->sy,
n->sz};
136 SceneNode *
n = resolveNode(hostName_, nodeId_);
137 if (!
n)
return false;
140 if (
h)
h->markSubtreeDirtyById(nodeId_);
145 const SceneNode *
n = resolveNode(hostName_, nodeId_);
146 return n ?
n->visible :
false;
150 const SceneNode *
n = resolveNode(hostName_, nodeId_);
151 return n ?
n->world[3][0] : 0.f;
155 const SceneNode *
n = resolveNode(hostName_, nodeId_);
156 return n ?
n->world[3][1] : 0.f;
160 const SceneNode *
n = resolveNode(hostName_, nodeId_);
161 return n ?
n->world[3][2] : 0.f;
165 const SceneNode *
n = resolveNode(hostName_, nodeId_);
166 if (!
n)
return {0.f, 0.f, 0.f};
167 return {
n->world[3][0],
n->world[3][1],
n->world[3][2]};
171 const SceneNode *
n = resolveNode(hostName_, nodeId_);
172 if (!
n)
return std::vector<float>(16, 0.f);
173 std::vector<float> out;
175 for (
int c = 0;
c < 4; ++
c)
176 for (
int r = 0; r < 4; ++r) out.push_back(
n->world[
c][r]);
181 const SceneNode *
n = resolveNode(hostName_, nodeId_);
182 if (!
n)
return {0.f, 0.f, 1.f};
183 glm::vec3
v = normalizedColumn(
n->world, 2);
184 return {
v.x,
v.y,
v.z};
188 const SceneNode *
n = resolveNode(hostName_, nodeId_);
189 if (!
n)
return {1.f, 0.f, 0.f};
190 glm::vec3
v = normalizedColumn(
n->world, 0);
191 return {
v.x,
v.y,
v.z};
195 const SceneNode *
n = resolveNode(hostName_, nodeId_);
196 if (!
n)
return {0.f, 1.f, 0.f};
197 glm::vec3
v = normalizedColumn(
n->world, 1);
198 return {
v.x,
v.y,
v.z};
205 return p ?
p->
id : std::string{};
210 return h ?
h->getChildCountById(nodeId_) : 0;
216 SceneNode *
c =
h->getChildAtById(nodeId_, ordinal);
217 return c ?
c->
id : std::string{};
222 return h ?
h->getPathById(nodeId_) : std::string{};
ECS mount point for one scene graph (full scene or nested subtree root). Isomorphic to eve::ui::UIHos...
float getPositionX() const
float getWorldPositionZ() const
std::vector< float > getForward() const
Normalized local axes in world space (forward = +Z).
bool isValid() const
True when host + node currently resolve.
float getWorldPositionX() const
float getRotationYaw() const
float getWorldPositionY() const
float getRotationPitch() const
Scene * getScene() const
The eve.Scene module instance (for entity binding forwarding).
std::string getPath() const
std::string getChildIdAt(int ordinal) const
std::vector< float > getPosition() const
std::vector< float > getWorldPosition() const
std::vector< float > getRotation() const
bool setPosition(float x, float y, float z)
float getPositionY() const
bool setScale(float sx, float sy, float sz)
float getRotationRoll() const
std::vector< float > getScale() const
int getChildCount() const
std::string getParentId() const
std::vector< float > getUp() const
bool setRotation(float yaw, float pitch, float roll)
std::vector< float > getRight() const
float getPositionZ() const
std::vector< float > getWorldMatrix() const
Column-major 4x4 world matrix, 16 floats.
Declarative scene module (eve.Scene).
Retained scene node (arena). Conceptual GameObject; isomorphic to eve::ui::UINode.