[openal] distance model questions
Victorious
dtvictorious at gmail.com
Mon May 18 08:29:40 EDT 2015
Hm, I think I figured it out. I was using the z component of the float3 vector when I should have used y, as this is rhs system.
How difficult would it be to expand this to include the following parameters on an object? X_range, y_range, and z_range? I.e the sound doesn't change when the listener is within these range coordinates of the object?
Thanks a lot for the help.
-----Original Message-----
From: openal [mailto:openal-bounces at openal.org] On Behalf Of Chris Robinson
Sent: Monday, May 18, 2015 7:22 AM
To: openal mailing list
Subject: Re: [openal] distance model questions
On 05/17/2015 10:29 AM, Victorious wrote:
> I've tried it, but it doesn't seem to work properly and creates weird
> panning effects. Here's what my source setPosition function looks
> like.
>
> ...
The first thing I notice is that you're calculating the distance and
lerp using the listener position instead of the source position. Another
thing is that you'll want to use the upper polar position when the sound
is above the listener, and the lower polar position when it's below.
This is luckily all fairly easy when the listener up orientation is
{0,1,0}. So, like this:
if(isPlaying())
{
float listenerX, listenerY, listenerZ;
alGetListener3f(AL_POSITION, &listenerX, &listenerY, &listenerZ);
math::float3 listenerPos(listenerX, listenerY, listenerZ);
math::float3 sourcePos(x, y, z);
float dist = polarPos.Distance(sourcePos);
if(dist < 1)
{
math::float3 polarPos;
if(sourcePos.z >= listenerPos.z)
polarPos = listenerPos + math::float3(0, 1, 0);
else
polarPos = listenerPos - math::float3(0, 1, 0);
math::float3 lerped = polarPos.Lerp(sourcePos, dist);
x = lerped.x;
y = lerped.y;
z = lerped.z;
}
}
alSource3f(source, AL_POSITION, x, y, z);
_______________________________________________
openal mailing list
openal at openal.org
http://openal.org/mailman/listinfo/openal
More information about the openal
mailing list