COgreVisualisation Class Reference

High level Ogre initialisation & management This class initializes the Ogre library, creates 3D scenes, windows (views of 3D scenes) and objects that populate such scenes. More...

Inherits TKernelObject< T >, and LogListener.

Public Member Functions

 COgreVisualisation (const OpenViBE::Kernel::IKernelContext &rKernelContext)
 Constructor. More...
 
 ~COgreVisualisation ()
 Destructor.
 
virtual void messageLogged (const Ogre::String &message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName)
 This is called whenever the log recieves a message and is about to write it out. More...
 
OpenViBE::boolean initializeOgre (const OpenViBE::CString &rPluginsFile, OpenViBE::boolean bLogToScreen, const OpenViBE::CString &rLogFileName) throw (std::exception)
 Load configuration files and initialise Ogre Creates Ogre root object, parses resource locations and initialises Ogre from last configuration (if any) or by displaying the Ogre configuration dialog if no ogre.cfg is available. More...
 
OpenViBE::boolean initializeOgre (void) throw (std::exception)
 Load configuration files and initialise Ogre Creates Ogre root object, parses resource locations and initialises Ogre from last configuration (if any) or by displaying the Ogre configuration dialog if no ogre.cfg is available. More...
 
OpenViBE::boolean ogreInitialized ()
 Determine whether Ogre has been initialized yet. More...
 
OpenViBE::boolean initializeResources () throw (Ogre::Exception)
 Complete Ogre initialisation once primary RenderWindow has been created This function initialises all resource groups. Additionally, render states may be initialized here if needed. More...
 
OpenViBE::boolean resourcesInitialized ()
 Determine whether resources have been initialized yet. More...
 
OpenViBE::boolean finish ()
 Delete all windows, scenes and the Ogre root. More...
 
void idle ()
 Refreshes all windows.
 
Ogre::RenderWindow * createRenderWindow (const std::string &rName, const std::string &rExternalHandle, unsigned int uiWidth, unsigned int uiHeight)
 Create a RenderWindow from an external window handle. More...
 
COgreScenecreateScene (const OpenViBE::CIdentifier &rSceneIdentifier)
 Create a COgreScene object At least one such object should have been created before createWindow() may be called. More...
 
COgreWindowcreateWindow (OpenViBE::CIdentifier rWindowIdentifier, const std::string &rWindowName, OpenViBE::CIdentifier rSceneIdentifier)
 Create a COgreWindow object A window is a view of a 3D scene. The COgreScene object referenced by rSceneIdentifier should have been created beforehand. More...
 
Ogre::Root * getOgreRoot ()
 Return Ogre root. More...
 
COgreWindowgetOgreWindow (OpenViBE::CIdentifier rWindowIdentifier)
 Return a window. More...
 
COgreScenegetOgreScene (OpenViBE::CIdentifier rSceneIdentifier)
 Return a scene. More...
 
OpenViBE::boolean deleteWindow (OpenViBE::CIdentifier rWindowIdentifier)
 Delete a window. More...
 
OpenViBE::boolean deleteScene (OpenViBE::CIdentifier rSceneIdentifier)
 
OpenViBE::boolean isOgreStatsOverlayEnabled ()
 Checks whether Ogre statistics overlay should be enabled in 3d windows. More...
 
Resource groups management
COgreResourceGroupcreateResourceGroup (OpenViBE::CIdentifier &rResourceGroupIdentifier, const std::string &rResourceGroupName)
 Create a resource group. More...
 
OpenViBE::boolean addResourceLocation (const OpenViBE::CIdentifier &rResourceGroupIdentifier, const std::string &rPath, const std::string &rType, bool bRecursive)
 Add a resource location. More...
 
OpenViBE::boolean initializeResourceGroup (const OpenViBE::CIdentifier &rResourceGroupIdentifier)
 Initialize resource group. More...
 
OpenViBE::boolean destroyResourceGroup (const OpenViBE::CIdentifier &rResourceGroupIdentifier)
 Destroy resource group. More...
 

Detailed Description

High level Ogre initialisation & management This class initializes the Ogre library, creates 3D scenes, windows (views of 3D scenes) and objects that populate such scenes.

Author
Vincent Delannoy (INRIA/IRISA)
Date
2008-06

Constructor & Destructor Documentation

Constructor.

Parameters
[in]rKernelContextOpenViBE kernel context

Member Function Documentation

virtual void messageLogged ( const Ogre::String &  message,
Ogre::LogMessageLevel  lml,
bool  maskDebug,
const Ogre::String &  logName 
)
virtual

This is called whenever the log recieves a message and is about to write it out.

Parameters
messageThe message to be logged
lmlThe message level the log is using
maskDebugIf we are printing to the console or not
logNamethe name of this log
OpenViBE::boolean initializeOgre ( const OpenViBE::CString rPluginsFile,
OpenViBE::boolean  bLogToScreen,
const OpenViBE::CString rLogFileName 
)
throw (std::exception
)

Load configuration files and initialise Ogre Creates Ogre root object, parses resource locations and initialises Ogre from last configuration (if any) or by displaying the Ogre configuration dialog if no ogre.cfg is available.

Parameters
rPluginsFileOgre plugins file
rLogFileNameIf not empty, Ogre log dumped to this file
Returns
True if Ogre was initialised, false otherwise
OpenViBE::boolean initializeOgre ( void  )
throw (std::exception
)

Load configuration files and initialise Ogre Creates Ogre root object, parses resource locations and initialises Ogre from last configuration (if any) or by displaying the Ogre configuration dialog if no ogre.cfg is available.

