Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7646 in orxonox.OLD


Ignore:
Timestamp:
May 17, 2006, 12:41:35 PM (18 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: added loop function in sound_source

Location:
branches/atmospheric_engine/src/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc

    r7628 r7646  
    1717#include "util/loading/load_param.h"
    1818#include "util/loading/factory.h"
     19#include "util/loading/resource_manager.h"
    1920
    2021#include "glincl.h"
    21 #include "debug.h"
     22// #include "debug.h"
    2223
    2324#include "state.h"
     
    4041  if (root != NULL)
    4142    this->loadParams(root);
     43
     44  // this->soundSource.setSourceNode(this);
     45
     46  //load sound
     47  if (this->rainBuffer != NULL)
     48    ResourceManager::getInstance()->unload(this->rainBuffer);
     49  this->rainBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
    4250
    4351  this->init();
     
    6573{
    6674  this->emitter = new PlaneEmitter(this->rainSize);
     75
    6776}
    6877
     
    7988                RainEffect::rainParticles->setName("RainParticles");
    8089                RainEffect::rainParticles->setLifeSpan(2, 2);
    81                 RainEffect::rainParticles->setRadius(0.05, 0.05);
     90                RainEffect::rainParticles->setRadius(0.02, 0.02);
     91                RainEffect::rainParticles->setRadius(0.01, 0.01);
     92                RainEffect::rainParticles->setRadius(0.03, 0.03);
    8293                RainEffect::rainParticles->setRadius(0.04, 0.04);
    83                 RainEffect::rainParticles->setRadius(0.03, 0.03);
    84                 RainEffect::rainParticles->setColor(0, 0, 0, 1, .3);
    85                 RainEffect::rainParticles->setColor(0.5, 0.5, 0.5, 1, 0.2);
    86                 RainEffect::rainParticles->setColor(0.8, 0.8, 0.2, 0.3, 0.3);
    87                 RainEffect::rainParticles->setColor(1, 0.5, 0.5, 1, 0);
     94                RainEffect::rainParticles->setColor(0.7, 0.3, 0.3, 0.5, 0.2); // grey blue 1
     95                RainEffect::rainParticles->setColor(1, 0.4, 0.4, 0.5, 0.1); // grey blue 2
     96                RainEffect::rainParticles->setColor(0.5, 0.7, 0.7, 0.7, 0); // light grey
    8897        }
    8998
    9099        this->emitter->setSystem(RainEffect::rainParticles);
    91100
    92         RainEffect::rainParticles->debug();
     101        // RainEffect::rainParticles->debug();
    93102
    94103        this->emitter->setRelCoor(this->rainCoord);
    95104
    96105        this->emitter->setEmissionRate(this->rainRate);
    97         this->emitter->setEmissionVelocity(-this->rainVelocity);
     106        this->emitter->setEmissionVelocity(this->rainVelocity);
    98107
    99         this->emitter->setSpread(0, .3);
     108        this->emitter->setSpread(0, .2);
     109
     110        this->soundSource.loop(this->rainBuffer);
     111        PRINTF(0)( "Playing RainSound\n" );
    100112}
    101113
     
    107119  this->emitter->setSystem(NULL);
    108120}
     121
     122void RainEffect::tick (float dt)
     123{
     124
     125}
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h

    r7628 r7646  
    1616#include "weather_effect.h"
    1717
     18#include "sound_buffer.h"
     19#include "sound_source.h"
     20
    1821
    1922class RainEffect : public WeatherEffect
     
    3033    virtual bool deactivate();
    3134
     35    virtual void tick(float dt);
     36
    3237    inline void setRainCoord(float x, float y, float z) { this->rainCoord = Vector(x, y, z); }
    3338    inline void setRainSize(float x, float y) { this->rainSize = Vector2D(x, y); }
    3439    inline void setRainRate(float rate) { this->rainRate = rate;}
    35     inline void setRainVelocity(float velocity) { this->rainVelocity = velocity; }
     40    inline void setRainVelocity(float velocity) { this->rainVelocity = -velocity; }
    3641
    3742  private:
     
    4348    GLfloat                           rainRate;
    4449    GLfloat                           rainVelocity;
     50
     51    SoundSource                       soundSource;
     52    SoundBuffer*                      rainBuffer;
    4553};
    4654
  • branches/atmospheric_engine/src/lib/sound/sound_source.cc

    r7326 r7646  
    122122      alSourceStop(this->sourceID);
    123123    alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    124       alSourcePlay(this->sourceID);
     124    alSourcePlay(this->sourceID);
    125125
    126126    if (DEBUG >= 3)
     
    153153  if (DEBUG >= 3)
    154154    SoundEngine::checkError("Play Source", __LINE__);
     155}
     156
     157
     158/**
     159 * @brief Plays back buffer on this Source and loops it
     160 * @param buffer the buffer to play back on this Source
     161 */
     162void SoundSource::loop(const SoundBuffer* buffer)
     163{
     164  if (!this->retrieveSource())
     165  {
     166    PRINTF(2)("No more Free sources (You might consider raising the Source-Count).\n");
     167    return;
     168  }
     169
     170  alSourceStop(this->sourceID);
     171  alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     172  alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE  );
     173
     174  alSourcePlay(this->sourceID);
     175
     176  if (unlikely(this->buffer != NULL))
     177    alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     178  this->bPlay = true;
     179
     180  if (DEBUG >= 3)
     181    SoundEngine::checkError("Play LoopSource", __LINE__);
    155182}
    156183
  • branches/atmospheric_engine/src/lib/sound/sound_source.h

    r7317 r7646  
    2828    void play();
    2929    void play(const SoundBuffer* buffer);
     30    void loop(const SoundBuffer* buffer);
    3031    void stop();
    3132    void pause();
Note: See TracChangeset for help on using the changeset viewer.