OMK::Inp::DistributedCameraListener Class Reference
[User inputs]

Simulated Object to control the camera. More...

#include <OMKDistributedCameraListener.h>

Inheritance diagram for OMK::Inp::DistributedCameraListener:

Inheritance graph
[legend]
Collaboration diagram for OMK::Inp::DistributedCameraListener:

Collaboration graph
[legend]
List of all members.

Protected Member Functions

virtual void windowResized (Ogre::RenderWindow *rw)
virtual void windowClosed (Ogre::RenderWindow *rw)
virtual bool processUnbufferedKeyInput (const Ogre::FrameEvent &evt)
virtual bool processUnbufferedMouseInput (const Ogre::FrameEvent &evt)
virtual bool frameStarted (const Ogre::FrameEvent &evt)
virtual void init ()
 initialise the object.
virtual void finish ()
 finish calculation of evolution.
virtual void compute ()
 compute evolution of this object.
void readConfigurationParameters ()

Protected Attributes

Vis::OgreVis_ogreVis
Type::Transform _transform
bool _updateTransform
float _translationSpeed
float _wheelTranslationSpeed
float _rotationSpeed
OIS::InputManager * _inputManager
OIS::Mouse * _mouse
OIS::Keyboard * _keyboard

Private Member Functions

 DECLARE_OBJECT_FACTORY (DistributedCameraListener)

Detailed Description

Simulated Object to control the camera.

Date:
200 7-02-28
Author:
Michaël Rouillé
Module description :
Define a frame and windowEvent listener which control the camera of a VisOgre object.

Definition at line 27 of file OMKDistributedCameraListener.h.


Member Function Documentation

OMK::Inp::DistributedCameraListener::DECLARE_OBJECT_FACTORY ( DistributedCameraListener   )  [private]

virtual void OMK::Inp::DistributedCameraListener::windowResized ( Ogre::RenderWindow *  rw  )  [protected, virtual]

Referenced by init().

virtual void OMK::Inp::DistributedCameraListener::windowClosed ( Ogre::RenderWindow *  rw  )  [protected, virtual]

Referenced by finish().

virtual bool OMK::Inp::DistributedCameraListener::processUnbufferedKeyInput ( const Ogre::FrameEvent &  evt  )  [protected, virtual]

virtual bool OMK::Inp::DistributedCameraListener::processUnbufferedMouseInput ( const Ogre::FrameEvent &  evt  )  [protected, virtual]

virtual bool OMK::Inp::DistributedCameraListener::frameStarted ( const Ogre::FrameEvent &  evt  )  [protected, virtual]

void DistributedCameraListener::init (  )  [protected, virtual]

initialise the object.

Use this member function for any initilisation than can only be done when all the simulated objects have been created. In particular, plugging the input of the objects should be done here. By default, this member function calls the initialisation of the associated computational object.

Reimplemented from OMK::SimulatedObject.

Definition at line 45 of file OMKDistributedCameraListener.cpp.

References _inputManager, _keyboard, _mouse, _ogreVis, readConfigurationParameters(), OMK::Vis::OgreVis::touchRoot(), and windowResized().

00046 {
00047   readConfigurationParameters() ;
00048 
00049   ParamList pl ;
00050   size_t windowHnd( 0 ) ;
00051   std::ostringstream windowHndStr ;
00052 
00053 #if defined WIN32
00054   // Uncomment these two lines to allow users to switch keyboards via the language bar
00055   pl.insert(std::make_pair( std::string( "w32_keyboard" ), std::string( "DISCL_FOREGROUND" ) ) );
00056   pl.insert(std::make_pair( std::string( "w32_keyboard" ), std::string( "DISCL_NONEXCLUSIVE" ) ) );
00057 
00058 #elif defined OIS_LINUX_PLATFORM
00059   pl.insert( std::make_pair( std::string( "XAutoRepeatOn" ), std::string( "true") ) );    
00060   pl.insert( std::make_pair( std::string( "x11_mouse_hide" ), std::string( "false" ) ) );    
00061   pl.insert( std::make_pair( std::string( "x11_mouse_grab" ), std::string( "false" ) ) );    
00062   pl.insert( std::make_pair( std::string( "x11_keyboard_grab" ), std::string( "false" ) ) );    
00063 #endif
00064 
00065   _ogreVis->touchRoot().getAutoCreatedWindow()->getCustomAttribute( "WINDOW", &windowHnd ) ;
00066   windowHndStr << windowHnd ;
00067   pl.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str() ) ) ;
00068 
00069   _inputManager = InputManager::createInputSystem( pl ) ;
00070 
00071   //create devices
00072   _keyboard = static_cast<Keyboard*>( _inputManager->createInputObject( OISKeyboard, false ) ) ;
00073   _mouse = static_cast<Mouse*>( _inputManager->createInputObject( OISMouse, false ) ) ;
00074 
00075   //Set initial mouse clipping size
00076   windowResized( _ogreVis->touchRoot().getAutoCreatedWindow() );
00077 
00078   //Register as a Window listener
00079   WindowEventUtilities::addWindowEventListener( _ogreVis->touchRoot().getAutoCreatedWindow(), this ) ;
00080 
00081   //register as a frame listener
00082   _ogreVis->touchRoot().addFrameListener( this ) ;
00083 }

void DistributedCameraListener::finish (  )  [protected, virtual]

finish calculation of evolution.

by default, this member function does nothing. Finish is usefull in the event of having the simulation restarted whitout complete destruction of the objects

Reimplemented from OMK::SimulatedObject.

Definition at line 89 of file OMKDistributedCameraListener.cpp.

References _ogreVis, OMK::Vis::OgreVis::touchRoot(), and windowClosed().

00090 {
00091   //Remove ourself as a Window listener
00092   WindowEventUtilities::removeWindowEventListener( _ogreVis->touchRoot().getAutoCreatedWindow(), this ) ;
00093   windowClosed( _ogreVis->touchRoot().getAutoCreatedWindow() ) ;
00094 }

void DistributedCameraListener::compute (  )  [protected, virtual]

compute evolution of this object.

Reimplemented from OMK::SimulatedObject.

Definition at line 100 of file OMKDistributedCameraListener.cpp.

References _transform, and _updateTransform.

00101 {
00102   if ( _updateTransform == true )
00103   {
00104    // std::cerr << "DistributedCameraListener::compute() Signal" << std::endl ;
00105     fireValuedSignal< TransformType >( "moveCamera", _transform ) ;
00106     _updateTransform = false ;
00107   }
00108 }

void DistributedCameraListener::readConfigurationParameters (  )  [protected]

Definition at line 114 of file OMKDistributedCameraListener.cpp.

References _ogreVis, OMK::ParametersAccessor::get(), OMK::SimulatedObject::getConfigurationParameters(), OMK::SimulatedObject::getController(), OMK::Vis::OgreVis::getRoot(), and OMASSERT.

Referenced by init().

00115 {
00116   const ConfigurationParameterDescriptor* node( getConfigurationParameters() ) ;
00117 
00118   // Retrieve the VisuName parameter
00119   std::string visuName ;
00120   ParametersAccessor::get( node, "VisuName", visuName ) ;
00121   OMASSERT( ( visuName.empty() == false ) && "The VisuName configuration parameter must be declared" ) ;
00122   SimulatedObject* vis( getController().getPointerToSimulatedObjectNamed( visuName ) ) ;
00123   OMASSERT( ( vis != NULL ) && "The VisuName configuration parameter is not a SimulatedObject" ) ;
00124   _ogreVis = dynamic_cast<OgreVis*>( vis ) ;
00125   OMASSERT( ( _ogreVis != NULL ) && "The VisuName configuration parameter is not an OgreVis" ) ;
00126   OMASSERT( ( _ogreVis->getRoot().isInitialised() == true ) && "The OgreVis 'VisuName' is incorrectly initialised" ) ;
00127 }


Member Data Documentation

Vis::OgreVis* OMK::Inp::DistributedCameraListener::_ogreVis [protected]

Definition at line 57 of file OMKDistributedCameraListener.h.

Referenced by finish(), init(), and readConfigurationParameters().

Type::Transform OMK::Inp::DistributedCameraListener::_transform [protected]

Definition at line 58 of file OMKDistributedCameraListener.h.

Referenced by compute().

bool OMK::Inp::DistributedCameraListener::_updateTransform [protected]

Definition at line 59 of file OMKDistributedCameraListener.h.

Referenced by compute().

float OMK::Inp::DistributedCameraListener::_translationSpeed [protected]

Definition at line 60 of file OMKDistributedCameraListener.h.

float OMK::Inp::DistributedCameraListener::_wheelTranslationSpeed [protected]

Definition at line 61 of file OMKDistributedCameraListener.h.

float OMK::Inp::DistributedCameraListener::_rotationSpeed [protected]

Definition at line 62 of file OMKDistributedCameraListener.h.

OIS::InputManager* OMK::Inp::DistributedCameraListener::_inputManager [protected]

Definition at line 65 of file OMKDistributedCameraListener.h.

Referenced by init().

OIS::Mouse* OMK::Inp::DistributedCameraListener::_mouse [protected]

Definition at line 66 of file OMKDistributedCameraListener.h.

Referenced by init().

OIS::Keyboard* OMK::Inp::DistributedCameraListener::_keyboard [protected]

Definition at line 67 of file OMKDistributedCameraListener.h.

Referenced by init().


logo OpenMask

Documentation generated on Mon Jun 9 11:46:04 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007