Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1563 for code/trunk


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
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/core/CommandEvaluation.cc

    r1543 r1563  
    7878        if (this->bEvaluatedParams_ && this->function_)
    7979        {
    80             COUT(4) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl;
     80            COUT(5) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl;
    8181            (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
    8282            return true;
  • code/trunk/src/orxonox/GraphicsEngine.cc

    r1538 r1563  
    5353
    5454#include "console/InGameConsole.h"
     55#include "tools/ParticleInterface.h"
    5556#include "Settings.h"
    5657
     
    7677  {
    7778    RegisterObject(GraphicsEngine);
     79
     80    this->detailLevelParticle_ = 0;
    7881
    7982    this->setConfigValues();
     
    9194    SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
    9295    SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
     96
     97    unsigned int old = this->detailLevelParticle_;
     98    SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high");
     99
     100    if (this->detailLevelParticle_ != old)
     101      for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it)
     102        it->detailLevelChanged(this->detailLevelParticle_);
    93103  }
    94104
  • code/trunk/src/orxonox/GraphicsEngine.h

    r1535 r1563  
    8080            void windowClosed      (Ogre::RenderWindow* rw);
    8181
     82            inline unsigned int getDetailLevelParticle() const
     83              { return this->detailLevelParticle_; }
     84
    8285            static GraphicsEngine& getSingleton();
    8386            static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }
     
    9497                             bool, const std::string&);
    9598
    96             Ogre::Root*         root_;              //!< Ogre's root
    97             Ogre::SceneManager* scene_;             //!< scene manager of the game
    98             Ogre::RenderWindow* renderWindow_;      //!< the current render window
    99             std::string         resourceFile_;      //!< resources file name
    100             std::string         ogreConfigFile_;    //!< ogre config file name
    101             std::string         ogrePluginsFile_;   //!< ogre plugins file name
    102             std::string         ogreLogFile_;       //!< log file name for Ogre log messages
    103             int ogreLogLevelTrivial_;               //!< Corresponding Orxonx debug level for LL_TRIVIAL
    104             int ogreLogLevelNormal_;                //!< Corresponding Orxonx debug level for LL_NORMAL
    105             int ogreLogLevelCritical_;              //!< Corresponding Orxonx debug level for LL_CRITICAL
     99            Ogre::Root*         root_;                  //!< Ogre's root
     100            Ogre::SceneManager* scene_;                 //!< scene manager of the game
     101            Ogre::RenderWindow* renderWindow_;          //!< the current render window
     102            std::string         resourceFile_;          //!< resources file name
     103            std::string         ogreConfigFile_;        //!< ogre config file name
     104            std::string         ogrePluginsFile_;       //!< ogre plugins file name
     105            std::string         ogreLogFile_;           //!< log file name for Ogre log messages
     106            int                 ogreLogLevelTrivial_;   //!< Corresponding Orxonx debug level for LL_TRIVIAL
     107            int                 ogreLogLevelNormal_;    //!< Corresponding Orxonx debug level for LL_NORMAL
     108            int                 ogreLogLevelCritical_;  //!< Corresponding Orxonx debug level for LL_CRITICAL
     109            unsigned int        detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
    106110    };
    107111}
  • code/trunk/src/orxonox/Orxonox.cc

    r1556 r1563  
    7171#include "hud/HUD.h"
    7272#include "objects/Tickable.h"
     73#include "tools/ParticleInterface.h"
    7374
    7475#include "GraphicsEngine.h"
     
    162163
    163164  /**
     165    @brief Changes the speed of Orxonox
     166  */
     167  void Orxonox::setTimeFactor(float factor)
     168  {
     169    float change = factor / Orxonox::getSingleton()->getTimeFactor();
     170    Orxonox::getSingleton()->timefactor_ = factor;
     171
     172    for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it)
     173        it->setSpeedFactor(it->getSpeedFactor() * change);
     174  }
     175
     176  /**
    164177   * initialization of Orxonox object
    165178   * @param argc argument counter
     
    379392    Level* startlevel = new Level("levels/sample.oxw");
    380393    Loader::open(startlevel);
    381    
     394
    382395    return true;
    383396  }
     
    421434    //Ogre::SceneManager* mSceneMgr = GraphicsEngine::getSingleton().getSceneManager();
    422435    //Ogre::Viewport* mViewport = mSceneMgr->getCurrentViewport();
    423    
     436
    424437    //Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "Bloom");
    425438    //Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "MotionBlur");
  • code/trunk/src/orxonox/Orxonox.h

    r1535 r1563  
    6767      static void destroySingleton();
    6868
    69       static inline void slomo(float factor) { Orxonox::getSingleton()->timefactor_ = factor; }
    70       static inline void setTimeFactor(float factor = 1.0) { Orxonox::getSingleton()->timefactor_ = factor; }
     69      static inline void slomo(float factor) { Orxonox::setTimeFactor(factor); }
     70      static void setTimeFactor(float factor = 1.0);
    7171      static inline float getTimeFactor() { return Orxonox::getSingleton()->timefactor_; }
    7272      static inline void exit() { Orxonox::getSingleton()->abortRequest(); }
  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r1558 r1563  
    6060//-----------------------------------------------------------------------
    6161
    62 namespace orxonox {
     62namespace orxonox
     63{
     64  namespace LODParticle
     65  {
     66    enum LOD
     67    {
     68      off = 0,
     69      low = 1,
     70      normal = 2,
     71      high = 3
     72    };
     73  }
     74
    6375  class GraphicsEngine;
    6476  class Orxonox;
  • code/trunk/src/orxonox/hud/RadarObject.cc

    r1562 r1563  
    6565{
    6666    unsigned int RadarObject::count_s = 0;
     67    unsigned int RadarObject::materialcount_s = 0;
    6768    std::map<std::string, std::map<ColourValue, std::string> > RadarObject::materials_s;
    6869
     
    99100        if (it == colourmap.end())
    100101        {
    101             materialname = "radarmaterial" + getConvertedValue<unsigned int, std::string>(RadarObject::count_s);
     102            materialname = "radarmaterial" + getConvertedValue<unsigned int, std::string>(RadarObject::materialcount_s++);
    102103            Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
     104            material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
    103105            Ogre::TextureUnitState* textureunitstate = material->getTechnique(0)->getPass(0)->createTextureUnitState();
    104106            textureunitstate->setTextureName(texturename);
  • code/trunk/src/orxonox/hud/RadarObject.h

    r1562 r1563  
    6464      private:
    6565        static std::map<std::string, std::map<ColourValue, std::string> > materials_s;
    66         unsigned static int count_s;
     66        static unsigned int count_s;
     67        static unsigned int materialcount_s;
    6768        Ogre::SceneNode* node_;                                 // node of object
    6869        ColourValue colour_;
  • code/trunk/src/orxonox/objects/ParticleProjectile.cc

    r1560 r1563  
    4343        if (this->owner_)
    4444        {
    45             this->particles_ = new ParticleInterface("Orxonox/shot2");
     45            this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal);
    4646            this->particles_->addToSceneNode(this->getNode());
    4747            this->particles_->getAllEmitters()->setDirection(-this->owner_->getInitialDir());
  • code/trunk/src/orxonox/objects/ParticleSpawner.cc

    r1559 r1563  
    4343    }
    4444
    45     ParticleSpawner::ParticleSpawner(const std::string& templateName, float lifetime, float delay, const Vector3& direction)
     45    ParticleSpawner::ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float delay, const Vector3& direction)
    4646    {
    4747        RegisterObject(ParticleSpawner);
     
    5050        executor->setDefaultValues(lifetime);
    5151        this->timer_.setTimer(delay, false, this, executor);
    52         this->particle_ = new ParticleInterface(templateName);
     52        this->particle_ = new ParticleInterface(templateName, detaillevel);
    5353        this->particle_->addToSceneNode(this->getNode());
    5454        this->particle_->setEnabled(false);
  • code/trunk/src/orxonox/objects/ParticleSpawner.h

    r1552 r1563  
    3333
    3434#include "WorldEntity.h"
    35 #include "../tools/Timer.h"
     35#include "tools/Timer.h"
    3636
    3737namespace orxonox
     
    4141        public:
    4242            ParticleSpawner();
    43             ParticleSpawner(const std::string& templateName, float lifetime, float delay = 0, const Vector3& direction = Vector3::ZERO);
     43            ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float delay = 0, const Vector3& direction = Vector3::ZERO);
    4444            virtual ~ParticleSpawner();
    4545            inline ParticleInterface* getParticleInterface() const
  • code/trunk/src/orxonox/objects/Projectile.cc

    r1558 r1563  
    9797                    if (it->isA(Class(SpaceShipAI)))
    9898                        ((SpaceShipAI*)(*it))->damage(this->damage_);
    99                     ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, 2.0);
     99                    ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, LODParticle::low, 2.0);
    100100                    explosion->setPosition(this->getPosition());
    101101                    explosion->create();
    102                     ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, 6.0, 0.0);
     102                    ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, LODParticle::normal, 6.0, 0.0);
    103103                    smoke->setPosition(this->getPosition());
    104104                    smoke->getParticleInterface()->setSpeedFactor(3.0);
  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1562 r1563  
    187187    {
    188188        // START CREATING THRUSTER
    189         this->tt1_ = new ParticleInterface("Orxonox/thruster1");
     189        this->tt1_ = new ParticleInterface("Orxonox/thruster1", LODParticle::low);
    190190        this->tt1_->createNewEmitter();
    191191        this->tt1_->getAllEmitters()->setDirection(-this->getInitialDir());
     
    199199        tt1_->addToSceneNode(node2a);
    200200
    201         this->tt2_ = new ParticleInterface("Orxonox/thruster2");
     201        this->tt2_ = new ParticleInterface("Orxonox/thruster2", LODParticle::normal);
    202202        this->tt2_->createNewEmitter();
    203203        this->tt2_->getAllEmitters()->setDirection(Vector3(-1, 0, 0));
  • code/trunk/src/orxonox/objects/SpaceShipAI.cc

    r1562 r1563  
    102102            newenemy->XMLPort(xmlelement, XMLPort::LoadObject);
    103103
    104             ParticleSpawner* spawneffect = new ParticleSpawner("Orxonox/fairytwirl", 2.0, 0.0, newenemy->getOrth());
     104            ParticleSpawner* spawneffect = new ParticleSpawner("Orxonox/fairytwirl", LODParticle::normal, 2.0, 0.0, newenemy->getOrth());
    105105            spawneffect->setPosition(newenemy->getPosition() - newenemy->getOrth() * 50);
    106106            spawneffect->create();
     
    182182    void SpaceShipAI::kill()
    183183    {
    184         ParticleSpawner* explosion = new ParticleSpawner("Orxonox/BigExplosion1part1", 3.0);
    185         explosion->setPosition(this->getPosition());
    186         explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
    187         explosion->setScale(4);
    188         explosion->create();
    189 
    190         explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", 3.0);
     184        ParticleSpawner* explosion = new ParticleSpawner("Orxonox/BigExplosion1part1", LODParticle::low, 3.0);
     185        explosion->setPosition(this->getPosition());
     186        explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
     187        explosion->setScale(4);
     188        explosion->create();
     189
     190        explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::normal, 3.0);
     191        explosion->setPosition(this->getPosition());
     192        explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
     193        explosion->setScale(4);
     194        explosion->create();
     195        explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::high, 3.0);
    191196        explosion->setPosition(this->getPosition());
    192197        explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
     
    196201        Vector3 ringdirection = Vector3(rnd(), rnd(), rnd());
    197202        ringdirection.normalise();
    198         explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", 3.0, 0.5, ringdirection);
     203        explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::normal, 3.0, 0.5, ringdirection);
     204        explosion->setPosition(this->getPosition());
     205        explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
     206        explosion->setScale(4);
     207        explosion->create();
     208        explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::high, 3.0, 0.5, ringdirection);
    199209        explosion->setPosition(this->getPosition());
    200210        explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
  • 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.