Tactics: Western Philosophers Vs. Musicians  0.12
A turn-based tactical game combining rules and gameplay elements inspired by Final Fantasy Tactics and the Mayfair Exponential Game System. Unlike most games of this type, motion is in full, grid-less 3D.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OgrePathAffector.h
Go to the documentation of this file.
1 // Copyright (C) 2006-2013 Dylan Blair
3 //
4 // email: dblair@alumni.cs.utexas.edu
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 
21 #ifndef OGRE_PATH_AFFECTOR_H
22 #define OGRE_PATH_AFFECTOR_H
23 
25 #include "CParticleObject.h"
26 #include "../../Libs/Utils_LIB/UPrecisionTimer.h"
27 
28 #include <OgreMath.h>
29 #include <OgreParticleAffector.h>
30 #include <OgreParticleAffectorFactory.h>
31 #include <OgreStringInterface.h>
32 
33 #define MAX_PATHS 10
34 #define MIN_SECS_BEFORE_NEW_PATH 1.0f
35 
36 namespace Ogre {
37  class PathEmitter;
38 
40  class _OgreParticleFXExport PathAffector : public ParticleAffector {
41  friend class Ogre::PathEmitter;
42  public:
44  class CmdInterpolatorType : public ParamCommand {
45  public:
46  String doGet(const void* target) const;
47  void doSet(void* target, const String& val);
48  };
49 
50  PathAffector(ParticleSystem* psys);
51  virtual ~PathAffector();
52 
54  void _initParticle(Particle* pParticle);
55 
57  void _affectParticles(ParticleSystem* pSystem, Real timeElapsed);
58 
59  inline void addPath(const OpenSkyNet::Math::Path& path_, const float& interpolatorValue_, bool force_=false) {
60  if (!force_ && (_timer.stop() < MIN_SECS_BEFORE_NEW_PATH)) return;
61 
62  if (_currPathIndex == MAX_PATHS)
63  _currPathIndex = 0;
64  _lastPathIndex = _currPathIndex;
65 
66  _particlePaths[_currPathIndex] = path_;
67  _interpolatorValues[_currPathIndex] = &interpolatorValue_;
68  ++_currPathIndex;
69  _timer.start();
70  }
71 
72  inline OpenSkyNet::Math::Path& getPath(unsigned int index_) { return _particlePaths[index_]; }
73 
74  inline void setInterpolatorType(OpenSkyNet::Math::Interpolator::TYPE interpolatorType_) { _interpolatorType = interpolatorType_; }
75 
76  inline OpenSkyNet::Math::Interpolator::TYPE getInterpolatorType() const { return _interpolatorType; }
77 
79  protected:
82  std::map<Ogre::Particle*, OpenSkyNet::Core::ParticleObject*> _partMap;
84  const float* _interpolatorValues[MAX_PATHS];
85  unsigned int _currPathIndex;
86  unsigned int _lastPathIndex;
88  };
89 
90  class _OgreParticleFXExport PathAffectorFactory : public ParticleAffectorFactory {
92  String getName() const { return "Path"; }
93 
95  ParticleAffector* createAffector(ParticleSystem* psys) {
96  ParticleAffector* p = new PathAffector(psys);
97  mAffectors.push_back(p);
98  return p;
99  }
100  };
101 }
102 
103 #endif //OGRE_PATH_AFFECTOR_H
unsigned int _currPathIndex
Definition: OgrePathAffector.h:85
Definition: OgrePathAffector.h:44
void setInterpolatorType(OpenSkyNet::Math::Interpolator::TYPE interpolatorType_)
Definition: OgrePathAffector.h:74
Definition: OgrePathEmitter.h:31
static CmdInterpolatorType msInterpolatorTypeCmd
Definition: OgrePathAffector.h:78
#define _OgreParticleFXExport
Definition: OgreParticlePluginPrerequisites.h:53
void addPath(const OpenSkyNet::Math::Path &path_, const float &interpolatorValue_, bool force_=false)
Definition: OgrePathAffector.h:59
TYPE
Definition: MInterpolator.h:37
OpenSkyNet::Math::Interpolator::TYPE getInterpolatorType() const
Definition: OgrePathAffector.h:76
#define MAX_PATHS
Definition: OgrePathAffector.h:33
OpenSkyNet::Math::Path & getPath(unsigned int index_)
Definition: OgrePathAffector.h:72
Definition: OgrePathAffector.h:90
OpenSkyNet::Utils::PrecisionTimer _timer
Definition: OgrePathAffector.h:80
OpenSkyNet::Core::PathUpdater * _pathUpd
Definition: OgrePathAffector.h:81
std::map< Ogre::Particle *, OpenSkyNet::Core::ParticleObject * > _partMap
Definition: OgrePathAffector.h:82
Definition: CPathUpdater.h:32
unsigned int _lastPathIndex
Definition: OgrePathAffector.h:86
Definition: UPrecisionTimer.h:58
OpenSkyNet::Math::Interpolator::TYPE _interpolatorType
Definition: OgrePathAffector.h:87
Definition: OgrePathAffector.h:40
#define MIN_SECS_BEFORE_NEW_PATH
Definition: OgrePathAffector.h:34
Definition: MPath.h:31