AnnEngine.cpp
Go to the documentation of this file.
1 // This is an open source non-commercial project. Dear PVS-Studio, please check it.
2 // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3 
4 #include "AnnEngine.hpp"
5 #include "AnnLogger.hpp"
6 #include "AnnException.hpp"
7 
8 //Include the built-in renderer that doesn't do VR
10 
11 #ifdef _WIN32
12 #include <io.h>
13 #include <fcntl.h>
14 #endif
15 
16 using namespace Annwvyn;
17 
19 
21 bool AnnEngine::noConsoleColor{ false };
22 bool AnnEngine::consoleReady{ false };
23 bool AnnEngine::manualConsole{ false };
24 std::string AnnEngine::logFileName{ "Annwvyn.log" };
26 
28 
29 #ifdef _WIN32
30 WORD AnnEngine::consoleGreen{ FOREGROUND_GREEN | FOREGROUND_INTENSITY };
31 WORD AnnEngine::consoleYellow{ FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY };
32 WORD AnnEngine::consoleWhite{ FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY };
33 #endif
34 
36 
38 {
39  engine = address;
40 }
41 
43 {
44  //Reset static members of friend class AnnEnigine that will outlive the object itself.
45  engine->singleton = nullptr;
46  engine->consoleReady = false;
47  engine->dynamicLibraries.clear();
48 }
49 
50 void AnnEngine::setDefaultRenderer(const char* renderer)
51 {
53 }
54 
57 
59 {
60  static std::string versionString{ "" };
61  if(!versionString.empty() && !padding) return versionString;
62 
63  if(versionString.empty())
64  {
65  std::stringstream version;
66  version << ANN_MAJOR << "." << ANN_MINOR << "." << ANN_PATCH;
68  version << "-experimental";
69  versionString = version.str();
70  }
71 
72  if(padding)
73  {
74  auto padded = versionString;
75 
76  padding -= padded.length();
77  for(auto i(0); i < padding; i++)
78  padded.push_back(' ');
79 
80  return padded;
81  }
82 
83  return versionString;
84 }
85 
87 {
88  while(refresh())
89  {
90  }
91 }
92 
93 void AnnEngine::selectAndCreateRenderer(const std::string& selectedRenderer, const std::string& title)
94 {
95  std::cerr << "Rendering VR target selection string : "
96  << selectedRenderer << std::endl;
97 
98  if(selectedRenderer == "DefaultRender" && (!defaultRenderer.empty() && (defaultRenderer != "DefaultRender")))
99  {
100  std::cerr << "Using the default renderer " << defaultRenderer << " as target\n";
101  std::cerr << "Re-running the renderer selection test...\n";
103  return;
104  }
105 
106  auto set{ false };
107 
108  std::cerr << "Looking for " << selectedRenderer << " in registered renderers\n";
109 
110  if(registeredRenderers.size() == 0)
111  std::cerr << "No renderer has been registered!\n";
112 
113  if(registeredRenderers.find(selectedRenderer) != std::end(registeredRenderers))
114  {
115  std::cerr << "found registered render!\n";
117  set = true;
118  }
119 
120  //Attempt to see if the application requested the built-in one (that doesn't do VR)
121  else if(selectedRenderer == "NoVR")
122  {
123  std::cerr << "User requested NOT to render in VR. Instantiating the built-in NoVR\n";
124  renderer = std::make_shared<AnnOgreNoVRRenderer>(title);
125  set = true;
126  }
127 
128  if(!set)
129  {
130 #ifdef _WIN32
132  "Error: Cannot understand VR System you want to use!",
133  "//TODO write error message");
134 #endif
135 
136  std::cerr << "It looks like we can't start the VR renderer. The engine is going to crash\n."
137  << "Dumping in standard error the current configuration : \n"
138  << "The default renderer is:" << defaultRenderer << '\n'
139  << "The selectedRenderer is: " << selectedRenderer << '\n';
140  if(renderer == nullptr) std::cerr << "The renderer is currently nullptr\n";
141 
142  throw AnnInitializationError(ANN_ERR_CANTHMD, "Can't find an HMD to use");
143  }
144 }
145 
147 {
148  //Check if we don't have this already registered
149  auto findResult = registeredRenderers.find(name);
150  if(findResult != registeredRenderers.end()) return true;
151 
152  AnnDebug() << "Looking for renderer : " << name;
153 #ifdef _DEBUG
154  const auto pluginName = "AnnOgre" + name + "Renderer_d";
155 #else
156  const auto pluginName = "AnnOgre" + name + "Renderer";
157 #endif
158  const auto boostrapFunctionName = "AnnRendererBootstrap_" + name;
159 
160 #ifdef _WIN32
161  auto dll = LoadLibraryA(pluginName.c_str());
162  if(dll)
163  {
164  AnnDebug() << "Found plugin library";
165  dynamicLibraries.push_back(std::move(std::make_unique<AnnDynamicLibraryHolder>(dll)));
166  auto functionPointer = GetProcAddress(dll, boostrapFunctionName.c_str());
167  if(functionPointer)
168  {
170  AnnDebug(Log::Important) << "Sucessfully registered " << name << " renderer!";
171  return true;
172  }
173  AnnDebug() << "Loaded " << pluginName << ".dll, but couldn't find symbol " << boostrapFunctionName;
174  return false;
175  }
176  AnnDebug(Log::Important) << "Could not find DLL for " << name << " renderer";
177  AnnDebug(Log::Important) << "Your executable should be able to find " << pluginName << ".dll somewhere!";
178 
179 #elif __linux__
180 
181  auto pluginNameSo = "lib" + pluginName + ".so";
182  auto library = dlopen(pluginNameSo.c_str(), RTLD_NOW);
183  if(library)
184  {
185  AnnDebug() << "Found plugin library";
186  dynamicLibraries.push_back(std::move(std::make_unique<AnnDynamicLibraryHolder>(library)));
187  auto fptr = dlsym(library, boostrapFunctionName.c_str());
188  if(fptr)
189  {
191  AnnDebug(Log::Important) << "Sucessfully registered " << name << " renderer!";
192  return true;
193  }
194  AnnDebug() << "Loaded " << pluginName << ", but couldn't find symbol " << boostrapFunctionName << '\n';
195  return false;
196  }
197  AnnDebug(Log::Important) << "Could not find lbrary file for " << name << " renderer!";
198  AnnDebug(Log::Important) << "Your executable should be able to find " << pluginName << " in your LD library path (hint, run ldconfig...)!";
199 
200 #endif
201 
202  return false;
203 }
204 
206 {
207  registeredRenderers[name] = boostrapFunctionPointer;
208 }
209 
210 void AnnEngine::setLogFileName(const char* logName)
211 {
212  logFileName = logName;
213 }
214 
215 AnnEngine::AnnEngine(const char title[], const std::string& hmdCommand) :
216  resetGuard(this),
217  applicationQuitRequested(false),
218  renderer(nullptr),
219  resourceManager(nullptr),
220  sceneryManager(nullptr),
221  filesystemManager(nullptr),
222  audioEngine(nullptr),
223  eventManager(nullptr),
224  physicsEngine(nullptr),
225  gameObjectManager(nullptr),
226  levelManager(nullptr),
227  player(nullptr),
228  SceneManager(nullptr),
229  vrRendererPovGameplayPlacement(nullptr),
230  updateTime(-1)
231 {
232  if(singleton)
233  {
234  writeToLog("Can't create 2 instances of the engine!");
235  throw AnnInitializationError(ANN_ERR_MEMORY, "Can't create 2 instances of AnnEngine");
236  }
237 
238  singleton = this;
239  consoleReady = false;
240 
241 #ifdef _WIN32 //Windows specific setup
242 
243  //Set current process to high priority.
244  //Looks like the scheduler of Windows sometimes don't give use the time we need to be consistent.
245  //This seems to fixes the problem.
248 
249 #endif //WIN32
250 
251  stringUtility = std::make_shared<AnnStringUility>();
252 
253  selectAndCreateRenderer(hmdCommand, title);
254  renderer->initOgreRoot(logFileName);
255  player = std::make_shared<AnnPlayerBody>();
256  renderer->initVrHmd();
257  renderer->initPipeline();
258  SceneManager = renderer->getSceneManager();
259  renderer->showDebug(AnnOgreVRRenderer::DebugMode::MONOSCOPIC);
260 
261  writeToLog("Setup Annwvyn's subsystems");
262 
263  // Subsystems are updated in their creation order :
264  // - level management is handeled
265  // - object management is handeled
266  // - physics is ticked (stuff move)
267  // - event happens (player input, timers...)
268  // - audio is synced (sounds comes form where they should)
269  // - other less important operation are done
270  // then the game can redraw
271 
272  subsystems.push_back(levelManager = std::make_shared<AnnLevelManager>());
273  subsystems.push_back(gameObjectManager = std::make_shared<AnnGameObjectManager>());
274  subsystems.push_back(physicsEngine = std::make_shared<AnnPhysicsEngine>(getSceneManager()->getRootSceneNode(), player));
275  subsystems.push_back(eventManager = std::make_shared<AnnEventManager>(renderer->getWindow()));
276  subsystems.push_back(audioEngine = std::make_shared<AnnAudioEngine>());
277  subsystems.push_back(filesystemManager = std::make_shared<AnnFilesystemManager>(title));
278  subsystems.push_back(resourceManager = std::make_shared<AnnResourceManager>());
279  subsystems.push_back(sceneryManager = std::make_shared<AnnSceneryManager>(renderer));
280  subsystems.push_back(scriptManager = std::make_shared<AnnScriptManager>());
281  renderer->initClientHmdRendering();
282 
283  vrRendererPovGameplayPlacement = renderer->getCameraInformationNode();
284  vrRendererPovGameplayPlacement->setPosition(player->getPosition() + AnnVect3(0.0f, player->getEyesHeight(), 0.0f));
285 
286  //This subsystem need the vrRendererPovGameplayPlacement object to be
287  //initialized. And the Resource manager because it wants a font file and an
288  //image background
289  subsystems.push_back(onScreenConsole = std::make_shared<AnnConsole>());
290 
291  consoleReady = true;
292  //Display start banner
293  writeToLog("============================================================", false);
294  writeToLog("| Annwvyn Game Engine - Step into the Other World |", false);
295  writeToLog("| Free/Libre C++ Game Engine designed for Virtual Reality |", false);
296  writeToLog("| |", false);
297  writeToLog("| Copyright Arthur Brainville (a.k.a. Ybalrid) 2013-2018 |", false);
298  writeToLog("| Distributed under the terms of the MIT license agreement |", false);
299  writeToLog("| |", false);
300  writeToLog("| Visit https://wwwannwvyn.org/ for more informations! |", false);
301  writeToLog("| Version : " + getAnnwvynVersion(61 - 13 - 1) + "|", false);
302  writeToLog("============================================================", false);
303 }
304 
306 {
307  //Some cute log messages
308  writeToLog("Game engine stopped. Subsystem are shutting down...");
309  writeToLog("Good luck with the real world now! :3");
310  consoleReady = false;
311 #ifdef _WIN32
312  if(manualConsole) FreeConsole();
313 #endif
314 }
315 
316 //All theses getter are for encapsulation purpose. Calling them directly would
317 //make very long lines of code. You can, but you should use the functions in
318 //AnnGetter.hpp
331 Ogre::SceneManager* AnnEngine::getSceneManager() const { return SceneManager; }
332 unsigned long AnnEngine::getTimeFromStartUp() const { return renderer->getTimer()->getMilliseconds(); }
333 double AnnEngine::getTimeFromStartupSeconds() const { return double(getTimeFromStartUp()) / 1000.0; }
338 
340 {
341 #ifdef _WIN32
342  if(!noConsoleColor)
343  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), consoleGreen);
344 #endif
345 }
346 
348 {
349 #ifdef _WIN32
350  if(!noConsoleColor)
351  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), consoleYellow);
352 #endif
353 }
354 
355 //This is static, but actually needs Ogre to be running. So be careful
356 void AnnEngine::writeToLog(std::string message, bool flag)
357 {
358  if(consoleReady)
359  singleton->onScreenConsole->append(message);
360 
361  if(flag)
362  {
364  message = "Annwvyn - " + message;
365  }
366  else
367  {
368  setConsoleGreen();
369  }
370 
371  if(Ogre::LogManager::getSingletonPtr())
372  Ogre::LogManager::getSingleton().logMessage(message);
373  else
374  std::cout << message << '\n';
375 
376  setConsoleGreen();
377 }
378 
379 //Need to be redone.
381 {
382  //If the user quit the App from the Oculus Home
383  if(renderer->shouldQuit())
384  return true;
386  return true;
387 
388  return false;
389 }
390 
391 // This is the most important function of the whole project. It's the heartbeat
392 // of the game or app using this engine.
394 {
395  //Set player position from gameplay to the rendering code
396  syncPalyerPov();
397  //Update VR form real world
398  renderer->updateTracking();
399 
400  updateTime = renderer->getUpdateTime();
401  player->engineUpdate(float(getFrameTime()));
402 
403  for(size_t i{ 0 }; i < subsystems.size(); ++i)
404  if(subsystems[i]->needUpdate())
405  subsystems[i]->update();
406 
407  //Update view
408  renderer->renderAndSubmitFrame();
409  return !checkNeedToQuit();
410 }
411 
413 {
414  vrRendererPovGameplayPlacement->setPosition(player->getPosition());
415  vrRendererPovGameplayPlacement->setOrientation(player->getOrientation().toQuaternion());
416 }
417 
418 //Bad. Don't use. Register an event listener and use the KeyEvent callback.
419 inline bool AnnEngine::isKeyDown(OIS::KeyCode key) const
420 {
421  if(!eventManager) return false;
422  return eventManager->Keyboard->isKeyDown(key);
423 }
424 
425 //the delta time of the last frame, not the current one
426 double AnnEngine::getFrameTime() const { return updateTime; }
427 
428 // Raw position and orientation of the head in world space. This is useful if
429 // you want to mess around with weird stuff. This has been bodged when I
430 // integrated a LEAP motion in that mess.
432 {
433  if(renderer)
434  return renderer->trackedHeadPose;
435  return AnnPose();
436 }
437 
439 {
440  for(const auto system : subsystems)
441  if(userSystem->name == system->name)
442  {
443  AnnDebug() << "A subsystem with the name "
444  << userSystem->name
445  << "is already registered.";
446 
447  return nullptr;
448  }
449  subsystems.push_back(userSystem);
450  return userSystem;
451 }
452 
453 void AnnEngine::loadUserSubSystemFromPlugin(const std::string& pluginName, bool local)
454 {
455  AnnDebug(Log::Important) << "Attempting to load an user subsystem from" << pluginName;
456  std::string bootstrapName = "AnnBootPlugin_";
457  bootstrapName += pluginName;
458 #ifdef _WIN32
459  if(const auto handle = LoadLibraryA(pluginName.c_str()))
460  {
461  AnnDebug(Log::Important) << "Sucessully loadded dynamic libray";
462  dynamicLibraries.push_back(std::move(std::make_unique<AnnDynamicLibraryHolder>(handle)));
463  if(const auto bootstrapPlugin = GetProcAddress(handle, bootstrapName.c_str()))
464  {
465  AnnDebug() << "Found address of bootstrap funciton for " << pluginName;
466  AnnDebug() << "Create and register subsystem...";
467  registerUserSubSystem(AnnUserSubSystemPtr{ reinterpret_cast<AnnUserSubSystem*>(bootstrapPlugin()) });
468  }
469  else
470  {
471  AnnDebug(Log::Important) << "Wasn't able to get boostrap function for " << pluginName;
472  }
473  }
474  else
475  {
476  AnnDebug(Log::Important) << "Wasn't able to load dynamic library " << pluginName;
477  }
478 
479 #else
480  //convert "PluginName" into a "libPluginName.so" format as dlopen need the name of the actual file
481  std::string pluginSoFile = (local ? "./lib" : "lib");
482  pluginSoFile += pluginName;
483  pluginSoFile += ".so";
484 
485  if(auto handle = dlopen(pluginSoFile.c_str(), RTLD_NOW))
486  {
487  AnnDebug(Log::Important) << "Sucessully loadded dynamic libray";
488  dynamicLibraries.push_back(std::move(std::make_unique<AnnDynamicLibraryHolder>(handle)));
489  if(auto bootstrapPlugin = (void* (*)())dlsym(handle, bootstrapName.c_str())) //We need to cast the pointer to a functor of the "void* boostrap(void)" format
490  {
491  AnnDebug() << "Found address of bootstrap funciton for " << pluginName;
492  AnnDebug() << "Create and register subsystem...";
493  registerUserSubSystem(AnnUserSubSystemPtr(reinterpret_cast<AnnUserSubSystem*>(bootstrapPlugin())));
494  }
495  else
496  {
497  AnnDebug(Log::Important) << "Wasn't able to get bootsrap function for " << pluginSoFile;
498  }
499  }
500  else
501  {
502  AnnDebug(Log::Important) << "Wasn't able to load dynamic library " << pluginName;
503  }
504 
505 #endif
506 }
507 
509 {
510  auto result = std::find_if(std::begin(subsystems),
512  [&](AnnSubSystemPtr s) {
513  return s->name == name;
514  });
515 
516  if(result == std::end(subsystems)) return nullptr;
517  return *result;
518 }
519 
521 {
522  const auto nakedSubSystem(subsystem.get());
523  const auto result = dynamic_cast<AnnUserSubSystem*>(nakedSubSystem);
524  return result != nullptr;
525 }
526 
528 {
529  subsystems.erase(std::remove(
532  subsystem),
534 }
535 
536 //Because Windows and the Win32 platform sucks.
538 {
539  auto state{ true };
540 #ifdef _WIN32
541 
542  //Allocate a console for this app
543  if(AllocConsole())
544  {
545  //put stdout on this console;
546  FILE* f;
547  const auto err = freopen_s(&f, "CONOUT$", "w", stdout);
548  if(!f) state = false;
549  if(err != 0) state = false;
550  manualConsole = true;
551  }
552 
553  //Redirect cerr to cout
554  std::cerr.rdbuf(std::cout.rdbuf());
555 
556  SetConsoleTitleA("Annwvyn Debug Console");
557  if(!noConsoleColor)
558  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
559  consoleWhite);
560 
561 #endif
562  return state;
563 }
564 
566 {
567  return renderer->isVisibleInHmd();
568 }
569 
571 {
572 #ifdef _WIN32
573  SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
574 #endif
575 }
576 
578 {
579 #ifdef _WIN32
580  SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
581 #endif
582 }
583 
AnnStringUtilityPtr stringUtility
String Utility;.
Definition: AnnEngine.hpp:273
T empty(T... args)
AnnEventManagerPtr getEventManager() const
Get the event manager.
Definition: AnnEngine.cpp:319
AnnConsolePtr onScreenConsole
The onScreenConsole object.
Definition: AnnEngine.hpp:277
void displayWin32ErrorMessage(const std::string &title, const std::string &content)
void initPlayerStandingPhysics() const
Init the static/standing physics model.
Definition: AnnEngine.cpp:334
AnnFilesystemManagerPtr getFileSystemManager() const
Get the file-system manager.
Definition: AnnEngine.cpp:327
std::shared_ptr< AnnUserSubSystem > AnnUserSubSystemPtr
void loadUserSubSystemFromPlugin(const std::string &pluginName, bool local=true)
Load and register an user subsystem from a dynamic library (DLL)
Definition: AnnEngine.cpp:453
AnnConsolePtr getOnScreenConsole() const
Get the console.
Definition: AnnEngine.cpp:336
AnnSceneryManagerPtr getSceneryManager() const
Get the SceneryManager.
Definition: AnnEngine.cpp:322
static AnnEngine * singleton
the singleton address itself is stored here
Definition: AnnEngine.hpp:75
void startGameplayLoop()
This start the render loop. This also calls objects "update" and current level "runLogic" methods eac...
Definition: AnnEngine.cpp:86
#define ANN_PATCH
Definition: AnnEngine.hpp:13
AnnOgreVRRenderer *(*)(const std::string &appName) AnnOgreVRRendererBootstrapFunction
Definition: AnnEngine.hpp:55
AnnSubSystemPtr getSubSystemByName(const std::string &name)
Get pointer to a subsystem by name.
Definition: AnnEngine.cpp:508
static bool registerVRRenderer(const std::string &name)
Register a renderer "plugin". Calls it before AnnInit.
Definition: AnnEngine.cpp:146
static void setProcessPriorityNormal()
Set the process priority to "normal".
Definition: AnnEngine.cpp:570
AnnLevelManagerPtr levelManager
LevelManager.
Definition: AnnEngine.hpp:293
T endl(T... args)
Main engine class. Creating an instance of this class make the engine start.
Definition: AnnEngine.hpp:70
AnnResourceManagerPtr getResourceManager() const
Get the ResourceManager.
Definition: AnnEngine.cpp:320
A 3D Vector.
Definition: AnnVect3.hpp:16
T end(T... args)
AnnFilesystemManagerPtr filesystemManager
FilesystemManager.
Definition: AnnEngine.hpp:283
#define ANN_EXPERIMENTAL
Definition: AnnEngine.hpp:14
Namespace containing the totality of Annwvyn components.
Definition: AnnGetter.cpp:8
static std::string getAnnwvynVersion(size_t padding=0)
Return a string describing the version of the engine.
Definition: AnnEngine.cpp:58
T remove(T... args)
void selectAndCreateRenderer(const std::string &hmd, const std::string &title)
Private method that configure the rendering from the two given strings. It may call itself again with...
Definition: AnnEngine.cpp:93
AnnResourceManagerPtr resourceManager
ResourceManager.
Definition: AnnEngine.hpp:279
Ogre::SceneNode * vrRendererPovGameplayPlacement
Point Of View : Node used as "root" for putting the VR "camera rig".
Definition: AnnEngine.hpp:302
Exception regarding engine utilisation. See message.
#define ANN_ERR_MEMORY
#define ANN_MINOR
Definition: AnnEngine.hpp:12
AnnPlayerBodyPtr getPlayer() const
Get the player.
Definition: AnnEngine.cpp:326
A pose refer to the combination of a position and an orientation. It permit to define the placement o...
static void setConsoleGreen()
Definition: AnnEngine.cpp:339
static bool manualConsole
If true, a console was manually allocated.
Definition: AnnEngine.hpp:265
AnnScriptManagerPtr scriptManager
ScriptManager.
Definition: AnnEngine.hpp:295
AnnPlayerBodyPtr player
Player.
Definition: AnnEngine.hpp:297
static bool autosetProcessPriorityHigh
Public flag, true by default : will ask Windows to give us high priority.
Definition: AnnEngine.hpp:100
DEPRECATED AnnPose getHmdPose() const
Get the pose of the HMD in VR world space.
Definition: AnnEngine.cpp:431
void requestQuit()
Permit.
Definition: AnnEngine.cpp:584
bool refresh()
Refresh all for you.
Definition: AnnEngine.cpp:393
~AnnEngine()
Class destructor. Do clean up stuff.
Definition: AnnEngine.cpp:305
AnnEngine(const char title[], const std::string &hmdCommand="DefaultRender")
Definition: AnnEngine.cpp:215
static std::vector< AnnUniqueDynamicLibraryHolder > dynamicLibraries
loaded libraries
Definition: AnnEngine.hpp:270
Create a ostream to the Ogre logger.
static bool openConsole()
Definition: AnnEngine.cpp:537
Ogre::SceneManager * getSceneManager() const
Get ogre scene manager.
Definition: AnnEngine.cpp:331
bool appVisibleInHMD() const
Return true if the app is visible inside the head mounted display.
Definition: AnnEngine.cpp:565
AnnOgreVRRendererPtr renderer
VR renderer.
Definition: AnnEngine.hpp:275
AnnGameObjectManagerPtr getGameObjectManager() const
Get the GameObjectManager.
Definition: AnnEngine.cpp:321
#define ANN_MAJOR
Definition: AnnEngine.hpp:11
double getFrameTime() const
Get elapsed time between two frames in seconds.
Definition: AnnEngine.cpp:426
void removeUserSubSystem(AnnUserSubSystemPtr subsystem)
Remove a subsystem form the engine. Only works if the system has been user defined.
Definition: AnnEngine.cpp:527
AnnUserSubSystemPtr registerUserSubSystem(AnnUserSubSystemPtr userSystem)
Register your own subsystem to be updated by the engine.
Definition: AnnEngine.cpp:438
T str(T... args)
AnnAudioEnginePtr audioEngine
Audio engine.
Definition: AnnEngine.hpp:285
Open an output stream to the engine log.
Definition: AnnLogger.hpp:24
double getTimeFromStartupSeconds() const
Get elapsed time from engine startup in seconds.
Definition: AnnEngine.cpp:333
static void setConsoleYellow()
Definition: AnnEngine.cpp:347
std::vector< AnnSubSystemPtr > subsystems
Container for all the subsystem. Populated in the update/delete order.
Definition: AnnEngine.hpp:308
static void setNoConsoleColor()
Set a flag that prevent Annwvyn to attempt to put colors on the console window.
Definition: AnnEngine.cpp:55
static void setProcessPriorityHigh()
Set the process priority to "high".
Definition: AnnEngine.cpp:577
static bool consoleReady
If true, there&#39;s a console to output log.
Definition: AnnEngine.hpp:261
AnnLevelManagerPtr getLevelManager() const
Get the current level manager.
Definition: AnnEngine.cpp:325
T move(T... args)
AnnOgreVRRendererPtr getVRRenderer() const
Get the VRRenderer.
Definition: AnnEngine.cpp:324
static void writeToLog(std::string message, bool flag=true)
Definition: AnnEngine.cpp:356
void syncPalyerPov() const
Set the POV node to the AnnPlayerBody gameplay defined position/orientation of the player&#39;s body...
Definition: AnnEngine.cpp:412
unsigned long getTimeFromStartUp() const
Get elapsed time from engine startup in millisecond.
Definition: AnnEngine.cpp:332
static AnnOgreVRRenderBootstrapMap registeredRenderers
Definition: AnnEngine.hpp:72
DEPRECATED bool isKeyDown(OIS::KeyCode key) const
Definition: AnnEngine.cpp:419
Main Annwvyn Engine class Initialize the renderer and all subsystem. Provide access to all of the eng...
AnnSceneryManagerPtr sceneryManager
SceneryManager.
Definition: AnnEngine.hpp:281
T get(T... args)
static void setLogFileName(const char *logName)
Public static parameter : name of the logfile. Please set it before AnnInit or creating an AnnEngine ...
Definition: AnnEngine.cpp:210
static std::string logFileName
Definition: AnnEngine.hpp:89
T find(T... args)
AnnGameObjectManagerPtr gameObjectManager
GameObjectManager.
Definition: AnnEngine.hpp:291
T size(T... args)
AnnPhysicsEnginePtr physicsEngine
Physics.
Definition: AnnEngine.hpp:289
static bool noConsoleColor
If true, don&#39;t use color in the output.
Definition: AnnEngine.hpp:263
AnnEngineSingletonReseter(AnnEngine *address)
Definition: AnnEngine.cpp:37
T begin(T... args)
AnnPhysicsEnginePtr getPhysicsEngine() const
Return the Physics Engine.
Definition: AnnEngine.cpp:329
static bool isUserSubSystem(AnnSubSystemPtr subsystem)
Know if subsystem is user defined.
Definition: AnnEngine.cpp:520
AnnEventManagerPtr eventManager
Event manager.
Definition: AnnEngine.hpp:287
T c_str(T... args)
bool applicationQuitRequested
If true, should quit the app ASAP.
Definition: AnnEngine.hpp:267
#define ANN_ERR_CANTHMD
AnnAudioEnginePtr getAudioEngine() const
Return the Annwvyn OpenAL simplified audio engine.
Definition: AnnEngine.cpp:328
double updateTime
Elapsed time between 2 frames.
Definition: AnnEngine.hpp:305
Ogre::SceneManager * SceneManager
The scene manager.
Definition: AnnEngine.hpp:300
Ogre::SceneNode * getPlayerPovNode() const
Get ogre camera scene node.
Definition: AnnEngine.cpp:330
AnnScriptManagerPtr getScriptManager() const
Get the ScriptManager.
Definition: AnnEngine.cpp:323
static std::string defaultRenderer
Definition: AnnEngine.hpp:90
static void setDefaultRenderer(const char *renderer)
Public static parameter : name of the "default" renderer to use. Please set it before AnnInit or crea...
Definition: AnnEngine.cpp:50
static void manuallyRegisterVRRender(const std::string &name, AnnOgreVRRendererBootstrapFunction boostrapFunctionPointer)
Regsiter a renderer manually (to use your own loading code, or to use statically linked code) ...
Definition: AnnEngine.cpp:205
AnnStringUtilityPtr getStringUtility() const
Get the string utility.
Definition: AnnEngine.cpp:337
bool checkNeedToQuit() const
Return true if the game want to terminate the program.
Definition: AnnEngine.cpp:380
static AnnEngine * Instance()
Get the current instance of AnnEngine. pointer.
Definition: AnnEngine.cpp:56
User defined subsystem base class.
void initPlayerRoomscalePhysics() const
Init the roomscale physics model.
Definition: AnnEngine.cpp:335