Ocular Engine
Scene.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_CORE_SCENE__H__
19 #define __H__OCULAR_CORE_SCENE__H__
20 
21 #include "SceneTreeType.hpp"
22 #include "UUID.hpp"
23 
24 #include "Math/Geometry/Frustum.hpp"
25 
26 #include <vector>
27 #include <list>
28 #include <queue>
29 #include <functional>
30 
31 //------------------------------------------------------------------------------------------
32 
37 namespace Ocular
38 {
39  namespace Graphics
40  {
41  class UniformBuffer;
42  }
43 
48  namespace Core
49  {
50  class SceneManager;
51  class ISceneTree;
52  class SceneObject;
53  class ARoutine;
54  class Renderer;
55 
70  class Scene
71  {
72  friend class SceneManager;
73 
74  public:
75 
76  virtual ~Scene();
77 
81  void initialize();
82 
87  void addObject(SceneObject* object);
88 
93  void addObjects(std::vector<SceneObject*> const& objects);
94 
103  void removeObject(SceneObject* object);
104 
113  void removeObjects(std::vector<SceneObject*> const& objects);
114 
121  void removeAllObjects();
122 
126  void update();
127 
131  void render();
132 
133  //------------------------------------------------------------------------------
134  // Getters / Setters
135  //------------------------------------------------------------------------------
136 
147  void getVisibleSceneObjects(std::vector<SceneObject*>& objects, Math::Frustum const& frustum);
148 
152  void setStaticTreeType(SceneTreeType type);
153 
157  SceneTreeType const& getStaticTreeType() const;
158 
162  void setDynamicTreeType(SceneTreeType type);
163 
167  SceneTreeType const& getDynamicTreeType() const;
168 
172  void setRendererType(std::string const& string);
173 
177  std::string const& getRendererType() const;
178 
179  protected:
180 
181  Scene();
182 
183  void updateTrees();
184 
185  void updateRoutines();
186  void sortRoutines();
187 
188  //------------------------------------------------------------
189  // Object State Change Methods
190 
197  void objectTreeChanged(SceneObject* object);
198 
206  void objectParentChanged(SceneObject* object, SceneObject* oldParent);
207 
212  void routineAdded(ARoutine* routine);
213 
218  void routineRemoved(ARoutine* routine);
219 
220  void triggerObjectDirty(UUID const& uuid, bool staticObject);
221 
222  private:
223 
224  bool verifySceneTrees() const;
225 
226  //------------------------------------------------------------------------------
227 
228  Renderer* m_Renderer;
229  std::string m_RendererType;
230 
231  Graphics::UniformBuffer* m_UniformBufferPerFrame;
232  Graphics::UniformBuffer* m_UniformBufferPerObject;
233 
234  SceneTreeType m_StaticTreeType;
235  SceneTreeType m_DynamicTreeType;
236 
237  ISceneTree* m_StaticSceneTree;
238  ISceneTree* m_DynamicSceneTree;
239 
240  std::vector<ARoutine*> m_Routines;
241  bool m_RoutinesAreDirty;
242 
243  };
244  }
248 }
253 //------------------------------------------------------------------------------------------
254 
255 #endif
void removeObjects(std::vector< SceneObject * > const &objects)
Definition: Scene.cpp:205
void addObjects(std::vector< SceneObject * > const &objects)
Definition: Scene.cpp:152
void objectParentChanged(SceneObject *object, SceneObject *oldParent)
Definition: Scene.cpp:407
void removeObject(SceneObject *object)
Definition: Scene.cpp:160
void objectTreeChanged(SceneObject *object)
Definition: Scene.cpp:388
void render()
Definition: Scene.cpp:230
Definition: SceneManager.hpp:64
Definition: Frustum.hpp:57
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
void routineRemoved(ARoutine *routine)
Definition: Scene.cpp:473
void addObject(SceneObject *object)
Definition: Scene.cpp:130
Definition: ARoutine.hpp:59
Definition: Scene.hpp:70
void setDynamicTreeType(SceneTreeType type)
Definition: Scene.cpp:317
void getVisibleSceneObjects(std::vector< SceneObject * > &objects, Math::Frustum const &frustum)
Definition: Scene.cpp:294
Definition: SceneObject.hpp:93
Definition: UUID.hpp:45
void update()
Definition: Scene.cpp:224
void setStaticTreeType(SceneTreeType type)
Definition: Scene.cpp:307
Definition: Renderer.hpp:49
void removeAllObjects()
Definition: Scene.cpp:213
Generic buffer for storing and binding of shader uniforms.
Definition: UniformBuffer.hpp:73
Definition: ISceneTree.hpp:51
void routineAdded(ARoutine *routine)
Definition: Scene.cpp:464