# Ogre::LinearForceAffector Class Reference

This class defines a ParticleAffector which applies a linear force to particles in a system. More...

`#include <OgreLinearForceAffector.h>`

Inheritance diagram for Ogre::LinearForceAffector:

List of all members.

## Public Types

enum | ForceApplication { FA_AVERAGE, FA_ADD }
| Choice of how to apply the force vector to particles. More...

## Public Member Functions

| LinearForceAffector (ParticleSystem *psys)
| Default constructor.
void | _affectParticles (ParticleSystem *pSystem, Real timeElapsed)
| See ParticleAffector.
void | setForceVector (const Vector3 &force)
| Sets the force vector to apply to the particles in a system.
Vector3 | getForceVector (void) const
| Gets the force vector to apply to the particles in a system.
void | setForceApplication (ForceApplication fa)
| Sets how the force vector is applied to a particle.
ForceApplication | getForceApplication (void) const
| Retrieves how the force vector is applied to a particle.
virtual void | _initParticle (Particle *pParticle)
| Method called to allow the affector to initialize all newly created particles in the system.
const String & | getType (void) const
| Returns the name of the type of affector.
ParamDictionary * | getParamDictionary (void)
| Retrieves the parameter dictionary for this class.
const ParamDictionary * | getParamDictionary (void) const
const ParameterList & | getParameters (void) const
| Retrieves a list of parameters valid for this object.
virtual bool | setParameter (const String &name, const String &value)
| Generic parameter setting method.
virtual void | setParameterList (const NameValuePairList &paramList)
| Generic multiple parameter setting method.
virtual String | getParameter (const String &name) const
| Generic parameter retrieval method.
virtual void | copyParametersTo (StringInterface *dest) const
| Method for copying this object's parameters to another object.

## Static Public Member Functions

