Class SceneNode#

Inheritance Relationships#

Base Type#

Derived Types#

Class Documentation#

class SceneNode : public Karana::Core::Base#

Base for objects with a transform i n the scene hierarchy.

See Scene layer for more discussion on the scene layer.

Subclassed by Karana::Scene::CollisionSceneNode, Karana::Scene::GraphicalSceneNode, Karana::Scene::ProxySceneNode, Karana::Scene::ScenePart

Public Functions

virtual ~SceneNode()#
const Karana::Math::Vec3 &getTranslation() const#

Get position of the node relative to its parent.

Returns:

The relative translation

virtual void setTranslation(const Karana::Math::Vec3 &translation)#

Set position of the node relative to its parent.

Parameters:

translation – - The relative translation

const Karana::Math::UnitQuaternion &getUnitQuaternion() const#

Get rotation of the node relative to its parent.

Returns:

The relative rotation as a unit quaternion

virtual void setUnitQuaternion(const Karana::Math::UnitQuaternion &quaternion)#

Set rotation of the node relative to its parent.

Parameters:

quaternion – - The relative rotation as a unit quaternion

double getScale() const#

Get uniform scale of the node relative to its parent.

Returns:

The relative uniform scale

virtual void setScale(double scale)#

Set uniform of the node relative to its parent.

Parameters:

scale – - The relative uniform scale

const Karana::Math::SimTran &getTransform() const#

Get similarity transform of the node relative to its parent.

Returns:

The similarity transform

const Karana::Math::SimTran &getWorldTransform() const#

Get similarity transform of the node relative to the scene’s root.

Returns:

The similarity transform

const Karana::Math::Vec3 &getWorldTranslation() const#

Get translation of the node relative to the scene’s root.

Returns:

The translation

const Karana::Math::UnitQuaternion &getWorldUnitQuaternion() const#

Get rotation of the node relative to the scene’s root.

Returns:

The rotation as a unit quaternion

double getWorldScale() const#

Get uniform scale of the node relative to the scene’s root.

Returns:

The uniform scale

const Karana::Core::ks_ptr<SceneNode> &parent() const#

Get the parent node.

Returns:

The parent node or nullptr

virtual void attachTo(const Karana::Core::ks_ptr<SceneNode> &parent, bool maintain_world_transform = false)#

Attach to a parent node.

Parameters:
  • parent – - The parent node

  • maintain_world_transform – - If true, update the node’s relative transform so that its overall world transform doesn’t change after attaching it to the parent

virtual void detach(bool maintain_world_transform = false)#

Detach the node from its parent.

Parameters:

maintain_world_transform – - If true, update the node’s relative transform so that its overall world transform doesn’t change after detaching

Karana::Core::RegistryList<SceneNode> children()#

Get the node’s children.

Returns:

A list of the node’s children

virtual void setVisible(bool visible)#

Set whether the object is visible.

Parameters:

visible – - The visibility flag

bool getVisible() const#

Get whether the object is visible.

Returns:

The visibility flag

Karana::Core::ks_ptr<SceneNode> getManager() const#

Get a SceneNode managing this one.

Returns:

The managing scene node or nullptr

void setManager(const Karana::Core::ks_ptr<SceneNode> &manager)#

Assign a managing scene node.

Parameters:

manager – The scene node managing this one (nullable)

Public Static Functions

static Karana::Core::ks_ptr<SceneNode> create(std::string_view name, const Karana::Core::ks_ptr<Scene> &scene)#

Create a scene node.

Parameters:
  • name – - Name of the node.

  • scene – - The scene to add the node to.

Returns:

Shared pointer to a scene node

static void discardNonRecursive(Karana::Core::ks_ptr<SceneNode> &node)#

Discard the given SceneNode non-recursively. Calling discard on a scene node will discard it and all of its children, which is the normal desired behavior. This specialized method will discard the node, but not its children.

Parameters:

node – - The node to discard

Protected Functions

SceneNode(std::string_view name, const Karana::Core::ks_ptr<Scene> &scene)#

SceneNode Constructor.

Parameters:
  • name – - Name of the node.

  • scene – - The scene to add the node to.

virtual void _computeWorldTransform(Karana::Math::SimTran &transform) const#

Helper to compute the node’s world transform.

Parameters:

transform – - The new relative transform

void _discard(Karana::Core::ks_ptr<Base> &base) override#

Discard the provided SceneNode.

Parameters:

base – - Base pointer to the SceneNode to discard.

Protected Attributes

Karana::Core::ks_ptr<Karana::Core::DataCache<Karana::Math::SimTran>> _world_transform_cache#

Cache to lazily recompute the world transform as needed.

std::weak_ptr<SceneNode> _manager#

The SceneNode managing this one (if any)