Index: code/trunk/src/orxonox/particle/ParticleInterface.cc
===================================================================
--- code/trunk/src/orxonox/particle/ParticleInterface.cc	(revision 1505)
+++ code/trunk/src/orxonox/particle/ParticleInterface.cc	(revision 1552)
@@ -34,115 +34,122 @@
 #include "ParticleInterface.h"
 
-// #include <OgreParticleSystem.h>
-// #include <Ogre.h>
-// #include <OIS/OIS.h>
-// #include <CEGUI/CEGUI.h>
-// #include <CEGUIRenderer.h>
+#include <OgreParticleSystem.h>
+#include <OgreParticleEmitter.h>
+#include <OgreSceneManager.h>
 
+#include "GraphicsEngine.h"
+#include "util/Convert.h"
 
+namespace orxonox
+{
+  unsigned int ParticleInterface::counter_s = 0;
+  ParticleInterface* ParticleInterface::currentParticleInterface_s = 0;
 
-namespace orxonox {
-  using namespace Ogre;
-
-  ParticleInterface::ParticleInterface( SceneManager *sceneManager, std::string name, std::string templateName )
+  ParticleInterface::ParticleInterface(const std::string& templateName)
   {
-    sceneManager_ = sceneManager;
-    particleSystem_ = sceneManager->createParticleSystem(name, templateName);
-
-    //Variabeln einlesen, Emitter1_ ist Referenz-Emitter
-    velocity_ = particleSystem_->getSpeedFactor();
-    colour_ = particleSystem_->getEmitter(0)->getColour();
-    rate_ = particleSystem_->getEmitter(0)->getEmissionRate();
-    distance_ = particleSystem_->getEmitter(0)->getTimeToLive();
-
-    //Anzahl der Emitter
-    numberOfEmitters_ = particleSystem_->getNumEmitters();
-    standardizeEmitters();
+    this->sceneNode_ = 0;
+    this->particleSystem_ = GraphicsEngine::getSingleton().getSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
   }
 
-  ParticleInterface::~ParticleInterface(void)
+  ParticleInterface::~ParticleInterface()
   {
-    while(particleSystem_->getNumEmitters()>0)
-      particleSystem_->removeEmitter(particleSystem_->getNumEmitters()-1);
-    sceneManager_->destroyParticleSystem(particleSystem_);
+    this->particleSystem_->removeAllEmitters();
+    GraphicsEngine::getSingleton().getSceneManager()->destroyParticleSystem(particleSystem_);
   }
 
-  void ParticleInterface::standardizeEmitters(void)
+  void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode)
   {
-    //Abgleichen der anderen Emitter an die Variabeln
-    for (int i=0; i < numberOfEmitters_; i++) {
-      particleSystem_->getEmitter(i)->setColour( colour_ );
-      particleSystem_->getEmitter(i)->setTimeToLive( distance_ );
-      particleSystem_->getEmitter(i)->setEmissionRate( rate_ );
-    }
-
+    this->sceneNode_ = sceneNode;
+    this->sceneNode_->attachObject(this->particleSystem_);
   }
 
-  void ParticleInterface::setVelocity(Real v)
+  void ParticleInterface::detachFromSceneNode()
   {
-    velocity_ = v;
-    //partikel anpassen
-    particleSystem_->setSpeedFactor(v);
-  }
-
-  void ParticleInterface::setRate(float r)
-  {
-    rate_ = r;
-    //partikel anpassen
-    for (int i=0; i<numberOfEmitters_; i++) {
-      particleSystem_->getEmitter(i)->setEmissionRate(rate_);
+    if (this->sceneNode_)
+    {
+      this->sceneNode_->detachObject(this->particleSystem_);
+      this->sceneNode_ = 0;
     }
   }
 
-  void ParticleInterface::setDistance(Real d)
+  Ogre::ParticleEmitter* ParticleInterface::createNewEmitter()
   {
-    distance_ = d;
-    //partikel anpassen
-    for (int i=0; i < numberOfEmitters_; i++) {
-      particleSystem_->getEmitter(i)->setTimeToLive(distance_);
+    if (this->particleSystem_->getNumEmitters() > 0)
+    {
+      Ogre::ParticleEmitter* newemitter = this->particleSystem_->addEmitter(this->particleSystem_->getEmitter(0)->getType());
+      this->particleSystem_->getEmitter(0)->copyParametersTo(newemitter);
+      return newemitter;
     }
+    else
+      return 0;
+  }
+  Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const
+  {
+    if (emitterNr < this->particleSystem_->getNumEmitters())
+      return this->particleSystem_->getEmitter(emitterNr);
+    else
+      return 0;
+  }
+  void ParticleInterface::removeEmitter(unsigned int emitterNr)
+  {
+    if (emitterNr < this->particleSystem_->getNumEmitters())
+      this->particleSystem_->removeEmitter(emitterNr);
+  }
+  void ParticleInterface::removeAllEmitters()
+  {
+    this->particleSystem_->removeAllEmitters();
+  }
+  unsigned int ParticleInterface::getNumEmitters() const
+  {
+    return this->particleSystem_->getNumEmitters();
   }
 
-  void ParticleInterface::setColour(ColourValue colour)
+  Ogre::ParticleAffector* ParticleInterface::addAffector(const std::string& name)
   {
-    colour_ = colour;
-    //partikel anpassen
-    for (int i=0; i < numberOfEmitters_; i++) {
-      particleSystem_->getEmitter(i)->setColour(colour_);
-    }
+    return this->particleSystem_->addAffector(name);
+  }
+  Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) const
+  {
+    if (affectorNr < this->particleSystem_->getNumAffectors())
+      return this->particleSystem_->getAffector(affectorNr);
+    else
+      return 0;
+  }
+  void ParticleInterface::removeAffector(unsigned int affectorNr)
+  {
+    if (affectorNr < this->particleSystem_->getNumAffectors())
+      this->particleSystem_->removeAffector(affectorNr);
+  }
+  void ParticleInterface::removeAllAffectors()
+  {
+    this->particleSystem_->removeAllAffectors();
+  }
+  unsigned int ParticleInterface::getNumAffectors() const
+  {
+    return this->particleSystem_->getNumAffectors();
   }
 
-  ParticleEmitter* ParticleInterface::getEmitter( int emitterNr )
+  void ParticleInterface::setEnabled(bool enable)
   {
-    if ( (emitterNr >= numberOfEmitters_) || (emitterNr < 0) ) return NULL;
-    return particleSystem_->getEmitter(emitterNr);
+    for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++)
+      this->particleSystem_->getEmitter(i)->setEnabled(enable);
   }
 
-  void ParticleInterface::newEmitter ()
+  void ParticleInterface::setSpeedFactor(float factor)
   {
-    particleSystem_->addEmitter(particleSystem_->getEmitter(0)->getType());
-    particleSystem_->getEmitter(0)->copyParametersTo( particleSystem_->getEmitter(numberOfEmitters_) );
-    numberOfEmitters_++;
+    this->particleSystem_->setSpeedFactor(factor);
+  }
+  float ParticleInterface::getSpeedFactor() const
+  {
+    return this->particleSystem_->getSpeedFactor();
   }
 
-  // TODO check if this really works
-  Vector3 ParticleInterface::getPositionOfEmitter ( int emitterNr )
+  bool ParticleInterface::getKeepParticlesInLocalSpace() const
   {
-    return particleSystem_->getEmitter(emitterNr)->getPosition();
+    return this->particleSystem_->getKeepParticlesInLocalSpace();
   }
-
-  void ParticleInterface::setDirection ( Vector3 direction )
+  void ParticleInterface::setKeepParticlesInLocalSpace(bool keep)
   {
-    for(int i=0; i < numberOfEmitters_; i++) {
-      particleSystem_->getEmitter(i)->setDirection(direction);
-    }
+    this->particleSystem_->setKeepParticlesInLocalSpace(keep);
   }
-
-  void ParticleInterface::switchEnable(){
-    bool enable=(!(particleSystem_->getEmitter(0)->getEnabled()));
-    for(int i=0; i < numberOfEmitters_; i++) {
-      particleSystem_->getEmitter(i)->setEnabled(enable);
-    }
-  }
-
 }
