cListener.cpp

00001 // Copyright (c) 2008-2010 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones
00002 // This file is part of the "cAudio Engine"
00003 // For conditions of distribution and use, see copyright notice in cAudio.h
00004 
00005 #include "../Headers/cListener.h"
00006 #include <AL/al.h>
00007 #include "../Headers/cEFXFunctions.h"
00008 
00009 namespace cAudio
00010 {
00011         void cListener::setPosition(const cVector3 pos)
00012         {
00013                 cAudioMutexBasicLock lock(Mutex);
00014                 Position = pos;
00015                 alListener3f(AL_POSITION, Position.x, Position.y, Position.z);
00016         }
00017         void cListener::setDirection(const cVector3 dir)
00018         {
00019                 cAudioMutexBasicLock lock(Mutex);
00020                 Direction = dir;
00021                 float orient[6] = {Direction[0], Direction[1], Direction[2], UpVector[0], UpVector[1], UpVector[2]};
00022                 alListenerfv(AL_ORIENTATION, orient);
00023         }
00024         void cListener::setUpVector(const cVector3 up)
00025         {
00026                 cAudioMutexBasicLock lock(Mutex);
00027                 UpVector = up;
00028                 float orient[6] = {Direction[0], Direction[1], Direction[2], UpVector[0], UpVector[1], UpVector[2]};
00029                 alListenerfv(AL_ORIENTATION, orient);
00030         }
00031         void cListener::setVelocity(const cVector3 vel)
00032         {
00033                 cAudioMutexBasicLock lock(Mutex);
00034                 Velocity = vel;
00035                 alListener3f(AL_VELOCITY, Velocity.x, Velocity.y, Velocity.z);
00036         }
00037         void cListener::setMasterVolume(const float volume)
00038         {
00039                 cAudioMutexBasicLock lock(Mutex);
00040                 MasterGain = volume;
00041                 alListenerf(AL_GAIN, MasterGain);
00042         }
00043         void cListener::move(const cVector3 pos)
00044         {
00045                 cAudioMutexBasicLock lock(Mutex);
00046                 Velocity = pos - Position;
00047                 Position = pos;
00048                 
00049                 alListener3f(AL_POSITION, Position.x, Position.y, Position.z);
00050                 alListener3f(AL_VELOCITY, Velocity.x, Velocity.y, Velocity.z);
00051         }
00052 #ifdef CAUDIO_EFX_ENABLED
00053                 void cListener::setMetersPerUnit(const float& meters)
00054                 {
00055                         cAudioMutexBasicLock lock(Mutex);
00056                         alListenerf(AL_METERS_PER_UNIT, meters);
00057                 }
00058 
00059                 float cListener::getMetersPerUnit(void) const
00060                 {
00061                         float value = 1.0f;
00062                         alGetListenerf(AL_METERS_PER_UNIT, &value);
00063                         return value;
00064                 }
00065 #endif
00066 };
 All Classes Namespaces Functions Variables Enumerations

Generated on Sat Feb 20 22:55:08 2010 for cAudio by  doxygen 1.6.2