Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 7, 2008, 11:40:50 PM (16 years ago)
Author:
landauf
Message:
  • added configurable detaillevel for particle effects to [GraphicsEngine]
  • thrusters work properly with changing gamespeed
Location:
code/trunk/src/orxonox/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/tools/ParticleInterface.cc

    r1555 r1563  
    4040#include "GraphicsEngine.h"
    4141#include "Orxonox.h"
     42#include "core/CoreIncludes.h"
    4243#include "util/Convert.h"
    4344
     
    4748  ParticleInterface* ParticleInterface::currentParticleInterface_s = 0;
    4849
    49   ParticleInterface::ParticleInterface(const std::string& templateName)
     50  ParticleInterface::ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel)
    5051  {
     52    RegisterRootObject(ParticleInterface);
     53
    5154    this->sceneNode_ = 0;
     55    this->bEnabled_ = true;
     56    this->detaillevel_ = (unsigned int)detaillevel;
    5257    this->particleSystem_ = GraphicsEngine::getSingleton().getSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
    5358    this->particleSystem_->setSpeedFactor(Orxonox::getSingleton()->getTimeFactor());
     59
     60    if (GraphicsEngine::getSingleton().getDetailLevelParticle() < (unsigned int)this->detaillevel_)
     61    {
     62      this->bVisible_ = false;
     63      this->updateVisibility();
     64    }
     65    else
     66    {
     67      this->bVisible_ = true;
     68    }
    5469  }
    5570
     
    134149  void ParticleInterface::setEnabled(bool enable)
    135150  {
     151    this->bEnabled_ = enable;
     152    this->updateVisibility();
     153  }
     154
     155  void ParticleInterface::detailLevelChanged(unsigned int newlevel)
     156  {
     157    if (newlevel >= (unsigned int)this->detaillevel_)
     158      this->bVisible_ = true;
     159    else
     160      this->bVisible_ = false;
     161
     162    this->updateVisibility();
     163  }
     164
     165  void ParticleInterface::updateVisibility()
     166  {
    136167    for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++)
    137       this->particleSystem_->getEmitter(i)->setEnabled(enable);
     168      this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bVisible_);
    138169  }
    139170
     
    144175  float ParticleInterface::getSpeedFactor() const
    145176  {
    146     return this->particleSystem_->getSpeedFactor();
     177    return (this->particleSystem_->getSpeedFactor() / Orxonox::getSingleton()->getTimeFactor());
    147178  }
    148179
  • code/trunk/src/orxonox/tools/ParticleInterface.h

    r1553 r1563  
    3535#include <OgreParticleEmitter.h>
    3636
     37#include "core/OrxonoxClass.h"
    3738#include "util/Math.h"
    3839
     
    4445namespace orxonox
    4546{
    46   class _OrxonoxExport ParticleInterface
     47  class _OrxonoxExport ParticleInterface : public OrxonoxClass
    4748  {
    4849    public:
    49       ParticleInterface(const std::string& templateName);
     50      ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel);
    5051      ~ParticleInterface();
    5152
     
    7475
    7576      void setEnabled(bool enable);
     77      void detailLevelChanged(unsigned int newlevel);
    7678
    7779      inline void storeThisAsCurrentParticleInterface()
     
    8183
    8284    private:
     85      void updateVisibility();
     86
    8387      static ParticleInterface* currentParticleInterface_s;
    8488      static unsigned int counter_s;
    8589      Ogre::SceneNode* sceneNode_;
    8690      Ogre::ParticleSystem* particleSystem_;
     91      bool bVisible_;
     92      bool bEnabled_;
     93      unsigned int detaillevel_;                            //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high)
    8794  };
    8895}
Note: See TracChangeset for help on using the changeset viewer.