void | cleanupDictionary ()
| Cleans up the static 'msDictionary' required to reset Ogre, otherwise the containers are left with invalid pointers, which will lead to a crash as soon as one of the ResourceManager implementers (e.g.

## Static Public Attributes

CmdForceVector | msForceVectorCmd
| Command objects.
CmdForceApp | msForceAppCmd

## Protected Member Functions

void | addBaseParameters (void)
| Internal method for setting up the basic parameter definitions for a subclass.
bool | createParamDictionary (const String &className)
| Internal method for creating a parameter dictionary for the class, if it does not already exist.

## Protected Attributes

Vector3 | mForceVector
| Force vector.
ForceApplication | mForceApplication
| How to apply force.
String | mType
| Name of the type of affector, MUST be initialised by subclasses.
ParticleSystem * | mParent
String | mParamDictName
| Class name for this instance to be used as a lookup (must be initialised by subclasses).

## Static Protected Attributes

ParamDictionaryMap | msDictionary
| Dictionary of parameters.

## Detailed Description

This class defines a ParticleAffector which applies a linear force to particles in a system.

Remarks:
  This affector (see ParticleAffector) applies a linear force, such as gravity, to a particle system. This force can be applied in 2 ways: by taking the average of the particle's current momentum and the force vector, or by adding the force vector to the current particle's momentum.

  The former approach is self-stabilising i.e. once a particle's momentum is equal to the force vector, no further change is made to it's momentum. It also results in a non-linear acceleration of particles. The latter approach is simpler and applies a constant acceleration to particles. However, it is not self-stabilising and can lead to perpetually increasing particle velocities. You choose the approach by calling the setForceApplication method.

Definition at line 48 of file OgreLinearForceAffector.h.

## Member Enumeration Documentation

enum Ogre::LinearForceAffector::ForceApplication

Choice of how to apply the force vector to particles.

Enumeration values:

  FA_AVERAGE | Take the average of the force vector and the particle momentum.
  FA_ADD | Add the force vector to the particle momentum.

Definition at line 67 of file OgreLinearForceAffector.h.

## Constructor & Destructor Documentation

Ogre::LinearForceAffector::LinearForceAffector | ( | ParticleSystem * | psys | ) |

| Default constructor.

## Member Function Documentation

void Ogre::LinearForceAffector::_affectParticles | ( | ParticleSystem * | pSystem,
|  | Real | timeElapsed
| ) | `[virtual]`

| See ParticleAffector. Implements Ogre::ParticleAffector.

virtual void Ogre::ParticleAffector::_initParticle | ( | Particle * | pParticle | ) | `[virtual, inherited]`

Method called to allow the affector to initialize all newly created particles in the system.

Remarks:
  This is where the affector gets the chance to initialize it's effects to the particles of a system. The affector is expected to initialize some or all of the particles in the system passed to it, depending on the affector's approach.

Parameters:

  pParticle | Pointer to a Particle to initialize.

Reimplemented in Ogre::ColourImageAffector, and Ogre::RotationAffector.

Definition at line 85 of file OgreParticleAffector.h.

void Ogre::ParticleAffector::addBaseParameters | ( | void |  | ) | `[protected, inherited]`

Internal method for setting up the basic parameter definitions for a subclass.

Remarks:
  Because StringInterface holds a dictionary of parameters per class, subclasses need to call this to ask the base class to add it's parameters to their dictionary as well. Can't do this in the constructor because that runs in a non-virtual context.

  The subclass must have called it's own createParamDictionary before calling this method.

Definition at line 68 of file OgreParticleAffector.h.

void Ogre::StringInterface::cleanupDictionary | ( |  | ) | `[static, inherited]`

| Cleans up the static 'msDictionary' required to reset Ogre, otherwise the containers are left with invalid pointers, which will lead to a crash as soon as one of the ResourceManager implementers (e.g. MaterialManager) initializes.

virtual void Ogre::StringInterface::copyParametersTo | ( | StringInterface * | dest | ) | const`[virtual, inherited]`

Method for copying this object's parameters to another object.

Remarks:
  This method takes the values of all the object's parameters and tries to set the same values on the destination object. This provides a completely type independent way to copy parameters to other objects. Note that because of the String manipulation involved, this should not be regarded as an efficient process and should be saved for times outside of the rendering loop.

  Any unrecognised parameters will be ignored as with setParameter method.

Parameters:

  dest | Pointer to object to have it's parameters set the same as this object.

Definition at line 296 of file OgreStringInterface.h.

References Ogre::ParamDictionary::mParamDefs, and Ogre::StringInterface::setParameter().

bool Ogre::StringInterface::createParamDictionary | ( | const String & | className | ) | `[protected, inherited]`

Internal method for creating a parameter dictionary for the class, if it does not already exist.

Remarks:
  This method will check to see if a parameter dictionary exist for this class yet, and if not will create one. NB you must supply the name of the class (RTTI is not used or performance).

Parameters:

  className | the name of the class using the dictionary

Returns:
  true if a new dictionary was created, false if it was already there

Definition at line 172 of file OgreStringInterface.h.

References Ogre::String.

ForceApplication Ogre::LinearForceAffector::getForceApplication | ( | void |  | ) | const

Retrieves how the force vector is applied to a particle.

Parameters:

  fa | A member of the ForceApplication enum.

Vector3 Ogre::LinearForceAffector::getForceVector | ( | void |  | ) | const

| Gets the force vector to apply to the particles in a system.

const ParamDictionary* Ogre::StringInterface::getParamDictionary | ( | void |  | ) | const`[inherited]`

| Definition at line 209 of file OgreStringInterface.h.

ParamDictionary* Ogre::StringInterface::getParamDictionary | ( | void |  | ) | `[inherited]`

Retrieves the parameter dictionary for this class.

Remarks:
  Only valid to call this after createParamDictionary.

Returns:
  Pointer to ParamDictionary shared by all instances of this class which you can add parameters to, retrieve parameters etc.

Definition at line 196 of file OgreStringInterface.h.

virtual String Ogre::StringInterface::getParameter | ( | const String & | name | ) | const`[virtual, inherited]`

Generic parameter retrieval method.

Remarks:
  Call this method with the name of a parameter to retrieve a string-format value of the parameter in question. If in doubt, check the parameter definition in the list returned from getParameters for the type of this parameter. If you like you can use StringConverter to convert this string back into a native type.

Parameters:

  name | The name of the parameter to get

Returns:
  String value of parameter, blank if not found

Definition at line 265 of file OgreStringInterface.h.

References Ogre::ParamCommand::doGet(), Ogre::ParamDictionary::getParamCommand(), and Ogre::String.

const ParameterList& Ogre::StringInterface::getParameters | ( | void |  | ) | const`[inherited]`

Retrieves a list of parameters valid for this object.

Returns:
  A reference to a static list of ParameterDef objects.

const String& Ogre::ParticleAffector::getType | ( | void |  | ) | const`[inherited]`

Returns the name of the type of affector.

Remarks:
  This property is useful for determining the type of affector procedurally so another can be created.

Definition at line 104 of file OgreParticleAffector.h.

References Ogre::String.

void Ogre::LinearForceAffector::setForceApplication | ( | ForceApplication | fa | ) |

Sets how the force vector is applied to a particle.

Remarks:
  The default is FA_ADD.

Parameters:

  fa | A member of the ForceApplication enum.

void Ogre::LinearForceAffector::setForceVector | ( | const Vector3 & | force | ) |

| Sets the force vector to apply to the particles in a system.

virtual bool Ogre::StringInterface::setParameter | ( | const String & | name,
|  | const String & | value
| ) | `[virtual, inherited]`

Generic parameter setting method.

Remarks:
  Call this method with the name of a parameter and a string version of the value to set. The implementor will convert the string to a native type internally. If in doubt, check the parameter definition in the list returned from StringInterface::getParameters.

Parameters:

  name | The name of the parameter to set
  value | String value. Must be in the right format for the type specified in the parameter definition. See the StringConverter class for more information.

Returns:
  true if set was successful, false otherwise (NB no exceptions thrown - tolerant method)

Referenced by Ogre::StringInterface::copyParametersTo().

virtual void Ogre::StringInterface::setParameterList | ( | const NameValuePairList & | paramList | ) | `[virtual, inherited]`

Generic multiple parameter setting method.

Remarks:
  Call this method with a list of name / value pairs to set. The implementor will convert the string to a native type internally. If in doubt, check the parameter definition in the list returned from StringInterface::getParameters.

Parameters:

  paramList | Name/value pair list

## Member Data Documentation

ForceApplication Ogre::LinearForceAffector::mForceApplication `[protected]`

| How to apply force. Definition at line 108 of file OgreLinearForceAffector.h.

Vector3 Ogre::LinearForceAffector::mForceVector `[protected]`

| Force vector. Definition at line 105 of file OgreLinearForceAffector.h.

String Ogre::StringInterface::mParamDictName `[protected, inherited]`

| Class name for this instance to be used as a lookup (must be initialised by subclasses). Definition at line 160 of file OgreStringInterface.h.

ParticleSystem* Ogre::ParticleAffector::mParent `[protected, inherited]`

| Definition at line 70 of file OgreParticleAffector.h.

ParamDictionaryMap Ogre::StringInterface::msDictionary `[static, protected, inherited]`

| Dictionary of parameters. Definition at line 157 of file OgreStringInterface.h.

CmdForceApp Ogre::LinearForceAffector::msForceAppCmd `[static]`

| Definition at line 101 of file OgreLinearForceAffector.h.

CmdForceVector Ogre::LinearForceAffector::msForceVectorCmd `[static]`

| Command objects. Definition at line 100 of file OgreLinearForceAffector.h.

String Ogre::ParticleAffector::mType `[protected, inherited]`

| Name of the type of affector, MUST be initialised by subclasses. Definition at line 58 of file OgreParticleAffector.h.

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

- OgreLinearForceAffector.h

Copyright © 2000-2005 by The OGRE Team
Last modified Sun Nov 20 12:43:55 2005