The Table Engine
SceneNode Class Reference

Represents a node in the scene graph, encapsulating a game object and its hierarchy. More...

#include <scene.h>

+ Collaboration diagram for SceneNode:

Public Member Functions

 SceneNode (GameObject *gameObject)
 Constructor that assigns a game object to this node. More...
 
void addChild (GameObject *child, bool isBackground=false)
 Adds a child game object to this node. More...
 
const std::vector< SceneNode * > getChildren ()
 Returns the children of this node. More...
 
SceneNodegetParent ()
 Gets the parent of this node. More...
 
GameObjectgetGameObject ()
 Gets the GameObject associated with this node. More...
 
bool readyToDestroy ()
 Checks if this node is marked for destruction. More...
 
void setDestroy (bool destroy)
 Sets the destruction state of this node. More...
 
bool isBackground ()
 Checks if this node is part of the background. More...
 
void setIsBackground (bool isBackground)
 Sets whether this node is part of the background. More...
 

Private Member Functions

 ~SceneNode ()
 Destructor, ensures proper cleanup of node resources. This destructor is private to ensure that SceneNode objects are managed correctly through smart pointers or specific management functions in the SceneTree class. More...
 

Private Attributes

SceneNodem_parent
 Pointer to the parent node in the scene graph. More...
 
GameObjectm_gameObject
 Pointer to the GameObject this node represents. More...
 
std::vector< SceneNode * > m_children
 List of child nodes. More...
 
bool m_destroy = false
 Flag to indicate whether this node is scheduled for destruction. More...
 
bool m_isBackground = false
 Flag to indicate whether this node is part of the background. More...
 

Friends

class SceneTree
 
class SceneManager
 

Detailed Description

Represents a node in the scene graph, encapsulating a game object and its hierarchy.

SceneNode provides functionality to manage a hierarchy of game objects, including adding children, managing lifecycle states, and setting background status.

Definition at line 24 of file scene.h.

Constructor & Destructor Documentation

◆ SceneNode()

SceneNode::SceneNode ( GameObject gameObject)

Constructor that assigns a game object to this node.

Parameters
gameObjectPointer to the GameObject associated with this node.

Definition at line 11 of file scene.cpp.

◆ ~SceneNode()

SceneNode::~SceneNode ( )
private

Destructor, ensures proper cleanup of node resources. This destructor is private to ensure that SceneNode objects are managed correctly through smart pointers or specific management functions in the SceneTree class.

Definition at line 20 of file scene.cpp.

Member Function Documentation

◆ addChild()

void SceneNode::addChild ( GameObject child,
bool  isBackground = false 
)

Adds a child game object to this node.

Parameters
childPointer to the child GameObject to add.
isBackgroundFlag indicating if the child is part of the background.

Definition at line 40 of file scene.cpp.

◆ getChildren()

const std::vector< SceneNode * > SceneNode::getChildren ( )

Returns the children of this node.

Returns
Vector of pointers to the child SceneNodes.

Definition at line 49 of file scene.cpp.

◆ getGameObject()

GameObject * SceneNode::getGameObject ( )

Gets the GameObject associated with this node.

Returns
Pointer to the GameObject.

Definition at line 57 of file scene.cpp.

◆ getParent()

SceneNode * SceneNode::getParent ( )

Gets the parent of this node.

Returns
Pointer to the parent SceneNode.

Definition at line 53 of file scene.cpp.

◆ isBackground()

bool SceneNode::isBackground ( )

Checks if this node is part of the background.

Returns
True if it is background, false otherwise.

Definition at line 69 of file scene.cpp.

◆ readyToDestroy()

bool SceneNode::readyToDestroy ( )

Checks if this node is marked for destruction.

Returns
True if marked for destruction, false otherwise.

Definition at line 61 of file scene.cpp.

◆ setDestroy()

void SceneNode::setDestroy ( bool  destroy)

Sets the destruction state of this node.

Parameters
destroyFlag indicating whether to mark this node for destruction.

Definition at line 65 of file scene.cpp.

◆ setIsBackground()

void SceneNode::setIsBackground ( bool  isBackground)

Sets whether this node is part of the background.

Parameters
isBackgroundFlag indicating background status.

Definition at line 73 of file scene.cpp.

Friends And Related Function Documentation

◆ SceneManager

friend class SceneManager
friend

Definition at line 27 of file scene.h.

◆ SceneTree

friend class SceneTree
friend

Definition at line 26 of file scene.h.

Member Data Documentation

◆ m_children

std::vector<SceneNode*> SceneNode::m_children
private

List of child nodes.

Definition at line 88 of file scene.h.

◆ m_destroy

bool SceneNode::m_destroy = false
private

Flag to indicate whether this node is scheduled for destruction.

Definition at line 90 of file scene.h.

◆ m_gameObject

GameObject* SceneNode::m_gameObject
private

Pointer to the GameObject this node represents.

Definition at line 87 of file scene.h.

◆ m_isBackground

bool SceneNode::m_isBackground = false
private

Flag to indicate whether this node is part of the background.

Definition at line 91 of file scene.h.

◆ m_parent

SceneNode* SceneNode::m_parent
private

Pointer to the parent node in the scene graph.

Definition at line 86 of file scene.h.


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