Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
Scene.h File Reference

Owns the game object tree and provides per-frame update + light collection. More...

#include <memory>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include "Common.h"
#include "Types.h"
#include "nlohmann/json.hpp"
#include "scene/GameObject.h"
+ Include dependency graph for Scene.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mnd::Scene
 Container for the entire game object graph. More...
 

Namespaces

namespace  mnd
 

Detailed Description

Owns the game object tree and provides per-frame update + light collection.

The Scene is the top-level container for all GameObjects. It owns them via unique_ptr — GameObjects must be created through Scene::CreateObject so that the scene always holds the authoritative lifetime.

Relationship with Engine

The Engine holds one active Scene (Engine::SetScene / Engine::GetScene). Each frame, Engine::Run() calls Scene-level queries to gather CameraData and LightData before handing them to RenderQueue::Draw().

Creating objects

Scene *scene = new Scene();
engine.SetScene(scene);
auto *player = scene->CreateObject("Player");
player->AddComponent(new PlayerControllerComponent());
auto *camera = scene->CreateObject("Camera", player); // child of player
camera->AddComponent(new CameraComponent());
scene->SetMainCamera(camera);
See also
GameObject, Engine::SetScene, CameraData, LightData

Definition in file Scene.h.