89 bool select(
const std::string &
name);
103 void bindOwner(uint32_t ownerId);
106 void setHostVisible(
bool visible);
108 void setHostLayer(
int layer);
111 void updateTransforms();
113 void updateTransformsAll();
116 bool setNodePosition(
const std::string &
id,
float x,
float y,
float z);
118 bool setNodeRotation(
const std::string &
id,
float yaw,
float pitch,
float roll);
120 bool setNodeScale(
const std::string &
id,
float sx,
float sy,
float sz);
122 bool setNodeVisible(
const std::string &
id,
bool visible);
129 bool unlinkNode(
const std::string &
nodeId);
134 bool linkRenderable2DAt(
const std::string &hostName,
const std::string &
nodeId,
137 bool linkRenderable3DAt(
const std::string &hostName,
const std::string &
nodeId,
140 bool linkPhysics2DAt(
const std::string &hostName,
const std::string &
nodeId,
143 bool linkPhysics3DAt(
const std::string &hostName,
const std::string &
nodeId,
146 bool linkCamera3DAt(
const std::string &hostName,
const std::string &
nodeId,
149 bool linkAudio3DAt(
const std::string &hostName,
const std::string &
nodeId,
152 bool unlinkNodeAt(
const std::string &hostName,
const std::string &
nodeId);
154 bool unlinkNodeKindAt(
const std::string &hostName,
const std::string &
nodeId,
155 const std::string &
kind);
157 int linkCountAt(
const std::string &hostName,
const std::string &
nodeId);
180 [[nodiscard]]
Result<void> linkScriptAt(
const std::string& hostName,
const std::string&
nodeId,
181 const std::string& providerName,
const std::string& mode);
187 std::vector<float> getNodePositionAt(
const std::string &hostName,
188 const std::string &
nodeId)
const;
190 std::vector<float> getNodeRotationAt(
const std::string &hostName,
191 const std::string &
nodeId)
const;
193 std::vector<float> getNodeScaleAt(
const std::string &hostName,
194 const std::string &
nodeId)
const;
196 bool getNodeVisibleAt(
const std::string &hostName,
const std::string &
nodeId)
const;
198 std::vector<float> getNodeWorldPositionAt(
const std::string &hostName,
199 const std::string &
nodeId)
const;
201 std::vector<float> getNodeWorldRotationAt(
const std::string &hostName,
202 const std::string &
nodeId)
const;
204 std::vector<float> getNodeWorldScaleAt(
const std::string &hostName,
205 const std::string &
nodeId)
const;
208 std::vector<float> localToWorldAt(
const std::string &hostName,
209 const std::string &
nodeId,
float x,
float y,
212 std::vector<float> worldToLocalAt(
const std::string &hostName,
213 const std::string &
nodeId,
float x,
float y,
217 bool setNodeParentAt(
const std::string &hostName,
const std::string &childId,
220 bool removeNodeAt(
const std::string &hostName,
const std::string &
nodeId);
234 bool addChildAt(
const std::string &hostName,
const std::string &
parentId,
235 const std::string &childId);
237 bool removeChildAt(
const std::string &hostName,
const std::string &
parentId,
238 const std::string &childId);
241 bool setNodeQuaternionAt(
const std::string &hostName,
const std::string &
nodeId,
242 float qx,
float qy,
float qz,
float qw);
244 std::vector<float> getNodeQuaternionAt(
const std::string &hostName,
245 const std::string &
nodeId)
const;
247 bool setNodeLookAtAt(
const std::string &hostName,
const std::string &
nodeId,
248 float tx,
float ty,
float tz);
251 bool addNodeTagAt(
const std::string &hostName,
const std::string &
nodeId,
252 const std::string &
tag);
254 bool removeNodeTagAt(
const std::string &hostName,
const std::string &
nodeId,
255 const std::string &
tag);
257 bool hasNodeTagAt(
const std::string &hostName,
const std::string &
nodeId,
258 const std::string &
tag)
const;
260 std::vector<std::string> getNodeTagsAt(
const std::string &hostName,
261 const std::string &
nodeId)
const;
263 std::vector<std::string> collectIdsByTagAt(
const std::string &hostName,
264 const std::string &
tag)
const;
266 bool setNodeLayerAt(
const std::string &hostName,
const std::string &
nodeId,
int layer);
268 int getNodeLayerAt(
const std::string &hostName,
const std::string &
nodeId)
const;
276 bool setNodeEventHandlerAt(
const std::string &hostName, ssq::Object cb);
280 bool setNodeBoundsAt(
const std::string &hostName,
const std::string &
nodeId,
281 float minX,
float minY,
float minZ,
float maxX,
float maxY,
284 bool hasNodeBoundsAt(
const std::string &hostName,
const std::string &
nodeId)
const;
286 std::vector<float> getNodeBoundsAt(
const std::string &hostName,
287 const std::string &
nodeId)
const;
291 std::string serializeHostAt(
const std::string &hostName)
const;
293 bool deserializeHostAt(
const std::string &hostName,
const std::string &json);
297 std::string pickRayAt(
const std::string &hostName,
float ox,
float oy,
float oz,
298 float dx,
float dy,
float dz)
const;
301 float screenX,
float screenY,
float viewW,
float viewH)
const;
305 std::vector<std::string> collectFrustumIdsAt(
const std::string &hostName,
319 [[nodiscard]]
Result<int> applyPcgTerrainCullingAt(
const std::string &hostName,
322 bool syncSpatialIndexAt(
const std::string &hostName,
spatial::Octree *ot)
const;
324 std::string nodeIdFromSpatialIdAt(
const std::string &hostName,
int index)
const;
328 bool hasNode(
const std::string &
id);
332 std::string getRootId();
334 std::string getParentId(
const std::string &
id);
336 int getChildCount(
const std::string &
id);
338 std::string getChildIdAt(
const std::string &
parentId,
int childOrdinal);
340 std::string findIdByName(
const std::string &
name);
342 std::string findIdByPath(
const std::string &
path);
344 std::string getNodePath(
const std::string &
id);
346 bool isAncestor(
const std::string &ancestorId,
const std::string &
nodeId);
348 bool isDescendant(
const std::string &
nodeId,
const std::string &ancestorId);
350 std::vector<std::string> collectIds();
352 std::vector<std::string> collectIdsFrom(
const std::string &
id);
354 std::vector<std::string> collectIdsByName(
const std::string &
name);
356 std::vector<std::string> collectIdsVisible(
bool visible);
358 std::vector<std::string> collectChildIds(
const std::string &
parentId);
360 std::vector<std::string> walkDepthFirstIds();
362 std::vector<std::string> walkBreadthFirstIds();
368 void beginNode(
const std::string &
id,
const std::string &
name =
"");
370 void beginGroup(
const std::string &
id =
"");
374 void addNode(
const std::string &
id,
const std::string &
name =
"");
376 void setBuildPosition(
float x,
float y,
float z = 0.f);
378 void setBuildRotation(
float yaw,
float pitch = 0.f,
float roll = 0.f);
380 void setBuildScale(
float sx,
float sy,
float sz = 1.f);
382 void setBuildSpace(
const std::string &space);
384 void setBuildVisible(
bool visible);
388 bool mountBuildAs(
const std::string &
name);
390 bool remountBuildAs(
const std::string &
name);
398 [[nodiscard]]
SceneHost *resolveHost(
const std::string &hostName)
const;
401 bool rootEntity(
const std::string &hostName,
const std::string &
nodeId,
402 ssq::Object instance);
404 bool unrootEntityAt(
const std::string &hostName,
const std::string &
nodeId,
407 int forEachEntity(
const std::string &hostName,
const std::string &
nodeId,
429 [[nodiscard]] std::vector<ssq::Object> scriptEntitiesAt(
const std::string& hostName,
430 const std::string&
nodeId)
const;
443 [[nodiscard]] std::vector<ScriptComponentInstanceState> scriptComponentStatesAt(
const std::string& hostName,
444 const std::string&
nodeId)
const;
447 void updateScripts(
float dt);
460 [[nodiscard]]
eve::Result<void> scheduleDetachEntityAt(
const std::string &hostName,
461 const std::string &
nodeId,
462 ssq::Object instance);
464 void flushDelayedDetaches();
467 std::string currentHostName()
const;
469 [[nodiscard]]
SceneNodeRef *getNodeRefAt(
const std::string &hostName,
const std::string &
nodeId)
const;
471 [[nodiscard]]
SceneNodeRef *getNodeRefByPathAt(
const std::string &hostName,
const std::string &
path)
const;
474 struct DelayedDetach {
475 std::string hostName;
477 HSQOBJECT instance{};
479 [[nodiscard]] SceneHost *ensureSelected(
const std::string &preferredName =
"");
480 NodeDesc ¤tParent();
489 NodeDesc& buildTarget();
491 enum class BuildCursor { None, OpenNode, LastAddedChild };
492 void pushOpen(NodeDesc
d);
493 bool buildComplete()
const;
495 [[nodiscard]] SceneObject *findSceneObjectById(uint32_t
id)
const;
496 [[nodiscard]] SceneObject *findSceneObjectByPersistentId(
eve::SceneObjectId id)
const;
497 [[nodiscard]] SceneObject *ensureSceneObject(SceneHost *
host, SceneNode *
node,
const std::string &hostName);
499 void pruneOrphanObjects();
501 void teardownBindings(SceneObject *obj);
503 void syncBindingRefs(SceneObject *obj);
505 bool callMethod(HSQOBJECT inst,
const char *
name,
float dt);
506 bool callMethod0(HSQOBJECT inst,
const char *
name);
507 bool callCallback(HSQOBJECT
fn, HSQOBJECT inst,
int index);
508 void callEventCallback(
const std::string &hostName,
const std::string &
action,
511 SceneHost *selected_ =
nullptr;
513 std::unordered_map<std::string, HSQOBJECT> eventCbs_;
514 std::vector<DelayedDetach> delayedDetaches_;
515 bool flushingDelayedDetaches_ =
false;
517 std::vector<NodeDesc> openStack_;
519 bool hasBuiltRoot_ =
false;
520 BuildCursor buildCursor_ = BuildCursor::None;
Backend-neutral 3D rigid body in meter-space coordinates (+Y up by convention). Owned by a World3D; c...
2D rigid body (Box2D) in pixel-space coordinates. Owned by a World; create shapes with newRectangleFi...