1
\$\begingroup\$

I have an isometric camera for an RTS that looks like this:

Screenshot of game

Basically, I don't know how to set the listener's position in OpenAL because I represent the camera's position with only two coordinates.

I build my projection matrix as a standard orthographic projection:

projectionMatrix = new Matrix4f()
            .setOrtho(-25, 25, -25 / aspect, 25 / aspect, -300, 300);

and my view matrix like so:

viewMatrix.identity()
            .rotate(-rotation.x / 180.0f * Util.PI, 1, 0, 0)
            .rotate(-225.0f / 180.0f * Util.PI, 0, 1, 0)
            .rotate(-rotation.z / 180.0f * Util.PI, 0, 0, 1)
            .scale(zoom)
            .translate(-position.x, 0, -position.y);

Where rotation is a 3D vector of the Euler angles, and position is a 2D vector controlled by the keyboard or dragging the mouse. (rotation.y is ignored)

How would I translate this 2D position into the 3 coordinates required for OpenAL? I tried to give a y-offset like: alListener3f(AL_POSITION, position.x, 20, position.z);, but it gave really weird attenuation results.

(PS: I'm using Java, LWJGL, and JOML for math)

\$\endgroup\$
2
  • \$\begingroup\$ Why are you even using a 3d sound system for a 2d game? It will make everything very quiet, since you're essentially listening to them from a bird's perspective. \$\endgroup\$
    – Bálint
    Jun 9 '18 at 23:37
  • \$\begingroup\$ @Bálint "Quiet" is relative, and I can just change the attenuation settings to make it louder. You can also zoom in/out in the game, and the sounds get quieter and louder when doing so. \$\endgroup\$ Jun 9 '18 at 23:51

You must log in to answer this question.

Browse other questions tagged .