calculate camera up vector after glulookat()?
- by carrots
I'm just starting out teaching myself openGL and now adding openAL to the mix.
I have some planets scattered around in 3D space and when I touch the screen, I'm assigning a sound to a random planet and then slowly and smoothly flying the "camera" over to look at it and listen to it. The animation/tweening part is working perfectly, but the openAL piece isn't quiet right. I move the camera around by doing a tiny translate() and gluLookAt() for every frame to keep things smooth (tweening the camera position and lookAt coords). The trouble seems to be with the stereo image I'm getting out of the headphones.. it seems like the left/right/up/down is mixed up sometimes after the camera rolls or spins. I am pretty sure the trouble is here:
ALfloat listenerPos[]={camera->currentX,camera->currentY,camera->currentZ};
ALfloat listenerOri[]={camera->currentLookX,
camera->currentLookY,
camera->currentLookZ,
0.0,//Camera Up X <--- here
0.1,//Camera Up Y <--- here
0.0}//Camera Up Z <--- and here
alListenerfv(AL_POSITION,listenerPos);
alListenerfv(AL_ORIENTATION,listenerOri);
I'm thinking I need to recompute the UP vector for the camera after each gluLookAt() to straighten out the audio positioning problem.. but after hours of googling and experimenting I'm stuck in math that suddenly got way over my head.
1) Am I right that I need to recalculate the up vector after each gluLookAt() i do?
2) If so, can someone please walk me though figuring out how to do that?