[Orxonox-commit 1489] r6207 - in code/branches/presentation2: data/levels/templates src/orxonox/items
youngk at orxonox.net
youngk at orxonox.net
Wed Dec 2 17:40:13 CET 2009
Author: youngk
Date: 2009-12-02 17:40:13 +0100 (Wed, 02 Dec 2009)
New Revision: 6207
Modified:
code/branches/presentation2/data/levels/templates/spaceship_assff.oxt
code/branches/presentation2/src/orxonox/items/MultiStateEngine.cc
code/branches/presentation2/src/orxonox/items/MultiStateEngine.h
Log:
Speed dependent pitching of the sounds works now for engine states: normal and boost.
Modified: code/branches/presentation2/data/levels/templates/spaceship_assff.oxt
===================================================================
--- code/branches/presentation2/data/levels/templates/spaceship_assff.oxt 2009-12-02 16:25:42 UTC (rev 6206)
+++ code/branches/presentation2/data/levels/templates/spaceship_assff.oxt 2009-12-02 16:40:13 UTC (rev 6207)
@@ -64,6 +64,7 @@
speedupdown = 50
defEngineSndNormal = "sounds/Engine_low.ogg"
+ defEngineSndBoost = "sounds/Engine_high.ogg"
accelerationfront = 500
accelerationbrake = 500
@@ -91,7 +92,7 @@
<EffectContainer condition="boost">
<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" />
<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" />
- <WorldSound mainstate="activity" source="sounds/Engine_high.ogg" loop=1 active=false/>
+ <!-- WorldSound mainstate="activity" source="sounds/Engine_high.ogg" loop=1 active=false -->
</EffectContainer>
<EffectContainer condition="brake">
<FadingBillboard mainstate=activity active=false scale=0.3 position=" 8, 0, 6" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
Modified: code/branches/presentation2/src/orxonox/items/MultiStateEngine.cc
===================================================================
--- code/branches/presentation2/src/orxonox/items/MultiStateEngine.cc 2009-12-02 16:25:42 UTC (rev 6206)
+++ code/branches/presentation2/src/orxonox/items/MultiStateEngine.cc 2009-12-02 16:40:13 UTC (rev 6207)
@@ -44,7 +44,7 @@
namespace orxonox
{
- static const float FORWARD_EFFECT_VELOCITY_THRESHOLD = 20;
+ static const float FORWARD_EFFECT_VELOCITY_THRESHOLD = 0;
static const float MAX_VELOCITY_NORMAL = 111;
static const float MAX_VELOCITY_BOOST = 221;
@@ -55,7 +55,9 @@
RegisterObject(MultiStateEngine);
defEngineSndNormal_ = new WorldSound(this);
+ defEngineSndBoost_ = new WorldSound(this);
defEngineSndNormal_->setLooping(true);
+ defEngineSndBoost_->setLooping(true);
this->lua_ = new LuaState();
this->state_ = 0;
@@ -72,6 +74,7 @@
for (std::vector<WorldEntity*>::const_iterator it2 = (*it)->getEffectsBegin(); it2 != (*it)->getEffectsBegin(); ++it2)
(*it2)->destroy();
delete this->defEngineSndNormal_;
+ delete this->defEngineSndBoost_;
delete this->lua_;
}
}
@@ -81,6 +84,7 @@
SUPER(MultiStateEngine, XMLPort, xmlelement, mode);
XMLPortObject(MultiStateEngine, EffectContainer, "", addEffectContainer, getEffectContainer, xmlelement, mode);
XMLPortParam(MultiStateEngine, "defEngineSndNormal", setDefEngSndNormal, getDefEngSndNormal, xmlelement, mode);
+ XMLPortParam(MultiStateEngine, "defEngineSndBoost", setDefEngSndBoost, getDefEngSndBoost, xmlelement, mode);
}
void MultiStateEngine::registerVariables()
@@ -106,10 +110,10 @@
if (this->getShip()->getBoost() && forward)
{
newState = Boost;
- /*pitch = pitch/MAX_VELOCITY_BOOST + 1;
+ pitch = pitch/MAX_VELOCITY_BOOST + 1;
pitch = pitch > 2 ? 2 : pitch;
pitch = pitch < 0.5 ? 0.5 : pitch;
- defEngineSndNormal_->setPitch(pitch);*/
+ defEngineSndBoost_->setPitch(pitch);
}
else if (forward && !newState) // newState == Boost
{
@@ -154,6 +158,14 @@
{
lua_pushboolean(this->lua_->getInternalLuaState(), newState & Boost);
lua_setglobal(this->lua_->getInternalLuaState(), "boost");
+ if(newState & Boost)
+ {
+ defEngineSndBoost_->play();
+ }
+ else
+ {
+ defEngineSndBoost_->stop();
+ }
}
// Update all effect conditions
@@ -180,6 +192,7 @@
return;
this->getShip()->attach(defEngineSndNormal_);
+ this->getShip()->attach(defEngineSndBoost_);
for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)
for (std::vector<WorldEntity*>::const_iterator it2 = (*it)->getEffectsBegin(); it2 != (*it)->getEffectsEnd(); ++it2)
@@ -219,4 +232,14 @@
{
return defEngineSndNormal_->getSource();
}
+
+ void MultiStateEngine::setDefEngSndBoost(const std::string &engineSound)
+ {
+ defEngineSndBoost_->setSource(engineSound);
+ }
+
+ const std::string& MultiStateEngine::getDefEngSndBoost()
+ {
+ return defEngineSndBoost_->getSource();
+ }
}
Modified: code/branches/presentation2/src/orxonox/items/MultiStateEngine.h
===================================================================
--- code/branches/presentation2/src/orxonox/items/MultiStateEngine.h 2009-12-02 16:25:42 UTC (rev 6206)
+++ code/branches/presentation2/src/orxonox/items/MultiStateEngine.h 2009-12-02 16:40:13 UTC (rev 6207)
@@ -63,14 +63,18 @@
void addEffectContainer(EffectContainer* effect);
EffectContainer* getEffectContainer(unsigned int index) const;
+
void setDefEngSndNormal(const std::string& engineSound);
const std::string& getDefEngSndNormal();
+ void setDefEngSndBoost(const std::string& engineSound);
+ const std::string& getDefEngSndBoost();
private:
int state_;
LuaState* lua_;
std::vector<EffectContainer*> effectContainers_;
WorldSound* defEngineSndNormal_;
+ WorldSound* defEngineSndBoost_;
};
}
More information about the Orxonox-commit
mailing list