Index: code/trunk/src/orxonox/particle/ParticleInterface.h
===================================================================
--- code/trunk/src/orxonox/particle/ParticleInterface.h	(revision 1505)
+++ code/trunk/src/orxonox/particle/ParticleInterface.h	(revision 1552)
@@ -21,5 +21,5 @@
  *
  *   Author:
- *      Fabian 'x3n' Landau
+ *      ...
  *   Co-authors:
  *      ...
@@ -33,77 +33,57 @@
 
 #include <string>
-
-// #include "ParticleInterface.h"
-// #include <Ogre.h>
-// #include <OIS/OIS.h>
-// #include <CEGUI/CEGUI.h>
-// #include <CEGUIRenderer.h>
-#include <OgreParticleSystem.h>
 #include <OgreParticleEmitter.h>
-#include <OgreSceneManager.h>
 
 #include "util/Math.h"
 
+#define getAllEmitters() \
+  storeThisAsCurrentParticleInterface(); \
+  for (unsigned int i = 0; i < ParticleInterface::getCurrentParticleInterface()->getNumEmitters(); ++i) \
+    ParticleInterface::getCurrentParticleInterface()->getEmitter(i)
 
 namespace orxonox
 {
-
   class _OrxonoxExport ParticleInterface
   {
-  public:
+    public:
+      ParticleInterface(const std::string& templateName);
+      ~ParticleInterface();
 
-    ParticleInterface( Ogre::SceneManager *sceneManager, std::string name, std::string templateName );
-    ~ParticleInterface( void );
+      inline Ogre::ParticleSystem* getParticleSystem() const
+        { return this->particleSystem_; }
 
-    inline void addToSceneNode( Ogre::SceneNode* sceneNode )
-        { sceneNode_ = sceneNode; sceneNode_->attachObject(particleSystem_);};
-    inline void detachFromSceneNode( void )
-        { sceneNode_->detachObject(particleSystem_); sceneNode_ = NULL;};
+      void addToSceneNode(Ogre::SceneNode* sceneNode);
+      void detachFromSceneNode();
 
-    Ogre::ParticleEmitter* getEmitter ( int emitterNr );
-    void newEmitter ( void );
+      Ogre::ParticleEmitter* createNewEmitter();
+      Ogre::ParticleEmitter* getEmitter(unsigned int emitterNr) const;
+      void removeEmitter(unsigned int emitterNr);
+      void removeAllEmitters();
+      unsigned int getNumEmitters() const;
 
-    Vector3 getPositionOfEmitter ( int emitterNr );
-    inline void setPositionOfEmitter ( int emitterNr, Vector3 position )
-        { particleSystem_->getEmitter(emitterNr)->setPosition(position); };
+      Ogre::ParticleAffector* addAffector(const std::string& name);
+      Ogre::ParticleAffector* getAffector(unsigned int affectorNr) const;
+      void removeAffector(unsigned int affectorNr);
+      void removeAllAffectors();
+      unsigned int getNumAffectors() const;
 
-    inline Vector3 getDirection ( void )
-        { return particleSystem_->getEmitter(0)->getDirection(); };
-    void setDirection ( Vector3 direction );
+      float getSpeedFactor() const;
+      void setSpeedFactor(float factor);
+      bool getKeepParticlesInLocalSpace() const;
+      void setKeepParticlesInLocalSpace(bool keep);
 
-    inline Real getVelocity()
-        {return velocity_; };
-    void setVelocity( Real v );
+      void setEnabled(bool enable);
 
-    inline float getRate()
-      { return rate_; };
-    void setRate( float r );
+      inline void storeThisAsCurrentParticleInterface()
+        { ParticleInterface::currentParticleInterface_s = this; }
+      inline static ParticleInterface* getCurrentParticleInterface()
+        { return ParticleInterface::currentParticleInterface_s; }
 
-    inline Real getDistance()
-        { return distance_; };
-    void setDistance( Real d );
-
-    inline ColourValue getColour( void )
-        {return colour_;};
-    void setColour( ColourValue colour );
-
-    void switchEnable();
-
-    inline Ogre::ParticleSystem* getParticleSystem()
-        { return this->particleSystem_; };
-
-  private:
-    Ogre::SceneNode *sceneNode_;
-    Ogre::SceneManager *sceneManager_;
-    Ogre::ParticleSystem *particleSystem_;
-    Real distance_;
-    Real velocity_;
-    float rate_;
-    ColourValue colour_;
-    int numberOfEmitters_;
-
-    void standardizeEmitters();
+    private:
+      static ParticleInterface* currentParticleInterface_s;
+      static unsigned int counter_s;
+      Ogre::SceneNode* sceneNode_;
+      Ogre::ParticleSystem* particleSystem_;
   };
-
 }
 
