Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9805 in orxonox.OLD


Ignore:
Timestamp:
Sep 24, 2006, 3:21:12 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: SoundSource completely added as a Resource

Location:
branches/new_class_id/src
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/lang/base_object.cc

    r9730 r9805  
    4545  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    4646  {
     47    PRINTF(5)("DELETING OBJECT %s::%s FROM %s\n", this->getClassCName(), getCName(), (*it)._objectList->name().c_str());
    4748    (*it)._objectList->unregisterObject((*it)._iterator);
    4849    delete (*it)._iterator;
  • branches/new_class_id/src/lib/lang/object_list.cc

    r9757 r9805  
    272272         ++it)
    273273    {
    274       printf("   + %s::%s\n", (*it)->getClassCName(), (*it)->getCName());
     274      printf("   + %s::%s (%p)\n", (*it)->getClassCName(), (*it)->getCName(), (*it));
    275275    }
    276276  }
  • branches/new_class_id/src/lib/shell/some_shell_commands.cc

    r9800 r9805  
    6767    ->setAlias("orxoquit");
    6868
     69#include "object_list.h"
     70SHELL_COMMAND_STATIC(debugAll, ObjectListBase, &ObjectListBase::debugAll);
  • branches/new_class_id/src/lib/sound/sound_buffer.cc

    r9804 r9805  
    2020namespace OrxSound
    2121{
    22   ObjectListDefinition(SoundBuffer);
    2322  //////////////////
    2423  /* SOUND-BUFFER */
    2524  //////////////////
    2625  SoundBuffer::SoundBuffer()
    27   : data(new SoundBufferData)
     26      : data(new SoundBufferData)
    2827  {
    29     this->registerObject(this, SoundBuffer::_objectList);
    3028  }
    3129  /**
     
    3432   */
    3533  SoundBuffer::SoundBuffer(const std::string& fileName)
    36   : data(new SoundBufferData)
     34      : data(new SoundBufferData)
    3735  {
    38     this->registerObject(this, SoundBuffer::_objectList);
    39     this->setName(fileName);
    40 
    4136    this->load(fileName);
    4237  }
     38
     39  SoundBuffer::SoundBuffer(const SoundBuffer& buffer)
     40      : data(buffer.data)
     41  {  }
     42
     43  SoundBuffer::SoundBuffer(const SoundBufferData::Pointer& dataPointer)
     44      : data(dataPointer)
     45  {  };
    4346}
  • branches/new_class_id/src/lib/sound/sound_buffer.h

    r9804 r9805  
    77#define _SOUND_BUFFER_H
    88
    9 #include "base_object.h"
    10 #include "alincl.h"
    11 
    129#include "sound_buffer_data.h"
    1310
     
    1512{
    1613  //! A class that represents a datastructure to play Sounds.
    17   class SoundBuffer : public BaseObject
     14  class SoundBuffer
    1815  {
    19     ObjectListDeclaration(SoundBuffer);
    2016  public:
    2117    SoundBuffer();
    22     SoundBuffer(const SoundBuffer& buffer) { this->data = buffer.data; }
    23     SoundBuffer(const SoundBufferData::Pointer& dataPointer) { this->data = dataPointer; };
     18    SoundBuffer(const SoundBuffer& buffer);
     19    SoundBuffer(const SoundBufferData::Pointer& dataPointer);
    2420    SoundBuffer(const std::string& fileName);
     21
     22    bool operator==(const SoundBuffer& buffer) const {return this->data == buffer.data; };
    2523
    2624    /** @see SoundBufferData::load */
     
    3331    /** @returns the ID of the buffer used in this SoundBuffer */
    3432    inline ALuint getID() const { return this->data->getID(); }
     33    inline bool loaded() const { return this->data->loaded(); }
    3534
    3635    /** @returns the DataPointer */
     
    3837    /** @param dataPointer the data to acquire @brief Buffer shall acquire dataPointers data */
    3938    void acquireData(const SoundBufferData::Pointer& dataPointer)  { data = dataPointer; };
     39
    4040  private:
    41     SoundBufferData::Pointer    data;
     41    SoundBufferData::Pointer    data;                //!< Pointer to the Stored Data
    4242  };
    4343}
  • branches/new_class_id/src/lib/sound/sound_buffer_data.cc

    r9803 r9805  
    5050    this->size = 0;
    5151    this->loop = AL_FALSE;
    52 
    53 
     52    this->bLoaded = false;
    5453  }
    5554
     
    112111    SDL_FreeWAV(wavBuffer);
    113112    if (SoundEngine::checkError("Could not load Wave file", __LINE__))
     113    {
     114      this->bLoaded = true;
    114115      return true;
     116    }
    115117    else
    116118      return false;
     
    160162      return false;
    161163
     164    this->bLoaded = true;
    162165    return true ;
    163 
    164166  }
    165167
  • branches/new_class_id/src/lib/sound/sound_buffer_data.h

    r9803 r9805  
    3333    /** @returns the ID of the buffer used in this SoundBuffer */
    3434    inline ALuint getID() const { return this->bufferID; }
     35    inline bool loaded() const { return bLoaded; };
    3536
    3637  private:
     
    4243    ALsizei       size;                 //!< The size of the Buffer.
    4344    ALboolean     loop;                 //!< loop information.
     45    bool          bLoaded;               //!< If the Sound was loaded this is true.
    4446  };
    4547}
  • branches/new_class_id/src/lib/sound/sound_engine.cc

    r9721 r9805  
    2626#include "util/preferences.h"
    2727#include "globals.h"
     28#include "resource_sound_buffer.h"
    2829
    2930namespace OrxSound
     
    119120  SoundSource* SoundEngine::createSource(const std::string& fileName, PNode* sourceNode)
    120121  {
    121     SoundBuffer* buffer = NULL;
     122    SoundBuffer buffer;
    122123    if (!fileName.empty())
    123124    {
    124       buffer= (SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL);
    125       if (buffer == NULL)
     125      buffer = ResourceSoundBuffer(fileName);
     126      if (!buffer.loaded())
    126127        PRINTF(2)("Wav-Sound %s could not be loaded onto new Source\n", fileName.c_str());
    127128    }
     
    215216        if(play == AL_PLAYING)
    216217        {
    217           if (likely((*sourceIT)->getNode() != NULL))
     218          if (likely((*sourceIT)->getNode() != NULL))
    218219          {
    219220            alSource3f((*sourceIT)->getID(), AL_POSITION,
  • branches/new_class_id/src/lib/sound/sound_source.cc

    r9715 r9805  
    1919#include "sound_engine.h"
    2020
    21 #include "alincl.h"
    2221#include "compiler.h"
    2322#include "debug.h"
     
    2928  * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer
    3029  */
    31   SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer)
     30  SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer& buffer)
    3231  {
    3332    this->registerObject(this, SoundSource::_objectList);
     
    120119  void SoundSource::play()
    121120  {
    122     if (this->buffer && this->retrieveSource())
     121    if (this->retrieveSource())
    123122    {
    124123      if (this->bPlay)
    125124        alSourceStop(this->sourceID);
    126125
    127       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     126      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    128127      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    129128      alSourcef (this->sourceID, AL_GAIN, 1);
     
    141140  * @param buffer the buffer to play back on this Source
    142141  */
    143   void SoundSource::play(const SoundBuffer* buffer)
     142  void SoundSource::play(const SoundBuffer& buffer)
    144143  {
    145144    if (!this->retrieveSource())
     
    150149
    151150    alSourceStop(this->sourceID);
    152     alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     151    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    153152    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    154153    alSourcef (this->sourceID, AL_GAIN, 1);
     
    156155    alSourcePlay(this->sourceID);
    157156
    158     if (unlikely(this->buffer != NULL))
    159       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     157    if (unlikely(this->buffer.getID() != 0))
     158      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    160159    this->bPlay = true;
    161160
     
    170169   * @param gain the gain of the sound buffer
    171170  */
    172   void SoundSource::play(const SoundBuffer* buffer, float gain)
     171  void SoundSource::play(const SoundBuffer& buffer, float gain)
    173172  {
    174173    if (!this->retrieveSource())
     
    179178
    180179    alSourceStop(this->sourceID);
    181     alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     180    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    182181    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    183182    alSourcef (this->sourceID, AL_GAIN, gain);
     
    185184    alSourcePlay(this->sourceID);
    186185
    187     if (unlikely(this->buffer != NULL))
    188       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     186    if (unlikely(this->buffer.getID() != 0))
     187      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    189188    this->bPlay = true;
    190189
     
    199198   * @param loop if true, sound gets looped
    200199   */
    201   void SoundSource::play(const SoundBuffer* buffer, float gain, bool loop)
     200  void SoundSource::play(const SoundBuffer& buffer, float gain, bool loop)
    202201  {
    203202    if (!this->retrieveSource())
     
    208207
    209208    alSourceStop(this->sourceID);
    210     alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     209    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    211210
    212211    if (loop)
     
    219218    alSourcePlay(this->sourceID);
    220219
    221     if (unlikely(this->buffer != NULL))
    222       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     220    if (unlikely(this->buffer.getID() != 0))
     221      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    223222    this->bPlay = true;
    224223
     
    232231   * @param gain the new gain value
    233232   */
    234   void SoundSource::gain(const SoundBuffer* buffer, float gain)
     233  void SoundSource::gain(const SoundBuffer& buffer, float gain)
    235234  {
    236235    // alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     
    347346  * @param duration time perios to fade in
    348347  */
    349   void SoundSource::fadein(const SoundBuffer* buffer, ALfloat duration)
     348  void SoundSource::fadein(const SoundBuffer& buffer, ALfloat duration)
    350349  {
    351350    //if (this->buffer && this->retrieveSource())
  • branches/new_class_id/src/lib/sound/sound_source.h

    r9715 r9805  
    88
    99#include "base_object.h"
     10#include "sound_buffer.h"
    1011#include "alincl.h"
    1112
     
    1415namespace OrxSound
    1516{
    16   class SoundBuffer;
    1717  //! A class that represents a SoundSource
    1818  class SoundSource : public BaseObject
     
    2020    ObjectListDeclaration(SoundSource);
    2121  public:
    22     SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL);
     22    SoundSource(const PNode* sourceNode = NULL, const SoundBuffer& buffer = SoundBuffer());
    2323    SoundSource(const SoundSource& source);
    2424    SoundSource& operator=(const SoundSource& source);
     
    2929    // user interaction
    3030    void play();
    31     void play(const SoundBuffer* buffer);
    32     void play(const SoundBuffer* buffer, float gain);
    33     void play(const SoundBuffer* buffer, float gain, bool loop);
     31    void play(const SoundBuffer& buffer);
     32    void play(const SoundBuffer& buffer, float gain);
     33    void play(const SoundBuffer& buffer, float gain, bool loop);
    3434
    35     void gain(const SoundBuffer* buffer, float gain);
     35    void gain(const SoundBuffer& buffer, float gain);
    3636
    3737    void stop();
    3838    void pause();
    3939    void rewind();
    40     void fadein(const SoundBuffer* buffer, ALfloat duration);
     40    void fadein(const SoundBuffer& buffer, ALfloat duration);
    4141
    4242    // development functions
     
    4747    void setSourceNode(const PNode* sourceNode);
    4848    /** @returns the SoundBuffer of this Source */
    49     inline const SoundBuffer* getBuffer() const { return this->buffer; };
     49    inline const SoundBuffer& getBuffer() const { return this->buffer; };
    5050    /** @returns the SourceNode of this Source */
    5151    inline const PNode* getNode() const { return this->sourceNode; };
     
    6666    bool                   resident;    //!< If the alSource should be resident (if true, the alSource will be returned on deletion).
    6767    ALuint                 sourceID;    //!< The ID of the Source
    68     const SoundBuffer*     buffer;      //!< The buffer to play in this source.
     68    SoundBuffer            buffer;      //!< The buffer to play in this source.
    6969    const PNode*           sourceNode;  //!< The SourceNode representing the position/velocity... of this source.
    7070  };
  • branches/new_class_id/src/lib/util/loading/resource_manager.cc

    r9721 r9805  
    442442    case WAV:
    443443      if(File(fullName).isFile())
    444         tmpResource->pointer = new OrxSound::SoundBuffer(fullName);
     444//        tmpResource->pointer = new OrxSound::SoundBuffer(fullName);
    445445      break;
    446446    case OGG:
  • branches/new_class_id/src/world_entities/effects/lightning_bolt.cc

    r9716 r9805  
    2020#include "material.h"
    2121
    22 #include "util/loading/resource_manager.h"
     22#include "sound/resource_sound_buffer.h"
    2323
    2424
     
    5656  this->seedTime = 4.0f;
    5757
    58   this->soundSource = NULL;
    59   this->thunderBuffer = NULL;
    60 
    6158  this->soundSource.setSourceNode(this);
    6259
    63   //load sound
    64   if (this->thunderBuffer != NULL)
    65     ResourceManager::getInstance()->unload(this->thunderBuffer);
    66   this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/thunder.wav", WAV);
     60  this->thunderBuffer = OrxSound::ResourceSoundBuffer("sound/atmosphere/thunder.wav");
    6761}
    6862
  • branches/new_class_id/src/world_entities/effects/lightning_bolt.h

    r9715 r9805  
    5252
    5353    OrxSound::SoundSource    soundSource;
    54     OrxSound::SoundBuffer*   thunderBuffer;
     54    OrxSound::SoundBuffer    thunderBuffer;
    5555};
    5656
  • branches/new_class_id/src/world_entities/power_ups/power_up.cc

    r9757 r9805  
    2121#include "primitive_model.h"
    2222
    23 #include "util/loading/resource_manager.h"
     23#include "sound/resource_sound_buffer.h"
    2424#include "util/loading/load_param.h"
    2525
     
    4747
    4848  this->soundSource.setSourceNode(this);
    49   this->pickupBuffer = NULL;
    50   this->respawnBuffer = NULL;
    5149
    5250  this->collider = NULL;
     
    5654{
    5755  delete this->sphereMaterial;
    58   if (this->pickupBuffer != NULL)
    59     ResourceManager::getInstance()->unload(this->pickupBuffer);
    60   if (this->respawnBuffer != NULL)
    61     ResourceManager::getInstance()->unload(this->respawnBuffer);
    6256}
    6357
     
    7973void PowerUp::loadPickupSound(const std::string& pickupSound)
    8074{
    81   if (this->pickupBuffer != NULL)
    82     ResourceManager::getInstance()->unload(this->pickupBuffer);
    83 
    84   else if (!pickupSound.empty())
    85   {
    86     this->pickupBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(pickupSound, WAV);
    87     if (this->pickupBuffer != NULL)
    88     {
    89       PRINTF(4)("Loaded sound %s to Pickup: %s.\n", pickupSound.c_str(), this->getCName());
    90     }
    91     else
    92     {
    93       PRINTF(2)("Failed to load sound %s to pickup %s.\n.", pickupSound.c_str(), this->getCName());
    94     }
    95   }
     75  if (!pickupSound.empty())
     76    this->pickupBuffer = OrxSound::ResourceSoundBuffer(pickupSound);
    9677  else
    97     this->pickupBuffer = NULL;
     78    this->pickupBuffer = OrxSound::SoundBuffer();
    9879}
    9980
    10081void PowerUp::loadRespawnSound(const std::string& respawnSound)
    10182{
    102   if (this->respawnBuffer != NULL)
    103     ResourceManager::getInstance()->unload(this->respawnBuffer);
    104 
    105   else if (!respawnSound.empty())
    106   {
    107     this->respawnBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(respawnSound, WAV);
    108     if (this->respawnBuffer != NULL)
    109     {
    110       PRINTF(4)("Loaded sound %s to Pickup: %s.\n", respawnSound.c_str(), this->getCName());
    111     }
    112     else
    113     {
    114       PRINTF(2)("Failed to load sound %s to respawn %s.\n.", respawnSound.c_str(), this->getCName());
    115     }
    116   }
     83  if (!respawnSound.empty())
     84    this->respawnBuffer = OrxSound::ResourceSoundBuffer(respawnSound);
    11785  else
    118     this->respawnBuffer = NULL;
     86    this->respawnBuffer = OrxSound::SoundBuffer();
    11987}
    12088
     
    12795    if(dynamic_cast<Extendable*>(entity)->pickup(this))
    12896    {
    129       if(pickupBuffer != NULL)
     97      if(pickupBuffer.loaded())
    13098        this->soundSource.play(this->pickupBuffer);
    13199
     
    156124      this->toList(OM_COMMON);
    157125      this->collider = NULL;
    158       if (likely(this->respawnBuffer != NULL))
     126      if (likely(this->respawnBuffer.loaded()))
    159127        this->soundSource.play(this->respawnBuffer);
    160128
  • branches/new_class_id/src/world_entities/power_ups/power_up.h

    r9715 r9805  
    4444private:
    4545  OrxSound::SoundSource  soundSource;
    46   OrxSound::SoundBuffer* pickupBuffer;
    47   OrxSound::SoundBuffer* respawnBuffer;
     46  OrxSound::SoundBuffer  pickupBuffer;
     47  OrxSound::SoundBuffer  respawnBuffer;
    4848  Material*              sphereMaterial;
    4949  PowerUpRespawn         respawnType;
  • branches/new_class_id/src/world_entities/projectiles/projectile.cc

    r9783 r9805  
    2222#include "world_entities/weapons/weapon.h"
    2323#include "model.h"
    24 #include "util/loading/resource_manager.h"
     24#include "sound/resource_sound_buffer.h"
    2525
    2626#include "debug.h"
     
    4444  this->setDamage(1.0f); // default damage of a projectile set to 100.0 damage points
    4545
    46   this->explosionBuffer = NULL;
    47   this->engineBuffer = NULL;
    48 
    4946  //this->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    5047}
     
    5653Projectile::~Projectile ()
    5754{
    58   if (this->explosionBuffer != NULL)
    59     ResourceManager::getInstance()->unload(this->explosionBuffer);
    60   if (this->engineBuffer != NULL)
    61     ResourceManager::getInstance()->unload(this->engineBuffer);
    6255  /*
    6356     do not delete the test projectModel, since it is pnode
     
    7063void Projectile::loadExplosionSound(const std::string& explosionSound)
    7164{
    72   if (this->explosionBuffer != NULL)
    73     ResourceManager::getInstance()->unload(this->explosionBuffer);
    74 
    75   else if (!explosionSound.empty())
    76   {
    77     this->explosionBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(explosionSound, WAV);
    78     if (this->explosionBuffer != NULL)
    79     {
    80       PRINTF(4)("Loaded sound %s to Pickup: %s.\n", explosionSound.c_str(), this->getCName());
    81     }
    82     else
    83     {
    84       PRINTF(2)("Failed to load sound %s to explosion %s.\n.", explosionSound.c_str(), this->getCName());
    85     }
    86   }
     65  if (!explosionSound.empty())
     66    this->explosionBuffer = OrxSound::ResourceSoundBuffer(explosionSound);
    8767  else
    88     this->explosionBuffer = NULL;
     68    this->explosionBuffer = OrxSound::SoundBuffer();
    8969}
    9070
     
    9272void Projectile::loadEngineSound(const std::string& engineSound)
    9373{
    94   if (this->engineBuffer != NULL)
    95     ResourceManager::getInstance()->unload(this->engineBuffer);
    96 
    97   else if (!engineSound.empty())
    98   {
    99     this->engineBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(engineSound, WAV);
    100     if (this->engineBuffer != NULL)
    101     {
    102       PRINTF(4)("Loaded sound %s to Pickup: %s.\n", engineSound.c_str(), this->getCName());
    103     }
    104     else
    105     {
    106       PRINTF(2)("Failed to load sound %s to engine %s.\n.", engineSound.c_str(), this->getCName());
    107     }
    108   }
     74  if (!engineSound.empty())
     75    this->engineBuffer = OrxSound::ResourceSoundBuffer(engineSound);
    10976  else
    110     this->engineBuffer = NULL;
     77    this->engineBuffer = OrxSound::SoundBuffer();
    11178}
    11279
     
    140107  //Vector offsetVel =
    141108  this->velocity = velocity;
    142  // offsetVel.normalize();
     109  // offsetVel.normalize();
    143110  //this->velocity += (offsetVel * 50.0);
    144111}
     
    174141void Projectile::destroy (WorldEntity* killer)
    175142{
    176   if (this->explosionBuffer != NULL)
     143  if (this->explosionBuffer.loaded())
    177144    this->soundSource.play(this->explosionBuffer);
    178145}
  • branches/new_class_id/src/world_entities/projectiles/projectile.h

    r9715 r9805  
    6767    OrxSound::SoundSource  soundSource;
    6868  private:
    69     OrxSound::SoundBuffer* explosionBuffer;
    70     OrxSound::SoundBuffer* engineBuffer;
     69    OrxSound::SoundBuffer  explosionBuffer;
     70    OrxSound::SoundBuffer  engineBuffer;
    7171};
    7272
  • branches/new_class_id/src/world_entities/space_ships/helicopter.cc

    r9757 r9805  
    2525
    2626#include "util/loading/factory.h"
    27 #include "util/loading/resource_manager.h"
     27#include "sound/resource_sound_buffer.h"
    2828
    2929#include "key_mapper.h"
     
    6363{
    6464  this->setPlayer(NULL);
    65 
    66   if (this->chopperBuffer != NULL)
    67     ResourceManager::getInstance()->unload(this->chopperBuffer);
    6865}
    6966
     
    115112
    116113  //load sound
    117   if (this->chopperBuffer != NULL)
    118     ResourceManager::getInstance()->unload(this->chopperBuffer);
    119   this->chopperBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/engine/chopper.wav", WAV);
     114  this->chopperBuffer = OrxSound::ResourceSoundBuffer("sound/engine/chopper.wav");
    120115
    121116}
     
    127122void Helicopter::init()
    128123{
    129   this->chopperBuffer = NULL;
    130 
    131124  this->registerObject(this, Helicopter::_objectList);
    132125  PRINTF(4)("HELICOPTER INIT\n");
  • branches/new_class_id/src/world_entities/space_ships/helicopter.h

    r9715 r9805  
    8080
    8181    OrxSound::SoundSource  soundSource;
    82     OrxSound::SoundBuffer* chopperBuffer;
     82    OrxSound::SoundBuffer  chopperBuffer;
    8383
    8484};
  • branches/new_class_id/src/world_entities/weapons/weapon.cc

    r9757 r9805  
    2424#include "world_entities/projectiles/projectile.h"
    2525
    26 #include "util/loading/resource_manager.h"
    2726#include "util/loading/factory.h"
    2827#include "util/loading/load_param.h"
     
    3231#include "sound_source.h"
    3332#include "sound_buffer.h"
     33#include "resource_sound_buffer.h"
    3434
    3535#include "elements/glgui_energywidget.h"
     
    5959    if (this->animation[i] && Animation::objectList().exists(animation[i]))  //!< @todo this should check animation3D
    6060      delete this->animation[i];
    61   for (int i = 0; i < WA_ACTION_COUNT; i++)
    62     if (this->soundBuffers[i] != NULL && OrxSound::SoundBuffer::objectList().exists(this->soundBuffers[i]))
    63       ResourceManager::getInstance()->unload(this->soundBuffers[i]);
    6461
    6562  if (OrxSound::SoundSource::objectList().exists(this->soundSource))
     
    121118    this->animation[i] = NULL;                   //< No animation
    122119  }
    123   for (int i = 0; i < WA_ACTION_COUNT; i++)
    124     this->soundBuffers[i] = NULL;                  //< No Sounds
    125120
    126121  this->soundSource = new OrxSound::SoundSource(this);       //< Every Weapon has exacty one SoundSource.
     
    273268  if (action >= WA_ACTION_COUNT)
    274269    return;
    275   if (this->soundBuffers[action] != NULL)
    276     ResourceManager::getInstance()->unload(this->soundBuffers[action]);
    277270
    278271  else if (!soundFile.empty())
    279272  {
    280     this->soundBuffers[action] = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(soundFile, WAV);
    281     if (this->soundBuffers[action] != NULL)
     273    this->soundBuffers[action] = OrxSound::ResourceSoundBuffer(soundFile);
     274    if (this->soundBuffers[action].loaded())
    282275    {
    283276      PRINTF(4)("Loaded sound %s to action %s.\n", soundFile.c_str(), actionToChar(action));
     
    289282  }
    290283  else
    291     this->soundBuffers[action] = NULL;
     284    this->soundBuffers[action] = OrxSound::SoundBuffer();
    292285}
    293286
     
    423416  {
    424417    case WA_SHOOT:
    425       return this->fireW();
    426       break;
     418    return this->fireW();
     419    break;
    427420    case WA_CHARGE:
    428       return this->chargeW();
    429       break;
     421    return this->chargeW();
     422    break;
    430423    case WA_RELOAD:
    431       return this->reloadW();
    432       break;
     424    return this->reloadW();
     425    break;
    433426    case WA_DEACTIVATE:
    434       return this->deactivateW();
    435       break;
     427    return this->deactivateW();
     428    break;
    436429    case WA_ACTIVATE:
    437       return this->activateW();
    438       break;
     430    return this->activateW();
     431    break;
    439432    default:
    440       PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
    441       return false;
     433    PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
     434    return false;
    442435  }
    443436}
     
    452445  {
    453446    // play Sound
    454     if (likely(this->soundBuffers[WA_ACTIVATE] != NULL))
     447    if (likely(this->soundBuffers[WA_ACTIVATE].loaded()))
    455448      this->soundSource->play(this->soundBuffers[WA_ACTIVATE]);
    456449    this->updateWidgets();
     
    474467    PRINTF(4)("Deactivating the Weapon %s\n", this->getCName());
    475468    // play Sound
    476     if (this->soundBuffers[WA_DEACTIVATE] != NULL)
     469    if (this->soundBuffers[WA_DEACTIVATE].loaded())
    477470      this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]);
    478471    // deactivate
     
    493486  {
    494487    // playing Sound
    495     if (this->soundBuffers[WA_CHARGE] != NULL)
     488    if (this->soundBuffers[WA_CHARGE].loaded())
    496489      this->soundSource->play(this->soundBuffers[WA_CHARGE]);
    497490
     
    518511  {
    519512    // playing Sound
    520     if (this->soundBuffers[WA_SHOOT] != NULL)
     513    if (this->soundBuffers[WA_SHOOT].loaded())
    521514      this->soundSource->play(this->soundBuffers[WA_SHOOT]);
    522515    this->updateWidgets();
     
    551544
    552545
    553   if (this->soundBuffers[WA_RELOAD] != NULL)
     546  if (this->soundBuffers[WA_RELOAD].loaded())
    554547    this->soundSource->play(this->soundBuffers[WA_RELOAD]);
    555548
     
    694687  {
    695688    case WA_SHOOT:
    696       return "shoot";
    697       break;
     689    return "shoot";
     690    break;
    698691    case WA_CHARGE:
    699       return "charge";
    700       break;
     692    return "charge";
     693    break;
    701694    case WA_RELOAD:
    702       return "reload";
    703       break;
     695    return "reload";
     696    break;
    704697    case WA_ACTIVATE:
    705       return "activate";
    706       break;
     698    return "activate";
     699    break;
    707700    case WA_DEACTIVATE:
    708       return "deactivate";
    709       break;
     701    return "deactivate";
     702    break;
    710703    case WA_SPECIAL1:
    711       return "special1";
    712       break;
     704    return "special1";
     705    break;
    713706    default:
    714       return "none";
    715       break;
     707    return "none";
     708    break;
    716709  }
    717710}
     
    757750  {
    758751    case WS_SHOOTING:
    759       return "shooting";
    760       break;
     752    return "shooting";
     753    break;
    761754    case WS_CHARGING:
    762       return "charging";
    763       break;
     755    return "charging";
     756    break;
    764757    case WS_RELOADING:
    765       return "reloading";
    766       break;
     758    return "reloading";
     759    break;
    767760    case WS_ACTIVATING:
    768       return "activating";
    769       break;
     761    return "activating";
     762    break;
    770763    case WS_DEACTIVATING:
    771       return "deactivating";
    772       break;
     764    return "deactivating";
     765    break;
    773766    case WS_IDLE:
    774       return "idle";
    775       break;
     767    return "idle";
     768    break;
    776769    case WS_INACTIVE:
    777       return "inactive";
    778       break;
     770    return "inactive";
     771    break;
    779772    default:
    780       return "none";
    781       break;
    782   }
    783 }
     773    return "none";
     774    break;
     775  }
     776}
  • branches/new_class_id/src/world_entities/weapons/weapon.h

    r9715 r9805  
    1818#include "count_pointer.h"
    1919#include "ammo_container.h"
     20
     21#include "sound_buffer.h"
    2022
    2123// FORWARD DECLARATION
     
    219221    // PHASES //
    220222    ////////////
    221     OrxSound::SoundSource* soundSource;                      //!< A SoundSource to play sound from (this is connected to the PNode of the Weapon)
    222 
    223     WeaponState            currentState;                     //!< The State the weapon is in.
    224     WeaponAction           requestedAction;                  //!< An action to try to Engage after the currentState ends.
    225     float                  stateDuration;                    //!< how long the state has taken until now.
    226     float                  times[WS_STATE_COUNT];            //!< Times to stay in the different States @see WeaponState.
    227     Animation3D*           animation[WS_STATE_COUNT];        //!< Animations for all the States (you can say yourself on what part of the gun this animation acts).
    228     OrxSound::SoundBuffer* soundBuffers[WA_ACTION_COUNT];    //!< SoundBuffers for all actions @see WeaponAction.
     223    OrxSound::SoundSource* soundSource;                     //!< A SoundSource to play sound from (this is connected to the PNode of the Weapon)
     224
     225    WeaponState            currentState;                    //!< The State the weapon is in.
     226    WeaponAction           requestedAction;                 //!< An action to try to Engage after the currentState ends.
     227    float                  stateDuration;                   //!< how long the state has taken until now.
     228    float                  times[WS_STATE_COUNT];           //!< Times to stay in the different States @see WeaponState.
     229    Animation3D*           animation[WS_STATE_COUNT];       //!< Animations for all the States (you can say yourself on what part of the gun this animation acts).
     230    OrxSound::SoundBuffer  soundBuffers[WA_ACTION_COUNT];   //!< SoundBuffers for all actions @see WeaponAction.
    229231
    230232    PNode                  emissionPoint;                   //!< The point, where the projectiles are emitted. (this is coppled with the Weapon by default)
  • branches/new_class_id/src/world_entities/weather_effects/lightning_effect.cc

    r9760 r9805  
    1919#include "util/loading/load_param.h"
    2020#include "util/loading/factory.h"
    21 #include "util/loading/resource_manager.h"
     21#include "sound/resource_sound_buffer.h"
    2222
    2323#include "effects/billboard.h"
     
    128128
    129129    //load sound
    130     this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/thunder.wav", WAV);
     130    this->thunderBuffer = OrxSound::ResourceSoundBuffer("sound/atmosphere/thunder.wav");
    131131
    132132}
  • branches/new_class_id/src/world_entities/weather_effects/lightning_effect.h

    r9760 r9805  
    118118
    119119  OrxSound::SoundSource    soundSource;
    120   OrxSound::SoundBuffer*   thunderBuffer;
     120  OrxSound::SoundBuffer    thunderBuffer;
    121121
    122122};
  • branches/new_class_id/src/world_entities/weather_effects/rain_effect.cc

    r9760 r9805  
    1919#include "util/loading/load_param.h"
    2020#include "util/loading/factory.h"
    21 #include "util/loading/resource_manager.h"
     21#include "sound/resource_sound_buffer.h"
    2222
    2323#include "glincl.h"
     
    6464
    6565    //load rain sound
    66     if (this->rainBuffer != NULL)
    67         ResourceManager::getInstance()->unload(this->rainBuffer);
    68     this->rainBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/rain.wav", WAV);
     66    this->rainBuffer = OrxSound::ResourceSoundBuffer("sound/atmosphere/rain.wav");
    6967
    7068    //load wind sound
    7169    if (this->rainWindForce != 0) {
    72         if (this->windBuffer != NULL)
    73             ResourceManager::getInstance()->unload(this->windBuffer);
    74         this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
     70      this->windBuffer = OrxSound::ResourceSoundBuffer("sound/atmosphere/wind.wav");
    7571    }
    7672
     
    8682RainEffect::~RainEffect() {
    8783    this->deactivate();
    88 
    89     if (this->rainBuffer != NULL)
    90         ResourceManager::getInstance()->unload(this->rainBuffer);
    91 
    92     if (this->windBuffer != NULL)
    93         ResourceManager::getInstance()->unload(this->windBuffer);
    9484}
    9585
     
    10191    this->rainParticles = NULL;
    10292    this->emitter = NULL;
    103     this->rainBuffer = NULL;
    104     this->windBuffer = NULL;
    10593    this->lightMan = NULL;
    10694
  • branches/new_class_id/src/world_entities/weather_effects/rain_effect.h

    r9760 r9805  
    128128
    129129  OrxSound::SoundSource       soundSource;
    130   OrxSound::SoundBuffer*      rainBuffer;
    131   OrxSound::SoundBuffer*      windBuffer;
     130  OrxSound::SoundBuffer       rainBuffer;
     131  OrxSound::SoundBuffer       windBuffer;
    132132
    133133  float                       soundRainVolume;
  • branches/new_class_id/src/world_entities/weather_effects/snow_effect.cc

    r9760 r9805  
    1717#include "util/loading/load_param.h"
    1818#include "util/loading/factory.h"
    19 #include "util/loading/resource_manager.h"
     19#include "sound/resource_sound_buffer.h"
    2020
    2121#include "glincl.h"
     
    3838
    3939CREATE_SCRIPTABLE_CLASS(SnowEffect,
    40                             addMethod("activate", Executor0<SnowEffect, lua_State*>(&SnowEffect::activate))
    41                             ->addMethod("deactivate", Executor0<SnowEffect, lua_State*>(&SnowEffect::deactivate))
     40                        addMethod("activate", Executor0<SnowEffect, lua_State*>(&SnowEffect::activate))
     41                        ->addMethod("deactivate", Executor0<SnowEffect, lua_State*>(&SnowEffect::deactivate))
    4242                       );
    4343
     
    4848  this->registerObject(this, SnowEffect::_objectList);
    4949
    50         this->init();
    51 
    52         if (root != NULL)
    53                 this->loadParams(root);
    54 
    55         this->windBuffer = NULL;
    56         //load wind sound
    57         if (this->snowWindForce >= 1) {
    58           this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
    59         }
    60 
    61   if(snowActivate) {
    62                 this->activate();
     50  this->init();
     51
     52  if (root != NULL)
     53    this->loadParams(root);
     54
     55  //load wind sound
     56  if (this->snowWindForce >= 1)
     57  {
     58    this->windBuffer = OrxSound::ResourceSoundBuffer("sound/atmosphere/wind.wav");
     59  }
     60
     61  if(snowActivate)
     62  {
     63    this->activate();
    6364    SnowEffect::snowParticles->precache((int) this->snowLife);
    6465  }
     
    6869SnowEffect::~SnowEffect()
    6970{
    70         this->deactivate();
     71  this->deactivate();
    7172}
    7273
     
    7576void SnowEffect::loadParams(const TiXmlElement* root)
    7677{
    77         WeatherEffect::loadParams(root);
    78 
    79         LoadParam(root, "numParticles", this, SnowEffect, numParticles);
    80         LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
    81         LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
    82         LoadParam(root, "radius", this, SnowEffect, radius);
    83         LoadParam(root, "mass", this, SnowEffect, mass);
    84         LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
    85         LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
    86         LoadParam(root, "wind", this, SnowEffect, wind);
    87         LoadParam(root, "size", this, SnowEffect, size);
    88         LoadParam(root, "coord", this, SnowEffect, coord);
     78  WeatherEffect::loadParams(root);
     79
     80  LoadParam(root, "numParticles", this, SnowEffect, numParticles);
     81  LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
     82  LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
     83  LoadParam(root, "radius", this, SnowEffect, radius);
     84  LoadParam(root, "mass", this, SnowEffect, mass);
     85  LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
     86  LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
     87  LoadParam(root, "wind", this, SnowEffect, wind);
     88  LoadParam(root, "size", this, SnowEffect, size);
     89  LoadParam(root, "coord", this, SnowEffect, coord);
    8990  LoadParam(root, "cloudcolor", this, SnowEffect, setCloudColor);
    9091  LoadParam(root, "skycolor", this, SnowEffect, setSkyColor);
    9192  LoadParam(root, "fadetime", this, SnowEffect, setFadeTime);
    9293
    93         LOAD_PARAM_START_CYCLE(root, element);
    94         {
    95                 LoadParam_CYCLE(element, "option", this, SnowEffect, setSnowOption);
    96         }
    97         LOAD_PARAM_END_CYCLE(element);
     94  LOAD_PARAM_START_CYCLE(root, element);
     95  {
     96    LoadParam_CYCLE(element, "option", this, SnowEffect, setSnowOption);
     97  }
     98  LOAD_PARAM_END_CYCLE(element);
    9899}
    99100
    100101void SnowEffect::init()
    101102{
    102         this->emitter = new PlaneEmitter();
    103 
    104         // Default values
    105         this->snowActivate = false;
    106         this->snowMove = false;
    107         this->particles = 12000;
    108         this->texture = "maps/snow_flake_01_32x32.png";
    109         this->snowLife = 8;
    110         this->randomLife = 2;
    111         this->snowRadius = 3.5;
    112         this->randomRadius = 1;
    113         this->snowMass = 1.0;
    114         this->randomMass = 0.3;
    115         this->rate = 900;
    116         this->velocity = -100;
    117         this->randomVelocity = 5;
    118         this->angle = 0.5;
    119         this->randomAngle = 0.2;
    120         this->alpha = 0.5;
    121         this->snowSize = Vector2D(2500, 2500);
    122         this->snowCoord = Vector(100,450,400);
    123         this->snowWindForce = 1;
     103  this->emitter = new PlaneEmitter();
     104
     105  // Default values
     106  this->snowActivate = false;
     107  this->snowMove = false;
     108  this->particles = 12000;
     109  this->texture = "maps/snow_flake_01_32x32.png";
     110  this->snowLife = 8;
     111  this->randomLife = 2;
     112  this->snowRadius = 3.5;
     113  this->randomRadius = 1;
     114  this->snowMass = 1.0;
     115  this->randomMass = 0.3;
     116  this->rate = 900;
     117  this->velocity = -100;
     118  this->randomVelocity = 5;
     119  this->angle = 0.5;
     120  this->randomAngle = 0.2;
     121  this->alpha = 0.5;
     122  this->snowSize = Vector2D(2500, 2500);
     123  this->snowCoord = Vector(100,450,400);
     124  this->snowWindForce = 1;
    124125
    125126  this->fadeTime = 10;
     
    130131void SnowEffect::activate()
    131132{
    132         PRINTF(3)("Activating SnowEffect\n");
    133 
    134         this->snowActivate = true;
    135 
    136         SnowEffect::snowParticles = new SpriteParticles(particles);
    137         SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
    138         SnowEffect::snowParticles->setMaterialTexture(texture);
    139         SnowEffect::snowParticles->setLifeSpan(snowLife, randomLife);
    140         SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
    141         SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius*0.8);
    142         SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius*0.5);
    143         SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
    144         SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    145         SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
    146         SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
    147 
    148         this->emitter->setSystem(SnowEffect::snowParticles);
    149 
    150         this->emitter->setRelCoor(snowCoord);
    151         this->emitter->setEmissionRate(rate);
    152         this->emitter->setEmissionVelocity(velocity, randomVelocity);
    153         this->emitter->setSpread(angle * this->snowWindForce , randomAngle * this->snowWindForce);
    154         this->emitter->setSize(snowSize);
     133  PRINTF(3)("Activating SnowEffect\n");
     134
     135  this->snowActivate = true;
     136
     137  SnowEffect::snowParticles = new SpriteParticles(particles);
     138  SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
     139  SnowEffect::snowParticles->setMaterialTexture(texture);
     140  SnowEffect::snowParticles->setLifeSpan(snowLife, randomLife);
     141  SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
     142  SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius*0.8);
     143  SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius*0.5);
     144  SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
     145  SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
     146  SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     147  SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     148
     149  this->emitter->setSystem(SnowEffect::snowParticles);
     150
     151  this->emitter->setRelCoor(snowCoord);
     152  this->emitter->setEmissionRate(rate);
     153  this->emitter->setEmissionVelocity(velocity, randomVelocity);
     154  this->emitter->setSpread(angle * this->snowWindForce , randomAngle * this->snowWindForce);
     155  this->emitter->setSize(snowSize);
    155156
    156157  if (this->snowWindForce != 0)
     
    170171void SnowEffect::deactivate()
    171172{
    172         PRINTF(3)("Deactivating SnowEffect\n");
    173 
    174         this->snowActivate = false;
    175         this->emitter->setSystem(NULL);
    176 
    177         if (this->windBuffer != NULL)
    178                 ResourceManager::getInstance()->unload(this->windBuffer);
     173  PRINTF(3)("Deactivating SnowEffect\n");
     174
     175  this->snowActivate = false;
     176  this->emitter->setSystem(NULL);
    179177
    180178  // Restore the old cloud- and sky color
     
    185183void SnowEffect::draw() const
    186184{
    187         if (!this->snowActivate)
    188                 return;
     185  if (!this->snowActivate)
     186    return;
    189187}
    190188
    191189void SnowEffect::tick(float dt)
    192190{
    193         if (!this->snowActivate)
    194                 return;
    195 
    196         /*
    197         float distance = (State::getCameraNode()->getAbsCoor() - Vector(snowCoord.x, State::getCameraNode()->getAbsCoor().y, snowCoord.z)).len();
    198 
    199         if(activated)
    200         {
    201         if(distance > 0.3*snowSize.x || distance > 0.3*snowSize.y)
    202                         this->deactivate();
    203         else if(distance > 0.25*snowSize.x || distance > 0.25*snowSize.y)
    204         this->alpha = 0.15;
    205         else if(distance > 0.2*snowSize.x || distance > 0.2*snowSize.y)
    206         this->alpha = 0.25;
    207         else if(distance > 0.1*snowSize.x || distance > 0.1*snowSize.y)
    208         this->alpha = 0.4;
    209 
    210         SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    211         SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
    212         SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
    213         }
    214         else
    215         {
    216         if(distance < 0.3*snowSize.x || distance < 0.3*snowSize.y )
    217         this->activate();
    218         if( distance < 0.25*snowSize.x || distance < 0.25*snowSize.y )
    219         this->alpha = 0.25;
    220         else if( distance < 0.2*snowSize.x || distance < 0.2*snowSize.y )
    221         this->alpha = 0.4;
    222         else if( distance < 0.1*snowSize.x || distance < 0.1*snowSize.y )
    223         this->alpha = 0.5;
    224 
    225         SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    226         SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
    227         SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
    228         }*/
    229 
    230         if (this->snowMove) {
    231                 this->snowCoord = State::getCameraNode()->getAbsCoor();
    232                 this->emitter->setRelCoor(this->snowCoord.x , this->snowCoord.y+300, this->snowCoord.z);
    233         }
    234 }
     191  if (!this->snowActivate)
     192    return;
     193
     194  /*
     195  float distance = (State::getCameraNode()->getAbsCoor() - Vector(snowCoord.x, State::getCameraNode()->getAbsCoor().y, snowCoord.z)).len();
     196
     197  if(activated)
     198  {
     199  if(distance > 0.3*snowSize.x || distance > 0.3*snowSize.y)
     200                  this->deactivate();
     201  else if(distance > 0.25*snowSize.x || distance > 0.25*snowSize.y)
     202  this->alpha = 0.15;
     203  else if(distance > 0.2*snowSize.x || distance > 0.2*snowSize.y)
     204  this->alpha = 0.25;
     205  else if(distance > 0.1*snowSize.x || distance > 0.1*snowSize.y)
     206  this->alpha = 0.4;
     207
     208  SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
     209  SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     210  SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     211  }
     212  else
     213  {
     214  if(distance < 0.3*snowSize.x || distance < 0.3*snowSize.y )
     215  this->activate();
     216  if( distance < 0.25*snowSize.x || distance < 0.25*snowSize.y )
     217  this->alpha = 0.25;
     218  else if( distance < 0.2*snowSize.x || distance < 0.2*snowSize.y )
     219  this->alpha = 0.4;
     220  else if( distance < 0.1*snowSize.x || distance < 0.1*snowSize.y )
     221  this->alpha = 0.5;
     222
     223  SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
     224  SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     225  SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     226  }*/
     227
     228  if (this->snowMove)
     229  {
     230    this->snowCoord = State::getCameraNode()->getAbsCoor();
     231    this->emitter->setRelCoor(this->snowCoord.x , this->snowCoord.y+300, this->snowCoord.z);
     232  }
     233}
  • branches/new_class_id/src/world_entities/weather_effects/snow_effect.h

    r9760 r9805  
    137137  static SpriteParticles*   snowParticles;
    138138  OrxSound::SoundSource     soundSource;
    139   OrxSound::SoundBuffer*    windBuffer;
     139  OrxSound::SoundBuffer     windBuffer;
    140140
    141141  Vector            oldSkyColor;
Note: See TracChangeset for help on using the changeset viewer.