[10321] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific |
---|
| 12 | main-programmer: Patrick Boenzli |
---|
| 13 | */ |
---|
| 14 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | #include "sound_entity.h" |
---|
| 18 | |
---|
[10368] | 19 | #include "util/loading/load_param.h" |
---|
[10321] | 20 | #include "util/loading/factory.h" |
---|
| 21 | #include "material.h" |
---|
| 22 | |
---|
| 23 | #include "sound/resource_sound_buffer.h" |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | |
---|
[10404] | 29 | |
---|
[10321] | 30 | ObjectListDefinition(SoundEntity); |
---|
| 31 | CREATE_FACTORY(SoundEntity); |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * standard constructor |
---|
| 35 | */ |
---|
| 36 | SoundEntity::SoundEntity (const TiXmlElement* root) |
---|
| 37 | { |
---|
| 38 | this->registerObject(this, SoundEntity::_objectList); |
---|
| 39 | |
---|
| 40 | this->toList(OM_COMMON); |
---|
| 41 | |
---|
| 42 | this->soundSource.setSourceNode(this); |
---|
| 43 | |
---|
[10403] | 44 | this->bInit = false; |
---|
| 45 | |
---|
[10351] | 46 | if( root != NULL) |
---|
| 47 | this->loadParams(root); |
---|
| 48 | |
---|
[10321] | 49 | } |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | /** |
---|
| 53 | * standard deconstructor |
---|
| 54 | */ |
---|
| 55 | SoundEntity::~SoundEntity () |
---|
| 56 | { |
---|
| 57 | } |
---|
| 58 | |
---|
[10351] | 59 | /** |
---|
| 60 | * loading stuff |
---|
| 61 | * @param root xml element |
---|
| 62 | */ |
---|
| 63 | void SoundEntity::loadParams(const TiXmlElement* root) |
---|
| 64 | { |
---|
| 65 | LoadParam(root, "soundfile", this, SoundEntity, setSoundFile) |
---|
| 66 | .describe("Sets the file of the sound source"); |
---|
| 67 | |
---|
| 68 | LoadParam(root, "frequency", this, SoundEntity, setSoundFile) |
---|
| 69 | .describe("Sets the file of the sound source"); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | /** |
---|
| 74 | * sets the sound file |
---|
| 75 | * @param fileName name of the sound source |
---|
| 76 | */ |
---|
[10368] | 77 | void SoundEntity::setSoundFile(const std::string& fileName) |
---|
[10351] | 78 | { |
---|
| 79 | this->soundBuffer = OrxSound::ResourceSoundBuffer(fileName); |
---|
[10403] | 80 | this->bInit = true; |
---|
[10351] | 81 | } |
---|
| 82 | |
---|
| 83 | |
---|
[10321] | 84 | void SoundEntity::activate() |
---|
| 85 | { |
---|
[10403] | 86 | this->soundSource.play(); |
---|
[10321] | 87 | } |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | void SoundEntity::deactivate() |
---|
| 91 | { |
---|
| 92 | |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | /** |
---|
| 97 | * signal tick, time dependent things will be handled here |
---|
| 98 | * @param time since last tick |
---|
| 99 | */ |
---|
| 100 | void SoundEntity::tick (float dt) |
---|
| 101 | { |
---|
| 102 | |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | |
---|