Changeset 4196 in orxonox.OLD for orxonox/branches/openAL
- Timestamp:
- May 16, 2005, 3:16:33 PM (20 years ago)
- Location:
- orxonox/branches/openAL/src
- Files:
-
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/openAL/src/Makefile.am
r4195 r4196 131 131 defs/stdincl.h \ 132 132 defs/glincl.h \ 133 defs/alincl.h \ 133 134 defs/comincl.h \ 134 135 defs/confincl.h \ -
orxonox/branches/openAL/src/Makefile.in
r4195 r4196 375 375 defs/stdincl.h \ 376 376 defs/glincl.h \ 377 defs/alincl.h \ 377 378 defs/comincl.h \ 378 379 defs/confincl.h \ -
orxonox/branches/openAL/src/defs/alincl.h
r4187 r4196 1 1 /*! 2 \file glincl.h3 \brief This file includes gl Headers.2 \file alincl.h 3 \brief This file includes al Headers. 4 4 5 no Class is defined here, but the open glHeaders5 no Class is defined here, but the openAL Headers 6 6 */ 7 7 8 #ifndef _GLINCL_H 9 #define _GLINCL_H 10 11 #include <SDL.h> 8 #ifndef _ALINCL_H 9 #define _ALINCL_H 12 10 13 11 #ifndef __APPLE__ 14 #include <GL/gl.h> 15 #include <GL/glu.h> 12 #include <AL/al.h> 13 #include <AL/alu.h> 14 #include <AL/alut.h> 16 15 #else 17 #include <OpenGL/gl.h> 18 #include <OpenGL/glu.h> 16 #include <OpenAL/al.h> 17 #include <OpenAL/alu.h> 18 #include <OpenAL/alut.h> 19 19 #endif 20 20 21 #endif /* _ GLINCL_H */21 #endif /* _ALINCL_H */ -
orxonox/branches/openAL/src/lib/coord/p_node.h
r4194 r4196 66 66 void setRelDir (const Quaternion& relDir); 67 67 inline const Quaternion& getAbsDir () const { return this->absDirection; } 68 inline Vector getAbsDirV(void) const { return this->absDirection.apply(Vector(0,1,0)); } 68 69 void setAbsDir (const Quaternion& absDir); 69 70 void shiftDir (const Quaternion& shift); -
orxonox/branches/openAL/src/lib/math/vector.cc
r4194 r4196 329 329 */ 330 330 331 Vector Quaternion::apply ( Vector& v) const331 Vector Quaternion::apply (const Vector& v) const 332 332 { 333 333 Quaternion q; -
orxonox/branches/openAL/src/lib/math/vector.h
r4194 r4196 96 96 return r;} 97 97 Quaternion inverse () const; 98 Vector apply ( Vector& f) const;98 Vector apply (const Vector& f) const; 99 99 float norm () const; 100 100 void matrix (float m[4][4]) const; -
orxonox/branches/openAL/src/lib/sound/sound_engine.cc
r4195 r4196 17 17 18 18 #include "sound_engine.h" 19 #include "p_node.h" 20 #include "list.h" 19 21 20 22 using namespace std; 21 23 24 25 /** 26 \brief Creates a Soundbuffer out of an inputfile 27 \param fileName The name of the File 28 */ 29 SoundBuffer::SoundBuffer(const char* fileName) 30 { 31 SoundEngine::getInstance()->addBuffer(this); 32 33 ALenum format; 34 ALvoid* data; 35 ALsizei freq; 36 37 alGenBuffers(1, &this->bufferID); 38 alutLoadWAVFile((ALbyte*)fileName, &format, &data, &this->size, &freq, &this->loop); 39 alBufferData(this->bufferID, format, data, this->size, freq); 40 alutUnloadWAV(format, data, this->size, freq); 41 } 42 43 SoundBuffer::~SoundBuffer(void) 44 { 45 SoundEngine::getInstance()->removeBuffer(this); 46 } 47 48 49 50 /** 51 \brief creates a SoundSource at position sourceNode with the SoundBuffer buffer 52 */ 53 SoundSource::SoundSource(SoundBuffer* buffer, PNode* sourceNode) 54 { 55 SoundEngine::getInstance()->addSource(this); 56 57 this->buffer = buffer; 58 this->sourceNode = sourceNode; 59 } 60 61 SoundSource::~SoundSource(void) 62 { 63 SoundEngine::getInstance()->removeSource(this); 64 } 22 65 23 66 /** … … 26 69 SoundEngine::SoundEngine () 27 70 { 28 this->setClassName ("SoundEngine"); 71 this->setClassName ("SoundEngine"); 72 73 this->initAudio(); 29 74 75 this->listener = NULL; 76 this->bufferList = new tList<SoundBuffer>; 77 this->sourceList = new tList<SoundSource>; 30 78 } 31 79 … … 54 102 55 103 } 104 105 /** 106 \brief sets The listener (normaly the Camera) 107 */ 108 void SoundEngine::setListener(PNode* listener) 109 { 110 this->listener = listener; 111 } 112 113 114 void SoundEngine::addBuffer(SoundBuffer* buffer) 115 { 116 this->bufferList->add(buffer); 117 } 118 119 void SoundEngine::removeBuffer(SoundBuffer* buffer) 120 { 121 this->bufferList->remove(buffer); 122 } 123 124 void SoundEngine::addSource(SoundSource* source) 125 { 126 this->sourceList->add(source); 127 } 128 void SoundEngine::removeSource(SoundSource* source) 129 { 130 this->sourceList->remove(source); 131 } 132 133 134 /** 135 \brief updates all The positions, Directions and Velocities of all Sounds 136 */ 137 void SoundEngine::update(void) 138 { 139 140 // updating the Listeners Position 141 if (this->listener) 142 { 143 alListener3f(AL_POSITION, 144 this->listener->getAbsCoor().x, 145 this->listener->getAbsCoor().y, 146 this->listener->getAbsCoor().z); 147 alListener3f(AL_VELOCITY, 148 this->listener->getVelocity().x, 149 this->listener->getVelocity().y, 150 this->listener->getVelocity().z); 151 Vector absDirV = this->listener->getAbsDirV(); 152 alListener3f(AL_ORIENTATION, 153 absDirV.x, 154 absDirV.y, 155 absDirV.z); 156 } 157 // updating all the Sources positions 158 tIterator<SoundSource>* iterator = this->sourceList->getIterator(); 159 SoundSource* enumSource = iterator->nextElement(); 160 while (enumSource) 161 { 162 alSource3f(enumSource->getID(), AL_POSITION, 163 enumSource->getNode()->getAbsCoor().x, 164 enumSource->getNode()->getAbsCoor().y, 165 enumSource->getNode()->getAbsCoor().z); 166 alSource3f(enumSource->getID(), AL_VELOCITY, 167 enumSource->getNode()->getVelocity().x, 168 enumSource->getNode()->getVelocity().y, 169 enumSource->getNode()->getVelocity().z); 170 171 enumSource = iterator->nextElement(); 172 } 173 delete iterator; 174 } 175 176 /** 177 \brief initializes Audio in general 178 */ 179 bool SoundEngine::initAudio(void) 180 { 181 alutInit(NULL, 0); 182 alGetError(); 183 } 184 -
orxonox/branches/openAL/src/lib/sound/sound_engine.h
r4195 r4196 9 9 10 10 #include "base_object.h" 11 #include "alincl.h" 11 12 12 13 // FORWARD DEFINITION 14 class PNode; 15 template<class T> class tList; 13 16 14 //! A Class that handles audio via the openAudioLibrary 17 18 //! A class that represents a datastructure to play Sounds. 19 class SoundBuffer 20 { 21 public: 22 SoundBuffer(const char* fileName); 23 ~SoundBuffer(void); 24 25 private: 26 ALuint bufferID; //!< The address of the Buffer. 27 28 ALsizei size; //!< The size of the Buffer. 29 ALboolean loop; //!< loop information. 30 }; 31 32 //! A class that represents a SoundSource 33 class SoundSource 34 { 35 public: 36 SoundSource(SoundBuffer* buffer, PNode* sourceNode = NULL); 37 ~SoundSource(void); 38 39 /** \retruns The ID of the Source */ 40 inline ALuint getID(void) { return this->sourceID; } 41 /** \returns the SourceNode of this Source */ 42 inline PNode* getNode(void) { return this->sourceNode;} 43 44 private: 45 ALuint sourceID; //!< The ID of the Source 46 SoundBuffer* buffer; //!< The buffer to play in this source. 47 PNode* sourceNode; //!< The SourceNode represente the position/velocity... of this source. 48 }; 49 50 51 52 //! A class that handles audio via the openAudioLibrary 15 53 class SoundEngine : public BaseObject { 16 54 … … 19 57 virtual ~SoundEngine(void); 20 58 59 void setListener(PNode* listener); 60 61 void addBuffer(SoundBuffer* buffer); 62 void removeBuffer(SoundBuffer* buffer); 63 void addSource(SoundSource* source); 64 void removeSource(SoundSource* source); 65 66 67 void update(void); 68 21 69 private: 22 70 SoundEngine(void); 23 71 static SoundEngine* singletonRef; 72 73 bool initAudio(void); 74 75 PNode* listener; //!< The listener of the Scene 76 tList<SoundBuffer>* bufferList; //!< A list of buffers 77 tList<SoundSource>* sourceList; //!< A list for all the sources in the scene. 78 24 79 }; 25 80 -
orxonox/branches/openAL/src/orxonox.cc
r4194 r4196 35 35 #include "game_loader.h" 36 36 #include "graphics_engine.h" 37 #include "sound_engine.h" 37 38 #include "resource_manager.h" 38 39 #include "text_engine.h" … … 151 152 printf("> Initializing sound\n"); 152 153 // SDL_Init(SDL_INIT_AUDIO); 153 printf("Not yet implemented\n");154 SoundEngine::getInstance(); 154 155 return 0; 155 156 }
Note: See TracChangeset
for help on using the changeset viewer.