CmSceneManager.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmModule.h"
  4. namespace CamelotEngine
  5. {
  6. /**
  7. * @brief Manages all objects in the scene and provides various query methods
  8. * for finding objects you need. This is just the base class with basic
  9. * query functionality. You should override it with your own version that
  10. * implements a spatial data structure of your choice for faster queries.
  11. */
  12. class CM_EXPORT SceneManager : public Module<SceneManager>
  13. {
  14. public:
  15. SceneManager();
  16. virtual ~SceneManager();
  17. GameObjectPtr getRootNode() const { return mRootNode; }
  18. virtual void update();
  19. /**
  20. * @brief Returns all cameras in the scene.
  21. */
  22. const vector<CameraPtr>::type& getAllCameras() const { return mCachedCameras; }
  23. vector<RenderablePtr>::type getVisibleRenderables(const CameraPtr camera) const;
  24. private:
  25. friend class GameObject;
  26. GameObjectPtr mRootNode;
  27. /**
  28. * @brief Register a new node in the scene manager, on the top-most level of the hierarchy.
  29. *
  30. * @note After you add a node in the scene manager, it takes ownership of its memory and is responsible for releasing it.
  31. * Do NOT add nodes that have already been added (i.e. if you just want to change their parent). Normally this method will only be called by GameObject.
  32. *
  33. * @param [in] node Node you wish to add. It's your responsibility not to add duplicate or null nodes. This method won't check.
  34. */
  35. void registerNewGO(GameObjectPtr node);
  36. void notifyComponentAdded(ComponentPtr component);
  37. void notifyComponentRemoved(ComponentPtr component);
  38. vector<CameraPtr>::type mCachedCameras;
  39. };
  40. CM_EXPORT SceneManager& gSceneManager();
  41. }