mirror of
https://github.com/SFML/SFML.git
synced 2024-12-01 15:51:04 +08:00
FS#109 - Fix sf::Listener's target being actually a relative direction
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1176 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
374af05d5f
commit
ac773e8161
@ -4,8 +4,8 @@ EXPORTS
|
|||||||
sfListener_GetGlobalVolume
|
sfListener_GetGlobalVolume
|
||||||
sfListener_SetPosition
|
sfListener_SetPosition
|
||||||
sfListener_GetPosition
|
sfListener_GetPosition
|
||||||
sfListener_SetTarget
|
sfListener_SetDirection
|
||||||
sfListener_GetTarget
|
sfListener_GetDirection
|
||||||
sfMusic_CreateFromFile
|
sfMusic_CreateFromFile
|
||||||
sfMusic_CreateFromMemory
|
sfMusic_CreateFromMemory
|
||||||
sfMusic_Destroy
|
sfMusic_Destroy
|
||||||
|
@ -4,8 +4,8 @@ EXPORTS
|
|||||||
sfListener_GetGlobalVolume
|
sfListener_GetGlobalVolume
|
||||||
sfListener_SetPosition
|
sfListener_SetPosition
|
||||||
sfListener_GetPosition
|
sfListener_GetPosition
|
||||||
sfListener_SetTarget
|
sfListener_SetDirection
|
||||||
sfListener_GetTarget
|
sfListener_GetDirection
|
||||||
sfMusic_CreateFromFile
|
sfMusic_CreateFromFile
|
||||||
sfMusic_CreateFromMemory
|
sfMusic_CreateFromMemory
|
||||||
sfMusic_Destroy
|
sfMusic_Destroy
|
||||||
|
@ -68,26 +68,24 @@ CSFML_API void sfListener_SetPosition(float x, float y, float z);
|
|||||||
CSFML_API void sfListener_GetPosition(float* x, float* y, float* z);
|
CSFML_API void sfListener_GetPosition(float* x, float* y, float* z);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Change the orientation of the listener (the point
|
/// Change the orientation of the listener
|
||||||
/// he must look at)
|
|
||||||
///
|
///
|
||||||
/// \param x : X position of the point the listener must look at
|
/// \param x : X component of the listener's direction
|
||||||
/// \param y : X position of the point the listener must look at
|
/// \param y : Y component of the listener's direction
|
||||||
/// \param z : X position of the point the listener must look at
|
/// \param z : Z component of the listener's direction
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_API void sfListener_SetTarget(float x, float y, float z);
|
CSFML_API void sfListener_SetDirection(float x, float y, float z);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Get the current orientation of the listener (the point
|
/// Get the current orientation of the listener
|
||||||
/// he's looking at)
|
|
||||||
///
|
///
|
||||||
/// \param x : X position of the point the listener is looking at
|
/// \param x : X component of the listener's direction
|
||||||
/// \param y : X position of the point the listener is looking at
|
/// \param y : Y component of the listener's direction
|
||||||
/// \param z : X position of the point the listener is looking at
|
/// \param z : Z component of the listener's direction
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_API void sfListener_GetTarget(float* x, float* y, float* z);
|
CSFML_API void sfListener_GetDirection(float* x, float* y, float* z);
|
||||||
|
|
||||||
|
|
||||||
#endif // SFML_LISTENER_H
|
#endif // SFML_LISTENER_H
|
||||||
|
@ -51,9 +51,9 @@ float sfListener_GetGlobalVolume()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Change the position of the listener
|
/// Change the position of the listener
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void sfListener_SetPosition(float x, float y, float PosZ)
|
void sfListener_SetPosition(float x, float y, float z)
|
||||||
{
|
{
|
||||||
sf::Listener::SetPosition(sf::Vector3f(x, y, PosZ));
|
sf::Listener::SetPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -73,26 +73,24 @@ void sfListener_GetPosition(float* x, float* y, float* z)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Change the orientation of the listener (the point
|
/// Change the orientation of the listener
|
||||||
/// he must look at)
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void sfListener_SetTarget(float x, float y, float z)
|
void sfListener_SetDirection(float x, float y, float z)
|
||||||
{
|
{
|
||||||
sf::Listener::SetTarget(sf::Vector3f(x, y, z));
|
sf::Listener::SetDirection(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Get the current orientation of the listener (the point
|
/// Get the current orientation of the listener
|
||||||
/// he's looking at)
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void sfListener_GetTarget(float* x, float* y, float* z)
|
void sfListener_GetDirection(float* x, float* y, float* z)
|
||||||
{
|
{
|
||||||
if (x && y && z)
|
if (x && y && z)
|
||||||
{
|
{
|
||||||
sf::Vector3f target = sf::Listener::GetTarget();
|
sf::Vector3f direction = sf::Listener::GetDirection();
|
||||||
*x = target.x;
|
*x = direction.x;
|
||||||
*y = target.y;
|
*y = direction.y;
|
||||||
*z = target.z;
|
*z = direction.z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,14 +39,13 @@ namespace SFML
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 3D position of the target, ie. the point the listener is looking at
|
/// 3D direction of the listener (default is (0, 0, -1))
|
||||||
/// (default is (0, 0, -1))
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
public static Vector3 Target
|
public static Vector3 Direction
|
||||||
{
|
{
|
||||||
get {Vector3 v; sfListener_GetTarget(out v.X, out v.Y, out v.Z); return v;}
|
get {Vector3 v; sfListener_GetDirection(out v.X, out v.Y, out v.Z); return v;}
|
||||||
set {sfListener_SetTarget(value.X, value.Y, value.Z);}
|
set {sfListener_SetDirection(value.X, value.Y, value.Z);}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Imports
|
#region Imports
|
||||||
@ -57,16 +56,16 @@ namespace SFML
|
|||||||
static extern float sfListener_GetGlobalVolume();
|
static extern float sfListener_GetGlobalVolume();
|
||||||
|
|
||||||
[DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity]
|
||||||
static extern void sfListener_SetPosition(float PosX, float PosY, float PosZ);
|
static extern void sfListener_SetPosition(float X, float Y, float Z);
|
||||||
|
|
||||||
[DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity]
|
||||||
static extern void sfListener_GetPosition(out float PosX, out float PosY, out float PosZ);
|
static extern void sfListener_GetPosition(out float X, out float Y, out float Z);
|
||||||
|
|
||||||
[DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity]
|
||||||
static extern void sfListener_SetTarget(float TargetX, float TargetY, float TargetZ);
|
static extern void sfListener_GetDirection(float X, float Y, float Z);
|
||||||
|
|
||||||
[DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-audio"), SuppressUnmanagedCodeSecurity]
|
||||||
static extern void sfListener_GetTarget(out float TargetX, out float TargetY, out float TargetZ);
|
static extern void sfListener_SetDirection(out float X, out float Y, out float Z);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,33 +87,32 @@ public :
|
|||||||
static Vector3f GetPosition();
|
static Vector3f GetPosition();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Change the orientation of the listener (the point
|
/// Change the orientation of the listener (take 3 values);
|
||||||
/// he must look at) (take 3 values).
|
/// the direction does not need to be normalized.
|
||||||
/// The default target is (0, 0, -1)
|
/// The default direction is (0, 0, -1)
|
||||||
///
|
///
|
||||||
/// \param x, y, z : Position of the point the listener must look at
|
/// \param x, y, z : Orientation of the listener
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static void SetTarget(float x, float y, float z);
|
static void SetDirection(float x, float y, float z);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Change the orientation of the listener (the point
|
/// Change the orientation of the listener (take a 3D vector);
|
||||||
/// he must look at) (take a 3D vector).
|
/// the direction does not need to be normalized.
|
||||||
/// The default target is (0, 0, -1)
|
/// The default direction is (0, 0, -1)
|
||||||
///
|
///
|
||||||
/// \param target : Position of the point the listener must look at
|
/// \param direction : Orientation of the listener
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static void SetTarget(const Vector3f& target);
|
static void SetDirection(const Vector3f& direction);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Get the current orientation of the listener (the point
|
/// Get the current orientation of the listener.
|
||||||
/// he's looking at)
|
|
||||||
///
|
///
|
||||||
/// \return : Position of the point the listener is looking at
|
/// \return Current direction of the listener
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Vector3f GetTarget();
|
static Vector3f GetDirection();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
@ -65,7 +65,7 @@ AudioDevice::AudioDevice()
|
|||||||
|
|
||||||
// Initialize the listener, located at the origin and looking along the Z axis
|
// Initialize the listener, located at the origin and looking along the Z axis
|
||||||
Listener::SetPosition(0.f, 0.f, 0.f);
|
Listener::SetPosition(0.f, 0.f, 0.f);
|
||||||
Listener::SetTarget(0.f, 0.f, -1.f);
|
Listener::SetDirection(0.f, 0.f, -1.f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -83,10 +83,9 @@ Vector3f Listener::GetPosition()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Change the orientation of the listener (the point
|
/// Change the orientation of the listener (take 3 values)
|
||||||
/// he must look at) (take 3 values)
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Listener::SetTarget(float x, float y, float z)
|
void Listener::SetDirection(float x, float y, float z)
|
||||||
{
|
{
|
||||||
float orientation[] = {x, y, z, 0.f, 1.f, 0.f};
|
float orientation[] = {x, y, z, 0.f, 1.f, 0.f};
|
||||||
ALCheck(alListenerfv(AL_ORIENTATION, orientation));
|
ALCheck(alListenerfv(AL_ORIENTATION, orientation));
|
||||||
@ -94,20 +93,18 @@ void Listener::SetTarget(float x, float y, float z)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Change the orientation of the listener (the point
|
/// Change the orientation of the listener (take a 3D vector)
|
||||||
/// he must look at) (take a 3D vector)
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Listener::SetTarget(const Vector3f& target)
|
void Listener::SetDirection(const Vector3f& direction)
|
||||||
{
|
{
|
||||||
SetTarget(target.x, target.y, target.z);
|
SetDirection(direction.x, direction.y, direction.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Get the current orientation of the listener (the point
|
/// Get the current orientation of the listener.
|
||||||
/// he's looking at)
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector3f Listener::GetTarget()
|
Vector3f Listener::GetDirection()
|
||||||
{
|
{
|
||||||
float orientation[6];
|
float orientation[6];
|
||||||
ALCheck(alGetListenerfv(AL_ORIENTATION, orientation));
|
ALCheck(alGetListenerfv(AL_ORIENTATION, orientation));
|
||||||
|
Loading…
Reference in New Issue
Block a user