16 if (!result.
ok())
return nullptr;
17 return std::move(result).takeValue();
20SceneHost *resolveHost(
const std::string &hostName) {
21 Scene *
s = Scene::create();
22 if (!
s)
return nullptr;
23 if (hostName.empty())
return s->current();
24 return borrowSceneResult(
s->findHost(hostName));
27SceneNode *resolveNode(
const std::string &hostName,
const std::string &
nodeId) {
28 if (
nodeId.empty())
return nullptr;
29 SceneHost *
h = resolveHost(hostName);
30 return h ? borrowSceneResult(
h->findById(
nodeId)) : nullptr;
33glm::vec3 normalizedColumn(
const glm::mat4 &
m,
int col) {
35 const float len = glm::length(
v);
36 if (len > 1e-8f)
v /= len;
53 SceneNode *
n = resolveNode(hostName_, nodeId_);
54 if (!
h || !
n)
return false;
58 h->markSubtreeDirtyById(nodeId_);
63 const SceneNode *
n = resolveNode(hostName_, nodeId_);
64 return n ?
n->x : 0.f;
68 const SceneNode *
n = resolveNode(hostName_, nodeId_);
69 return n ?
n->y : 0.f;
73 const SceneNode *
n = resolveNode(hostName_, nodeId_);
74 return n ?
n->z : 0.f;
78 const SceneNode *
n = resolveNode(hostName_, nodeId_);
79 if (!
n)
return {0.f, 0.f, 0.f};
80 return {
n->x,
n->y,
n->z};
85 SceneNode *
n = resolveNode(hostName_, nodeId_);
86 if (!
h || !
n)
return false;
90 h->markSubtreeDirtyById(nodeId_);
95 const SceneNode *
n = resolveNode(hostName_, nodeId_);
96 return n ?
n->yaw : 0.f;
100 const SceneNode *
n = resolveNode(hostName_, nodeId_);
101 return n ?
n->pitch : 0.f;
105 const SceneNode *
n = resolveNode(hostName_, nodeId_);
106 return n ?
n->roll : 0.f;
110 const SceneNode *
n = resolveNode(hostName_, nodeId_);
111 if (!
n)
return {0.f, 0.f, 0.f};
112 return {
n->yaw,
n->pitch,
n->roll};
117 SceneNode *
n = resolveNode(hostName_, nodeId_);
118 if (!
h || !
n)
return false;
122 h->markSubtreeDirtyById(nodeId_);
127 const SceneNode *
n = resolveNode(hostName_, nodeId_);
128 return n ?
n->sx : 0.f;
132 const SceneNode *
n = resolveNode(hostName_, nodeId_);
133 return n ?
n->sy : 0.f;
137 const SceneNode *
n = resolveNode(hostName_, nodeId_);
138 return n ?
n->sz : 0.f;
142 const SceneNode *
n = resolveNode(hostName_, nodeId_);
143 if (!
n)
return {0.f, 0.f, 0.f};
144 return {
n->sx,
n->sy,
n->sz};
148 SceneNode *
n = resolveNode(hostName_, nodeId_);
149 if (!
n)
return false;
152 if (
h)
h->markSubtreeDirtyById(nodeId_);
157 const SceneNode *
n = resolveNode(hostName_, nodeId_);
158 return n ?
n->visible :
false;
162 const SceneNode *
n = resolveNode(hostName_, nodeId_);
163 return n ?
n->world[3][0] : 0.f;
167 const SceneNode *
n = resolveNode(hostName_, nodeId_);
168 return n ?
n->world[3][1] : 0.f;
172 const SceneNode *
n = resolveNode(hostName_, nodeId_);
173 return n ?
n->world[3][2] : 0.f;
177 const SceneNode *
n = resolveNode(hostName_, nodeId_);
178 if (!
n)
return {0.f, 0.f, 0.f};
179 return {
n->world[3][0],
n->world[3][1],
n->world[3][2]};
183 const SceneNode *
n = resolveNode(hostName_, nodeId_);
184 if (!
n)
return std::vector<float>(16, 0.f);
185 std::vector<float> out;
187 for (
int c = 0;
c < 4; ++
c)
188 for (
int r = 0;
r < 4; ++
r) out.push_back(
n->world[
c][
r]);
193 const SceneNode *
n = resolveNode(hostName_, nodeId_);
194 if (!
n)
return {0.f, 0.f, 1.f};
195 glm::vec3
v = normalizedColumn(
n->world, 2);
196 return {
v.x,
v.y,
v.z};
200 const SceneNode *
n = resolveNode(hostName_, nodeId_);
201 if (!
n)
return {1.f, 0.f, 0.f};
202 glm::vec3
v = normalizedColumn(
n->world, 0);
203 return {
v.x,
v.y,
v.z};
207 const SceneNode *
n = resolveNode(hostName_, nodeId_);
208 if (!
n)
return {0.f, 1.f, 0.f};
209 glm::vec3
v = normalizedColumn(
n->world, 1);
210 return {
v.x,
v.y,
v.z};
217 return p ?
p->
id : std::string{};
222 return h ?
h->getChildCountById(nodeId_) : 0;
228 SceneNode *
c =
h->getChildAtById(nodeId_, ordinal);
229 return c ?
c->
id : std::string{};
234 return h ?
h->getPathById(nodeId_) : std::string{};
Move-only operation result carrying either a value or Status.
bool ok() const noexcept
Whether this result represents a non-failure outcome.
static constexpr Id128 nil() noexcept
Returns the all-zero nil value.
ECS mount point for one scene graph (full scene or nested subtree root). Isomorphic to eve::ui::UIHos...
float getPositionX() const
Returns the position x.
float getWorldPositionZ() const
Returns the world position z.
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
Returns the world position x.
float getRotationYaw() const
Returns the rotation yaw.
float getWorldPositionY() const
Returns the world position y.
float getRotationPitch() const
Returns the rotation pitch.
bool setVisible(bool v)
Sets the visible.
float getScaleZ() const
Returns the scale z.
float getScaleX() const
Returns the scale x.
Scene * getScene() const
Returns the eve.Scene module instance for entity-binding forwarding.
std::string getPath() const
Returns the path.
std::string getChildIdAt(int ordinal) const
Returns the child id at.
std::vector< float > getPosition() const
Returns the position.
eve::SceneObjectId persistentId() const
Return the persisted UUID of the resolved node, or nil if absent.
std::vector< float > getWorldPosition() const
Returns the world position.
std::vector< float > getRotation() const
Returns the rotation.
bool setPosition(float x, float y, float z)
Sets the position.
float getPositionY() const
Returns the position y.
bool setScale(float sx, float sy, float sz)
Sets the scale.
float getRotationRoll() const
Returns the rotation roll.
std::vector< float > getScale() const
Returns the scale.
int getChildCount() const
Returns the child count.
bool isVisible() const
True when visible.
float getScaleY() const
Returns the scale y.
std::string getParentId() const
Returns the parent id.
std::vector< float > getUp() const
Returns the up.
bool setRotation(float yaw, float pitch, float roll)
Sets the rotation.
std::vector< float > getRight() const
Returns the right.
float getPositionZ() const
Returns the position z.
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.