Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 2, 2009, 5:40:13 PM (15 years ago)
Author:
youngk
Message:

Speed dependent pitching of the sounds works now for engine states: normal and boost.

Location:
code/branches/presentation2/src/orxonox/items
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/items/MultiStateEngine.cc

    r6205 r6207  
    4545namespace orxonox
    4646{
    47     static const float FORWARD_EFFECT_VELOCITY_THRESHOLD = 20;
     47    static const float FORWARD_EFFECT_VELOCITY_THRESHOLD = 0;
    4848    static const float MAX_VELOCITY_NORMAL = 111;
    4949    static const float MAX_VELOCITY_BOOST = 221;
     
    5656
    5757        defEngineSndNormal_ = new WorldSound(this);
     58        defEngineSndBoost_ = new WorldSound(this);
    5859        defEngineSndNormal_->setLooping(true);
     60        defEngineSndBoost_->setLooping(true);
    5961
    6062        this->lua_ = new LuaState();
     
    7375                    (*it2)->destroy();
    7476            delete this->defEngineSndNormal_;
     77            delete this->defEngineSndBoost_;
    7578            delete this->lua_;
    7679        }
     
    8285        XMLPortObject(MultiStateEngine, EffectContainer, "",  addEffectContainer,  getEffectContainer,  xmlelement, mode);
    8386        XMLPortParam(MultiStateEngine, "defEngineSndNormal",  setDefEngSndNormal,  getDefEngSndNormal,  xmlelement, mode);
     87        XMLPortParam(MultiStateEngine, "defEngineSndBoost",  setDefEngSndBoost,  getDefEngSndBoost,  xmlelement, mode);
    8488    }
    8589
     
    107111                {
    108112                    newState = Boost;
    109                     /*pitch = pitch/MAX_VELOCITY_BOOST + 1;
     113                    pitch = pitch/MAX_VELOCITY_BOOST + 1;
    110114                    pitch = pitch > 2 ? 2 : pitch;
    111115                    pitch = pitch < 0.5 ? 0.5 : pitch;
    112                     defEngineSndNormal_->setPitch(pitch);*/
     116                    defEngineSndBoost_->setPitch(pitch);
    113117                }
    114118                else if (forward && !newState) // newState == Boost
     
    155159                        lua_pushboolean(this->lua_->getInternalLuaState(), newState & Boost);
    156160                        lua_setglobal(this->lua_->getInternalLuaState(), "boost");
     161                        if(newState & Boost)
     162                        {
     163                            defEngineSndBoost_->play();
     164                        }
     165                        else
     166                        {
     167                            defEngineSndBoost_->stop();
     168                        }
    157169                    }
    158170
     
    181193
    182194        this->getShip()->attach(defEngineSndNormal_);
     195        this->getShip()->attach(defEngineSndBoost_);
    183196
    184197        for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)
     
    220233        return defEngineSndNormal_->getSource();
    221234    }
     235
     236    void MultiStateEngine::setDefEngSndBoost(const std::string &engineSound)
     237    {
     238        defEngineSndBoost_->setSource(engineSound);
     239    }
     240
     241    const std::string& MultiStateEngine::getDefEngSndBoost()
     242    {
     243        return defEngineSndBoost_->getSource();
     244    }
    222245}
  • code/branches/presentation2/src/orxonox/items/MultiStateEngine.h

    r6202 r6207  
    6464            void addEffectContainer(EffectContainer* effect);
    6565            EffectContainer* getEffectContainer(unsigned int index) const;
     66           
    6667            void setDefEngSndNormal(const std::string& engineSound);
    6768            const std::string& getDefEngSndNormal();
     69            void setDefEngSndBoost(const std::string& engineSound);
     70            const std::string& getDefEngSndBoost();
    6871
    6972        private:
     
    7275            std::vector<EffectContainer*> effectContainers_;
    7376            WorldSound* defEngineSndNormal_;
     77            WorldSound* defEngineSndBoost_;
    7478    };
    7579}
Note: See TracChangeset for help on using the changeset viewer.