[openal] distance model questions
chris.kcat at gmail.com
Sun May 24 10:00:51 EDT 2015
On 05/24/2015 06:06 AM, Victorious wrote:
> I have a river on the left edge of a 10x10 grid. What I want to have
> is a single sound source for the river that plays towards the left
> when you're near the left edge (i.e a line segment of 10 units)
In that case, you can simply place the source at the closest point on
the line to the listener. The easiest way to handle a sound that covers
a convex area is to do a point-to-line (or plane or volume) test to find
the closest point in the source area to the listener, and set the set
the source position to that point.
For axis-aligned areas, you should be able to merely take the listener
position and clamp the individual X, Y, and Z values to the source's
world extents. i.e.
sourceX = clamp(listenerX, x - x_range, x + x_range);
sourceY = clamp(listenerY, y - y_range, y + y_range);
sourceZ = clamp(listenerZ, z - z_range, z + z_range);
where x, y, z is the center location of the sound, x_range, y_range,
z_range is the radius for each axis (which must be >= 0), and sourceX,
sourceY, sourceZ is the resulting position to set on the source.
More information about the openal