MezzanineEngine March 18, 2012

Mezzanine::World Class Reference

This is the main entry point for the entire library. More...

#include <world.h>

List of all members.

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.
ActorManagerGetActorManager (const short unsigned int &WhichOne=0)
 This gets the ActorManager from the manager list.
AudioManagerGetAudioManager (const short unsigned int &WhichOne=0)
 This gets the AudioManager from the manager list.
CameraManagerGetCameraManager (const short unsigned int &WhichOne=0)
 This gets the CameraManager from the manager list.
CollisionShapeManagerGetCollisionShapeManager (const short unsigned int &WhichOne=0)
 This gets the CollisionShapeManager from the manager list.
EventManagerGetEventManager (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.
GraphicsManagerGetGraphicsManager (const short unsigned int &WhichOne=0)
 This gets the GraphicsManager from the manager list.
LoggingFrequency GetLoggingFrequency ()
 Returns the frequency of logging commits.
ManagerBaseGetManager (const ManagerBase::ManagerTypeName &ManagersToRemoveType, short unsigned int WhichOne=0)
 This is will find the manager of a given type.
MeshManagerGetMeshManager (const short unsigned int &WhichOne=0)
 This gets the MeshManager from the manager list.
PhysicsManagerGetPhysicsManager (const short unsigned int &WhichOne=0)
 This gets the PhysicsManager from the manager list.
ResourceManagerGetResourceManager (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.
SceneManagerGetSceneManager (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.
TimerManagerGetTimerManager (const short unsigned int &WhichOne=0)
 This gets the TimerManager from the manager list.
UIManagerGetUIManager (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 WorldGetWorldPointer ()
 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 WorldTheRealWorld = 0
 A pointer to the one and only world.

Detailed Description

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.

Definition at line 304 of file world.h.


Member Enumeration Documentation

Used to indicate the frequency of logging.

Enumerator:
LogNever 

Never log.

LogOncePerFrame 

The Default, log each and every frame.

LogOncePerXFrames 

Log once per every Xth frame, X is the FrequencyCounter Value passed in with this.

LogOncePerXSeconds 

Log once per every Xth second, X is the FrequencyCounter Value passed in with this.

Definition at line 412 of file world.h.


Constructor & Destructor Documentation

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.

Parameters:
PhysicsInfoAll the info needed to initialize the physics subsystem.
SceneTypeA cue to the scenemanager as to how rendering should occur.
PluginsFileNameThe filename of the plugins file to be loaded. This is relative to the EngineDataPath.
EngineDataPathThe directory where engine specific data (as opposed to game/application data) reside, and it include the plugins file and potentially othe low level resources.
LogFileNameThis is the place that log messages get sent to.
Warning:
Do not make a new world if one already exists. This can only cause problems

Definition at line 77 of file world.cpp.

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

Parameters:
PhysicsInfoAll the info needed to initialize the physics subsystem.
PluginsFileNameThe filename of the plugins file to be loaded. This is relative to the EngineDataPath.
EngineDataPathThe directory where engine specific data (as opposed to game/application data) reside, and it include the plugins file and potentially othe low level resources.
LogFileNameThis is the place that log messages get sent to.
SceneTypeA cue to the scenemanager as to how rendering should occur.
ManagerToBeAddedThis is a vector of manager pointers that will be used instead of creating new ones
Warning:
Do not make a new world if one already exists. This can only cause problems.

Definition at line 92 of file world.cpp.

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

Warning:
Do not make a new world if one already exists. This can only cause problems

Definition at line 69 of file world.cpp.

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)

Definition at line 205 of file world.cpp.


Member Function Documentation

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.

Parameters:
ManagerToAddThe pointer to the manager to be added

Definition at line 533 of file world.cpp.

void Mezzanine::World::BreakMainLoop ( )

This makes the main loop end after it's current iteration.

If called while not in the main loop, it will simply cause the next call to the main loop to do a single iteration and then exit.

Definition at line 496 of file world.cpp.

void Mezzanine::World::CommitLog ( )

Forces the log to commit to disk (or whereever)

Any outstanding log messages or entries into the logstream will be written in chronological order to to the appropriate place.

Definition at line 363 of file world.cpp.

void Mezzanine::World::DoMainLoopLogging ( )

This commits the log stream to the log.

This is called automatically at the end of each main loop iteration. You only need to call it if you are using your own main loop.

Definition at line 487 of file world.cpp.

void Mezzanine::World::GameInit ( const bool &  CallMainLoop = true)

This creates the game window and starts the game.

Parameters:
CallMainLoopshould 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.

Definition at line 383 of file world.cpp.

ActorManager * Mezzanine::World::GetActorManager ( const short unsigned int &  WhichOne = 0)

This gets the ActorManager from the manager list.

Parameters:
WhichOneIf you have multiple ActorManagers this will choose which one to return.
Returns:
This returns a pointer to a ActorManager, or a NULL pointer if no matching manager exists.

Definition at line 663 of file world.cpp.

AudioManager * Mezzanine::World::GetAudioManager ( const short unsigned int &  WhichOne = 0)

This gets the AudioManager from the manager list.

Parameters:
WhichOneIf you have multiple AudioManagers this will choose which one to return.
Returns:
This returns a pointer to a AudioManager, or a NULL pointer if no matching manager exists.

Definition at line 668 of file world.cpp.

CameraManager * Mezzanine::World::GetCameraManager ( const short unsigned int &  WhichOne = 0)

This gets the CameraManager from the manager list.

Parameters:
WhichOneIf you have multiple CameraManagers this will choose which one to return.
Returns:
This returns a pointer to a CameraManager, or a NULL pointer if no matching manager exists.

Definition at line 673 of file world.cpp.

CollisionShapeManager * Mezzanine::World::GetCollisionShapeManager ( const short unsigned int &  WhichOne = 0)

This gets the CollisionShapeManager from the manager list.

Parameters:
WhichOneIf you have multiple CollisionShapeManagers this will choose which one to return.
Returns:
This returns a pointer to a CollisionShapeManager, or a NULL pointer if no matching manager exists.

Definition at line 678 of file world.cpp.

EventManager * Mezzanine::World::GetEventManager ( const short unsigned int &  WhichOne = 0)

This gets the EventManager from the manager list.

Parameters:
WhichOneIf you have multiple EventManagers this will choose which one to return.
Returns:
This returns a pointer to a EventManager, or a NULL pointer if no matching manager exists.

Definition at line 683 of file world.cpp.

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)

Returns:
This returns a whole number which can be used to aid in the timimg of various algorithms.

Definition at line 520 of file world.cpp.

GraphicsManager * Mezzanine::World::GetGraphicsManager ( const short unsigned int &  WhichOne = 0)

This gets the GraphicsManager from the manager list.

Parameters:
WhichOneIf you have multiple GraphicsManagers this will choose which one to return.
Returns:
This returns a pointer to a GraphicsManager, or a NULL pointer if no matching manager exists.

Definition at line 688 of file world.cpp.

World::LoggingFrequency Mezzanine::World::GetLoggingFrequency ( )

Returns the frequency of logging commits.

Returns:
A World::LoggingFrequency containing the requested information.

Definition at line 348 of file world.cpp.

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).

Parameters:
ManagersToRemoveType
WhichOneIf not getting the first/only manager of the given type, get one.
Returns:
This returns a pointer to a ManagerBase, or a NULL pointer if no matching manager exists

Definition at line 596 of file world.cpp.

MeshManager * Mezzanine::World::GetMeshManager ( const short unsigned int &  WhichOne = 0)

This gets the MeshManager from the manager list.

Parameters:
WhichOneIf you have multiple MeshManagers this will choose which one to return.
Returns:
This returns a pointer to a MeshManager, or a NULL pointer if no matching manager exists.

Definition at line 693 of file world.cpp.

PhysicsManager * Mezzanine::World::GetPhysicsManager ( const short unsigned int &  WhichOne = 0)

This gets the PhysicsManager from the manager list.

Parameters:
WhichOneIf you have multiple PhysicsManagers this will choose which one to return.
Returns:
This returns a pointer to a PhysicsManager, or a NULL pointer if no matching manager exists.

Definition at line 703 of file world.cpp.

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.

Parameters:
WhichOneIf you have multiple ResourceManagers this will choose which one to return.
Returns:
This returns a pointer to a ResourceManager, or a NULL pointer if no matching manager exists.

Definition at line 713 of file world.cpp.

SceneManager * Mezzanine::World::GetSceneManager ( const short unsigned int &  WhichOne = 0)

This gets the SceneManager from the manager list.

Parameters:
WhichOneIf you have multiple SceneManagers this will choose which one to return.
Returns:
This returns a pointer to a SceneManager, or a NULL pointer if no matching manager exists.

Definition at line 708 of file world.cpp.

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.

Returns:
This returns a Whole with the current Value

Definition at line 505 of file world.cpp.

TimerManager * Mezzanine::World::GetTimerManager ( const short unsigned int &  WhichOne = 0)

This gets the TimerManager from the manager list.

Parameters:
WhichOneIf you have multiple TimerManagers this will choose which one to return.
Returns:
This returns a pointer to a TimerManager, or a NULL pointer if no matching manager exists.

Definition at line 718 of file world.cpp.

UIManager * Mezzanine::World::GetUIManager ( const short unsigned int &  WhichOne = 0)

This gets the UIManager from the manager list.

Parameters:
WhichOneIf you have multiple UIManagers this will choose which one to return.
Returns:
This returns a pointer to a UIManager, or a NULL pointer if no matching manager exists.

Definition at line 723 of file world.cpp.

World * Mezzanine::World::GetWorldPointer ( ) [static]

Return a pointer to the world.

Returns:
This returns a pointer the one and only Mezzanine::World

Definition at line 108 of file world.cpp.

template<class T >
void Mezzanine::World::Log ( const T &  Message) [inline]

Runtime event and message logging.

Parameters:
MessageThis 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.

Definition at line 444 of file world.h.

void Mezzanine::World::LogAndThrow ( Exception  Err) [inline]

This is the preferred way to throw an exception.

Parameters:
ErrA Mezzanine::Exception to be logged and thrown

Definition at line 459 of file world.h.

template<class T >
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 ( << )

Parameters:
MessageThis will be streamed to the log, then used in a thrown exception.

Definition at line 471 of file world.h.

void Mezzanine::World::LogString ( const String message)

Log String directly with no conversion.

Parameters:
messageThe string to log

Definition at line 366 of file world.cpp.

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)