Returns
True if Ogre was initialised, false otherwise
OpenViBE::boolean ogreInitialized ( )

Determine whether Ogre has been initialized yet.

Returns
True if Ogre was initialized, false otherwise
OpenViBE::boolean initializeResources ( )
throw (Ogre::Exception
)

Complete Ogre initialisation once primary RenderWindow has been created This function initialises all resource groups. Additionally, render states may be initialized here if needed.

Returns
True if Ogre resources could be initialized, false otherwise
OpenViBE::boolean resourcesInitialized ( )

Determine whether resources have been initialized yet.

Returns
True if resources were initialized, false otherwise
OpenViBE::boolean finish ( )

Delete all windows, scenes and the Ogre root.

Returns
True if all Ogre resources were successfully released, false otherwise
Ogre::RenderWindow* createRenderWindow ( const std::string &  rName,
const std::string &  rExternalHandle,
unsigned int  uiWidth,
unsigned int  uiHeight 
)

Create a RenderWindow from an external window handle.

Remarks
This function is used to create the primary render window which is then hidden and destroyed only when the application is shut down. Secondary windows should be created by COgreWindow objects
Returns
Pointer to RenderWindow or NULL if it couldn't be created
COgreResourceGroup* createResourceGroup ( OpenViBE::CIdentifier rResourceGroupIdentifier,
const std::string &  rResourceGroupName 
)

Create a resource group.

Parameters
in/out]rResourceGroupIdentifier Must be OV_UndefinedIdentifier if a new resource group is to be created. Otherwise the method looks for the resource group with the identifier passed in parameter, returning NULL if none matches this ID.
[in]rResourceGroupNameIf rResourceGroupIdentifier is OV_UndefinedIdentifier and a group named rResourceGroupName already exists, rResourceGroupIdentifier will be set to the identifier of this group. Otherwise, a new group named rResourceGroupName will be created.
Returns
Pointer to resource group or NULL if creation failed
OpenViBE::boolean addResourceLocation ( const OpenViBE::CIdentifier rResourceGroupIdentifier,
const std::string &  rPath,
const std::string &  rType,
bool  bRecursive 
)

Add a resource location.

Remarks
Resources can't be added once Resource Group has been initialized
Parameters
rResourceGroupIdentifierResource group identifier
rPathResources location path
typeResources type (path or zip file)
bRecursiveResources are added recursively from location passed in parameter if true
Returns
True if resource location could be added, false otherwise
OpenViBE::boolean initializeResourceGroup ( const OpenViBE::CIdentifier rResourceGroupIdentifier)

Initialize resource group.

Remarks
Each call to this method increments the group's internal reference counter. When it is set to one (upon first call to this method) the group is actually initialized, but isn't upon subsequent calls. It has to be destroyed (its ref count set back to 0) and recreated to be reinitialized.
Parameters
rResourceGroupIdentifierResource group identifier
Returns
True if resource group could be initialized (or was initialized already), false if an error occurred
OpenViBE::boolean destroyResourceGroup ( const OpenViBE::CIdentifier rResourceGroupIdentifier)

Destroy resource group.

Remarks
Each call to this method decrements the group's internal reference counter. Only when this counter reaches 0 is the group actually destroyed.
Parameters
rResourceGroupIdentifierResource group identifier
Returns
True if resource group could be destroyed (or was initialized already), false if an error occurred
COgreScene* createScene ( const OpenViBE::CIdentifier rSceneIdentifier)

Create a COgreScene object At least one such object should have been created before createWindow() may be called.

Parameters
rSceneIdentifieridentifier to give to scene to be created
Returns
Pointer to newly created COgreScene object
COgreWindow* createWindow ( OpenViBE::CIdentifier  rWindowIdentifier,
const std::string &  rWindowName,
OpenViBE::CIdentifier  rSceneIdentifier 
)

Create a COgreWindow object A window is a view of a 3D scene. The COgreScene object referenced by rSceneIdentifier should have been created beforehand.

Parameters
rWindowIdentifieridentifier to give to window to be created
rWindowNamename to give to window to be created
rSceneIdentifieridentifier of scene this window is a view of. Must reference an existing scene!
Returns
Pointer to newly created COgreWindow object if creation succeeded, false otherwise
Ogre::Root* getOgreRoot ( )

Return Ogre root.

Returns
Pointer to Ogre root or NULL if it wasn't created
COgreWindow* getOgreWindow ( OpenViBE::CIdentifier  rWindowIdentifier)

Return a window.

Parameters
rWindowIdentifierIdentifier of window to be retrieved
Returns
Pointer to COgreWindow if it could be retrieved, NULL otherwise
COgreScene* getOgreScene ( OpenViBE::CIdentifier  rSceneIdentifier)

Return a scene.

Parameters
rSceneIdentifierIdentifier of scene to be retrieved
Returns
Pointer to COgreScene if it could be retrieved, NULL otherwise
OpenViBE::boolean deleteWindow ( OpenViBE::CIdentifier  rWindowIdentifier)

Delete a window.

Parameters
rWindowIdentifierIdentifier of window to be deleted
Returns
True if window was deleted, NULL otherwise
OpenViBE::boolean deleteScene ( OpenViBE::CIdentifier  rSceneIdentifier)
Remarks
Windows using this scene should be deleted first
OpenViBE::boolean isOgreStatsOverlayEnabled ( )

Checks whether Ogre statistics overlay should be enabled in 3d windows.

Returns
True if stats overlay should be enabled, false otherwise