Instead of using
getPosition() you would call
getAbsolutePosition().
I think the problem is much more obvious than I had originally thought. The parameters passed to
setListenerPosition() are the absolute position, look direction, velocity and up vector. You are passing the relative position, relative rotation and relative position. That will not get you what you want.
I think you want to write
Code: Select all
// get the up vector
core::vector3df upwards(0.f, 1.f, 0.f);
camera->getAbsoluteTransformation().rotateVect(upwards);
// and forward vector
core::vector3df forwards(0.f, 0.f, 1.f);
camera->getAbsoluteTransformation().rotateVect(forwards);
// do doppler
const f32 elapsed = (timeMs - PreviousTime) / 1000.f;
PreviousTime = timeMs;
// do position/velocity
const core::vector3df position = getAbsolutePosition();
const core::vector3df velocity = (position - PreviousPosition) / elapsed;
PreviousPosition = position;
// feed position, velocity and orientation information to sound engine
SoundEngine->setListenerPosition(position, forwards, velocity, upwards);