|
Monad Engine da02fba2
> Undercity Codex_
|
Container for the entire game object graph. More...
#include <Scene.h>
Public Member Functions | |
| void | Update (f32 deltaTime) |
| void | Clear () |
| Destroy all objects and reset the scene to an empty state. | |
| GameObject * | CreateObject (const std::string &name, GameObject *parent=nullptr) |
| Create a plain GameObject owned by this scene. | |
| GameObject * | CreateObject (const std::string &type, const std::string &name, GameObject *parent=nullptr) |
| template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<GameObject, T>>> | |
| T * | CreateObject (const str &name, GameObject *parent=nullptr) |
| Create a typed GameObject subclass owned by this scene. | |
| bool | SetParent (GameObject *obj, GameObject *parent) |
| Move a GameObject in the hierarchy. | |
| void | SetMainCamera (GameObject *camera) |
| Designate the camera object whose CameraComponent drives the view. | |
| GameObject * | GetMainCamera () |
| Returns the current main camera object (set via SetMainCamera). | |
| std::vector< LightData > | CollectLight () |
| Walk the entire object tree and collect all LightData. | |
| const std::vector< std::unique_ptr< GameObject > > & | GetRootObjects () const |
| Editor access: iterate root GameObjects (non-owning). | |
Static Public Member Functions | |
| static void | RegisterTypes () |
| Update all root objects (which recursively update their children). | |
| static std::shared_ptr< Scene > | Load (const str &path) |
Container for the entire game object graph.
Owns root-level GameObjects and provides the three services that Engine::Run() needs each frame:
| void mnd::Scene::Clear | ( | ) |
| std::vector< LightData > mnd::Scene::CollectLight | ( | ) |
Walk the entire object tree and collect all LightData.
Called by Engine::Run() once per frame. Each GameObject that has a LightComponent contributes one LightData entry.
| GameObject * mnd::Scene::CreateObject | ( | const std::string & | name, |
| GameObject * | parent = nullptr |
||
| ) |
Create a plain GameObject owned by this scene.
| name | Display name for the new object. |
| parent | Optional parent; makes the object a child rather than a root. |
Definition at line 132 of file Scene.cpp.
References mnd::GameObject::GetName(), kRootObjectLabel, LOG_INFO, mnd::GameObject::SetName(), and SetParent().
Referenced by mnd::ModelImporter::Import(), mnd::GameObject::LoadGLTF(), and mnd::ParseGLTFNode().
| GameObject * mnd::Scene::CreateObject | ( | const std::string & | type, |
| const std::string & | name, | ||
| GameObject * | parent = nullptr |
||
| ) |
Definition at line 114 of file Scene.cpp.
References mnd::GameObjectFactory::CreateGameObject(), mnd::GameObjectFactory::GetInstance(), mnd::GameObject::SetName(), and SetParent().
|
inline |
Create a typed GameObject subclass owned by this scene.
Use this overload when you need to store extra data directly on the GameObject instead of in a Component.
| T | A class derived from GameObject. |
| name | Display name. |
| parent | Optional parent node. |
Definition at line 92 of file Scene.h.
References SetParent(), and mnd::T.
| GameObject * mnd::Scene::GetMainCamera | ( | ) |
|
inline |
Definition at line 266 of file Scene.cpp.
References mnd::Engine::GetFileSystem(), mnd::Engine::GetInstance(), kDefaultSceneName, kJsonKeyCamera, kJsonKeyName, kJsonKeyObjects, mnd::FileSystem::LoadAssetFileText(), LOG_ERROR, LOG_INFO, LOG_WARN, and mnd::Engine::UpdateLoadingProgress().
|
static |
Update all root objects (which recursively update their children).
| deltaTime | Seconds since the previous frame. |
Definition at line 29 of file Scene.cpp.
Referenced by mnd::Engine::Init().
| void mnd::Scene::SetMainCamera | ( | GameObject * | camera | ) |
Designate the camera object whose CameraComponent drives the view.
| camera | A GameObject that must have a CameraComponent attached. |
| bool mnd::Scene::SetParent | ( | GameObject * | obj, |
| GameObject * | parent | ||
| ) |
Move a GameObject in the hierarchy.
| obj | The object to re-parent. |
| parent | New parent, or nullptr to promote to root. |
Definition at line 339 of file Scene.cpp.
References mnd::GameObject::GetName(), mnd::GameObject::GetParent(), LOG_ERROR, and LOG_WARN.
Referenced by CreateObject(), CreateObject(), CreateObject(), mnd::GameObject::SetParent(), and Update().
| void mnd::Scene::Update | ( | f32 | deltaTime | ) |
Definition at line 44 of file Scene.cpp.
References SetParent().