i6engine  1.0
GraphicsManager.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_MODULES_GRAPHICSMANAGER_H__
26 #define __I6ENGINE_MODULES_GRAPHICSMANAGER_H__
27 
29 
32 
34 
35 #include "OGRE/OgreFrameListener.h"
36 #include "OGRE/OgreWindowEventUtilities.h"
37 
38 namespace Ogre {
39  class LogManager;
40  class OverlaySystem;
41  class RaySceneQuery;
42  class RenderWindow;
43  class Root;
44  class SceneManager;
45 } /* namespace Ogre */
46 
47 namespace i6e {
48 namespace modules {
49 
50  class Debug;
51  class GraphicsNode;
52  class GraphicsController;
53  class GUIController;
54  class ListenerFactoryLogic;
55  class ResourceManager;
56  class Terrain;
57 
58  class ISIXE_MODULES_API GraphicsManager : public Ogre::WindowEventListener, public Ogre::FrameListener {
59  public:
64 
68  ~GraphicsManager();
69 
74  inline Ogre::Root * getRoot() const { return _objRoot; }
75 
83  inline Ogre::SceneManager * getSceneManager() const { return _sceneManager; }
84 
88  GraphicsNode * getOrCreateGraphicsNode(const int64_t goid, const Vec3 & position = Vec3(0.0, 0.0, 0.0), const Quaternion & rotation = Quaternion(1.0, 0.0, 0.0, 0.0), const Vec3 & scale = Vec3(1.0, 1.0, 1.0));
89 
95  GraphicsNode * getGraphicsNode(const int64_t goid) const;
96 
102  void deleteGraphicsNode(const int64_t goid);
103 
109  void addTerrain(const int64_t id, const boost::shared_ptr<Terrain> & t);
110 
116  void removeTerrain(const int64_t id);
117 
127  void Tick();
128 
138  bool windowClosing(Ogre::RenderWindow * rw);
139 
143  void NewsCreate(const api::GameMessage::Ptr & msg);
144 
148  void NewsUpdate(const api::GameMessage::Ptr & msg);
149 
153  void NewsDelete(const api::GameMessage::Ptr & msg);
154 
158  void NewsNodeCreate(const api::GameMessage::Ptr & msg);
159 
163  void NewsNodeUpdate(const api::GameMessage::Ptr & msg);
164 
168  void NewsNodeDelete(const api::GameMessage::Ptr & msg);
169 
173  void addTicker(GraphicsNode * gn);
174 
178  void removeTicker(GraphicsNode * gn);
179 
180  Ogre::RenderWindow * getRenderWindow() const {
181  return _rWindow;
182  }
183 
184  private:
188  Ogre::RenderWindow * _rWindow;
189 
193  Ogre::Root * _objRoot;
194 
198  Ogre::SceneManager * _sceneManager;
199 
203  std::map<int64_t, GraphicsNode *> _nodes;
204 
208  std::map<int64_t, boost::shared_ptr<Terrain>> _terrains;
209 
213  ResourceManager * _resourceManager;
214 
218  Debug * _debug;
219 
220  Ogre::RaySceneQuery * _raySceneQuery;
221 
225  std::set<GraphicsNode *> _tickers;
226 
230  GUIController * _guiController;
231 
232  GraphicsController * _ctrl;
233 
234  bool _initialized;
235 
236  bool _showFPS;
237 
238  Ogre::OverlaySystem * _overlaySystem;
239 
240  Ogre::LogManager * _logManager;
241 
242  std::vector<ListenerFactoryLogic *> _compositorLogics;
243 
244  void loadResources(const std::string & resourcesFile, const std::function<void(uint16_t)> & callback);
245 
250  bool frameEnded(const Ogre::FrameEvent & evt) override;
251 
255  GraphicsManager(const GraphicsManager &) = delete;
256 
260  GraphicsManager & operator=(const GraphicsManager &) = delete;
261 
263  };
264 
265 } /* namespace modules */
266 } /* namespace i6e */
267 
268 #endif /* __I6ENGINE_MODULES_GRAPHICSMANAGER_H__ */
269 
Saves all graphics-related data associated with one GameObject.
Definition: GraphicsNode.h:61
Class describing a 3d rotation.
Definition: i6eQuaternion.h:58
i6e::math::i6eVector Vec3
Definition: i6eVector.h:309
Responsible for initializing and updating the gui.
Definition: GUIController.h:44
#define ISIXE_MODULES_API
boost::shared_ptr< Message > Ptr
Definition: Message.h:66
i6e::math::i6eQuaternion Quaternion
Implements 3-dimensional vectors.
Definition: i6eVector.h:48
This class is responsible for loading all required resources into memory.
Ogre::RenderWindow * getRenderWindow() const
#define ASSERT_THREAD_SAFETY_HEADER
This class handles the whole Ogre graphics subsystem.
Ogre::SceneManager * getSceneManager() const
Returns a pointer to the sceneManager of the object.
void * HWND
Ogre::Root * getRoot() const
Returns a pointer the root element of the graphics library.