Pauses all animations, particles, and object movement throughout the world.

Parameters:
PausePauses the world if true, unpauses if false.

Definition at line 235 of file world.cpp.

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.

Parameters:
ManagersToRemoveTypeThe ManagerBase::ManagerTypeName of the manager to remove.
WhichOneIf not removing the first/only manager of the given type, which one by count are you erasing.

Definition at line 575 of file world.cpp.

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.

Parameters:
ManagerToRemoveA pointer to the manager to be removed

Definition at line 558 of file world.cpp.

void Mezzanine::World::SetFrameTime ( const Whole FrameTime_)

Sets the amount of time since the last time Rendering began.

Parameters:
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.

Definition at line 525 of file world.cpp.

void Mezzanine::World::SetLoggingFrequency ( World::LoggingFrequency  HowOften,
Whole  FrequencyCounter = 5 
)

Set how often log message should be commited to disk (or network, or whatever).

Parameters:
HowOftenThe actual setting for how often.
FrequencyCounterFor 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.

Definition at line 321 of file world.cpp.

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

Parameters:
NewFrameRateThe new desired frame rate.
Warning:
Setting vary low or very High values could cause unknown errors, This is on our todo list of issues to fix.

Definition at line 515 of file world.cpp.

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.

Parameters:
NewTargetTimeThe new length of time, in milliseconds.
Warning:
Setting vary low or very High values could cause unknown errors, This is on our todo list of issues to fix.

Definition at line 510 of file world.cpp.

void Mezzanine::World::UpdateManagerOrder ( )

This forces the list of managers to be resorted.

This should only need to be called if the Priority attribute of a manager in the list has changed. This sorts the list of managers

Definition at line 648 of file world.cpp.

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.

Parameters:
ManagerToChangeA pointer to the manager that needs to be changed
Priority_the new desire priority/execution order of the Manager

Definition at line 628 of file world.cpp.


Member Data Documentation

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.

Definition at line 455 of file world.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines