Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ogre::ControllerManager Class Reference

Class for managing Controller instances. More...

#include <OgreControllerManager.h>

Inheritance diagram for Ogre::ControllerManager:

Inheritance graph
[legend]
List of all members.

Public Methods

 ControllerManager ()
 ~ControllerManager ()
Controller< Real > * createController (SharedPtr< ControllerValue< Real > > src, SharedPtr< ControllerValue< Real > > dest, SharedPtr< ControllerFunction< Real > > func)
 Creates a new controller and registers it with the manager.

void clearControllers (void)
 Destroys all the controllers in existence.

void updateAllControllers (void)
 Updates all the registered controllers.

SharedPtr< ControllerValue<
Real > > 
getFrameTimeSource (void) const
 Returns a ControllerValue which provides the time since the last frame as a control value source.

Controller< Real > * createTextureAnimator (TextureUnitState *layer, Real sequenceTime)
 Creates a texture layer animator controller.

Controller< Real > * createTextureScroller (TextureUnitState *layer, Real uSpeed, Real vSpeed)
 Creates a basic time-based texture coordinate modifier designed for creating scrolling textures.

Controller< Real > * createTextureRotater (TextureUnitState *layer, Real speed)
 Creates a basic time-based texture coordinate modifier designed for creating rotating textures.

Controller< Real > * createTextureWaveTransformer (TextureUnitState *layer, TextureUnitState::TextureTransformType ttype, WaveformType waveType, Real base=0, Real frequency=1, Real phase=0, Real amplitude=1)
 Creates a very flexible time-based texture transformation which can alter the scale, position or rotation of a texture based on a wave function.

Controller< Real > * createGpuProgramTimerParam (GpuProgramParameters *params, size_t paramIndex, Real timeFactor=1.0f)
 Creates a controller for passing a frame time value through to a vertex / fragment program parameter.

void destroyController (Controller< Real > *controller)
 Removes & destroys the controller passed in as a pointer.

Real getTimeFactor (void) const
 Return relative speed of time as perceived by time based controllers.

void setTimeFactor (Real tf)
 Set the relative speed to update frame time based controllers.


Static Public Methods

ControllerManager & getSingleton (void)
 Override standard Singleton retrieval.

ControllerManager * getSingletonPtr (void)
 Override standard Singleton retrieval.


Protected Types

typedef std::set< Controller<
Real > * > 
ControllerList

Protected Attributes

ControllerList mControllers
SharedPtr< ControllerValue<
Real > > 
mFrameTimeController
 Global predefined controller.


Static Protected Attributes

ControllerManager * ms_Singleton = 0

Detailed Description

Class for managing Controller instances.

Remarks:
This class is responsible to keeping tabs on all the Controller instances registered and updating them when requested. It also provides a number of convenience methods for creating commonly used controllers (such as texture animators).

Definition at line 46 of file OgreControllerManager.h.


Member Typedef Documentation

typedef std::set<Controller<Real>*> Ogre::ControllerManager::ControllerList [protected]
 

Definition at line 49 of file OgreControllerManager.h.


Constructor & Destructor Documentation

Ogre::ControllerManager::ControllerManager  
 

Definition at line 44 of file OgreControllerManager.cpp.

References new.

Ogre::ControllerManager::~ControllerManager  
 

Definition at line 50 of file OgreControllerManager.cpp.

References clearControllers().


Member Function Documentation

void Ogre::ControllerManager::clearControllers void   
 

Destroys all the controllers in existence.

Definition at line 74 of file OgreControllerManager.cpp.

References mControllers.

Referenced by ~ControllerManager().

Controller< Real > * Ogre::ControllerManager::createController SharedPtr< ControllerValue< Real > >    src,
SharedPtr< ControllerValue< Real > >    dest,
SharedPtr< ControllerFunction< Real > >    func
 

Creates a new controller and registers it with the manager.

Definition at line 55 of file OgreControllerManager.cpp.

References mControllers.

Referenced by createGpuProgramTimerParam(), createTextureAnimator(), createTextureRotater(), createTextureScroller(), and createTextureWaveTransformer().

Controller< Real > * Ogre::ControllerManager::createGpuProgramTimerParam GpuProgramParameters   params,
size_t    paramIndex,
Real    timeFactor = 1.0f
 

Creates a controller for passing a frame time value through to a vertex / fragment program parameter.

Remarks:
The destination parameter is expected to be a float, and the '.x' attribute will be populated with the appropriately scaled time value.
Parameters:
params  The parameters to update
paramIndex  The index of the parameter to update; if you want a named parameter, then retrieve the index beforehand using GpuProgramParameters::getParamIndex
factor  The factor by which to adjust the time elapsed by before passing it to the program

Definition at line 187 of file OgreControllerManager.cpp.

References Ogre::SharedPtr< T >::bind(), createController(), mFrameTimeController, params, and Ogre::Real.

Controller< Real > * Ogre::ControllerManager::createTextureAnimator TextureUnitState   layer,
Real    sequenceTime
 

Creates a texture layer animator controller.

Remarks:
This helper method creates the Controller, ControllerValue and ControllerFunction classes required to animate a texture.
Parameters:
layer  TextureUnitState object to animate
sequenceTime  The amount of time in seconds it will take to loop through all the frames.

Definition at line 89 of file OgreControllerManager.cpp.

References createController(), mFrameTimeController, and Ogre::Real.

Controller< Real > * Ogre::ControllerManager::createTextureRotater TextureUnitState   layer,
Real    speed
 

Creates a basic time-based texture coordinate modifier designed for creating rotating textures.

Returns:
This simple method allows you to easily create constant-speed rotating textures. If you want more control, look up the ControllerManager::createTextureWaveTransformer for more complex wave-based scrollers / stretchers / rotaters.
Parameters:
layer  The texture layer to rotate.
vSpeed  Speed of rotation, in complete anticlockwise revolutions per second

Definition at line 137 of file OgreControllerManager.cpp.

References Ogre::SharedPtr< T >::bind(), createController(), mFrameTimeController, and Ogre::Real.

Referenced by Ogre::TextureUnitState::createEffectController().

Controller< Real > * Ogre::ControllerManager::createTextureScroller TextureUnitState   layer,
Real    uSpeed,
Real    vSpeed
 

Creates a basic time-based texture coordinate modifier designed for creating scrolling textures.

Remarks:
This simple method allows you to easily create constant-speed scrolling textures. If you want more control, look up the ControllerManager::createTextureWaveTransformer for more complex wave-based scrollers / stretchers / rotaters.
Parameters:
layer  The texture layer to animate.
uSpeed  Speed of horizontal (u-coord) scroll, in complete wraps per second
vSpeed  Speed of vertical (v-coord) scroll, in complete wraps per second

Definition at line 97 of file OgreControllerManager.cpp.

References Ogre::SharedPtr< T >::bind(), createController(), mFrameTimeController, and Ogre::Real.

Referenced by Ogre::TextureUnitState::createEffectController().

Controller< Real > * Ogre::ControllerManager::createTextureWaveTransformer TextureUnitState   layer,
TextureUnitState::TextureTransformType    ttype,
WaveformType    waveType,
Real    base = 0,
Real    frequency = 1,
Real    phase = 0,
Real    amplitude = 1
 

Creates a very flexible time-based texture transformation which can alter the scale, position or rotation of a texture based on a wave function.

Parameters:
layer  The texture layer to affect
ttype  The type of transform, either translate (scroll), scale (stretch) or rotate (spin)
waveType  The shape of the wave, see WaveformType enum for details
base  The base value of the output
frequency  The speed of the wave in cycles per second
phase  The offset of the start of the wave, e.g. 0.5 to start half-way through the wave
amplitude  Scales the output so that instead of lying within 0..1 it lies within 0..1*amplitude for exaggerated effects

Definition at line 152 of file OgreControllerManager.cpp.

References Ogre::SharedPtr< T >::bind(), createController(), mFrameTimeController, Ogre::Real, and Ogre::WaveformType.

Referenced by Ogre::TextureUnitState::createEffectController().

void Ogre::ControllerManager::destroyController Controller< Real > *    controller
 

Removes & destroys the controller passed in as a pointer.

Definition at line 200 of file OgreControllerManager.cpp.

References mControllers.

SharedPtr< ControllerValue< Real > > Ogre::ControllerManager::getFrameTimeSource void    const
 

Returns a ControllerValue which provides the time since the last frame as a control value source.

Remarks:
A common source value to use to feed into a controller is the time since the last frame. This method returns a pointer to a common source value which provides this information.

Remember the value will only be up to date after the RenderSystem::beginFrame method is called.

See also:
RenderSystem::beginFrame

Definition at line 84 of file OgreControllerManager.cpp.

References mFrameTimeController.

ControllerManager & Ogre::ControllerManager::getSingleton void    [static]
 

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.

This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from Ogre::Singleton< ControllerManager >.

Definition at line 39 of file OgreControllerManager.cpp.

References Ogre::Singleton< ControllerManager >::ms_Singleton.

ControllerManager * Ogre::ControllerManager::getSingletonPtr void    [static]
 

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.

This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from Ogre::Singleton< ControllerManager >.

Definition at line 35 of file OgreControllerManager.cpp.

References Ogre::Singleton< ControllerManager >::ms_Singleton.

Real Ogre::ControllerManager::getTimeFactor void    const
 

Return relative speed of time as perceived by time based controllers.

Remarks:
See setTimeFactor for full information on the meaning of this value.

Definition at line 210 of file OgreControllerManager.cpp.

References Ogre::SharedPtr< ControllerValue< Real > >::get(), mFrameTimeController, and Ogre::Real.

void Ogre::ControllerManager::setTimeFactor Real    tf
 

Set the relative speed to update frame time based controllers.

Remarks:
Normally any controllers which use time as an input (FrameTimeController) are updated automatically in line with the real passage of time. This method allows you to change that, so that controllers are told that the time is passing slower or faster than it actually is. Use this to globally speed up / slow down the effect of time-based controllers.
Parameters:
tf  The virtual speed of time (1.0 is real time).

Definition at line 214 of file OgreControllerManager.cpp.

References Ogre::SharedPtr< ControllerValue< Real > >::getPointer(), mFrameTimeController, and Ogre::Real.

void Ogre::ControllerManager::updateAllControllers void   
 

Updates all the registered controllers.

Definition at line 65 of file OgreControllerManager.cpp.

References mControllers, and Ogre::Controller< T >::update().


Member Data Documentation

ControllerList Ogre::ControllerManager::mControllers [protected]
 

Definition at line 50 of file OgreControllerManager.h.

Referenced by clearControllers(), createController(), destroyController(), and updateAllControllers().

SharedPtr< ControllerValue<Real> > Ogre::ControllerManager::mFrameTimeController [protected]
 

Global predefined controller.

Definition at line 53 of file OgreControllerManager.h.

Referenced by createGpuProgramTimerParam(), createTextureAnimator(), createTextureRotater(), createTextureScroller(), createTextureWaveTransformer(), getFrameTimeSource(), getTimeFactor(), and setTimeFactor().

ControllerManager * Ogre::Singleton< ControllerManager >::ms_Singleton = 0 [static, protected, inherited]
 

Definition at line 34 of file OgreControllerManager.cpp.

Referenced by getSingleton(), and getSingletonPtr().


The documentation for this class was generated from the following files:

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:50:51 2004