View Single Post
Join Date: Feb 2008
Posts: 4
Reputation: paulscode is an unknown quantity at this point 
Solved Threads: 0
paulscode paulscode is offline Offline
Newbie Poster

Re: 3D Sound, calculating pan

 
0
  #3
Aug 9th, 2008
Originally Posted by MattEvans View Post
assuming that look at and 'up' are at roughly at right angles; take the cross product of the look-at and up direction. this will give you a vector that points from the characters left to right ( or right to left ). if the look at and up aren't at right angles... this still should work, but you must normalize the result.

now, calculate the normalized vector between the listeners position and the source position.

finally take the dot product of the normalized vector between listener and source and the normalized vector that points left to right.

the dot product between two vectors gives the scalar projection of one vector onto another, when both vectors are normalized, this projection is a number between -1 and 1. If the value comes out backwards ( negative when it should be positive ) reverse the order of operands to the cross product, or of course, just multiply by -1. Test with something visual first, to see the magnitude of difference between different positions, then scale/offset the result according.

S = source position
L = listeners positon
A = look at direction
B = up direction

dot( normalize( cross( A, B ) ), normalize( S - L ) )
Thanks for the speedy response! I will try this out.

Thanks again!
Reply With Quote