Elevate Engine 1
Loading...
Searching...
No Matches
Scene.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <entt/entt.hpp>
5
10
12
13// Forward declarations
14namespace Elevate {
15 class Cubemap;
16 class Shader;
17 class GameObject;
18 class Camera;
19 class ComponentRegistry;
20 class RendererAPI;
21}
22
23namespace Elevate
24{
25 class Scene;
26 using ScenePtr = std::shared_ptr<Scene>;
27
33
34 class Scene : public ISerializable
35 {
36 public:
37 Scene();
38 Scene(std::string name, SceneType type = SceneType::RuntimeScene);
39 //~Scene(); // todo check if we remove in the future
40 ~Scene() = default;
41
42 void UpdateScene();
43 void RenderScene(Camera* cam = nullptr);
44 void Notify(Event& event); // Dispatch an event to gameobjects
46
47 inline const std::string& GetName() const { return m_name; };
48
49 void AddObject(std::shared_ptr<GameObject> newObject, std::shared_ptr<GameObject> parent);
50 const std::set<std::shared_ptr<GameObject>> GetRootObjects() const { return m_rootObjects; }
51
52 inline SceneType GetType() { return m_type; }
53
54 static ScenePtr Create(std::string name, SceneType type = SceneType::RuntimeScene);
55
56 // Cubemap
57 void SetSkybox(const std::string& skyboxFilePath);
58 std::weak_ptr<Cubemap> GetSkybox();
59
60 inline void SetLighting(std::unique_ptr<SceneLighting> newLighting)
61 {
62 m_sceneLighting = std::move(newLighting);
63 }
65 {
66 return m_sceneLighting.get();
67 }
68
69 std::string Serialize() const override;
70 private:
71 void RemoveFromRoot(std::shared_ptr<GameObject> object);
72 void AddRootObject(std::shared_ptr<GameObject> newRootObject);
73
74 private:
75 static uint32_t s_nextRegistryId;
76
77 private:
78 std::string m_name;
79 SceneType m_type;
80
81 uint32_t m_registryId; // Component registry id for all entt::entity
82
83 // TODO ENLEVER ON VA REMPLACER PAR LE REGISTRY ENTT OU EXTENDRE LA CLASSE GAMEOBJECT
84 std::set<std::shared_ptr<GameObject>> m_rootObjects;
85
86 std::shared_ptr<Cubemap> m_cubemap;
87 std::unique_ptr<SceneLighting> m_sceneLighting = nullptr;
88
89 friend class GameObject;
90 friend class ComponentRegistry;
91 };
92}
void Notify(Event &event)
Definition Scene.cpp:123
static ScenePtr Create(std::string name, SceneType type=SceneType::RuntimeScene)
Definition Scene.cpp:153
void SubmitDrawCalls(RendererAPI &renderer)
void UpdateScene()
Definition Scene.cpp:50
void AddObject(std::shared_ptr< GameObject > newObject, std::shared_ptr< GameObject > parent)
Definition Scene.cpp:131
~Scene()=default
void RenderScene(Camera *cam=nullptr)
Definition Scene.cpp:63
void SetSkybox(const std::string &skyboxFilePath)
Definition Scene.cpp:161
std::weak_ptr< Cubemap > GetSkybox()
Definition Scene.cpp:166
const SceneLighting * GetSceneLighting()
Definition Scene.h:64
SceneType GetType()
Definition Scene.h:52
std::string Serialize() const override
Definition Scene.cpp:183
void SetLighting(std::unique_ptr< SceneLighting > newLighting)
Definition Scene.h:60
const std::string & GetName() const
Definition Scene.h:47
const std::set< std::shared_ptr< GameObject > > GetRootObjects() const
Definition Scene.h:50
SceneType
Definition Scene.h:28
@ RuntimeScene
Definition Scene.h:29
@ DebugScene
Definition Scene.h:31
@ EditorScene
Definition Scene.h:30
std::shared_ptr< Scene > ScenePtr
Definition Renderer.h:12