Changeset 9805 in orxonox.OLD for branches/new_class_id
- Timestamp:
- Sep 24, 2006, 3:21:12 PM (18 years ago)
- 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 45 45 for (it = this->_classes.begin(); it != this->_classes.end(); ++it) 46 46 { 47 PRINTF(5)("DELETING OBJECT %s::%s FROM %s\n", this->getClassCName(), getCName(), (*it)._objectList->name().c_str()); 47 48 (*it)._objectList->unregisterObject((*it)._iterator); 48 49 delete (*it)._iterator; -
branches/new_class_id/src/lib/lang/object_list.cc
r9757 r9805 272 272 ++it) 273 273 { 274 printf(" + %s::%s \n", (*it)->getClassCName(), (*it)->getCName());274 printf(" + %s::%s (%p)\n", (*it)->getClassCName(), (*it)->getCName(), (*it)); 275 275 } 276 276 } -
branches/new_class_id/src/lib/shell/some_shell_commands.cc
r9800 r9805 67 67 ->setAlias("orxoquit"); 68 68 69 #include "object_list.h" 70 SHELL_COMMAND_STATIC(debugAll, ObjectListBase, &ObjectListBase::debugAll); -
branches/new_class_id/src/lib/sound/sound_buffer.cc
r9804 r9805 20 20 namespace OrxSound 21 21 { 22 ObjectListDefinition(SoundBuffer);23 22 ////////////////// 24 23 /* SOUND-BUFFER */ 25 24 ////////////////// 26 25 SoundBuffer::SoundBuffer() 27 : data(new SoundBufferData)26 : data(new SoundBufferData) 28 27 { 29 this->registerObject(this, SoundBuffer::_objectList);30 28 } 31 29 /** … … 34 32 */ 35 33 SoundBuffer::SoundBuffer(const std::string& fileName) 36 : data(new SoundBufferData)34 : data(new SoundBufferData) 37 35 { 38 this->registerObject(this, SoundBuffer::_objectList);39 this->setName(fileName);40 41 36 this->load(fileName); 42 37 } 38 39 SoundBuffer::SoundBuffer(const SoundBuffer& buffer) 40 : data(buffer.data) 41 { } 42 43 SoundBuffer::SoundBuffer(const SoundBufferData::Pointer& dataPointer) 44 : data(dataPointer) 45 { }; 43 46 } -
branches/new_class_id/src/lib/sound/sound_buffer.h
r9804 r9805 7 7 #define _SOUND_BUFFER_H 8 8 9 #include "base_object.h"10 #include "alincl.h"11 12 9 #include "sound_buffer_data.h" 13 10 … … 15 12 { 16 13 //! A class that represents a datastructure to play Sounds. 17 class SoundBuffer : public BaseObject14 class SoundBuffer 18 15 { 19 ObjectListDeclaration(SoundBuffer);20 16 public: 21 17 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); 24 20 SoundBuffer(const std::string& fileName); 21 22 bool operator==(const SoundBuffer& buffer) const {return this->data == buffer.data; }; 25 23 26 24 /** @see SoundBufferData::load */ … … 33 31 /** @returns the ID of the buffer used in this SoundBuffer */ 34 32 inline ALuint getID() const { return this->data->getID(); } 33 inline bool loaded() const { return this->data->loaded(); } 35 34 36 35 /** @returns the DataPointer */ … … 38 37 /** @param dataPointer the data to acquire @brief Buffer shall acquire dataPointers data */ 39 38 void acquireData(const SoundBufferData::Pointer& dataPointer) { data = dataPointer; }; 39 40 40 private: 41 SoundBufferData::Pointer data; 41 SoundBufferData::Pointer data; //!< Pointer to the Stored Data 42 42 }; 43 43 } -
branches/new_class_id/src/lib/sound/sound_buffer_data.cc
r9803 r9805 50 50 this->size = 0; 51 51 this->loop = AL_FALSE; 52 53 52 this->bLoaded = false; 54 53 } 55 54 … … 112 111 SDL_FreeWAV(wavBuffer); 113 112 if (SoundEngine::checkError("Could not load Wave file", __LINE__)) 113 { 114 this->bLoaded = true; 114 115 return true; 116 } 115 117 else 116 118 return false; … … 160 162 return false; 161 163 164 this->bLoaded = true; 162 165 return true ; 163 164 166 } 165 167 -
branches/new_class_id/src/lib/sound/sound_buffer_data.h
r9803 r9805 33 33 /** @returns the ID of the buffer used in this SoundBuffer */ 34 34 inline ALuint getID() const { return this->bufferID; } 35 inline bool loaded() const { return bLoaded; }; 35 36 36 37 private: … … 42 43 ALsizei size; //!< The size of the Buffer. 43 44 ALboolean loop; //!< loop information. 45 bool bLoaded; //!< If the Sound was loaded this is true. 44 46 }; 45 47 } -
branches/new_class_id/src/lib/sound/sound_engine.cc
r9721 r9805 26 26 #include "util/preferences.h" 27 27 #include "globals.h" 28 #include "resource_sound_buffer.h" 28 29 29 30 namespace OrxSound … … 119 120 SoundSource* SoundEngine::createSource(const std::string& fileName, PNode* sourceNode) 120 121 { 121 SoundBuffer * buffer = NULL;122 SoundBuffer buffer; 122 123 if (!fileName.empty()) 123 124 { 124 buffer = (SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL);125 if ( buffer == NULL)125 buffer = ResourceSoundBuffer(fileName); 126 if (!buffer.loaded()) 126 127 PRINTF(2)("Wav-Sound %s could not be loaded onto new Source\n", fileName.c_str()); 127 128 } … … 215 216 if(play == AL_PLAYING) 216 217 { 217 218 if (likely((*sourceIT)->getNode() != NULL)) 218 219 { 219 220 alSource3f((*sourceIT)->getID(), AL_POSITION, -
branches/new_class_id/src/lib/sound/sound_source.cc
r9715 r9805 19 19 #include "sound_engine.h" 20 20 21 #include "alincl.h"22 21 #include "compiler.h" 23 22 #include "debug.h" … … 29 28 * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer 30 29 */ 31 SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer *buffer)30 SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer& buffer) 32 31 { 33 32 this->registerObject(this, SoundSource::_objectList); … … 120 119 void SoundSource::play() 121 120 { 122 if (this-> buffer && this->retrieveSource())121 if (this->retrieveSource()) 123 122 { 124 123 if (this->bPlay) 125 124 alSourceStop(this->sourceID); 126 125 127 alSourcei (this->sourceID, AL_BUFFER, this->buffer ->getID());126 alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID()); 128 127 alSourcei (this->sourceID, AL_LOOPING, AL_FALSE); 129 128 alSourcef (this->sourceID, AL_GAIN, 1); … … 141 140 * @param buffer the buffer to play back on this Source 142 141 */ 143 void SoundSource::play(const SoundBuffer *buffer)142 void SoundSource::play(const SoundBuffer& buffer) 144 143 { 145 144 if (!this->retrieveSource()) … … 150 149 151 150 alSourceStop(this->sourceID); 152 alSourcei (this->sourceID, AL_BUFFER, buffer ->getID());151 alSourcei (this->sourceID, AL_BUFFER, buffer.getID()); 153 152 alSourcei (this->sourceID, AL_LOOPING, AL_FALSE); 154 153 alSourcef (this->sourceID, AL_GAIN, 1); … … 156 155 alSourcePlay(this->sourceID); 157 156 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()); 160 159 this->bPlay = true; 161 160 … … 170 169 * @param gain the gain of the sound buffer 171 170 */ 172 void SoundSource::play(const SoundBuffer *buffer, float gain)171 void SoundSource::play(const SoundBuffer& buffer, float gain) 173 172 { 174 173 if (!this->retrieveSource()) … … 179 178 180 179 alSourceStop(this->sourceID); 181 alSourcei (this->sourceID, AL_BUFFER, buffer ->getID());180 alSourcei (this->sourceID, AL_BUFFER, buffer.getID()); 182 181 alSourcei (this->sourceID, AL_LOOPING, AL_FALSE); 183 182 alSourcef (this->sourceID, AL_GAIN, gain); … … 185 184 alSourcePlay(this->sourceID); 186 185 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()); 189 188 this->bPlay = true; 190 189 … … 199 198 * @param loop if true, sound gets looped 200 199 */ 201 void SoundSource::play(const SoundBuffer *buffer, float gain, bool loop)200 void SoundSource::play(const SoundBuffer& buffer, float gain, bool loop) 202 201 { 203 202 if (!this->retrieveSource()) … … 208 207 209 208 alSourceStop(this->sourceID); 210 alSourcei (this->sourceID, AL_BUFFER, buffer ->getID());209 alSourcei (this->sourceID, AL_BUFFER, buffer.getID()); 211 210 212 211 if (loop) … … 219 218 alSourcePlay(this->sourceID); 220 219 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()); 223 222 this->bPlay = true; 224 223 … … 232 231 * @param gain the new gain value 233 232 */ 234 void SoundSource::gain(const SoundBuffer *buffer, float gain)233 void SoundSource::gain(const SoundBuffer& buffer, float gain) 235 234 { 236 235 // alSourcei (this->sourceID, AL_BUFFER, buffer->getID()); … … 347 346 * @param duration time perios to fade in 348 347 */ 349 void SoundSource::fadein(const SoundBuffer *buffer, ALfloat duration)348 void SoundSource::fadein(const SoundBuffer& buffer, ALfloat duration) 350 349 { 351 350 //if (this->buffer && this->retrieveSource()) -
branches/new_class_id/src/lib/sound/sound_source.h
r9715 r9805 8 8 9 9 #include "base_object.h" 10 #include "sound_buffer.h" 10 11 #include "alincl.h" 11 12 … … 14 15 namespace OrxSound 15 16 { 16 class SoundBuffer;17 17 //! A class that represents a SoundSource 18 18 class SoundSource : public BaseObject … … 20 20 ObjectListDeclaration(SoundSource); 21 21 public: 22 SoundSource(const PNode* sourceNode = NULL, const SoundBuffer * buffer = NULL);22 SoundSource(const PNode* sourceNode = NULL, const SoundBuffer& buffer = SoundBuffer()); 23 23 SoundSource(const SoundSource& source); 24 24 SoundSource& operator=(const SoundSource& source); … … 29 29 // user interaction 30 30 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); 34 34 35 void gain(const SoundBuffer *buffer, float gain);35 void gain(const SoundBuffer& buffer, float gain); 36 36 37 37 void stop(); 38 38 void pause(); 39 39 void rewind(); 40 void fadein(const SoundBuffer *buffer, ALfloat duration);40 void fadein(const SoundBuffer& buffer, ALfloat duration); 41 41 42 42 // development functions … … 47 47 void setSourceNode(const PNode* sourceNode); 48 48 /** @returns the SoundBuffer of this Source */ 49 inline const SoundBuffer *getBuffer() const { return this->buffer; };49 inline const SoundBuffer& getBuffer() const { return this->buffer; }; 50 50 /** @returns the SourceNode of this Source */ 51 51 inline const PNode* getNode() const { return this->sourceNode; }; … … 66 66 bool resident; //!< If the alSource should be resident (if true, the alSource will be returned on deletion). 67 67 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. 69 69 const PNode* sourceNode; //!< The SourceNode representing the position/velocity... of this source. 70 70 }; -
branches/new_class_id/src/lib/util/loading/resource_manager.cc
r9721 r9805 442 442 case WAV: 443 443 if(File(fullName).isFile()) 444 tmpResource->pointer = new OrxSound::SoundBuffer(fullName);444 // tmpResource->pointer = new OrxSound::SoundBuffer(fullName); 445 445 break; 446 446 case OGG: -
branches/new_class_id/src/world_entities/effects/lightning_bolt.cc
r9716 r9805 20 20 #include "material.h" 21 21 22 #include " util/loading/resource_manager.h"22 #include "sound/resource_sound_buffer.h" 23 23 24 24 … … 56 56 this->seedTime = 4.0f; 57 57 58 this->soundSource = NULL;59 this->thunderBuffer = NULL;60 61 58 this->soundSource.setSourceNode(this); 62 59 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"); 67 61 } 68 62 -
branches/new_class_id/src/world_entities/effects/lightning_bolt.h
r9715 r9805 52 52 53 53 OrxSound::SoundSource soundSource; 54 OrxSound::SoundBuffer *thunderBuffer;54 OrxSound::SoundBuffer thunderBuffer; 55 55 }; 56 56 -
branches/new_class_id/src/world_entities/power_ups/power_up.cc
r9757 r9805 21 21 #include "primitive_model.h" 22 22 23 #include " util/loading/resource_manager.h"23 #include "sound/resource_sound_buffer.h" 24 24 #include "util/loading/load_param.h" 25 25 … … 47 47 48 48 this->soundSource.setSourceNode(this); 49 this->pickupBuffer = NULL;50 this->respawnBuffer = NULL;51 49 52 50 this->collider = NULL; … … 56 54 { 57 55 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);62 56 } 63 57 … … 79 73 void PowerUp::loadPickupSound(const std::string& pickupSound) 80 74 { 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); 96 77 else 97 this->pickupBuffer = NULL;78 this->pickupBuffer = OrxSound::SoundBuffer(); 98 79 } 99 80 100 81 void PowerUp::loadRespawnSound(const std::string& respawnSound) 101 82 { 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); 117 85 else 118 this->respawnBuffer = NULL;86 this->respawnBuffer = OrxSound::SoundBuffer(); 119 87 } 120 88 … … 127 95 if(dynamic_cast<Extendable*>(entity)->pickup(this)) 128 96 { 129 if(pickupBuffer != NULL)97 if(pickupBuffer.loaded()) 130 98 this->soundSource.play(this->pickupBuffer); 131 99 … … 156 124 this->toList(OM_COMMON); 157 125 this->collider = NULL; 158 if (likely(this->respawnBuffer != NULL))126 if (likely(this->respawnBuffer.loaded())) 159 127 this->soundSource.play(this->respawnBuffer); 160 128 -
branches/new_class_id/src/world_entities/power_ups/power_up.h
r9715 r9805 44 44 private: 45 45 OrxSound::SoundSource soundSource; 46 OrxSound::SoundBuffer *pickupBuffer;47 OrxSound::SoundBuffer *respawnBuffer;46 OrxSound::SoundBuffer pickupBuffer; 47 OrxSound::SoundBuffer respawnBuffer; 48 48 Material* sphereMaterial; 49 49 PowerUpRespawn respawnType; -
branches/new_class_id/src/world_entities/projectiles/projectile.cc
r9783 r9805 22 22 #include "world_entities/weapons/weapon.h" 23 23 #include "model.h" 24 #include " util/loading/resource_manager.h"24 #include "sound/resource_sound_buffer.h" 25 25 26 26 #include "debug.h" … … 44 44 this->setDamage(1.0f); // default damage of a projectile set to 100.0 damage points 45 45 46 this->explosionBuffer = NULL;47 this->engineBuffer = NULL;48 49 46 //this->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 50 47 } … … 56 53 Projectile::~Projectile () 57 54 { 58 if (this->explosionBuffer != NULL)59 ResourceManager::getInstance()->unload(this->explosionBuffer);60 if (this->engineBuffer != NULL)61 ResourceManager::getInstance()->unload(this->engineBuffer);62 55 /* 63 56 do not delete the test projectModel, since it is pnode … … 70 63 void Projectile::loadExplosionSound(const std::string& explosionSound) 71 64 { 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); 87 67 else 88 this->explosionBuffer = NULL;68 this->explosionBuffer = OrxSound::SoundBuffer(); 89 69 } 90 70 … … 92 72 void Projectile::loadEngineSound(const std::string& engineSound) 93 73 { 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); 109 76 else 110 this->engineBuffer = NULL;77 this->engineBuffer = OrxSound::SoundBuffer(); 111 78 } 112 79 … … 140 107 //Vector offsetVel = 141 108 this->velocity = velocity; 142 // offsetVel.normalize();109 // offsetVel.normalize(); 143 110 //this->velocity += (offsetVel * 50.0); 144 111 } … … 174 141 void Projectile::destroy (WorldEntity* killer) 175 142 { 176 if (this->explosionBuffer != NULL)143 if (this->explosionBuffer.loaded()) 177 144 this->soundSource.play(this->explosionBuffer); 178 145 } -
branches/new_class_id/src/world_entities/projectiles/projectile.h
r9715 r9805 67 67 OrxSound::SoundSource soundSource; 68 68 private: 69 OrxSound::SoundBuffer *explosionBuffer;70 OrxSound::SoundBuffer *engineBuffer;69 OrxSound::SoundBuffer explosionBuffer; 70 OrxSound::SoundBuffer engineBuffer; 71 71 }; 72 72 -
branches/new_class_id/src/world_entities/space_ships/helicopter.cc
r9757 r9805 25 25 26 26 #include "util/loading/factory.h" 27 #include " util/loading/resource_manager.h"27 #include "sound/resource_sound_buffer.h" 28 28 29 29 #include "key_mapper.h" … … 63 63 { 64 64 this->setPlayer(NULL); 65 66 if (this->chopperBuffer != NULL)67 ResourceManager::getInstance()->unload(this->chopperBuffer);68 65 } 69 66 … … 115 112 116 113 //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"); 120 115 121 116 } … … 127 122 void Helicopter::init() 128 123 { 129 this->chopperBuffer = NULL;130 131 124 this->registerObject(this, Helicopter::_objectList); 132 125 PRINTF(4)("HELICOPTER INIT\n"); -
branches/new_class_id/src/world_entities/space_ships/helicopter.h
r9715 r9805 80 80 81 81 OrxSound::SoundSource soundSource; 82 OrxSound::SoundBuffer *chopperBuffer;82 OrxSound::SoundBuffer chopperBuffer; 83 83 84 84 }; -
branches/new_class_id/src/world_entities/weapons/weapon.cc
r9757 r9805 24 24 #include "world_entities/projectiles/projectile.h" 25 25 26 #include "util/loading/resource_manager.h"27 26 #include "util/loading/factory.h" 28 27 #include "util/loading/load_param.h" … … 32 31 #include "sound_source.h" 33 32 #include "sound_buffer.h" 33 #include "resource_sound_buffer.h" 34 34 35 35 #include "elements/glgui_energywidget.h" … … 59 59 if (this->animation[i] && Animation::objectList().exists(animation[i])) //!< @todo this should check animation3D 60 60 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]);64 61 65 62 if (OrxSound::SoundSource::objectList().exists(this->soundSource)) … … 121 118 this->animation[i] = NULL; //< No animation 122 119 } 123 for (int i = 0; i < WA_ACTION_COUNT; i++)124 this->soundBuffers[i] = NULL; //< No Sounds125 120 126 121 this->soundSource = new OrxSound::SoundSource(this); //< Every Weapon has exacty one SoundSource. … … 273 268 if (action >= WA_ACTION_COUNT) 274 269 return; 275 if (this->soundBuffers[action] != NULL)276 ResourceManager::getInstance()->unload(this->soundBuffers[action]);277 270 278 271 else if (!soundFile.empty()) 279 272 { 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()) 282 275 { 283 276 PRINTF(4)("Loaded sound %s to action %s.\n", soundFile.c_str(), actionToChar(action)); … … 289 282 } 290 283 else 291 this->soundBuffers[action] = NULL;284 this->soundBuffers[action] = OrxSound::SoundBuffer(); 292 285 } 293 286 … … 423 416 { 424 417 case WA_SHOOT: 425 426 418 return this->fireW(); 419 break; 427 420 case WA_CHARGE: 428 429 421 return this->chargeW(); 422 break; 430 423 case WA_RELOAD: 431 432 424 return this->reloadW(); 425 break; 433 426 case WA_DEACTIVATE: 434 435 427 return this->deactivateW(); 428 break; 436 429 case WA_ACTIVATE: 437 438 430 return this->activateW(); 431 break; 439 432 default: 440 441 433 PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action)); 434 return false; 442 435 } 443 436 } … … 452 445 { 453 446 // play Sound 454 if (likely(this->soundBuffers[WA_ACTIVATE] != NULL))447 if (likely(this->soundBuffers[WA_ACTIVATE].loaded())) 455 448 this->soundSource->play(this->soundBuffers[WA_ACTIVATE]); 456 449 this->updateWidgets(); … … 474 467 PRINTF(4)("Deactivating the Weapon %s\n", this->getCName()); 475 468 // play Sound 476 if (this->soundBuffers[WA_DEACTIVATE] != NULL)469 if (this->soundBuffers[WA_DEACTIVATE].loaded()) 477 470 this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]); 478 471 // deactivate … … 493 486 { 494 487 // playing Sound 495 if (this->soundBuffers[WA_CHARGE] != NULL)488 if (this->soundBuffers[WA_CHARGE].loaded()) 496 489 this->soundSource->play(this->soundBuffers[WA_CHARGE]); 497 490 … … 518 511 { 519 512 // playing Sound 520 if (this->soundBuffers[WA_SHOOT] != NULL)513 if (this->soundBuffers[WA_SHOOT].loaded()) 521 514 this->soundSource->play(this->soundBuffers[WA_SHOOT]); 522 515 this->updateWidgets(); … … 551 544 552 545 553 if (this->soundBuffers[WA_RELOAD] != NULL)546 if (this->soundBuffers[WA_RELOAD].loaded()) 554 547 this->soundSource->play(this->soundBuffers[WA_RELOAD]); 555 548 … … 694 687 { 695 688 case WA_SHOOT: 696 697 689 return "shoot"; 690 break; 698 691 case WA_CHARGE: 699 700 692 return "charge"; 693 break; 701 694 case WA_RELOAD: 702 703 695 return "reload"; 696 break; 704 697 case WA_ACTIVATE: 705 706 698 return "activate"; 699 break; 707 700 case WA_DEACTIVATE: 708 709 701 return "deactivate"; 702 break; 710 703 case WA_SPECIAL1: 711 712 704 return "special1"; 705 break; 713 706 default: 714 715 707 return "none"; 708 break; 716 709 } 717 710 } … … 757 750 { 758 751 case WS_SHOOTING: 759 760 752 return "shooting"; 753 break; 761 754 case WS_CHARGING: 762 763 755 return "charging"; 756 break; 764 757 case WS_RELOADING: 765 766 758 return "reloading"; 759 break; 767 760 case WS_ACTIVATING: 768 769 761 return "activating"; 762 break; 770 763 case WS_DEACTIVATING: 771 772 764 return "deactivating"; 765 break; 773 766 case WS_IDLE: 774 775 767 return "idle"; 768 break; 776 769 case WS_INACTIVE: 777 778 770 return "inactive"; 771 break; 779 772 default: 780 781 782 } 783 } 773 return "none"; 774 break; 775 } 776 } -
branches/new_class_id/src/world_entities/weapons/weapon.h
r9715 r9805 18 18 #include "count_pointer.h" 19 19 #include "ammo_container.h" 20 21 #include "sound_buffer.h" 20 22 21 23 // FORWARD DECLARATION … … 219 221 // PHASES // 220 222 //////////// 221 OrxSound::SoundSource* soundSource; 222 223 WeaponState currentState; 224 WeaponAction requestedAction; 225 float stateDuration; 226 float times[WS_STATE_COUNT]; 227 Animation3D* animation[WS_STATE_COUNT]; 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. 229 231 230 232 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 19 19 #include "util/loading/load_param.h" 20 20 #include "util/loading/factory.h" 21 #include " util/loading/resource_manager.h"21 #include "sound/resource_sound_buffer.h" 22 22 23 23 #include "effects/billboard.h" … … 128 128 129 129 //load sound 130 this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/thunder.wav", WAV);130 this->thunderBuffer = OrxSound::ResourceSoundBuffer("sound/atmosphere/thunder.wav"); 131 131 132 132 } -
branches/new_class_id/src/world_entities/weather_effects/lightning_effect.h
r9760 r9805 118 118 119 119 OrxSound::SoundSource soundSource; 120 OrxSound::SoundBuffer *thunderBuffer;120 OrxSound::SoundBuffer thunderBuffer; 121 121 122 122 }; -
branches/new_class_id/src/world_entities/weather_effects/rain_effect.cc
r9760 r9805 19 19 #include "util/loading/load_param.h" 20 20 #include "util/loading/factory.h" 21 #include " util/loading/resource_manager.h"21 #include "sound/resource_sound_buffer.h" 22 22 23 23 #include "glincl.h" … … 64 64 65 65 //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"); 69 67 70 68 //load wind sound 71 69 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"); 75 71 } 76 72 … … 86 82 RainEffect::~RainEffect() { 87 83 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);94 84 } 95 85 … … 101 91 this->rainParticles = NULL; 102 92 this->emitter = NULL; 103 this->rainBuffer = NULL;104 this->windBuffer = NULL;105 93 this->lightMan = NULL; 106 94 -
branches/new_class_id/src/world_entities/weather_effects/rain_effect.h
r9760 r9805 128 128 129 129 OrxSound::SoundSource soundSource; 130 OrxSound::SoundBuffer *rainBuffer;131 OrxSound::SoundBuffer *windBuffer;130 OrxSound::SoundBuffer rainBuffer; 131 OrxSound::SoundBuffer windBuffer; 132 132 133 133 float soundRainVolume; -
branches/new_class_id/src/world_entities/weather_effects/snow_effect.cc
r9760 r9805 17 17 #include "util/loading/load_param.h" 18 18 #include "util/loading/factory.h" 19 #include " util/loading/resource_manager.h"19 #include "sound/resource_sound_buffer.h" 20 20 21 21 #include "glincl.h" … … 38 38 39 39 CREATE_SCRIPTABLE_CLASS(SnowEffect, 40 41 40 addMethod("activate", Executor0<SnowEffect, lua_State*>(&SnowEffect::activate)) 41 ->addMethod("deactivate", Executor0<SnowEffect, lua_State*>(&SnowEffect::deactivate)) 42 42 ); 43 43 … … 48 48 this->registerObject(this, SnowEffect::_objectList); 49 49 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(); 63 64 SnowEffect::snowParticles->precache((int) this->snowLife); 64 65 } … … 68 69 SnowEffect::~SnowEffect() 69 70 { 70 71 this->deactivate(); 71 72 } 72 73 … … 75 76 void SnowEffect::loadParams(const TiXmlElement* root) 76 77 { 77 78 79 80 81 82 83 84 85 86 87 88 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); 89 90 LoadParam(root, "cloudcolor", this, SnowEffect, setCloudColor); 90 91 LoadParam(root, "skycolor", this, SnowEffect, setSkyColor); 91 92 LoadParam(root, "fadetime", this, SnowEffect, setFadeTime); 92 93 93 94 95 96 97 94 LOAD_PARAM_START_CYCLE(root, element); 95 { 96 LoadParam_CYCLE(element, "option", this, SnowEffect, setSnowOption); 97 } 98 LOAD_PARAM_END_CYCLE(element); 98 99 } 99 100 100 101 void SnowEffect::init() 101 102 { 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 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; 124 125 125 126 this->fadeTime = 10; … … 130 131 void SnowEffect::activate() 131 132 { 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 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); 155 156 156 157 if (this->snowWindForce != 0) … … 170 171 void SnowEffect::deactivate() 171 172 { 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); 179 177 180 178 // Restore the old cloud- and sky color … … 185 183 void SnowEffect::draw() const 186 184 { 187 188 185 if (!this->snowActivate) 186 return; 189 187 } 190 188 191 189 void SnowEffect::tick(float dt) 192 190 { 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 137 137 static SpriteParticles* snowParticles; 138 138 OrxSound::SoundSource soundSource; 139 OrxSound::SoundBuffer *windBuffer;139 OrxSound::SoundBuffer windBuffer; 140 140 141 141 Vector oldSkyColor;
Note: See TracChangeset
for help on using the changeset viewer.