16#ifndef AEONGAMES_SCENE_H
17#define AEONGAMES_SCENE_H
43 Scene& operator= (
const Scene& ) =
delete;
44 Scene (
const Scene& ) =
delete;
51 DLL
void Load ( uint32_t aId );
54 DLL
void Load (
const std::string& aFilename );
58 DLL
void Load (
const void* aBuffer,
size_t aBufferSize );
61 DLL
void SetName (
const char* aName );
64 DLL
const char*
const GetName()
const;
68 DLL Node*
Add ( std::unique_ptr<Node> aNode );
73 DLL Node*
Insert (
size_t aIndex, std::unique_ptr<Node> aNode );
77 DLL std::unique_ptr<Node>
Remove ( Node* aNode );
88 DLL Node*
GetChild (
size_t aIndex )
const;
96 DLL
const Node&
operator[] (
const std::size_t index )
const;
100 DLL Node&
operator[] (
const std::size_t index );
103 DLL
void Update (
const double delta );
107 DLL
void BroadcastMessage ( uint32_t aMessageType,
const void* aMessageData );
115 const std::function<
void ( Node& ) >& aPreamble,
116 const std::function<
void ( Node& ) >& aPostamble );
135 DLL Node*
Find (
const std::function<
bool (
const Node& ) >& aUnaryPredicate )
const;
139 DLL std::string
Serialize (
bool aAsBinary =
true )
const;
142 DLL
void Deserialize (
const std::string& aSerializedScene );
154 DLL
void SetCamera (
const std::string& aNodeName );
170 DLL
void SetNear (
float aNear );
173 DLL
void SetFar (
float aFar );
186 float mFieldOfView{60.0f};
191 std::vector<std::unique_ptr<Node >> mNodes{};
201 std::vector<std::unique_ptr<Node >> mNodeStorage{};
Header for 4x4 matrix class.
#define LoopTraverseDFSPreOrder(...)
Macro generating LoopTraverseDFSPreOrder implementations for const and non-const variants.
4 by 4 matrix in colum mayor order.
Scene graph node representing an entity in the game world.
Abstract base class for rendering backends.
DLL void BroadcastMessage(uint32_t aMessageType, const void *aMessageData)
Broadcast a message to all nodes in the scene.
DLL void Deserialize(const std::string &aSerializedScene)
Deserialize a scene from a string.
DLL const Node * GetCamera() const
Get the current camera node.
DLL void RecursiveTraverseDFSPostOrder(const std::function< void(Node &) > &aAction)
Recursive depth-first post-order traversal of all nodes in the scene.
DLL float GetNear() const
Get the near clipping plane distance.
DLL void SetNear(float aNear)
Set the near clipping plane distance.
DLL std::unique_ptr< Node > RemoveByIndex(size_t aIndex)
Remove a top-level node by index.
DLL void RecursiveTraverseDFSPreOrder(const std::function< void(Node &) > &aAction)
Recursive depth-first pre-order traversal of all nodes in the scene.
DLL void LoopTraverseDFSPostOrder(const std::function< void(Node &) > &aAction)
Iterative depth-first post-order traversal of all nodes in the scene.
DLL void SetFieldOfView(float aFieldOfView)
Set the vertical field of view.
DLL float GetFar() const
Get the far clipping plane distance.
DLL void SetCamera(Node *aNode)
Set rendering camera.
DLL void SetName(const char *aName)
Set the scene name.
DLL Node * Insert(size_t aIndex, std::unique_ptr< Node > aNode)
Insert a top-level node at a specific index.
DLL void SetFar(float aFar)
Set the far clipping plane distance.
DLL const char *const GetName() const
Get the scene name.
DLL void Load(uint32_t aId)
Load a scene from a resource identified by id.
DLL float GetFieldOfView() const
Get the vertical field of view.
DLL Scene()
Construct an empty scene.
DLL size_t GetChildIndex(const Node *aNode) const
Get the index of a top-level child node.
DLL std::string Serialize(bool aAsBinary=true) const
Serialize the scene to a string.
DLL const Node & operator[](const std::size_t index) const
Access a top-level child node by index (const).
DLL size_t GetChildrenCount() const
Get the number of top-level child nodes.
DLL Node * Add(std::unique_ptr< Node > aNode)
Add a top-level node to the scene.
DLL const Matrix4x4 & GetViewMatrix() const
Get the current view matrix.
DLL void Update(const double delta)
Update all nodes in the scene.
DLL void SetViewMatrix(const Matrix4x4 &aMatrix)
Set the view matrix directly.
DLL Node * Find(const std::function< bool(const Node &) > &aUnaryPredicate) const
Find the first node matching a predicate via depth-first search.
DLL Node * GetChild(size_t aIndex) const
Get a top-level child node by index.
DLL std::unique_ptr< Node > Remove(Node *aNode)
Remove a top-level node by pointer.
<- This is here just for the literals