Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6207


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

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

Location:
code/branches/presentation2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/data/levels/templates/spaceship_assff.oxt

    r6202 r6207  
    6565
    6666   defEngineSndNormal = "sounds/Engine_low.ogg"
     67   defEngineSndBoost = "sounds/Engine_high.ogg"
    6768
    6869   accelerationfront     = 500
     
    9293      <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 0, 6" colour="0.6, 0.75, 0.8, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
    9394      <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 6" colour="0.6, 0.75, 0.8, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
    94       <WorldSound mainstate="activity" source="sounds/Engine_high.ogg" loop=1 active=false/>
     95      <!-- WorldSound mainstate="activity" source="sounds/Engine_high.ogg" loop=1 active=false -->
    9596    </EffectContainer>
    9697    <EffectContainer condition="brake">
  • 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.