1
\$\begingroup\$

Currently my game engine allows the player/camera to pitch and yaw, so there's no roll.

The pitch angle starts at 0°, which means the camera is facing straight ahead. From here it can go up to +85° (looking almost straight up) or down to -85° (looking almost straight down).

The yaw angle starts at 0°, which means the camera is facing east. The rotation is clockwise so 90° is south, 180° is west and 270° north. What would be 360° is 0° again obviously.

How do I get from this to the direction vector (lookdir) IrrKlang's SetListenerPosition requires to get directional audio working?

PS: x and z are my horizontal axis, y is the vertical one.

\$\endgroup\$
1
\$\begingroup\$

x = cos(yaw)

y = sin(pitch)

z = sin(yaw)

(Depending on the orientation of you coordinate system you could have to put a "-" somewhere)

Roll is irrelevant for the lookDir Vector, as it just changes the Up-Vector. Remember that there are theoretically infinite "correct" lookDir Vectors, the one above has the length 1.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.