Using absolute transform

This commit is contained in:
stiffly
2016-01-08 15:29:20 +01:00
parent da6e50dc7e
commit 3cce9f8075
4 changed files with 111 additions and 35 deletions
+10 -18
View File
@@ -10,6 +10,7 @@
#include "Core/World.h"
#include "Core/EventBroker.h"
#include "Rendering/RenderQueueFactory.h" // Absolute transform
#include "Sound/Sound.h"
#include "Sound/EPlaySound.h"
@@ -27,35 +28,27 @@ public:
~SoundSystem();
void Update(); // Update emitters
private:
// Private setters and getters for working with glm
// Help functions for working with OpenaAL
void setListenerPos(glm::vec3 pos) { alListener3f(AL_POSITION, pos.x, pos.y, pos.z); };
glm::vec3 listnerPos() { glm::vec3 pos; alGetListener3f(AL_POSITION, &pos.x, &pos.y, &pos.z); return pos; };
void setListenerVel(glm::vec3 vel) { alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); };
glm::vec3 listenerVel() { glm::vec3 vel; alGetListener3f(AL_VELOCITY, &vel.x, &vel.y, &vel.z); return vel; };
void setListenerOri(glm::vec3 ori)
{
glm::vec3 forward = glm::vec3(0.0, 0.0, -1.0);
forward = glm::rotateX(forward, ori.x);
forward = glm::rotateY(forward, ori.y);
forward = glm::rotateZ(forward, ori.z);
glm::normalize(forward);
glm::vec3 up = glm::vec3(0.0, 1.0, 0.0);
up = glm::rotateX(up, ori.x);
up = glm::rotateY(up, ori.y);
up = glm::rotateZ(up, ori.z);
glm::normalize(up);
ALfloat lori[6] = { forward.x, forward.y, forward.z , up.x, up.y, up.z };
alListenerfv(AL_ORIENTATION, lori);
};
void setListenerOri(glm::vec3 ori);
glm::vec3 listenerOri() { glm::vec3 ori; alGetListener3f(AL_ORIENTATION, &ori.x, &ori.y, &ori.z); return ori; };
void setSourcePos(ALuint source, glm::vec3 pos) { ALfloat spos[3] = { pos.x, pos.y, pos.z }; alSourcefv(source, AL_POSITION, spos); };
void setSourceVel(ALuint source, glm::vec3 vel) { ALfloat svel[3] = { vel.x, vel.y, vel.z }; alSourcefv(source, AL_VELOCITY, svel); };
void setSourceOri(ALuint source, glm::vec3 ori) { ALfloat sori[3] = { ori.x, ori.y, ori.z }; alSourcefv(source, AL_ORIENTATION, sori); };
bool isPlaying(ALuint source);
// Logic
World* m_World;
EventBroker* m_EventBroker;
void initOpenAL();
void updateEmitters();
void updateListener();
void deleteInactiveEmitters();
void addNewEmitters();
ALuint createSource();
void playSound(Source source);
void stopSound(Source source);
@@ -71,7 +64,6 @@ private:
// Events
EventRelay<SoundSystem, Events::PlaySound> m_EPlaySound;
bool OnPlaySound(const Events::PlaySound &e);
};
#endif