mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-15 06:52:34 +02:00
Fix grabbing orientation from camera to listener
Codes has been a bit refactored. Btw it looks like resampling of sfx won't be needed.
This commit is contained in:
parent
a8bdc83b0e
commit
cb69ad596e
@ -275,25 +275,21 @@ void SoundManager::pause(bool p) {
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::updateListenerTransform(const ViewCamera& currentCam) {
|
||||
// @todo ShFil119 it should be improved
|
||||
_engine->sound.setListenerPosition(currentCam.position);
|
||||
_engine->sound.setListenerOrientation(glm::vec3(
|
||||
currentCam.rotation.x, currentCam.rotation.y, currentCam.rotation.z));
|
||||
//world->sound.setListenerVelocity(glm::vec3());
|
||||
}
|
||||
void SoundManager::updateListenerTransform(const ViewCamera& cam) {
|
||||
// Orientation
|
||||
auto up = cam.rotation * glm::vec3(0.f, 0.f, 1.f);
|
||||
auto at = cam.rotation * glm::vec3(1.f, 0.f, 0.f);
|
||||
float orientation[6] = {at.x, at.y, at.z, up.x, up.y, up.z};
|
||||
alListenerfv(AL_ORIENTATION, orientation);
|
||||
|
||||
void SoundManager::setListenerPosition(const glm::vec3& position) {
|
||||
alListener3f(AL_POSITION, position.x, position.y, position.z);
|
||||
}
|
||||
// Position
|
||||
float position[3] = {cam.position.x, cam.position.y, cam.position.z};
|
||||
alListenerfv(AL_POSITION, position);
|
||||
|
||||
void SoundManager::setListenerVelocity(const glm::vec3& vel) {
|
||||
alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z);
|
||||
}
|
||||
|
||||
void SoundManager::setListenerOrientation(const glm::vec3& at) {
|
||||
float v[6] = {0, at.y, 0, 0, 0, at.z};
|
||||
alListenerfv(AL_ORIENTATION, v);
|
||||
// @todo ShFil119 it should be implemented
|
||||
// Velocity
|
||||
// float velocity[3] = ...
|
||||
// alListenerfv(AL_VELOCITY, velocity);
|
||||
}
|
||||
|
||||
void SoundManager::setSoundPosition(const std::string& name,
|
||||
|
@ -77,17 +77,7 @@ public:
|
||||
void stopMusic(const std::string& name);
|
||||
|
||||
/// Updating listener tranform, called by main loop of game.
|
||||
void updateListenerTransform(const ViewCamera& currentCam);
|
||||
|
||||
/// Setting position of listener for openAL.
|
||||
void setListenerPosition(const glm::vec3& position);
|
||||
|
||||
/// Setting velocity of velocity for openAL.
|
||||
void setListenerVelocity(const glm::vec3& vel);
|
||||
|
||||
/// Setting orientation of listener for openAL.
|
||||
/// Worth noted v = { at.x, at.y, at.z, up.x, up.y, up.z}
|
||||
void setListenerOrientation(const glm::vec3& at);
|
||||
void updateListenerTransform(const ViewCamera& cam);
|
||||
|
||||
/// Setting position of sound source in buffer.
|
||||
void setSoundPosition(const std::string& name, const glm::vec3& position);
|
||||
|
Loading…
Reference in New Issue
Block a user