Skip to main content

SceneNodeConfig Class

Fluent configuration for scene graph integration. More...

Declaration

class helios::engine::builder::gameObject::builders::configs::SceneNodeConfig { ... }

Public Constructors Index

SceneNodeConfig (const helios::engine::ecs::GameObject gameObject)

Constructs a SceneNodeConfig for the given GameObject. More...

Public Member Functions Index

SceneNodeConfig &parent (helios::scene::SceneNode *parent)

Creates a SceneNode and parents it to the given node. More...

SceneNodeConfig &parent (helios::engine::ecs::GameObject parent)

Creates a SceneNode and parents it to another GameObject's node. More...

SceneNodeConfig &inherit (helios::math::TransformType transformType)

Sets the transform inheritance mode. More...

Private Member Functions Index

voidensureRenderableComponent ()

Validates that a RenderableComponent exists. More...

voidensureSceneNode (const bool shouldBeAvailable)

Validates SceneNodeComponent presence. More...

Private Member Attributes Index

helios::engine::ecs::GameObjectgameObject_

Non-owning pointer to the target GameObject. More...

Description

Fluent configuration for scene graph integration.

Allows attaching a GameObject's renderable to the scene graph by creating a SceneNode and setting its parent and inheritance mode. The config automatically manages HierarchyComponent relationships when parenting to another GameObject.

## Usage

```cpp sceneConfig.parent(rootNode) .inherit(TransformType::Translation | TransformType::Rotation); ```

See Also

SceneNodeComponent

See Also

HierarchyComponent

See Also

TransformType

Definition at line 41 of file SceneNodeConfig.ixx.

Public Constructors

SceneNodeConfig()

helios::engine::builder::gameObject::builders::configs::SceneNodeConfig::SceneNodeConfig (const helios::engine::ecs::GameObject gameObject)
inline explicit

Constructs a SceneNodeConfig for the given GameObject.

Parameters
<a href="/docs/helios/namespaces/helios/engine/builder/gameobject">gameObject</a>

Target GameObject to configure.

Definition at line 80 of file SceneNodeConfig.ixx.

Referenced by inherit, parent and parent.

Public Member Functions

inherit()

SceneNodeConfig & helios::engine::builder::gameObject::builders::configs::SceneNodeConfig::inherit (helios::math::TransformType transformType)
inline

Sets the transform inheritance mode.

Parameters
transformType

Which transforms to inherit from parent.

Returns

Reference to this config for chaining.

Definition at line 149 of file SceneNodeConfig.ixx.

150 ensureSceneNode(true);
151
153 ->sceneNode()
154 ->setInheritance(transformType) ;
155
156 return *this;
157 }

Reference SceneNodeConfig.

parent()

SceneNodeConfig & helios::engine::builder::gameObject::builders::configs::SceneNodeConfig::parent (helios::scene::SceneNode * parent)
inline

Creates a SceneNode and parents it to the given node.

Parameters
parent

Parent SceneNode in the scene graph.

Returns

Reference to this config for chaining.

Definition at line 89 of file SceneNodeConfig.ixx.

90 ensureSceneNode(false);
91 ensureRenderableComponent();
92
93 const auto* renderableComponent = gameObject_.get<helios::engine::modules::rendering::renderable::components::RenderableComponent>();
94
95 auto renderable = renderableComponent->shareRenderable();
96
97 auto node = std::make_unique<helios::scene::SceneNode>(renderable);
98 auto node_ptr = parent->addNode(std::move(node));
99
101
102 return *this;
103 }

References parent, SceneNodeConfig and helios::engine::modules::rendering::renderable::components::RenderableComponent::shareRenderable.

Referenced by helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::attachTo, helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::attachTo, helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::attachTo, parent and parent.

parent()

SceneNodeConfig & helios::engine::builder::gameObject::builders::configs::SceneNodeConfig::parent (helios::engine::ecs::GameObject parent)
inline

Creates a SceneNode and parents it to another GameObject's node.

Establishes both scene graph and ECS hierarchy relationships:

  • Adds HierarchyComponent to both entities if not present
  • Sets parent-child relationship in HierarchyComponent
  • Parents the SceneNode to the parent GameObject's SceneNode
Parameters
parent

Parent GameObject whose SceneNode will be the parent.

Returns

Reference to this config for chaining.

Definition at line 118 of file SceneNodeConfig.ixx.

119 ensureSceneNode(false);
120 ensureRenderableComponent();
121
122 parent.getOrAdd<helios::engine::ecs::components::HierarchyComponent>().addChild(gameObject_.entityHandle());
123 gameObject_.getOrAdd<helios::engine::ecs::components::HierarchyComponent>().setParent(parent.entityHandle());
124
125 const auto* renderableComponent = gameObject_.get<helios::engine::modules::rendering::renderable::components::RenderableComponent>();
126
127 auto renderable = renderableComponent->shareRenderable();
128
129 auto node = std::make_unique<helios::scene::SceneNode>(renderable);
130
132 assert(psn && "Unexpected missing SceneNodeComponent for parent GameObject");
133 assert(psn->sceneNode() && "Unexpected missing SceneNode for parent GameObject");
134
135 auto node_ptr = psn->sceneNode()->addNode(std::move(node));
136
138
139 return *this;
140 }

References parent, SceneNodeConfig and helios::engine::modules::rendering::renderable::components::RenderableComponent::shareRenderable.

Private Member Functions

ensureRenderableComponent()

void helios::engine::builder::gameObject::builders::configs::SceneNodeConfig::ensureRenderableComponent ()
inline

Validates that a RenderableComponent exists.

Definition at line 52 of file SceneNodeConfig.ixx.

52 void ensureRenderableComponent() {
54 assert(renderableComponent && "Unexpected nullptr for RenderableComponent.");
55 }

ensureSceneNode()

void helios::engine::builder::gameObject::builders::configs::SceneNodeConfig::ensureSceneNode (const bool shouldBeAvailable)
inline

Validates SceneNodeComponent presence.

Parameters
shouldBeAvailable

Whether the component should exist.

Definition at line 62 of file SceneNodeConfig.ixx.

62 void ensureSceneNode(const bool shouldBeAvailable) {
64
65 if (shouldBeAvailable) {
66 assert(snc && "Unexpected nullptr for SceneNodeComponent.");
67 } else {
68 assert(!snc && "Unexpected SceneNodeComponent.");
69 }
70
71 }

Private Member Attributes

gameObject_

helios::engine::ecs::GameObject helios::engine::builder::gameObject::builders::configs::SceneNodeConfig::gameObject_

Non-owning pointer to the target GameObject.

Definition at line 46 of file SceneNodeConfig.ixx.


The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.