This is the main entry point for the entire library. More...
#include <world.h>
Public Types | |
| enum | LoggingFrequency { LogNever = 0, LogOncePerFrame = 1, LogOncePerXFrames = 2, LogOncePerXSeconds = 3 } |
Used to indicate the frequency of logging. More... | |
Public Member Functions | |
| World (const PhysicsConstructionInfo &PhysicsInfo, SceneManager::SceneManagerType SceneType, const String &PluginsFileName, const String &EngineDataPath, std::string LogFileName="Mezzanine.log") | |
| Descriptive constructor With Manager Pointers. | |
| World (const PhysicsConstructionInfo &PhysicsInfo, SceneManager::SceneManagerType SceneType, const String &PluginsFileName, const String &EngineDataPath, const String &LogFileName, const std::vector< ManagerBase * > &ManagerToBeAdded) | |
| Descriptive constructor. | |
| World () | |
| Default constructor. | |
| ~World () | |
| Deconstructor. | |
| void | AddManager (ManagerBase *ManagerToAdd) |
| This adds a manager, in the correct order, to the list that the world calls on. | |
| void | BreakMainLoop () |
| This makes the main loop end after it's current iteration. | |
| void | CommitLog () |
| Forces the log to commit to disk (or whereever) | |
| void | DoMainLoopLogging () |
| This commits the log stream to the log. | |
| void | GameInit (const bool &CallMainLoop=true) |
| This creates the game window and starts the game. | |
| ActorManager * | GetActorManager (const short unsigned int &WhichOne=0) |
| This gets the ActorManager from the manager list. | |
| AudioManager * | GetAudioManager (const short unsigned int &WhichOne=0) |
| This gets the AudioManager from the manager list. | |
| CameraManager * | GetCameraManager (const short unsigned int &WhichOne=0) |
| This gets the CameraManager from the manager list. | |
| CollisionShapeManager * | GetCollisionShapeManager (const short unsigned int &WhichOne=0) |
| This gets the CollisionShapeManager from the manager list. | |
| EventManager * | GetEventManager (const short unsigned int &WhichOne=0) |
| This gets the EventManager from the manager list. | |
| Whole | GetFrameTime () |
| Gets the amount of time since the last time Rendering began. | |
| GraphicsManager * | GetGraphicsManager (const short unsigned int &WhichOne=0) |
| This gets the GraphicsManager from the manager list. | |
| LoggingFrequency | GetLoggingFrequency () |
| Returns the frequency of logging commits. | |
| ManagerBase * | GetManager (const ManagerBase::ManagerTypeName &ManagersToRemoveType, short unsigned int WhichOne=0) |
| This is will find the manager of a given type. | |
| MeshManager * | GetMeshManager (const short unsigned int &WhichOne=0) |
| This gets the MeshManager from the manager list. | |
| PhysicsManager * | GetPhysicsManager (const short unsigned int &WhichOne=0) |
| This gets the PhysicsManager from the manager list. | |
| ResourceManager * | GetResourceManager (const short unsigned int &WhichOne=0) |
| This gets the ResourceManager from the manager list. These are responsible for reading and writing files on the disk. | |
| SceneManager * | GetSceneManager (const short unsigned int &WhichOne=0) |
| This gets the SceneManager from the manager list. | |
| Whole | GetTargetFrameTime () |
| Retrieves the amount of milliseconds we would like each iteration of the Main Loop to be. | |
| TimerManager * | GetTimerManager (const short unsigned int &WhichOne=0) |
| This gets the TimerManager from the manager list. | |
| UIManager * | GetUIManager (const short unsigned int &WhichOne=0) |
| This gets the UIManager from the manager list. | |
| void | Log () |
| Force any outstanding logs to be commited to logs. | |
| template<class T > | |
| void | Log (const T &Message) |
| Runtime event and message logging. | |
| void | LogAndThrow (Exception Err) |
| This is the preferred way to throw an exception. | |
| template<class T > | |
| void | LogAndThrow (const T &Message) |
| This is the preferred a good way to throw an exception, in a recordable fashion. It streams any thrown object to the log. | |
| void | LogString (const String &message) |
| Log String directly with no conversion. | |
| void | MainLoop () |
| This Function house the main loop. | |
| void | PauseWorld (bool Pause) |
| Pauses all animations, particles, and object movement throughout the world. | |
| void | RemoveManager (const ManagerBase::ManagerTypeName &ManagersToRemoveType, short unsigned int WhichOne) |
| This removes a manager of a specific type from the list. | |
| void | RemoveManager (ManagerBase *ManagerToRemove) |
| This removes a manager by finding the matching pointer. | |
| void | SetFrameTime (const Whole &FrameTime_) |
| Sets the amount of time since the last time Rendering began. | |
| void | SetLoggingFrequency (LoggingFrequency HowOften, Whole FrequencyCounter=5) |
| Set how often log message should be commited to disk (or network, or whatever). | |
| void | SetTargetFrameRate (const Whole &NewFrameRate) |
| This sets a new Target Frame Rate. | |
| void | SetTargetFrameTime (const Whole &NewTargetTime) |
| This sets a new Target Time. | |
| void | UpdateManagerOrder (ManagerBase *ManagerToChange, short int Priority_) |
| Changes a Manager's time of execution. | |
| void | UpdateManagerOrder () |
| This forces the list of managers to be resorted. | |
Static Public Member Functions | |
| static World * | GetWorldPointer () |
| Return a pointer to the world. | |
Public Attributes | |
| std::stringstream | LogStream |
| This is another way to put data in the log. | |
Static Protected Attributes | |
| static World * | TheRealWorld = 0 |
| A pointer to the one and only world. | |
This is the main entry point for the entire library.
The world coordinates and integrates all the underlying subsystems, Currently Ogre3d is used for 3d Graphics, Bullet is used for physics, and SDL is used for user input and window management. Games will need a container for all the playing pieces. It makes sense to tie all of this functionality into one world object.
Used to indicate the frequency of logging.
| Mezzanine::World::World | ( | const PhysicsConstructionInfo & | PhysicsInfo, |
| SceneManager::SceneManagerType | SceneType, | ||
| const String & | PluginsFileName, | ||
| const String & | EngineDataPath, | ||
| std::string | LogFileName = "Mezzanine.log" |
||
| ) |
Descriptive constructor With Manager Pointers.
This constructor allows for an easier way to define the boundaries for items moving about inside the world.
| PhysicsInfo | All the info needed to initialize the physics subsystem. |
| SceneType | A cue to the scenemanager as to how rendering should occur. |
| PluginsFileName | The filename of the plugins file to be loaded. This is relative to the EngineDataPath. |
| EngineDataPath | The directory where engine specific data (as opposed to game/application data) reside, and it include the plugins file and potentially othe low level resources. |
| LogFileName | This is the place that log messages get sent to. |
| Mezzanine::World::World | ( | const PhysicsConstructionInfo & | PhysicsInfo, |
| SceneManager::SceneManagerType | SceneType, | ||
| const String & | PluginsFileName, | ||
| const String & | EngineDataPath, | ||
| const String & | LogFileName, | ||
| const std::vector< ManagerBase * > & | ManagerToBeAdded | ||
| ) |
Descriptive constructor.
This constructor allows for an easier way to define the boundaries for items moving about inside the world. This constructor provides no default arguments, but allows for maximum customization. In addition to everything the other constructors this one can accept a vector of pointers to managers. They will be add
| PhysicsInfo | All the info needed to initialize the physics subsystem. |
| PluginsFileName | The filename of the plugins file to be loaded. This is relative to the EngineDataPath. |
| EngineDataPath | The directory where engine specific data (as opposed to game/application data) reside, and it include the plugins file and potentially othe low level resources. |
| LogFileName | This is the place that log messages get sent to. |
| SceneType | A cue to the scenemanager as to how rendering should occur. |
| ManagerToBeAdded | This is a vector of manager pointers that will be used instead of creating new ones |
| Mezzanine::World::World | ( | ) |
Default constructor.
This simply performs the same work as the descriptive constructor with some sane, but small, limits. It will give you a world which expands for 100 units from the Origin, and only allows 10 Actors
| Mezzanine::World::~World | ( | ) |
Deconstructor.
This Tears down all the items created by the world, and safely frees any graphical resources, we will also delete any Objects passed into the world by pointer. We will not delete any pointers we pass out (like from the Events from the Event manager)
| void Mezzanine::World::AddManager | ( | ManagerBase * | ManagerToAdd | ) |
This adds a manager, in the correct order, to the list that the world calls on.
Internally the world had a list of managers that is sorted by the ManagerBase::Priority. Everytime a manager is added, the list is searched for the sorted point to insert the manager at.
| ManagerToAdd | The pointer to the manager to be added |
| void Mezzanine::World::BreakMainLoop | ( | ) |
| void Mezzanine::World::CommitLog | ( | ) |
| void Mezzanine::World::DoMainLoopLogging | ( | ) |
| void Mezzanine::World::GameInit | ( | const bool & | CallMainLoop = true | ) |
This creates the game window and starts the game.
| CallMainLoop | should the main loop be called |
Prior to this all of the physics and graphical object containers should have been loaded and prepared for use. There should be minimal delay from the time you call this and the game actually begins. This will automatically call the Main Loop unless passed false.
| ActorManager * Mezzanine::World::GetActorManager | ( | const short unsigned int & | WhichOne = 0 | ) |
This gets the ActorManager from the manager list.
| WhichOne | If you have multiple ActorManagers this will choose which one to return. |
| AudioManager * Mezzanine::World::GetAudioManager | ( | const short unsigned int & | WhichOne = 0 | ) |
This gets the AudioManager from the manager list.
| WhichOne | If you have multiple AudioManagers this will choose which one to return. |
| CameraManager * Mezzanine::World::GetCameraManager | ( | const short unsigned int & | WhichOne = 0 | ) |
This gets the CameraManager from the manager list.
| WhichOne | If you have multiple CameraManagers this will choose which one to return. |
| CollisionShapeManager * Mezzanine::World::GetCollisionShapeManager | ( | const short unsigned int & | WhichOne = 0 | ) |
This gets the CollisionShapeManager from the manager list.
| WhichOne | If you have multiple CollisionShapeManagers this will choose which one to return. |
| EventManager * Mezzanine::World::GetEventManager | ( | const short unsigned int & | WhichOne = 0 | ) |
This gets the EventManager from the manager list.
| WhichOne | If you have multiple EventManagers this will choose which one to return. |
| Whole Mezzanine::World::GetFrameTime | ( | ) |
Gets the amount of time since the last time Rendering began.
This returns, in milliseconds the amount of time since the frame started (since the last rendering began)
| GraphicsManager * Mezzanine::World::GetGraphicsManager | ( | const short unsigned int & | WhichOne = 0 | ) |
This gets the GraphicsManager from the manager list.
| WhichOne | If you have multiple GraphicsManagers this will choose which one to return. |
| World::LoggingFrequency Mezzanine::World::GetLoggingFrequency | ( | ) |
Returns the frequency of logging commits.
| ManagerBase * Mezzanine::World::GetManager | ( | const ManagerBase::ManagerTypeName & | ManagersToRemoveType, |
| short unsigned int | WhichOne = 0 |
||
| ) |
This is will find the manager of a given type.
Specifically this will iterate from lowest priority to highest priority, and return a pointer to the first Manager with a matching type found. If you specify WhichOne, it will the Nth+1 in the list matching the type (kind of like array subscript).
| ManagersToRemoveType | |
| WhichOne | If not getting the first/only manager of the given type, get one. |
| MeshManager * Mezzanine::World::GetMeshManager | ( | const short unsigned int & | WhichOne = 0 | ) |
This gets the MeshManager from the manager list.
| WhichOne | If you have multiple MeshManagers this will choose which one to return. |
| PhysicsManager * Mezzanine::World::GetPhysicsManager | ( | const short unsigned int & | WhichOne = 0 | ) |
This gets the PhysicsManager from the manager list.
| WhichOne | If you have multiple PhysicsManagers this will choose which one to return. |
| ResourceManager * Mezzanine::World::GetResourceManager | ( | const short unsigned int & | WhichOne = 0 | ) |
This gets the ResourceManager from the manager list. These are responsible for reading and writing files on the disk.
| WhichOne | If you have multiple ResourceManagers this will choose which one to return. |
| SceneManager * Mezzanine::World::GetSceneManager | ( | const short unsigned int & | WhichOne = 0 | ) |
This gets the SceneManager from the manager list.
| WhichOne | If you have multiple SceneManagers this will choose which one to return. |
| Whole Mezzanine::World::GetTargetFrameTime | ( | ) |
Retrieves the amount of milliseconds we would like each iteration of the Main Loop to be.
In practice harI've done some more testing, started out digging through the code to see if there was anything wrong, there seemed to be random extra words inside our code that the compiler didn't mind that shouldn't be there. like there was a " Schedule : " right after a line where a pointer was initialized. I only found such occurrences in gamebase.cpp though, removed them and did two tests. First test I was just randomly clicking and then I inadvertently threw the metal sphere down into the abyss, the sphere was really close to the camera when this happened, about to go over. Second time I ran the game trying to click stuff, I simply couldn't click anything. I even tried zooming in on the robots, although I can only get so close to them before I have to tamper with the camera, which I haven't done yet, but there were no results with the Robots. The third time I was successfully able to stop two spheres and move them around the platform quite smoothly. These spheres were slightly further away from the camera compared to the first run. I stopped the wooden sphere and the second metal sphere. I included a screen shot and a copy of my log for the third run. The spheres in the screenshot are both in a rest position.dware performance or timing concerns can cause this goal to be unnaitanable or trivially easy. The main loop with actually pause execution until this amount of time is reach is main loop iteration, However, the mainloop will always skip waiting if hardware is overburdened.
| TimerManager * Mezzanine::World::GetTimerManager | ( | const short unsigned int & | WhichOne = 0 | ) |
This gets the TimerManager from the manager list.
| WhichOne | If you have multiple TimerManagers this will choose which one to return. |
| UIManager * Mezzanine::World::GetUIManager | ( | const short unsigned int & | WhichOne = 0 | ) |
| World * Mezzanine::World::GetWorldPointer | ( | ) | [static] |
Return a pointer to the world.
| void Mezzanine::World::Log | ( | const T & | Message | ) | [inline] |
Runtime event and message logging.
| Message | This is what will be streamed to the log |
This also gathers any outstanding Log messages from any subsystem. Currently the Graphics subsystem (Ogre3d) and the sound subsystem (cAudio) are the Only ones to produce meaningul log messages.
| void Mezzanine::World::LogAndThrow | ( | Exception | Err | ) | [inline] |
This is the preferred way to throw an exception.
| Err | A Mezzanine::Exception to be logged and thrown |
| void Mezzanine::World::LogAndThrow | ( | const T & | Message | ) | [inline] |
This is the preferred a good way to throw an exception, in a recordable fashion. It streams any thrown object to the log.
This will log the Message, and will throw an exception with the Message included. Currently this supports all the Data types that overload the stream insertion operator ( << )
| Message | This will be streamed to the log, then used in a thrown exception. |
| void Mezzanine::World::LogString | ( | const String & | message | ) |
| void Mezzanine::World::MainLoop | ( | ) |
This Function house the main loop.
By default this is called from the function World.GameInit() this is were the bulk of the simulation is ran from, see Main Loop Structure and Flow
| void Mezzanine::World::PauseWorld | ( | bool | Pause | ) |
| void Mezzanine::World::RemoveManager | ( | const ManagerBase::ManagerTypeName & | ManagersToRemoveType, |
| short unsigned int | WhichOne | ||
| ) |
This removes a manager of a specific type from the list.
This starts at the beginning (should be the lowest priority)of the list and iterates through looking for a matching type, at some future point this could replaced with more sophisticated algorithm, but for now assume this operates in linear time.
| ManagersToRemoveType | The ManagerBase::ManagerTypeName of the manager to remove. |
| WhichOne | If not removing the first/only manager of the given type, which one by count are you erasing. |
| void Mezzanine::World::RemoveManager | ( | ManagerBase * | ManagerToRemove | ) |
This removes a manager by finding the matching pointer.
Currently this just iterates through the list looking for the matching pointer, at some future point this could replaced with more sophisticated algorithm, but for now assume this operates in linear time.
| ManagerToRemove | A pointer to the manager to be removed |
| void Mezzanine::World::SetFrameTime | ( | const Whole & | FrameTime_ | ) |
Sets the amount of time since the last time Rendering began.
| FrameTime_ | This is the amount of time in milliseconds. |
This sets, in milliseconds the amount of time since the frame started (since the last rendering began). Don't set this carelessely can screw up a lot of stuff, for the most part this should be by the rendering manager during the rendering process.
| void Mezzanine::World::SetLoggingFrequency | ( | World::LoggingFrequency | HowOften, |
| Whole | FrequencyCounter = 5 |
||
| ) |
Set how often log message should be commited to disk (or network, or whatever).
| HowOften | The actual setting for how often. |
| FrequencyCounter | For settings that use X this is X, this defaults to 5 |
By default this is set to LogOncePerFrame.
There are a series of functions internally that represent each of the LoggingFrequency values. When You pass in one of these values you are setting which of these functions will be called. This way the only cost that is guaranteed to be incurred is the dereferencing of a function pointer (constant time). Additionally the members of the enum are sorted by the amount of time they are expected to take to run, of course your performance will vary, the best way to know how it will perform is to test.
| void Mezzanine::World::SetTargetFrameRate | ( | const Whole & | NewFrameRate | ) |
This sets a new Target Frame Rate.
This sets a new time for each frame. This divides 1000 by the NewFrameRate, drops and floating point amount and uses that amount in an call to World::SetTargetFrameTime. For example a target frame rate of 40 with cause each frame to take 25 milliseconds, and a Framerate of 70 would take 14 ms
| NewFrameRate | The new desired frame rate. |
| void Mezzanine::World::SetTargetFrameTime | ( | const Whole & | NewTargetTime | ) |
This sets a new Target Time.
This sets a new time for each frame. Each iteration of the game loop will take around this long to run, but rarely exactly this long. Setting this value Higher can results in power savings (battery life), but setting it too High can cause choppiness. Settings this value higher can result in smoother gameplay, but set it too high, and system resources could becom completely taxed and power will be wasted.
| NewTargetTime | The new length of time, in milliseconds. |
| void Mezzanine::World::UpdateManagerOrder | ( | ) |
| void Mezzanine::World::UpdateManagerOrder | ( | ManagerBase * | ManagerToChange, |
| short int | Priority_ | ||
| ) |
Changes a Manager's time of execution.
Searches through the Manager list and removes any previous entries to the changing manager, and add a new entry in the correct location.
| ManagerToChange | A pointer to the manager that needs to be changed |
| Priority_ | the new desire priority/execution order of the Manager |
| std::stringstream Mezzanine::World::LogStream |
This is another way to put data in the log.
The contents of this will be commited to the log as per the logging frequency. Because the entry of this data into the actual log file(or whatever destination) is delayed, do not use this for data that is likely to be required to debug something the frame something crashes. However, for other kinds of debugging data and creating in game logs and gameworld recreations.
1.7.3