Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6372


Ignore:
Timestamp:
Dec 17, 2009, 4:52:45 PM (15 years ago)
Author:
rgrieder
Message:

Added new XML parameter for the Scene: soundReferenceDistance.
This value represents the distance to a sound source where the gain is still 1.0. Further away it will decrease with 1/(distance - soundReferenceDistance).
Default value is 20.

Location:
code/branches/presentation2/src/orxonox
Files:
4 edited

Legend:

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

    r6107 r6372  
    5858        this->setScene(SmartPtr<Scene>(this, false), OBJECTID_UNKNOWN);
    5959        this->bShadows_ = true;
     60        this->soundReferenceDistance_ = 20.0;
    6061
    6162        if (GameMode::showsGraphics())
     
    113114        XMLPortParam(Scene, "ambientlight", setAmbientLight, getAmbientLight, xmlelement, mode).defaultValues(ColourValue(0.2f, 0.2f, 0.2f, 1.0f));
    114115        XMLPortParam(Scene, "shadow", setShadow, getShadow, xmlelement, mode).defaultValues(true);
     116        XMLPortParam(Scene, "soundReferenceDistance", setSoundReferenceDistance, getSoundReferenceDistance, xmlelement, mode).defaultValues(true);
    115117
    116118        XMLPortParam(Scene, "gravity", setGravity, getGravity, xmlelement, mode);
  • code/branches/presentation2/src/orxonox/Scene.h

    r5929 r6372  
    7171                { return this->bShadows_; }
    7272
     73            inline void setSoundReferenceDistance(float distance)
     74                { this->soundReferenceDistance_ = distance; }
     75            inline float getSoundReferenceDistance() const
     76                { return this->soundReferenceDistance_; }
     77
    7378            inline Radar* getRadar()
    7479                { return this->radar_; }
     
    96101            std::list<BaseObject*>   objects_;
    97102            bool                     bShadows_;
     103            float                    soundReferenceDistance_;
    98104            Radar*                   radar_;
    99105
  • code/branches/presentation2/src/orxonox/sound/BaseSound.cc

    r6370 r6372  
    132132        alSource3f(this->audioSource_, AL_VELOCITY,  0, 0, 0);
    133133        alSource3f(this->audioSource_, AL_DIRECTION, 0, 0, 0);
    134         alSourcei(this->audioSource_, AL_REFERENCE_DISTANCE, 20);
    135         alSourcei(this->audioSource_, AL_MAX_DISTANCE, 10000);
    136134        if (ALint error = alGetError())
    137135            COUT(2) << "Sound Warning: Setting source parameters to 0 failed: "
  • code/branches/presentation2/src/orxonox/sound/WorldSound.cc

    r6370 r6372  
    3535#include "core/EventIncludes.h"
    3636#include "core/XMLPort.h"
     37#include "Scene.h"
    3738#include "SoundManager.h"
    3839#include <core/ConsoleCommandCompilation.h>
     
    7980    {
    8081        BaseSound::initialiseSource();
     82        if (this->getScene())
     83        {
     84            float refDist = this->getScene()->getSoundReferenceDistance();
     85            alSourcei(this->audioSource_, AL_REFERENCE_DISTANCE, refDist);
     86            // TODO: 500 is very magical here. Derive something better
     87            alSourcei(this->audioSource_, AL_MAX_DISTANCE, refDist * 500);
     88        }
    8189        this->tick(0); // update position, orientation and velocity
    8290    }
Note: See TracChangeset for help on using the changeset viewer.