1 //////////////////////////////////////////////////////////////////////////////// 2 // Scorched3D (c) 2000-2011 3 // 4 // This file is part of Scorched3D. 5 // 6 // Scorched3D 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 of the License, or 9 // (at your option) any later version. 10 // 11 // Scorched3D is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License along 17 // with this program; if not, write to the Free Software Foundation, Inc., 18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 //////////////////////////////////////////////////////////////////////////////// 20 21 #if !defined(__INCLUDE_LandscapeSoundh_INCLUDE__) 22 #define __INCLUDE_LandscapeSoundh_INCLUDE__ 23 24 #include <XML/XMLFile.h> 25 #include <string> 26 #include <vector> 27 28 class LandscapeSoundTiming 29 { 30 public: 31 virtual bool readXML(XMLNode *node) = 0; 32 virtual float getNextEventTime() = 0; 33 }; 34 35 class LandscapeSoundTimingLooped : public LandscapeSoundTiming 36 { 37 public: 38 virtual bool readXML(XMLNode *node); 39 virtual float getNextEventTime(); 40 }; 41 42 class LandscapeSoundTimingRepeat : public LandscapeSoundTiming 43 { 44 public: 45 virtual bool readXML(XMLNode *node); 46 virtual float getNextEventTime(); 47 48 protected: 49 float min, max; 50 }; 51 52 class LandscapeSoundItem 53 { 54 public: LandscapeSoundItem()55 LandscapeSoundItem() 56 { 57 } ~LandscapeSoundItem()58 virtual ~LandscapeSoundItem() 59 { 60 } 61 }; 62 63 class VirtualSoundSource; 64 class LandscapeSoundPosition 65 { 66 public: 67 virtual bool readXML(XMLNode *node) = 0; 68 virtual bool setPosition(VirtualSoundSource *source, LandscapeSoundItem *data) = 0; 69 getInitCount()70 virtual int getInitCount() { return 1; } getInitData(int count)71 virtual LandscapeSoundItem *getInitData(int count) { return 0; } 72 }; 73 74 class LandscapeSoundPositionAmbient : public LandscapeSoundPosition 75 { 76 public: 77 virtual bool readXML(XMLNode *node); 78 virtual bool setPosition(VirtualSoundSource *source, LandscapeSoundItem *data); 79 }; 80 81 class LandscapeSoundPositionAbsoulte : public LandscapeSoundPosition 82 { 83 public: 84 virtual bool readXML(XMLNode *node); 85 virtual bool setPosition(VirtualSoundSource *source, LandscapeSoundItem *data); 86 87 protected: 88 Vector position; 89 }; 90 91 class LandscapeSoundPositionWater : public LandscapeSoundPosition 92 { 93 public: 94 virtual bool readXML(XMLNode *node); 95 virtual bool setPosition(VirtualSoundSource *source, LandscapeSoundItem *data); 96 97 protected: 98 float falloff; 99 }; 100 101 class LandscapeSoundPositionGroup : public LandscapeSoundPosition 102 { 103 public: 104 virtual bool readXML(XMLNode *node); 105 virtual bool setPosition(VirtualSoundSource *source, LandscapeSoundItem *data); 106 107 protected: 108 std::string name; 109 float falloff; 110 }; 111 112 class ObjectGroupEntryReference; 113 class LandscapeSoundPositionSetItem : public LandscapeSoundItem 114 { 115 public: 116 LandscapeSoundPositionSetItem(ObjectGroupEntryReference *reference); 117 virtual ~LandscapeSoundPositionSetItem(); 118 getReference()119 ObjectGroupEntryReference *getReference() { return reference_; } 120 121 private: 122 ObjectGroupEntryReference *reference_; 123 }; 124 125 class LandscapeSoundPositionSet : public LandscapeSoundPosition 126 { 127 public: 128 virtual bool readXML(XMLNode *node); 129 virtual bool setPosition(VirtualSoundSource *source, LandscapeSoundItem *data); 130 131 virtual int getInitCount(); 132 virtual LandscapeSoundItem *getInitData(int count); 133 134 protected: 135 std::string name; 136 int maxsounds; 137 }; 138 139 class LandscapeSoundSound 140 { 141 public: 142 virtual bool readXML(XMLNode *node) = 0; 143 virtual bool play(VirtualSoundSource *source, float ambientGain) = 0; 144 virtual float getGain() = 0; 145 }; 146 147 class LandscapeSoundSoundFile : public LandscapeSoundSound 148 { 149 public: 150 virtual bool readXML(XMLNode *node); 151 virtual bool play(VirtualSoundSource *source, float ambientGain); getGain()152 virtual float getGain() { return gain; } 153 154 protected: 155 std::vector<std::string> files; 156 float gain; 157 float referencedistance; 158 float rolloff; 159 }; 160 161 class LandscapeSoundType 162 { 163 public: 164 LandscapeSoundType(); 165 virtual ~LandscapeSoundType(); 166 167 virtual bool readXML(XMLNode *node); 168 169 LandscapeSoundPosition *position; 170 LandscapeSoundTiming *timing; 171 LandscapeSoundSound *sound; 172 }; 173 174 #endif // __INCLUDE_LandscapeSoundh_INCLUDE__ 175