CmSceneManager.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. /**
  19. * @brief Returns all cameras in the scene.
  20. */
  21. const vector<CameraPtr>::type& getAllCameras() const { return mCachedCameras; }
  22. vector<RenderablePtr>::type getVisibleRenderables(const CameraPtr camera) const;
  23. private:
  24. friend class GameObject;
  25. GameObjectPtr mRootNode;
  26. /**
  27. * @brief Register a new node in the scene manager, on the top-most level of the hierarchy.
  28. *
  29. * @note After you add a node in the scene manager, it takes ownership of its memory and is responsible for releasing it.
  30. * 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.
  31. *
  32. * @param [in] node Node you wish to add. It's your responsibility not to add duplicate or null nodes. This method won't check.
  33. */
  34. void registerNewGO(GameObjectPtr node);
  35. void notifyComponentAdded(ComponentPtr component);
  36. void notifyComponentRemoved(ComponentPtr component);
  37. vector<CameraPtr>::type mCachedCameras;
  38. };
  39. CM_EXPORT SceneManager& gSceneManager();
  40. }