Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
oe::scene::Manager Class Reference

Scene manager. More...

#include <OxygenEngine/scene/manager.h>

Inheritance diagram for oe::scene::Manager:
[legend]
Collaboration diagram for oe::scene::Manager:
[legend]

Public Member Functions

 Manager ()
 Default Constructor.
 
 Manager (const Camera &camera)
 Constructor where Camera settings are filled from a reference one.
 
template<typename T = Node, typename... Args>
T & addNode (Args &&... args)
 Generate a new root node in the the scene.
 
template<typename T = Node, typename... Args>
T & addNamedNode (const std::string &name, Args &&... args)
 Generate a new root node in the the scene.
 
void addChildNodeToParent (Node &child, Node *parent)
 Attach a child node to a parent one.
 
void deleteNode (Node &node)
 Remove a node from the scene.
 
const std::vector< std::shared_ptr< Node > > & getAllNodes () const
 Get all nodes in the scene.
 
const std::vector< Node * > & getRootNodes () const
 Get root nodes of the scene.
 
template<typename T = Node>
T * search (const std::string path, const std::string separator="/") const
 Search for a node using a name path.
 
CameragetCamera ()
 Get currently bound scene camera.
 
void setCamera (Camera &camera)
 Set scene camera.
 
void setCamera (Node &node)
 Set scene camera using a node's camera component.
 
void setCamera (Node &node, const std::string &component_name)
 Set scene camera using a node's named camera component.
 
template<typename ComponentType >
void setCameraFromComponent (ComponentType &component)
 Set scene camera using a component providing a camera.
 
CameragetDefaultCamera ()
 Get a reference to the default camera.
 
void resetCameraToDefault ()
 Reset scene camera to the default camera.
 
void addNodeInGroup (Node &node, const NodeType type)
 Add a node in a group (For example nodes that need to be in specific pass)
 
std::vector< Node * > getNodesByType (const NodeType type) const
 Get nodes belonging to a type (For exemple nodes that need to be in specific pass)
 
void removeNodeFromGroup (Node &node, const NodeType type)
 Remove node from specified group.
 
void removeNodeFromAllGroups (Node &node)
 Remove node from all of its groups.
 
void update (const double delta, const int8_t flags=0)
 Update the scene.
 
- Public Member Functions inherited from oe::component::HasComponents< Manager, SceneComponent >
 HasComponents (Manager &entity)
 
ComponentList< Manager, SceneComponent > & getComponents () noexcept
 Get components bound to the entity.
 
const ComponentList< Manager, SceneComponent > & getComponents () const noexcept
 Get components bound to the entity.
 
std::shared_ptr< T > addComponent (Args &&... args)
 Add a new a component.
 
std::shared_ptr< T > addNamedComponent (const std::string &name, Args &&... args)
 Add a new a component.
 
void removeComponent (const std::string &name)
 Remove a component.
 
const T * getComponentByType () const noexcept
 Fetch a component by its type.
 
T * getComponentByType () noexcept
 Fetch a component by its type.
 
T * getComponentByName (const std::string &name) noexcept
 Fetch a component when you know its name.
 
const T * getComponentByName (const std::string &name) const noexcept
 Fetch a component when you know its name.
 

Additional Inherited Members

- Protected Attributes inherited from oe::component::HasComponents< Manager, SceneComponent >
ComponentList< Manager, SceneComponent > _components
 

Detailed Description

Scene manager.

Note
By default, the scene manager is provided with a default Camera (see constructors)

Constructor & Destructor Documentation

◆ Manager() [1/2]

oe::scene::Manager::Manager ( )

Default Constructor.

Note
a 4:3 perspective Camera is used as default one

◆ Manager() [2/2]

oe::scene::Manager::Manager ( const Camera camera)

Constructor where Camera settings are filled from a reference one.

Parameters
cameraCamera used as source for settings (Position, Projection, etc...)
Note
The camera parameter won't be used as the default camera (only its settings are copied)

Member Function Documentation

◆ addChildNodeToParent()

void oe::scene::Manager::addChildNodeToParent ( Node child,
Node parent 
)

Attach a child node to a parent one.

Parameters
childChild node
parentParent Node, might be null if the child should be a root node

◆ addNamedNode()

template<typename T = Node, typename... Args>
T & oe::scene::Manager::addNamedNode ( const std::string &  name,
Args &&...  args 
)
inline

Generate a new root node in the the scene.

Parameters
nameNode name
argsArguments to create node (see specific node constructor)

◆ addNode()

template<typename T = Node, typename... Args>
T & oe::scene::Manager::addNode ( Args &&...  args)
inline

Generate a new root node in the the scene.

Parameters
argsArguments to create node (see specific node constructor)

◆ addNodeInGroup()

void oe::scene::Manager::addNodeInGroup ( Node node,
const NodeType  type 
)

Add a node in a group (For example nodes that need to be in specific pass)

Note
A node can be in multiple groups You can call this function multiple times on the same Node

◆ deleteNode()

void oe::scene::Manager::deleteNode ( Node node)

Remove a node from the scene.

Parameters
nodethe node to remove

◆ removeNodeFromAllGroups()

void oe::scene::Manager::removeNodeFromAllGroups ( Node node)

Remove node from all of its groups.

Note
No errors raised if the node isn't part of any group

◆ removeNodeFromGroup()

void oe::scene::Manager::removeNodeFromGroup ( Node node,
const NodeType  type 
)

Remove node from specified group.

Note
No errors raised if the node isn't part of the group

◆ search()

template<typename T = Node>
T * oe::scene::Manager::search ( const std::string  path,
const std::string  separator = "/" 
) const
inline

Search for a node using a name path.

Note
if multiple nodes at same level has same name, only the first one is returned

◆ setCamera() [1/2]

void oe::scene::Manager::setCamera ( Node node)

Set scene camera using a node's camera component.

Note
If no camera component found on node, this function will silently fail and keep the old camera

◆ setCamera() [2/2]

void oe::scene::Manager::setCamera ( Node node,
const std::string &  component_name 
)

Set scene camera using a node's named camera component.

Note
If no camera component found on node, this function will silently fail and keep the old camera

◆ setCameraFromComponent()

template<typename ComponentType >
void oe::scene::Manager::setCameraFromComponent ( ComponentType &  component)
inline

Set scene camera using a component providing a camera.

Note
If no camera component found on node, this function will silently fail and keep the old camera

◆ update()

void oe::scene::Manager::update ( const double  delta,
const int8_t  flags = 0 
)

Update the scene.

Update all component, nodes, etc

The flags value is not used by OxygenEngine, but you can use it to implement differents levels of update For example, other engines uses functions such as BeforeUpdate, PreUpdate, PostUpdate, LateUpdate, etc Here, it would translates to using custom flags values

Note
oe::core::Device::getDeltaTime() returns values ready for this function
Parameters
deltaseconds since last call of this function
flagscustom flags

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