Merge remote-tracking branch 'upstream/master'
Former-commit-id: 8fe411f0146d6cc64cf8d32cc4896f7f417f62a5
This commit is contained in:
commit
7bd6202389
|
|
@ -1,4 +1,4 @@
|
||||||
if (not _OPTIONS["one-library"]) then
|
if (not _OPTIONS["united"]) then
|
||||||
project "NazaraModuleName"
|
project "NazaraModuleName"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@ else
|
||||||
excludes { "../src/Nazara/ModuleName/Win32/*.hpp", "../src/Nazara/ModuleName/Win32/*.cpp" }
|
excludes { "../src/Nazara/ModuleName/Win32/*.hpp", "../src/Nazara/ModuleName/Win32/*.cpp" }
|
||||||
end
|
end
|
||||||
|
|
||||||
if (_OPTIONS["one-library"]) then
|
if (_OPTIONS["united"]) then
|
||||||
excludes "../src/Nazara/ModuleName/Debug/Leaks.cpp"
|
excludes "../src/Nazara/ModuleName/Debug/Leaks.cpp"
|
||||||
else
|
else
|
||||||
configuration "DebugStatic"
|
configuration "DebugStatic"
|
||||||
|
|
@ -31,4 +31,3 @@ else
|
||||||
configuration "ReleaseDLL"
|
configuration "ReleaseDLL"
|
||||||
links "NazaraCore"
|
links "NazaraCore"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
@ -2,7 +2,7 @@ kind "ConsoleApp"
|
||||||
|
|
||||||
files "main.cpp"
|
files "main.cpp"
|
||||||
|
|
||||||
if (_OPTIONS["one-library"]) then
|
if (_OPTIONS["united"]) then
|
||||||
configuration "DebugStatic"
|
configuration "DebugStatic"
|
||||||
links "NazaraEngine-s-d"
|
links "NazaraEngine-s-d"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ kind "ConsoleApp"
|
||||||
|
|
||||||
files "main.cpp"
|
files "main.cpp"
|
||||||
|
|
||||||
if (_OPTIONS["one-library"]) then
|
if (_OPTIONS["united"]) then
|
||||||
configuration "DebugStatic"
|
configuration "DebugStatic"
|
||||||
links "NazaraEngine-s-d"
|
links "NazaraEngine-s-d"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ int main()
|
||||||
sound.EnableLooping(true);
|
sound.EnableLooping(true);
|
||||||
|
|
||||||
// La source du son se situe vers la gauche (Et un peu en avant)
|
// La source du son se situe vers la gauche (Et un peu en avant)
|
||||||
sound.SetPosition(NzVector3f::Left()*50.f + NzVector3f::Forward()*5.);
|
sound.SetPosition(NzVector3f::Left()*50.f + NzVector3f::Forward()*5.f);
|
||||||
|
|
||||||
// Et possède une vitesse de 10 par seconde vers la droite
|
// Et possède une vitesse de 10 par seconde vers la droite
|
||||||
sound.SetVelocity(NzVector3f::Left()*-10.f);
|
sound.SetVelocity(NzVector3f::Left()*-10.f);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ kind "ConsoleApp"
|
||||||
|
|
||||||
files "main.cpp"
|
files "main.cpp"
|
||||||
|
|
||||||
if (_OPTIONS["one-library"]) then
|
if (_OPTIONS["united"]) then
|
||||||
configuration "DebugStatic"
|
configuration "DebugStatic"
|
||||||
links "NazaraEngine-s-d"
|
links "NazaraEngine-s-d"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ inline unsigned int NzGetNumberLength(unsigned long long number);
|
||||||
inline unsigned int NzGetNumberLength(float number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION);
|
inline unsigned int NzGetNumberLength(float number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION);
|
||||||
inline unsigned int NzGetNumberLength(double number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION);
|
inline unsigned int NzGetNumberLength(double number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION);
|
||||||
inline unsigned int NzGetNumberLength(long double number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION);
|
inline unsigned int NzGetNumberLength(long double number, nzUInt8 precision = NAZARA_CORE_REAL_PRECISION);
|
||||||
|
template<typename T, typename T2> T NzLerp(T from, T to, T2 interpolation);
|
||||||
template<typename T> T NzNormalizeAngle(T angle);
|
template<typename T> T NzNormalizeAngle(T angle);
|
||||||
template<typename T> bool NzNumberEquals(T a, T b);
|
template<typename T> bool NzNumberEquals(T a, T b);
|
||||||
inline NzString NzNumberToString(long long number, nzUInt8 radix = 10);
|
inline NzString NzNumberToString(long long number, nzUInt8 radix = 10);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
||||||
#define F(a) static_cast<T>(a)
|
#define F(a) static_cast<T>(a)
|
||||||
|
#define F2(a) static_cast<T2>(a)
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T NzApproach(T value, T objective, T increment)
|
T NzApproach(T value, T objective, T increment)
|
||||||
|
|
@ -132,11 +133,25 @@ unsigned int NzGetNumberLength(long double number, nzUInt8 precision)
|
||||||
return NzGetNumberLength(static_cast<long long>(number)) + precision + 1; // Plus un pour le point
|
return NzGetNumberLength(static_cast<long long>(number)) + precision + 1; // Plus un pour le point
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, typename T2>
|
||||||
|
T NzLerp(T from, T to, T2 interpolation)
|
||||||
|
{
|
||||||
|
#ifdef NAZARA_DEBUG
|
||||||
|
if (interpolation < F2(0.0) || interpolation > F2(1.0))
|
||||||
|
{
|
||||||
|
NazaraError("Interpolation must be in range [0..1] (Got " + NzString::Number(interpolation) + ')');
|
||||||
|
return F(0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return from + interpolation*(to - from);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T NzNormalizeAngle(T angle)
|
T NzNormalizeAngle(T angle)
|
||||||
{
|
{
|
||||||
#if NAZARA_MATH_ANGLE_RADIAN
|
#if NAZARA_MATH_ANGLE_RADIAN
|
||||||
const T limit = M_PI;
|
const T limit = F(M_PI);
|
||||||
#else
|
#else
|
||||||
const T limit = F(180.0);
|
const T limit = F(180.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -270,6 +285,7 @@ long long NzStringToNumber(NzString str, nzUInt8 radix, bool* ok)
|
||||||
return (negative) ? -static_cast<long long>(total) : total;
|
return (negative) ? -static_cast<long long>(total) : total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef F2
|
||||||
#undef F
|
#undef F
|
||||||
|
|
||||||
#include <Nazara/Core/DebugOff.hpp>
|
#include <Nazara/Core/DebugOff.hpp>
|
||||||
|
|
|
||||||
|
|
@ -20,28 +20,30 @@ class NzCube
|
||||||
NzCube(const T cube[6]);
|
NzCube(const T cube[6]);
|
||||||
NzCube(const NzRect<T>& rect);
|
NzCube(const NzRect<T>& rect);
|
||||||
NzCube(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
NzCube(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||||
template<typename U> explicit NzCube(const NzCube<U>& rect);
|
template<typename U> explicit NzCube(const NzCube<U>& cube);
|
||||||
NzCube(const NzCube& rect) = default;
|
NzCube(const NzCube& cube) = default;
|
||||||
~NzCube() = default;
|
~NzCube() = default;
|
||||||
|
|
||||||
bool Contains(T X, T Y, T Z) const;
|
bool Contains(T X, T Y, T Z) const;
|
||||||
bool Contains(const NzVector3<T>& point) const;
|
bool Contains(const NzVector3<T>& point) const;
|
||||||
bool Contains(const NzCube& rect) const;
|
bool Contains(const NzCube& cube) const;
|
||||||
|
|
||||||
void ExtendTo(const NzVector3<T>& point);
|
void ExtendTo(const NzVector3<T>& point);
|
||||||
void ExtendTo(const NzCube& rect);
|
void ExtendTo(const NzCube& cube);
|
||||||
|
|
||||||
NzVector3<T> GetCenter() const;
|
NzVector3<T> GetCenter() const;
|
||||||
|
|
||||||
bool Intersect(const NzCube& rect, NzCube* intersection = nullptr) const;
|
bool Intersect(const NzCube& cube, NzCube* intersection = nullptr) const;
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
|
void MakeZero();
|
||||||
|
|
||||||
void Set(T X, T Y, T Z, T Width, T Height, T Depth);
|
void Set(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||||
void Set(const T rect[6]);
|
void Set(const T cube[6]);
|
||||||
void Set(const NzRect<T>& rect);
|
void Set(const NzRect<T>& rect);
|
||||||
void Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
void Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||||
template<typename U> void Set(const NzCube<U>& rect);
|
template<typename U> void Set(const NzCube<U>& cube);
|
||||||
|
|
||||||
NzString ToString() const;
|
NzString ToString() const;
|
||||||
|
|
||||||
|
|
@ -50,6 +52,16 @@ class NzCube
|
||||||
T& operator[](unsigned int i);
|
T& operator[](unsigned int i);
|
||||||
T operator[](unsigned int i) const;
|
T operator[](unsigned int i) const;
|
||||||
|
|
||||||
|
NzCube operator*(T scalar) const;
|
||||||
|
|
||||||
|
NzCube& operator*=(T scalar);
|
||||||
|
|
||||||
|
bool operator==(const NzCube& cube) const;
|
||||||
|
bool operator!=(const NzCube& cube) const;
|
||||||
|
|
||||||
|
static NzCube Lerp(const NzCube& from, const NzCube& to, T interpolation);
|
||||||
|
static NzCube Zero();
|
||||||
|
|
||||||
T x, y, z, width, height, depth;
|
T x, y, z, width, height, depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,9 @@ NzCube<T>::NzCube(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
template<typename U>
|
template<typename U>
|
||||||
NzCube<T>::NzCube(const NzCube<U>& rect)
|
NzCube<T>::NzCube(const NzCube<U>& cube)
|
||||||
{
|
{
|
||||||
Set(rect);
|
Set(cube);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -59,10 +59,10 @@ bool NzCube<T>::Contains(const NzVector3<T>& point) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool NzCube<T>::Contains(const NzCube<T>& rect) const
|
bool NzCube<T>::Contains(const NzCube<T>& cube) const
|
||||||
{
|
{
|
||||||
return Contains(rect.x, rect.y, rect.z) &&
|
return Contains(cube.x, cube.y, cube.z) &&
|
||||||
Contains(rect.x + rect.width, rect.y + rect.height, rect.z + rect.depth);
|
Contains(cube.x + cube.width, cube.y + cube.height, cube.z + cube.depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -77,14 +77,14 @@ void NzCube<T>::ExtendTo(const NzVector3<T>& point)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzCube<T>::ExtendTo(const NzCube& rect)
|
void NzCube<T>::ExtendTo(const NzCube& cube)
|
||||||
{
|
{
|
||||||
x = std::min(x, rect.x);
|
x = std::min(x, cube.x);
|
||||||
y = std::min(y, rect.y);
|
y = std::min(y, cube.y);
|
||||||
z = std::min(y, rect.z);
|
z = std::min(y, cube.z);
|
||||||
width = std::max(x+width, rect.x+rect.width)-x;
|
width = std::max(x+width, cube.x+cube.width)-x;
|
||||||
height = std::max(x+height, rect.y+rect.height)-y;
|
height = std::max(x+height, cube.y+cube.height)-y;
|
||||||
depth = std::max(x+depth, rect.z+rect.depth)-z;
|
depth = std::max(x+depth, cube.z+cube.depth)-z;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -94,14 +94,14 @@ NzVector3<T> NzCube<T>::GetCenter() const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool NzCube<T>::Intersect(const NzCube& rect, NzCube* intersection) const
|
bool NzCube<T>::Intersect(const NzCube& cube, NzCube* intersection) const
|
||||||
{
|
{
|
||||||
T left = std::max(x, rect.x);
|
T left = std::max(x, cube.x);
|
||||||
T right = std::min(x+width, rect.x+rect.width);
|
T right = std::min(x+width, cube.x+cube.width);
|
||||||
T top = std::max(y, rect.y);
|
T top = std::max(y, cube.y);
|
||||||
T bottom = std::min(y+height, rect.y+rect.height);
|
T bottom = std::min(y+height, cube.y+cube.height);
|
||||||
T up = std::max(z, rect.z);
|
T up = std::max(z, cube.z);
|
||||||
T down = std::min(z+depth, rect.z+rect.depth);
|
T down = std::min(z+depth, cube.z+cube.depth);
|
||||||
|
|
||||||
if (left < right && top < bottom && up < down)
|
if (left < right && top < bottom && up < down)
|
||||||
{
|
{
|
||||||
|
|
@ -127,6 +127,17 @@ bool NzCube<T>::IsValid() const
|
||||||
return width > F(0.0) && height > F(0.0) && depth > F(0.0);
|
return width > F(0.0) && height > F(0.0) && depth > F(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void NzCube<T>::MakeZero()
|
||||||
|
{
|
||||||
|
x = F(0.0);
|
||||||
|
y = F(0.0);
|
||||||
|
z = F(0.0);
|
||||||
|
width = F(0.0);
|
||||||
|
height = F(0.0);
|
||||||
|
depth = F(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzCube<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
void NzCube<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||||
{
|
{
|
||||||
|
|
@ -139,14 +150,14 @@ void NzCube<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzCube<T>::Set(const T rect[6])
|
void NzCube<T>::Set(const T cube[6])
|
||||||
{
|
{
|
||||||
x = rect[0];
|
x = cube[0];
|
||||||
y = rect[1];
|
y = cube[1];
|
||||||
z = rect[2];
|
z = cube[2];
|
||||||
width = rect[3];
|
width = cube[3];
|
||||||
height = rect[4];
|
height = cube[4];
|
||||||
depth = rect[5];
|
depth = cube[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -230,9 +241,67 @@ T NzCube<T>::operator[](unsigned int i) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::ostream& operator<<(std::ostream& out, const NzCube<T>& rect)
|
NzCube<T> NzCube<T>::operator*(T scalar) const
|
||||||
{
|
{
|
||||||
return out << rect.ToString();
|
return NzCube(x, y, z, width*scalar, height*scalar, depth*scalar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzCube<T>& NzCube<T>::operator*=(T scalar)
|
||||||
|
{
|
||||||
|
width *= scalar;
|
||||||
|
height *= scalar;
|
||||||
|
depth *= scalar;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzCube<T>::operator==(const NzCube& cube) const
|
||||||
|
{
|
||||||
|
return NzNumberEquals(x, cube.x) && NzNumberEquals(y, cube.y) && NzNumberEquals(z, cube.z) &&
|
||||||
|
NzNumberEquals(width, cube.width) && NzNumberEquals(height, cube.height) && NzNumberEquals(depth, cube.depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzCube<T>::operator!=(const NzCube& cube) const
|
||||||
|
{
|
||||||
|
return !operator==(cube);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzCube<T> NzCube<T>::Lerp(const NzCube& from, const NzCube& to, T interpolation)
|
||||||
|
{
|
||||||
|
#ifdef NAZARA_DEBUG
|
||||||
|
if (interpolation < F(0.0) || interpolation > F(1.0))
|
||||||
|
{
|
||||||
|
NazaraError("Interpolation must be in range [0..1] (Got " + NzString::Number(interpolation) + ')');
|
||||||
|
return Zero();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NzCube cube;
|
||||||
|
cube.x = NzLerp(from.x, to.x, interpolation);
|
||||||
|
cube.y = NzLerp(from.y, to.y, interpolation);
|
||||||
|
cube.z = NzLerp(from.z, to.z, interpolation);
|
||||||
|
cube.width = NzLerp(from.width, to.width, interpolation);
|
||||||
|
cube.height = NzLerp(from.height, to.height, interpolation);
|
||||||
|
cube.depth = NzLerp(from.depth, to.depth, interpolation);
|
||||||
|
|
||||||
|
return cube;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzCube<T> NzCube<T>::Zero()
|
||||||
|
{
|
||||||
|
NzCube cube;
|
||||||
|
cube.MakeZero();
|
||||||
|
|
||||||
|
return cube;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::ostream& operator<<(std::ostream& out, const NzCube<T>& cube)
|
||||||
|
{
|
||||||
|
return out << cube.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef F
|
#undef F
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,14 @@ class NzMatrix4
|
||||||
NzMatrix4(NzMatrix4&& matrix) noexcept;
|
NzMatrix4(NzMatrix4&& matrix) noexcept;
|
||||||
~NzMatrix4();
|
~NzMatrix4();
|
||||||
|
|
||||||
|
NzMatrix4& ApplyScale(const NzVector3<T>& scale);
|
||||||
|
|
||||||
NzMatrix4 Concatenate(const NzMatrix4& matrix) const;
|
NzMatrix4 Concatenate(const NzMatrix4& matrix) const;
|
||||||
NzMatrix4 ConcatenateAffine(const NzMatrix4& matrix) const;
|
NzMatrix4 ConcatenateAffine(const NzMatrix4& matrix) const;
|
||||||
|
|
||||||
T GetDeterminant() const;
|
T GetDeterminant() const;
|
||||||
NzMatrix4 GetInverse() const;
|
NzMatrix4 GetInverse(bool* succeeded = nullptr) const;
|
||||||
|
NzMatrix4 GetInverseAffine(bool* succeeded = nullptr) const;
|
||||||
NzQuaternion<T> GetRotation() const;
|
NzQuaternion<T> GetRotation() const;
|
||||||
//NzMatrix3 GetRotationMatrix() const;
|
//NzMatrix3 GetRotationMatrix() const;
|
||||||
NzVector3<T> GetScale() const;
|
NzVector3<T> GetScale() const;
|
||||||
|
|
@ -52,30 +55,34 @@ class NzMatrix4
|
||||||
bool HasNegativeScale() const;
|
bool HasNegativeScale() const;
|
||||||
bool HasScale() const;
|
bool HasScale() const;
|
||||||
|
|
||||||
|
NzMatrix4& Inverse(bool* succeeded = nullptr);
|
||||||
|
NzMatrix4& InverseAffine(bool* succeeded = nullptr);
|
||||||
|
|
||||||
bool IsAffine() const;
|
bool IsAffine() const;
|
||||||
bool IsDefined() const;
|
bool IsDefined() const;
|
||||||
|
|
||||||
void MakeIdentity();
|
NzMatrix4& MakeIdentity();
|
||||||
void MakeLookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up = NzVector3<T>::Up());
|
NzMatrix4& MakeLookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up = NzVector3<T>::Up());
|
||||||
void MakeOrtho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
|
NzMatrix4& MakeOrtho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
|
||||||
void MakePerspective(T angle, T ratio, T zNear, T zFar);
|
NzMatrix4& MakePerspective(T angle, T ratio, T zNear, T zFar);
|
||||||
void MakeRotation(const NzQuaternion<T>& rotation);
|
NzMatrix4& MakeRotation(const NzQuaternion<T>& rotation);
|
||||||
void MakeScale(const NzVector3<T>& scale);
|
NzMatrix4& MakeScale(const NzVector3<T>& scale);
|
||||||
void MakeTranslation(const NzVector3<T>& translation);
|
NzMatrix4& MakeTranslation(const NzVector3<T>& translation);
|
||||||
void MakeZero();
|
NzMatrix4& MakeTransform(const NzVector3<T>& translation, const NzVector3<T>& scale, const NzQuaternion<T>& rotation);
|
||||||
|
NzMatrix4& MakeZero();
|
||||||
|
|
||||||
void Set(T r11, T r12, T r13, T r14,
|
NzMatrix4& Set(T r11, T r12, T r13, T r14,
|
||||||
T r21, T r22, T r23, T r24,
|
T r21, T r22, T r23, T r24,
|
||||||
T r31, T r32, T r33, T r34,
|
T r31, T r32, T r33, T r34,
|
||||||
T r41, T r42, T r43, T r44);
|
T r41, T r42, T r43, T r44);
|
||||||
void Set(const T matrix[16]);
|
NzMatrix4& Set(const T matrix[16]);
|
||||||
//NzMatrix4(const NzMatrix3<T>& matrix);
|
//NzMatrix4(const NzMatrix3<T>& matrix);
|
||||||
void Set(const NzMatrix4& matrix);
|
NzMatrix4& Set(const NzMatrix4& matrix);
|
||||||
void Set(NzMatrix4&& matrix);
|
NzMatrix4& Set(NzMatrix4&& matrix);
|
||||||
template<typename U> void Set(const NzMatrix4<U>& matrix);
|
template<typename U> NzMatrix4& Set(const NzMatrix4<U>& matrix);
|
||||||
void SetRotation(const NzQuaternion<T>& rotation);
|
NzMatrix4& SetRotation(const NzQuaternion<T>& rotation);
|
||||||
void SetScale(const NzVector3<T>& scale);
|
NzMatrix4& SetScale(const NzVector3<T>& scale);
|
||||||
void SetTranslation(const NzVector3<T>& translation);
|
NzMatrix4& SetTranslation(const NzVector3<T>& translation);
|
||||||
|
|
||||||
NzString ToString() const;
|
NzString ToString() const;
|
||||||
|
|
||||||
|
|
@ -85,6 +92,8 @@ class NzMatrix4
|
||||||
|
|
||||||
NzMatrix4& Transpose();
|
NzMatrix4& Transpose();
|
||||||
|
|
||||||
|
NzMatrix4& Undefine();
|
||||||
|
|
||||||
operator NzString() const;
|
operator NzString() const;
|
||||||
|
|
||||||
operator T*();
|
operator T*();
|
||||||
|
|
@ -117,6 +126,7 @@ class NzMatrix4
|
||||||
static NzMatrix4 Rotate(const NzQuaternion<T>& rotation);
|
static NzMatrix4 Rotate(const NzQuaternion<T>& rotation);
|
||||||
static NzMatrix4 Scale(const NzVector3<T>& scale);
|
static NzMatrix4 Scale(const NzVector3<T>& scale);
|
||||||
static NzMatrix4 Translate(const NzVector3<T>& translation);
|
static NzMatrix4 Translate(const NzVector3<T>& translation);
|
||||||
|
static NzMatrix4 Transform(const NzVector3<T>& translation, const NzVector3<T>& scale, const NzQuaternion<T>& rotation);
|
||||||
static NzMatrix4 Zero();
|
static NzMatrix4 Zero();
|
||||||
|
|
||||||
struct SharedMatrix
|
struct SharedMatrix
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
//#include <Nazara/Core/Debug.hpp>
|
//#include <Nazara/Core/Debug.hpp>
|
||||||
///FIXME: Le MLT détecte de faux-leaks ici (Problème lié aux inline ?)
|
///FIXME: Le MLT détecte des leaks ici, mais dont la véracité n'a pu être prouvée (Problème lié aux classes inlines ?)
|
||||||
|
|
||||||
#define F(a) static_cast<T>(a)
|
#define F(a) static_cast<T>(a)
|
||||||
|
|
||||||
|
|
@ -68,6 +68,24 @@ NzMatrix4<T>::~NzMatrix4()
|
||||||
ReleaseMatrix();
|
ReleaseMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzMatrix4<T>& NzMatrix4<T>::ApplyScale(const NzVector3<T>& scale)
|
||||||
|
{
|
||||||
|
m_sharedMatrix->m11 *= scale.x;
|
||||||
|
m_sharedMatrix->m12 *= scale.x;
|
||||||
|
m_sharedMatrix->m13 *= scale.x;
|
||||||
|
|
||||||
|
m_sharedMatrix->m21 *= scale.y;
|
||||||
|
m_sharedMatrix->m22 *= scale.y;
|
||||||
|
m_sharedMatrix->m23 *= scale.y;
|
||||||
|
|
||||||
|
m_sharedMatrix->m31 *= scale.z;
|
||||||
|
m_sharedMatrix->m32 *= scale.z;
|
||||||
|
m_sharedMatrix->m33 *= scale.z;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzMatrix4<T> NzMatrix4<T>::Concatenate(const NzMatrix4& matrix) const
|
NzMatrix4<T> NzMatrix4<T>::Concatenate(const NzMatrix4& matrix) const
|
||||||
{
|
{
|
||||||
|
|
@ -100,45 +118,17 @@ T NzMatrix4<T>::GetDeterminant() const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzMatrix4<T> NzMatrix4<T>::GetInverse() const
|
NzMatrix4<T> NzMatrix4<T>::GetInverse(bool* succeeded) const
|
||||||
{
|
{
|
||||||
#if NAZARA_MATH_SAFE
|
NzMatrix4f matInv(*this);
|
||||||
if (!IsDefined())
|
return matInv.Inverse(succeeded);
|
||||||
{
|
|
||||||
NazaraError("Matrix not defined");
|
|
||||||
return NzMatrix4();
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
T det = GetDeterminant();
|
template<typename T>
|
||||||
if (!NzNumberEquals(det, F(0.0)))
|
NzMatrix4<T> NzMatrix4<T>::GetInverseAffine(bool* succeeded) const
|
||||||
{
|
{
|
||||||
return NzMatrix4((m_sharedMatrix->m22*(m_sharedMatrix->m33*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m43) - m_sharedMatrix->m32*(m_sharedMatrix->m23*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m24) + m_sharedMatrix->m42*(m_sharedMatrix->m23*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m24)) / det,
|
NzMatrix4f matInv(*this);
|
||||||
-(m_sharedMatrix->m12*(m_sharedMatrix->m33*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m34) - m_sharedMatrix->m32*(m_sharedMatrix->m13*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m14) + m_sharedMatrix->m42*(m_sharedMatrix->m13*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m14)) / det,
|
return matInv.InverseAffine(succeeded);
|
||||||
(m_sharedMatrix->m12*(m_sharedMatrix->m23*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m24) - m_sharedMatrix->m22*(m_sharedMatrix->m13*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m14) + m_sharedMatrix->m42*(m_sharedMatrix->m13*m_sharedMatrix->m24 - m_sharedMatrix->m23*m_sharedMatrix->m14)) / det,
|
|
||||||
-(m_sharedMatrix->m12*(m_sharedMatrix->m23*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m24) - m_sharedMatrix->m22*(m_sharedMatrix->m13*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m14) + m_sharedMatrix->m32*(m_sharedMatrix->m13*m_sharedMatrix->m24 - m_sharedMatrix->m23*m_sharedMatrix->m14)) / det,
|
|
||||||
|
|
||||||
-(m_sharedMatrix->m21*(m_sharedMatrix->m33*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m43) - m_sharedMatrix->m23*(m_sharedMatrix->m31*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m41) + m_sharedMatrix->m24*(m_sharedMatrix->m31*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m41)) / det,
|
|
||||||
(m_sharedMatrix->m11*(m_sharedMatrix->m33*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m43) - m_sharedMatrix->m13*(m_sharedMatrix->m31*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m41) + m_sharedMatrix->m14*(m_sharedMatrix->m31*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m41)) / det,
|
|
||||||
-(m_sharedMatrix->m11*(m_sharedMatrix->m23*m_sharedMatrix->m44 - m_sharedMatrix->m24*m_sharedMatrix->m43) - m_sharedMatrix->m13*(m_sharedMatrix->m21*m_sharedMatrix->m44 - m_sharedMatrix->m24*m_sharedMatrix->m41) + m_sharedMatrix->m14*(m_sharedMatrix->m21*m_sharedMatrix->m43 - m_sharedMatrix->m23*m_sharedMatrix->m41)) / det,
|
|
||||||
(m_sharedMatrix->m11*(m_sharedMatrix->m23*m_sharedMatrix->m34 - m_sharedMatrix->m24*m_sharedMatrix->m33) - m_sharedMatrix->m13*(m_sharedMatrix->m21*m_sharedMatrix->m34 - m_sharedMatrix->m24*m_sharedMatrix->m31) + m_sharedMatrix->m14*(m_sharedMatrix->m21*m_sharedMatrix->m33 - m_sharedMatrix->m23*m_sharedMatrix->m31)) / det,
|
|
||||||
|
|
||||||
(m_sharedMatrix->m21*(m_sharedMatrix->m32*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m42) - m_sharedMatrix->m22*(m_sharedMatrix->m31*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m41) + m_sharedMatrix->m24*(m_sharedMatrix->m31*m_sharedMatrix->m42 - m_sharedMatrix->m32*m_sharedMatrix->m41)) / det,
|
|
||||||
-(m_sharedMatrix->m11*(m_sharedMatrix->m32*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m42) - m_sharedMatrix->m12*(m_sharedMatrix->m31*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m41) + m_sharedMatrix->m14*(m_sharedMatrix->m31*m_sharedMatrix->m42 - m_sharedMatrix->m32*m_sharedMatrix->m41)) / det,
|
|
||||||
(m_sharedMatrix->m11*(m_sharedMatrix->m22*m_sharedMatrix->m44 - m_sharedMatrix->m24*m_sharedMatrix->m42) - m_sharedMatrix->m12*(m_sharedMatrix->m21*m_sharedMatrix->m44 - m_sharedMatrix->m24*m_sharedMatrix->m41) + m_sharedMatrix->m14*(m_sharedMatrix->m21*m_sharedMatrix->m42 - m_sharedMatrix->m22*m_sharedMatrix->m41)) / det,
|
|
||||||
-(m_sharedMatrix->m11*(m_sharedMatrix->m22*m_sharedMatrix->m34 - m_sharedMatrix->m24*m_sharedMatrix->m32) - m_sharedMatrix->m12*(m_sharedMatrix->m21*m_sharedMatrix->m34 - m_sharedMatrix->m24*m_sharedMatrix->m31) + m_sharedMatrix->m14*(m_sharedMatrix->m21*m_sharedMatrix->m32 - m_sharedMatrix->m22*m_sharedMatrix->m31)) / det,
|
|
||||||
|
|
||||||
-(m_sharedMatrix->m21*(m_sharedMatrix->m32*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m42) - m_sharedMatrix->m22*(m_sharedMatrix->m31*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m41) + m_sharedMatrix->m23*(m_sharedMatrix->m31*m_sharedMatrix->m42 - m_sharedMatrix->m32*m_sharedMatrix->m41)) / det,
|
|
||||||
(m_sharedMatrix->m11*(m_sharedMatrix->m32*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m42) - m_sharedMatrix->m12*(m_sharedMatrix->m31*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m41) + m_sharedMatrix->m13*(m_sharedMatrix->m31*m_sharedMatrix->m42 - m_sharedMatrix->m32*m_sharedMatrix->m41)) / det,
|
|
||||||
-(m_sharedMatrix->m11*(m_sharedMatrix->m22*m_sharedMatrix->m43 - m_sharedMatrix->m23*m_sharedMatrix->m42) - m_sharedMatrix->m12*(m_sharedMatrix->m21*m_sharedMatrix->m43 - m_sharedMatrix->m23*m_sharedMatrix->m41) + m_sharedMatrix->m13*(m_sharedMatrix->m21*m_sharedMatrix->m42 - m_sharedMatrix->m22*m_sharedMatrix->m41)) / det,
|
|
||||||
(m_sharedMatrix->m11*(m_sharedMatrix->m22*m_sharedMatrix->m33 - m_sharedMatrix->m23*m_sharedMatrix->m32) - m_sharedMatrix->m12*(m_sharedMatrix->m21*m_sharedMatrix->m33 - m_sharedMatrix->m23*m_sharedMatrix->m31) + m_sharedMatrix->m13*(m_sharedMatrix->m21*m_sharedMatrix->m32 - m_sharedMatrix->m22*m_sharedMatrix->m31)) / det);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NazaraError("Matrix has no inverse");
|
|
||||||
|
|
||||||
return Identity();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -220,6 +210,259 @@ bool NzMatrix4<T>::HasScale() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzMatrix4<T>& NzMatrix4<T>::Inverse(bool* succeeded)
|
||||||
|
{
|
||||||
|
#if NAZARA_MATH_SAFE
|
||||||
|
if (!IsDefined())
|
||||||
|
{
|
||||||
|
NazaraError("Matrix not defined");
|
||||||
|
if (succeeded)
|
||||||
|
*succeeded = false;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
T det = GetDeterminant();
|
||||||
|
if (!NzNumberEquals(det, F(0.0)))
|
||||||
|
{
|
||||||
|
// http://stackoverflow.com/questions/1148309/inverting-a-4x4-matrix
|
||||||
|
T inv[16];
|
||||||
|
inv[0] = m_sharedMatrix->m22 * m_sharedMatrix->m33 * m_sharedMatrix->m44 -
|
||||||
|
m_sharedMatrix->m22 * m_sharedMatrix->m34 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m32 * m_sharedMatrix->m23 * m_sharedMatrix->m44 +
|
||||||
|
m_sharedMatrix->m32 * m_sharedMatrix->m24 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m42 * m_sharedMatrix->m23 * m_sharedMatrix->m34 -
|
||||||
|
m_sharedMatrix->m42 * m_sharedMatrix->m24 * m_sharedMatrix->m33;
|
||||||
|
|
||||||
|
inv[1] = -m_sharedMatrix->m12 * m_sharedMatrix->m33 * m_sharedMatrix->m44 +
|
||||||
|
m_sharedMatrix->m12 * m_sharedMatrix->m34 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m32 * m_sharedMatrix->m13 * m_sharedMatrix->m44 -
|
||||||
|
m_sharedMatrix->m32 * m_sharedMatrix->m14 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m42 * m_sharedMatrix->m13 * m_sharedMatrix->m34 +
|
||||||
|
m_sharedMatrix->m42 * m_sharedMatrix->m14 * m_sharedMatrix->m33;
|
||||||
|
|
||||||
|
inv[2] = m_sharedMatrix->m12 * m_sharedMatrix->m23 * m_sharedMatrix->m44 -
|
||||||
|
m_sharedMatrix->m12 * m_sharedMatrix->m24 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m22 * m_sharedMatrix->m13 * m_sharedMatrix->m44 +
|
||||||
|
m_sharedMatrix->m22 * m_sharedMatrix->m14 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m42 * m_sharedMatrix->m13 * m_sharedMatrix->m24 -
|
||||||
|
m_sharedMatrix->m42 * m_sharedMatrix->m14 * m_sharedMatrix->m23;
|
||||||
|
|
||||||
|
inv[3] = -m_sharedMatrix->m12 * m_sharedMatrix->m23 * m_sharedMatrix->m34 +
|
||||||
|
m_sharedMatrix->m12 * m_sharedMatrix->m24 * m_sharedMatrix->m33 +
|
||||||
|
m_sharedMatrix->m22 * m_sharedMatrix->m13 * m_sharedMatrix->m34 -
|
||||||
|
m_sharedMatrix->m22 * m_sharedMatrix->m14 * m_sharedMatrix->m33 -
|
||||||
|
m_sharedMatrix->m32 * m_sharedMatrix->m13 * m_sharedMatrix->m24 +
|
||||||
|
m_sharedMatrix->m32 * m_sharedMatrix->m14 * m_sharedMatrix->m23;
|
||||||
|
|
||||||
|
inv[4] = -m_sharedMatrix->m21 * m_sharedMatrix->m33 * m_sharedMatrix->m44 +
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m34 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m23 * m_sharedMatrix->m44 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m24 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m23 * m_sharedMatrix->m34 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m24 * m_sharedMatrix->m33;
|
||||||
|
|
||||||
|
inv[5] = m_sharedMatrix->m11 * m_sharedMatrix->m33 * m_sharedMatrix->m44 -
|
||||||
|
m_sharedMatrix->m11 * m_sharedMatrix->m34 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m13 * m_sharedMatrix->m44 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m14 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m13 * m_sharedMatrix->m34 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m14 * m_sharedMatrix->m33;
|
||||||
|
|
||||||
|
inv[6] = -m_sharedMatrix->m11 * m_sharedMatrix->m23 * m_sharedMatrix->m44 +
|
||||||
|
m_sharedMatrix->m11 * m_sharedMatrix->m24 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m13 * m_sharedMatrix->m44 -
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m14 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m13 * m_sharedMatrix->m24 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m14 * m_sharedMatrix->m23;
|
||||||
|
|
||||||
|
inv[7] = m_sharedMatrix->m11 * m_sharedMatrix->m23 * m_sharedMatrix->m34 -
|
||||||
|
m_sharedMatrix->m11 * m_sharedMatrix->m24 * m_sharedMatrix->m33 -
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m13 * m_sharedMatrix->m34 +
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m14 * m_sharedMatrix->m33 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m13 * m_sharedMatrix->m24 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m14 * m_sharedMatrix->m23;
|
||||||
|
|
||||||
|
inv[8] = m_sharedMatrix->m21 * m_sharedMatrix->m32 * m_sharedMatrix->m44 -
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m34 * m_sharedMatrix->m42 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m22 * m_sharedMatrix->m44 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m24 * m_sharedMatrix->m42 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m22 * m_sharedMatrix->m34 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m24 * m_sharedMatrix->m32;
|
||||||
|
|
||||||
|
inv[9] = -m_sharedMatrix->m11 * m_sharedMatrix->m32 * m_sharedMatrix->m44 +
|
||||||
|
m_sharedMatrix->m11 * m_sharedMatrix->m34 * m_sharedMatrix->m42 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m12 * m_sharedMatrix->m44 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m14 * m_sharedMatrix->m42 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m12 * m_sharedMatrix->m34 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m14 * m_sharedMatrix->m32;
|
||||||
|
|
||||||
|
inv[10] = m_sharedMatrix->m11 * m_sharedMatrix->m22 * m_sharedMatrix->m44 -
|
||||||
|
m_sharedMatrix->m11 * m_sharedMatrix->m24 * m_sharedMatrix->m42 -
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m12 * m_sharedMatrix->m44 +
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m14 * m_sharedMatrix->m42 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m12 * m_sharedMatrix->m24 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m14 * m_sharedMatrix->m22;
|
||||||
|
|
||||||
|
inv[11] = -m_sharedMatrix->m11 * m_sharedMatrix->m22 * m_sharedMatrix->m34 +
|
||||||
|
m_sharedMatrix->m11 * m_sharedMatrix->m24 * m_sharedMatrix->m32 +
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m12 * m_sharedMatrix->m34 -
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m14 * m_sharedMatrix->m32 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m12 * m_sharedMatrix->m24 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m14 * m_sharedMatrix->m22;
|
||||||
|
|
||||||
|
inv[12] = -m_sharedMatrix->m21 * m_sharedMatrix->m32 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m33 * m_sharedMatrix->m42 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m22 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m23 * m_sharedMatrix->m42 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m22 * m_sharedMatrix->m33 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m23 * m_sharedMatrix->m32;
|
||||||
|
|
||||||
|
inv[13] = m_sharedMatrix->m11 * m_sharedMatrix->m32 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m11 * m_sharedMatrix->m33 * m_sharedMatrix->m42 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m12 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m13 * m_sharedMatrix->m42 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m12 * m_sharedMatrix->m33 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m13 * m_sharedMatrix->m32;
|
||||||
|
|
||||||
|
inv[14] = -m_sharedMatrix->m11 * m_sharedMatrix->m22 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m11 * m_sharedMatrix->m23 * m_sharedMatrix->m42 +
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m12 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m13 * m_sharedMatrix->m42 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m12 * m_sharedMatrix->m23 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m13 * m_sharedMatrix->m22;
|
||||||
|
|
||||||
|
inv[15] = m_sharedMatrix->m11 * m_sharedMatrix->m22 * m_sharedMatrix->m33 -
|
||||||
|
m_sharedMatrix->m11 * m_sharedMatrix->m23 * m_sharedMatrix->m32 -
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m12 * m_sharedMatrix->m33 +
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m13 * m_sharedMatrix->m32 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m12 * m_sharedMatrix->m23 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m13 * m_sharedMatrix->m22;
|
||||||
|
|
||||||
|
T invDet = F(1.0) / det;
|
||||||
|
for (unsigned int i = 0; i < 16; ++i)
|
||||||
|
inv[i] *= invDet;
|
||||||
|
|
||||||
|
Set(inv);
|
||||||
|
if (succeeded)
|
||||||
|
*succeeded = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NazaraError("Matrix has no inverse");
|
||||||
|
if (succeeded)
|
||||||
|
*succeeded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzMatrix4<T>& NzMatrix4<T>::InverseAffine(bool* succeeded)
|
||||||
|
{
|
||||||
|
#if NAZARA_MATH_SAFE
|
||||||
|
if (!IsDefined())
|
||||||
|
{
|
||||||
|
NazaraError("Matrix not defined");
|
||||||
|
if (succeeded)
|
||||||
|
*succeeded = false;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsAffine())
|
||||||
|
{
|
||||||
|
NazaraError("Matrix not affine");
|
||||||
|
if (succeeded)
|
||||||
|
*succeeded = false;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
T det = GetDeterminant();
|
||||||
|
if (!NzNumberEquals(det, F(0.0)))
|
||||||
|
{
|
||||||
|
// http://stackoverflow.com/questions/1148309/inverting-a-4x4-matrix
|
||||||
|
T inv[16];
|
||||||
|
inv[0] = m_sharedMatrix->m22 * m_sharedMatrix->m33 -
|
||||||
|
m_sharedMatrix->m32 * m_sharedMatrix->m23;
|
||||||
|
|
||||||
|
inv[1] = -m_sharedMatrix->m12 * m_sharedMatrix->m33 +
|
||||||
|
m_sharedMatrix->m32 * m_sharedMatrix->m13;
|
||||||
|
|
||||||
|
inv[2] = m_sharedMatrix->m12 * m_sharedMatrix->m23 -
|
||||||
|
m_sharedMatrix->m22 * m_sharedMatrix->m13;
|
||||||
|
|
||||||
|
inv[3] = F(0.0);
|
||||||
|
|
||||||
|
inv[4] = -m_sharedMatrix->m21 * m_sharedMatrix->m33 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m23;
|
||||||
|
|
||||||
|
inv[5] = m_sharedMatrix->m11 * m_sharedMatrix->m33 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m13;
|
||||||
|
|
||||||
|
inv[6] = -m_sharedMatrix->m11 * m_sharedMatrix->m23 +
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m13;
|
||||||
|
|
||||||
|
inv[7] = F(0.0);
|
||||||
|
|
||||||
|
inv[8] = m_sharedMatrix->m21 * m_sharedMatrix->m32 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m22;
|
||||||
|
|
||||||
|
inv[9] = -m_sharedMatrix->m11 * m_sharedMatrix->m32 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m12;
|
||||||
|
|
||||||
|
inv[10] = m_sharedMatrix->m11 * m_sharedMatrix->m22 -
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m12;
|
||||||
|
|
||||||
|
inv[11] = F(0.0);
|
||||||
|
|
||||||
|
inv[12] = -m_sharedMatrix->m21 * m_sharedMatrix->m32 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m33 * m_sharedMatrix->m42 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m22 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m23 * m_sharedMatrix->m42 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m22 * m_sharedMatrix->m33 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m23 * m_sharedMatrix->m32;
|
||||||
|
|
||||||
|
inv[13] = m_sharedMatrix->m11 * m_sharedMatrix->m32 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m11 * m_sharedMatrix->m33 * m_sharedMatrix->m42 -
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m12 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m31 * m_sharedMatrix->m13 * m_sharedMatrix->m42 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m12 * m_sharedMatrix->m33 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m13 * m_sharedMatrix->m32;
|
||||||
|
|
||||||
|
inv[14] = -m_sharedMatrix->m11 * m_sharedMatrix->m22 * m_sharedMatrix->m43 +
|
||||||
|
m_sharedMatrix->m11 * m_sharedMatrix->m23 * m_sharedMatrix->m42 +
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m12 * m_sharedMatrix->m43 -
|
||||||
|
m_sharedMatrix->m21 * m_sharedMatrix->m13 * m_sharedMatrix->m42 -
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m12 * m_sharedMatrix->m23 +
|
||||||
|
m_sharedMatrix->m41 * m_sharedMatrix->m13 * m_sharedMatrix->m22;
|
||||||
|
|
||||||
|
inv[15] = F(0.0);
|
||||||
|
|
||||||
|
T invDet = F(1.0) / det;
|
||||||
|
for (unsigned int i = 0; i < 16; ++i)
|
||||||
|
inv[i] *= invDet;
|
||||||
|
|
||||||
|
inv[15] = F(1.0);
|
||||||
|
|
||||||
|
Set(inv);
|
||||||
|
if (succeeded)
|
||||||
|
*succeeded = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NazaraError("Matrix has no inverse");
|
||||||
|
if (succeeded)
|
||||||
|
*succeeded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool NzMatrix4<T>::IsAffine() const
|
bool NzMatrix4<T>::IsAffine() const
|
||||||
{
|
{
|
||||||
|
|
@ -244,26 +487,30 @@ bool NzMatrix4<T>::IsDefined() const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::MakeIdentity()
|
NzMatrix4<T>& NzMatrix4<T>::MakeIdentity()
|
||||||
{
|
{
|
||||||
Set(F(1.0), F(0.0), F(0.0), F(0.0),
|
Set(F(1.0), F(0.0), F(0.0), F(0.0),
|
||||||
F(0.0), F(1.0), F(0.0), F(0.0),
|
F(0.0), F(1.0), F(0.0), F(0.0),
|
||||||
F(0.0), F(0.0), F(1.0), F(0.0),
|
F(0.0), F(0.0), F(1.0), F(0.0),
|
||||||
F(0.0), F(0.0), F(0.0), F(1.0));
|
F(0.0), F(0.0), F(0.0), F(1.0));
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::MakeOrtho(T left, T top, T width, T height, T zNear, T zFar)
|
NzMatrix4<T>& NzMatrix4<T>::MakeOrtho(T left, T top, T width, T height, T zNear, T zFar)
|
||||||
{
|
{
|
||||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb204941(v=vs.85).aspx
|
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb204941(v=vs.85).aspx
|
||||||
Set(F(2.0)/(width-left), F(0.0), F(0.0), -(width+left)/(width-left),
|
Set(F(2.0)/(width-left), F(0.0), F(0.0), -(width+left)/(width-left),
|
||||||
F(0.0), F(2.0)/(top-height), F(0.0), -(top+height)/(top-height),
|
F(0.0), F(2.0)/(top-height), F(0.0), -(top+height)/(top-height),
|
||||||
F(0.0), F(0.0), F(-2.0)/(zFar-zNear), -(zFar+zNear)/(zFar-zNear),
|
F(0.0), F(0.0), F(-2.0)/(zFar-zNear), -(zFar+zNear)/(zFar-zNear),
|
||||||
F(0.0), F(0.0), F(0.0), F(1.0));
|
F(0.0), F(0.0), F(0.0), F(1.0));
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::MakeLookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up)
|
NzMatrix4<T>& NzMatrix4<T>::MakeLookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up)
|
||||||
{
|
{
|
||||||
NzVector3<T> f = NzVector3<T>::Normalize(target - eye);
|
NzVector3<T> f = NzVector3<T>::Normalize(target - eye);
|
||||||
NzVector3<T> u(up.GetNormal());
|
NzVector3<T> u(up.GetNormal());
|
||||||
|
|
@ -274,10 +521,12 @@ void NzMatrix4<T>::MakeLookAt(const NzVector3<T>& eye, const NzVector3<T>& targe
|
||||||
s.y, u.y, -f.y, T(0.0),
|
s.y, u.y, -f.y, T(0.0),
|
||||||
s.z, u.z, -f.z, T(0.0),
|
s.z, u.z, -f.z, T(0.0),
|
||||||
-s.DotProduct(eye), -u.DotProduct(eye), f.DotProduct(eye), T(1.0));
|
-s.DotProduct(eye), -u.DotProduct(eye), f.DotProduct(eye), T(1.0));
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::MakePerspective(T angle, T ratio, T zNear, T zFar)
|
NzMatrix4<T>& NzMatrix4<T>::MakePerspective(T angle, T ratio, T zNear, T zFar)
|
||||||
{
|
{
|
||||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb204944(v=vs.85).aspx
|
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb204944(v=vs.85).aspx
|
||||||
#if NAZARA_MATH_ANGLE_RADIAN
|
#if NAZARA_MATH_ANGLE_RADIAN
|
||||||
|
|
@ -292,10 +541,12 @@ void NzMatrix4<T>::MakePerspective(T angle, T ratio, T zNear, T zFar)
|
||||||
F(0.0), yScale, F(0.0), F(0.0),
|
F(0.0), yScale, F(0.0), F(0.0),
|
||||||
F(0.0), F(0.0), zFar / (zNear-zFar), F(-1.0),
|
F(0.0), F(0.0), zFar / (zNear-zFar), F(-1.0),
|
||||||
F(0.0), F(0.0), (zNear*zFar) / (zNear-zFar), F(0.0));
|
F(0.0), F(0.0), (zNear*zFar) / (zNear-zFar), F(0.0));
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::MakeRotation(const NzQuaternion<T>& rotation)
|
NzMatrix4<T>& NzMatrix4<T>::MakeRotation(const NzQuaternion<T>& rotation)
|
||||||
{
|
{
|
||||||
// http://www.flipcode.com/documents/matrfaq.html#Q54
|
// http://www.flipcode.com/documents/matrfaq.html#Q54
|
||||||
/*
|
/*
|
||||||
|
|
@ -309,7 +560,7 @@ void NzMatrix4<T>::MakeRotation(const NzQuaternion<T>& rotation)
|
||||||
| 2XZ + 2YW 2YZ - 2XW 1 - 2X - 2Y |
|
| 2XZ + 2YW 2YZ - 2XW 1 - 2X - 2Y |
|
||||||
| |
|
| |
|
||||||
*/
|
*/
|
||||||
///FIXME: À corriger (Rotation quaternino != rotation matricielle)
|
///FIXME: À corriger (Rotation quaternion != rotation matricielle)
|
||||||
Set(F(1.0) - F(2.0)*rotation.y*rotation.y - F(2.0)*rotation.z*rotation.z,
|
Set(F(1.0) - F(2.0)*rotation.y*rotation.y - F(2.0)*rotation.z*rotation.z,
|
||||||
F(2.0)*rotation.x*rotation.y + F(2.0)*rotation.z*rotation.w,
|
F(2.0)*rotation.x*rotation.y + F(2.0)*rotation.z*rotation.w,
|
||||||
F(2.0)*rotation.x*rotation.z - F(2.0)*rotation.y*rotation.w,
|
F(2.0)*rotation.x*rotation.z - F(2.0)*rotation.y*rotation.w,
|
||||||
|
|
@ -329,43 +580,71 @@ void NzMatrix4<T>::MakeRotation(const NzQuaternion<T>& rotation)
|
||||||
F(0.0),
|
F(0.0),
|
||||||
F(0.0),
|
F(0.0),
|
||||||
F(1.0));
|
F(1.0));
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::MakeScale(const NzVector3<T>& scale)
|
NzMatrix4<T>& NzMatrix4<T>::MakeScale(const NzVector3<T>& scale)
|
||||||
{
|
{
|
||||||
Set(scale.x, F(0.0), F(0.0), F(0.0),
|
Set(scale.x, F(0.0), F(0.0), F(0.0),
|
||||||
F(0.0), scale.y, F(0.0), F(0.0),
|
F(0.0), scale.y, F(0.0), F(0.0),
|
||||||
F(0.0), F(0.0), scale.z, F(0.0),
|
F(0.0), F(0.0), scale.z, F(0.0),
|
||||||
F(0.0), F(0.0), F(0.0), F(1.0));
|
F(0.0), F(0.0), F(0.0), F(1.0));
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::MakeTranslation(const NzVector3<T>& translation)
|
NzMatrix4<T>& NzMatrix4<T>::MakeTranslation(const NzVector3<T>& translation)
|
||||||
{
|
{
|
||||||
Set(F(1.0), F(0.0), F(0.0), F(0.0),
|
Set(F(1.0), F(0.0), F(0.0), F(0.0),
|
||||||
F(0.0), F(1.0), F(0.0), F(0.0),
|
F(0.0), F(1.0), F(0.0), F(0.0),
|
||||||
F(0.0), F(0.0), F(1.0), F(0.0),
|
F(0.0), F(0.0), F(1.0), F(0.0),
|
||||||
translation.x, translation.y, translation.z, F(1.0));
|
translation.x, translation.y, translation.z, F(1.0));
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::MakeZero()
|
NzMatrix4<T>& NzMatrix4<T>::MakeTransform(const NzVector3<T>& translation, const NzVector3<T>& scale, const NzQuaternion<T>& rotation)
|
||||||
|
{
|
||||||
|
// La rotation et la translation peuvent être appliquées directement
|
||||||
|
SetRotation(rotation);
|
||||||
|
SetTranslation(translation);
|
||||||
|
|
||||||
|
// On complète la matrice (les transformations sont affines)
|
||||||
|
m_sharedMatrix->m14 = F(0.0);
|
||||||
|
m_sharedMatrix->m24 = F(0.0);
|
||||||
|
m_sharedMatrix->m34 = F(0.0);
|
||||||
|
m_sharedMatrix->m44 = F(1.0);
|
||||||
|
|
||||||
|
// Ensuite on fait une mise à l'échelle des valeurs déjà présentes
|
||||||
|
ApplyScale(scale);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzMatrix4<T>& NzMatrix4<T>::MakeZero()
|
||||||
{
|
{
|
||||||
Set(F(0.0), F(0.0), F(0.0), F(0.0),
|
Set(F(0.0), F(0.0), F(0.0), F(0.0),
|
||||||
F(0.0), F(0.0), F(0.0), F(0.0),
|
F(0.0), F(0.0), F(0.0), F(0.0),
|
||||||
F(0.0), F(0.0), F(0.0), F(0.0),
|
F(0.0), F(0.0), F(0.0), F(0.0),
|
||||||
F(0.0), F(0.0), F(0.0), F(0.0));
|
F(0.0), F(0.0), F(0.0), F(0.0));
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::Set(T r11, T r12, T r13, T r14,
|
NzMatrix4<T>& NzMatrix4<T>::Set(T r11, T r12, T r13, T r14,
|
||||||
T r21, T r22, T r23, T r24,
|
T r21, T r22, T r23, T r24,
|
||||||
T r31, T r32, T r33, T r34,
|
T r31, T r32, T r33, T r34,
|
||||||
T r41, T r42, T r43, T r44)
|
T r41, T r42, T r43, T r44)
|
||||||
{
|
{
|
||||||
EnsureOwnership();
|
ReleaseMatrix();
|
||||||
|
|
||||||
|
m_sharedMatrix = new SharedMatrix;
|
||||||
m_sharedMatrix->m11 = r11;
|
m_sharedMatrix->m11 = r11;
|
||||||
m_sharedMatrix->m12 = r12;
|
m_sharedMatrix->m12 = r12;
|
||||||
m_sharedMatrix->m13 = r13;
|
m_sharedMatrix->m13 = r13;
|
||||||
|
|
@ -382,19 +661,24 @@ void NzMatrix4<T>::Set(T r11, T r12, T r13, T r14,
|
||||||
m_sharedMatrix->m42 = r42;
|
m_sharedMatrix->m42 = r42;
|
||||||
m_sharedMatrix->m43 = r43;
|
m_sharedMatrix->m43 = r43;
|
||||||
m_sharedMatrix->m44 = r44;
|
m_sharedMatrix->m44 = r44;
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::Set(const T matrix[16])
|
NzMatrix4<T>& NzMatrix4<T>::Set(const T matrix[16])
|
||||||
{
|
{
|
||||||
EnsureOwnership();
|
ReleaseMatrix();
|
||||||
|
|
||||||
|
m_sharedMatrix = new SharedMatrix;
|
||||||
// Ici nous sommes certains de la continuité des éléments en mémoire
|
// Ici nous sommes certains de la continuité des éléments en mémoire
|
||||||
std::memcpy(&m_sharedMatrix->m11, matrix, 16*sizeof(T));
|
std::memcpy(&m_sharedMatrix->m11, matrix, 16*sizeof(T));
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::Set(const NzMatrix4& matrix)
|
NzMatrix4<T>& NzMatrix4<T>::Set(const NzMatrix4& matrix)
|
||||||
{
|
{
|
||||||
ReleaseMatrix();
|
ReleaseMatrix();
|
||||||
|
|
||||||
|
|
@ -405,26 +689,32 @@ void NzMatrix4<T>::Set(const NzMatrix4& matrix)
|
||||||
m_sharedMatrix->refCount++;
|
m_sharedMatrix->refCount++;
|
||||||
NazaraMutexUnlock(m_sharedMatrix->mutex);
|
NazaraMutexUnlock(m_sharedMatrix->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::Set(NzMatrix4&& matrix)
|
NzMatrix4<T>& NzMatrix4<T>::Set(NzMatrix4&& matrix)
|
||||||
{
|
{
|
||||||
std::swap(m_sharedMatrix, matrix.m_sharedMatrix);
|
std::swap(m_sharedMatrix, matrix.m_sharedMatrix);
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
template<typename U>
|
template<typename U>
|
||||||
void NzMatrix4<T>::Set(const NzMatrix4<U>& matrix)
|
NzMatrix4<T>& NzMatrix4<T>::Set(const NzMatrix4<U>& matrix)
|
||||||
{
|
{
|
||||||
Set(F(matrix.m_sharedMatrix->m11), F(matrix.m_sharedMatrix->m12), F(matrix.m_sharedMatrix->m13), F(matrix.m_sharedMatrix->m14),
|
Set(F(matrix.m_sharedMatrix->m11), F(matrix.m_sharedMatrix->m12), F(matrix.m_sharedMatrix->m13), F(matrix.m_sharedMatrix->m14),
|
||||||
F(matrix.m_sharedMatrix->m21), F(matrix.m_sharedMatrix->m22), F(matrix.m_sharedMatrix->m23), F(matrix.m_sharedMatrix->m24),
|
F(matrix.m_sharedMatrix->m21), F(matrix.m_sharedMatrix->m22), F(matrix.m_sharedMatrix->m23), F(matrix.m_sharedMatrix->m24),
|
||||||
F(matrix.m_sharedMatrix->m31), F(matrix.m_sharedMatrix->m32), F(matrix.m_sharedMatrix->m33), F(matrix.m_sharedMatrix->m34),
|
F(matrix.m_sharedMatrix->m31), F(matrix.m_sharedMatrix->m32), F(matrix.m_sharedMatrix->m33), F(matrix.m_sharedMatrix->m34),
|
||||||
F(matrix.m_sharedMatrix->m41), F(matrix.m_sharedMatrix->m42), F(matrix.m_sharedMatrix->m43), F(matrix.m_sharedMatrix->m44));
|
F(matrix.m_sharedMatrix->m41), F(matrix.m_sharedMatrix->m42), F(matrix.m_sharedMatrix->m43), F(matrix.m_sharedMatrix->m44));
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::SetRotation(const NzQuaternion<T>& rotation)
|
NzMatrix4<T>& NzMatrix4<T>::SetRotation(const NzQuaternion<T>& rotation)
|
||||||
{
|
{
|
||||||
// http://www.flipcode.com/documents/matrfaq.html#Q54
|
// http://www.flipcode.com/documents/matrfaq.html#Q54
|
||||||
EnsureOwnership();
|
EnsureOwnership();
|
||||||
|
|
@ -439,20 +729,24 @@ void NzMatrix4<T>::SetRotation(const NzQuaternion<T>& rotation)
|
||||||
m_sharedMatrix->m23 = F(2.0)*rotation.y*rotation.z - F(2.0)*rotation.x*rotation.w;
|
m_sharedMatrix->m23 = F(2.0)*rotation.y*rotation.z - F(2.0)*rotation.x*rotation.w;
|
||||||
m_sharedMatrix->m31 = F(2.0)*rotation.x*rotation.z - F(2.0)*rotation.y*rotation.w;
|
m_sharedMatrix->m31 = F(2.0)*rotation.x*rotation.z - F(2.0)*rotation.y*rotation.w;
|
||||||
m_sharedMatrix->m32 = F(2.0)*rotation.y*rotation.z + F(2.0)*rotation.x*rotation.w;
|
m_sharedMatrix->m32 = F(2.0)*rotation.y*rotation.z + F(2.0)*rotation.x*rotation.w;
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::SetScale(const NzVector3<T>& scale)
|
NzMatrix4<T>& NzMatrix4<T>::SetScale(const NzVector3<T>& scale)
|
||||||
{
|
{
|
||||||
EnsureOwnership();
|
EnsureOwnership();
|
||||||
|
|
||||||
m_sharedMatrix->m11 = scale.x;
|
m_sharedMatrix->m11 = scale.x;
|
||||||
m_sharedMatrix->m22 = scale.y;
|
m_sharedMatrix->m22 = scale.y;
|
||||||
m_sharedMatrix->m33 = scale.z;
|
m_sharedMatrix->m33 = scale.z;
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzMatrix4<T>::SetTranslation(const NzVector3<T>& translation)
|
NzMatrix4<T>& NzMatrix4<T>::SetTranslation(const NzVector3<T>& translation)
|
||||||
{
|
{
|
||||||
EnsureOwnership();
|
EnsureOwnership();
|
||||||
|
|
||||||
|
|
@ -460,6 +754,8 @@ void NzMatrix4<T>::SetTranslation(const NzVector3<T>& translation)
|
||||||
m_sharedMatrix->m42 = translation.y;
|
m_sharedMatrix->m42 = translation.y;
|
||||||
m_sharedMatrix->m43 = translation.z;
|
m_sharedMatrix->m43 = translation.z;
|
||||||
m_sharedMatrix->m44 = F(1.0);
|
m_sharedMatrix->m44 = F(1.0);
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -534,6 +830,8 @@ NzMatrix4<T>& NzMatrix4<T>::Transpose()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
EnsureOwnership();
|
||||||
|
|
||||||
std::swap(m_sharedMatrix->m12, m_sharedMatrix->m21);
|
std::swap(m_sharedMatrix->m12, m_sharedMatrix->m21);
|
||||||
std::swap(m_sharedMatrix->m13, m_sharedMatrix->m31);
|
std::swap(m_sharedMatrix->m13, m_sharedMatrix->m31);
|
||||||
std::swap(m_sharedMatrix->m14, m_sharedMatrix->m41);
|
std::swap(m_sharedMatrix->m14, m_sharedMatrix->m41);
|
||||||
|
|
@ -544,6 +842,14 @@ NzMatrix4<T>& NzMatrix4<T>::Transpose()
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzMatrix4<T>& NzMatrix4<T>::Undefine()
|
||||||
|
{
|
||||||
|
ReleaseMatrix();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzMatrix4<T>::operator NzString() const
|
NzMatrix4<T>::operator NzString() const
|
||||||
{
|
{
|
||||||
|
|
@ -734,7 +1040,7 @@ bool NzMatrix4<T>::operator==(const NzMatrix4& mat) const
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 16; ++i)
|
for (unsigned int i = 0; i < 16; ++i)
|
||||||
if (!NzNumberEquals((&m_sharedMatrix->m11)[i]))
|
if (!NzNumberEquals((&m_sharedMatrix->m11)[i], (&mat.m_sharedMatrix->m11)[i]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -904,6 +1210,15 @@ NzMatrix4<T> NzMatrix4<T>::Translate(const NzVector3<T>& translation)
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzMatrix4<T> NzMatrix4<T>::Transform(const NzVector3<T>& translation, const NzVector3<T>& scale, const NzQuaternion<T>& rotation)
|
||||||
|
{
|
||||||
|
NzMatrix4 mat;
|
||||||
|
mat.MakeTransform(translation, scale, rotation);
|
||||||
|
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzMatrix4<T> NzMatrix4<T>::Zero()
|
NzMatrix4<T> NzMatrix4<T>::Zero()
|
||||||
{
|
{
|
||||||
|
|
@ -937,6 +1252,8 @@ void NzMatrix4<T>::EnsureOwnership()
|
||||||
|
|
||||||
SharedMatrix* sharedMatrix = new SharedMatrix;
|
SharedMatrix* sharedMatrix = new SharedMatrix;
|
||||||
std::memcpy(&sharedMatrix->m11, &m_sharedMatrix->m11, 16*sizeof(T));
|
std::memcpy(&sharedMatrix->m11, &m_sharedMatrix->m11, 16*sizeof(T));
|
||||||
|
|
||||||
|
m_sharedMatrix = sharedMatrix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,8 @@ template<typename T> class NzQuaternion
|
||||||
bool operator>=(const NzQuaternion& quat) const;
|
bool operator>=(const NzQuaternion& quat) const;
|
||||||
|
|
||||||
static NzQuaternion Identity();
|
static NzQuaternion Identity();
|
||||||
static NzQuaternion Slerp(const NzQuaternion& quatA, const NzQuaternion& quatB, T interp);
|
static NzQuaternion Lerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation);
|
||||||
|
static NzQuaternion Slerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation);
|
||||||
static NzQuaternion Zero();
|
static NzQuaternion Zero();
|
||||||
|
|
||||||
T w, x, y, z;
|
T w, x, y, z;
|
||||||
|
|
|
||||||
|
|
@ -365,32 +365,54 @@ NzQuaternion<T> NzQuaternion<T>::Identity()
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzQuaternion<T> NzQuaternion<T>::Slerp(const NzQuaternion& quatA, const NzQuaternion& quatB, T interp)
|
NzQuaternion<T> NzQuaternion<T>::Lerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation)
|
||||||
{
|
{
|
||||||
if (interp <= F(0.0))
|
#ifdef NAZARA_DEBUG
|
||||||
return quatA;
|
if (interpolation < F(0.0) || interpolation > F(1.0))
|
||||||
|
{
|
||||||
|
NazaraError("Interpolation must be in range [0..1] (Got " + NzString::Number(interpolation) + ')');
|
||||||
|
return Zero();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (interp >= F(1.0))
|
NzQuaternion interpolated;
|
||||||
return quatB;
|
interpolated.w = NzLerp(from.w, to.w, interpolation);
|
||||||
|
interpolated.x = NzLerp(from.x, to.x, interpolation);
|
||||||
|
interpolated.y = NzLerp(from.y, to.y, interpolation);
|
||||||
|
interpolated.z = NzLerp(from.z, to.z, interpolation);
|
||||||
|
|
||||||
|
return interpolated;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzQuaternion<T> NzQuaternion<T>::Slerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation)
|
||||||
|
{
|
||||||
|
#ifdef NAZARA_DEBUG
|
||||||
|
if (interpolation < F(0.0) || interpolation > F(1.0))
|
||||||
|
{
|
||||||
|
NazaraError("Interpolation must be in range [0..1] (Got " + NzString::Number(interpolation) + ')');
|
||||||
|
return Zero();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
NzQuaternion q;
|
NzQuaternion q;
|
||||||
|
|
||||||
T cosOmega = quatA.DotProduct(quatB);
|
T cosOmega = from.DotProduct(to);
|
||||||
if (cosOmega < F(0.0))
|
if (cosOmega < F(0.0))
|
||||||
{
|
{
|
||||||
// On inverse tout
|
// On inverse tout
|
||||||
q.Set(-quatB.w, -quatB.x, -quatB.y, -quatB.z);
|
q.Set(-to.w, -to.x, -to.y, -to.z);
|
||||||
cosOmega = -cosOmega;
|
cosOmega = -cosOmega;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
q.Set(quatB);
|
q.Set(to);
|
||||||
|
|
||||||
T k0, k1;
|
T k0, k1;
|
||||||
if (cosOmega > F(0.9999))
|
if (cosOmega > F(0.9999))
|
||||||
{
|
{
|
||||||
// Interpolation linéaire pour éviter une division par zéro
|
// Interpolation linéaire pour éviter une division par zéro
|
||||||
k0 = F(1.0) - interp;
|
k0 = F(1.0) - interpolation;
|
||||||
k1 = interp;
|
k1 = interpolation;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -400,11 +422,11 @@ NzQuaternion<T> NzQuaternion<T>::Slerp(const NzQuaternion& quatA, const NzQuater
|
||||||
// Pour éviter deux divisions
|
// Pour éviter deux divisions
|
||||||
sinOmega = F(1.0)/sinOmega;
|
sinOmega = F(1.0)/sinOmega;
|
||||||
|
|
||||||
k0 = std::sin((F(1.0) - interp) * omega) * sinOmega;
|
k0 = std::sin((F(1.0) - interpolation) * omega) * sinOmega;
|
||||||
k1 = std::sin(interp*omega) * sinOmega;
|
k1 = std::sin(interpolation*omega) * sinOmega;
|
||||||
}
|
}
|
||||||
|
|
||||||
NzQuaternion result(k0 * quatA.w, k0 * quatA.x, k0 * quatA.y, k0 * quatA.z);
|
NzQuaternion result(k0 * from.w, k0 * from.x, k0 * from.y, k0 * from.z);
|
||||||
return result += q*k1;
|
return result += q*k1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@ class NzRect
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
|
void MakeZero();
|
||||||
|
|
||||||
void Set(T X, T Y, T Width, T Height);
|
void Set(T X, T Y, T Width, T Height);
|
||||||
void Set(const T rect[4]);
|
void Set(const T rect[4]);
|
||||||
void Set(const NzVector2<T>& vec1, const NzVector2<T>& vec2);
|
void Set(const NzVector2<T>& vec1, const NzVector2<T>& vec2);
|
||||||
|
|
@ -47,6 +49,16 @@ class NzRect
|
||||||
T& operator[](unsigned int i);
|
T& operator[](unsigned int i);
|
||||||
T operator[](unsigned int i) const;
|
T operator[](unsigned int i) const;
|
||||||
|
|
||||||
|
NzRect operator*(T scalar) const;
|
||||||
|
|
||||||
|
NzRect& operator*=(T scalar);
|
||||||
|
|
||||||
|
bool operator==(const NzRect& rect) const;
|
||||||
|
bool operator!=(const NzRect& rect) const;
|
||||||
|
|
||||||
|
static NzRect Lerp(const NzRect& from, const NzRect& to, T interpolation);
|
||||||
|
static NzRect Zero();
|
||||||
|
|
||||||
T x, y, width, height;
|
T x, y, width, height;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,15 @@ bool NzRect<T>::IsValid() const
|
||||||
return width > F(0.0) && height > F(0.0);
|
return width > F(0.0) && height > F(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void NzRect<T>::MakeZero()
|
||||||
|
{
|
||||||
|
x = F(0.0);
|
||||||
|
y = F(0.0);
|
||||||
|
width = F(0.0);
|
||||||
|
height = F(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzRect<T>::Set(T X, T Y, T Width, T Height)
|
void NzRect<T>::Set(T X, T Y, T Width, T Height)
|
||||||
{
|
{
|
||||||
|
|
@ -195,6 +204,61 @@ T NzRect<T>::operator[](unsigned int i) const
|
||||||
return *(&x+i);
|
return *(&x+i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzRect<T> NzRect<T>::operator*(T scalar) const
|
||||||
|
{
|
||||||
|
return NzRect(x, y, width*scalar, height*scalar);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzRect<T>& NzRect<T>::operator*=(T scalar)
|
||||||
|
{
|
||||||
|
width *= scalar;
|
||||||
|
height *= scalar;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzRect<T>::operator==(const NzRect& rect) const
|
||||||
|
{
|
||||||
|
return NzNumberEquals(x, rect.x) && NzNumberEquals(y, rect.y) &&
|
||||||
|
NzNumberEquals(width, rect.width) && NzNumberEquals(height, rect.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NzRect<T>::operator!=(const NzRect& rect) const
|
||||||
|
{
|
||||||
|
return !operator==(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzRect<T> NzRect<T>::Lerp(const NzRect& from, const NzRect& to, T interpolation)
|
||||||
|
{
|
||||||
|
#ifdef NAZARA_DEBUG
|
||||||
|
if (interpolation < F(0.0) || interpolation > F(1.0))
|
||||||
|
{
|
||||||
|
NazaraError("Interpolation must be in range [0..1] (Got " + NzString::Number(interpolation) + ')');
|
||||||
|
return Zero();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NzRect rect;
|
||||||
|
rect.x = NzLerp(from.x, to.x, interpolation);
|
||||||
|
rect.y = NzLerp(from.y, to.y, interpolation);
|
||||||
|
rect.width = NzLerp(from.width, to.width, interpolation);
|
||||||
|
rect.height = NzLerp(from.height, to.height, interpolation);
|
||||||
|
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzRect<T> NzRect<T>::Zero()
|
||||||
|
{
|
||||||
|
NzRect rect;
|
||||||
|
rect.MakeZero();
|
||||||
|
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::ostream& operator<<(std::ostream& out, const NzRect<T>& rect)
|
std::ostream& operator<<(std::ostream& out, const NzRect<T>& rect)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ template<typename T> class NzVector2
|
||||||
bool operator>(const NzVector2& vec) const;
|
bool operator>(const NzVector2& vec) const;
|
||||||
bool operator>=(const NzVector2& vec) const;
|
bool operator>=(const NzVector2& vec) const;
|
||||||
|
|
||||||
|
static NzVector2 Lerp(const NzVector2& from, const NzVector2& to, T interpolation);
|
||||||
static NzVector2 UnitX();
|
static NzVector2 UnitX();
|
||||||
static NzVector2 UnitY();
|
static NzVector2 UnitY();
|
||||||
static NzVector2 Zero();
|
static NzVector2 Zero();
|
||||||
|
|
|
||||||
|
|
@ -428,6 +428,12 @@ bool NzVector2<T>::operator>=(const NzVector2& vec) const
|
||||||
return !operator<(vec);
|
return !operator<(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzVector2<T> NzVector2<T>::Lerp(const NzVector2& from, const NzVector2& to, T interpolation)
|
||||||
|
{
|
||||||
|
return NzLerp(from, to, interpolation);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzVector2<T> NzVector2<T>::UnitX()
|
NzVector2<T> NzVector2<T>::UnitX()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ template<typename T> class NzVector3
|
||||||
static T DotProduct(const NzVector3& vec1, const NzVector3& vec2);
|
static T DotProduct(const NzVector3& vec1, const NzVector3& vec2);
|
||||||
static NzVector3 Forward();
|
static NzVector3 Forward();
|
||||||
static NzVector3 Left();
|
static NzVector3 Left();
|
||||||
|
static NzVector3 Lerp(const NzVector3& from, const NzVector3& to, T interpolation);
|
||||||
static NzVector3 Normalize(const NzVector3& vec);
|
static NzVector3 Normalize(const NzVector3& vec);
|
||||||
static NzVector3 UnitX();
|
static NzVector3 UnitX();
|
||||||
static NzVector3 UnitY();
|
static NzVector3 UnitY();
|
||||||
|
|
|
||||||
|
|
@ -515,6 +515,12 @@ NzVector3<T> NzVector3<T>::Left()
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzVector3<T> NzVector3<T>::Lerp(const NzVector3& from, const NzVector3& to, T interpolation)
|
||||||
|
{
|
||||||
|
return NzLerp(from, to, interpolation);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzVector3<T> NzVector3<T>::Normalize(const NzVector3& vec)
|
NzVector3<T> NzVector3<T>::Normalize(const NzVector3& vec)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,20 +37,32 @@
|
||||||
|
|
||||||
///TODO: Rajouter des tests d'identification de compilateurs
|
///TODO: Rajouter des tests d'identification de compilateurs
|
||||||
// NAZARA_THREADLOCAL n'existe qu'en attendant le support complet de thread_local
|
// NAZARA_THREADLOCAL n'existe qu'en attendant le support complet de thread_local
|
||||||
#if defined(_MSC_VER)
|
#if defined(__BORLANDC__)
|
||||||
#define NAZARA_COMPILER_MSVC
|
#define NAZARA_COMPILER_BORDLAND
|
||||||
#define NAZARA_DEPRECATED(txt) __declspec(deprecated(txt))
|
#define NAZARA_DEPRECATED(txt)
|
||||||
#define NAZARA_FUNCTION __FUNCSIG__
|
#define NAZARA_FUNCTION __FUNC__
|
||||||
#define NAZARA_THREADLOCAL __declspec(thread)
|
#define NAZARA_THREADLOCAL __declspec(thread)
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__clang__)
|
||||||
|
#define NAZARA_COMPILER_CLANG
|
||||||
|
#define NAZARA_DEPRECATED(txt) __attribute__((__deprecated__(txt)))
|
||||||
|
#define NAZARA_FUNCTION __PRETTY_FUNCTION__
|
||||||
|
#define NAZARA_THREADLOCAL __declspec(thread)
|
||||||
|
#elif defined(__GNUC__) || defined(__MINGW32__)
|
||||||
#define NAZARA_COMPILER_GCC
|
#define NAZARA_COMPILER_GCC
|
||||||
#define NAZARA_DEPRECATED(txt) __attribute__((__deprecated__(txt)))
|
#define NAZARA_DEPRECATED(txt) __attribute__((__deprecated__(txt)))
|
||||||
#define NAZARA_FUNCTION __PRETTY_FUNCTION__
|
#define NAZARA_FUNCTION __PRETTY_FUNCTION__
|
||||||
#define NAZARA_THREADLOCAL __thread
|
#define NAZARA_THREADLOCAL __thread
|
||||||
#elif defined(__BORLANDC__)
|
|
||||||
#define NAZARA_COMPILER_BORDLAND
|
#ifdef __MINGW32__
|
||||||
#define NAZARA_DEPRECATED(txt)
|
#define NAZARA_COMPILER_MINGW
|
||||||
#define NAZARA_FUNCTION __FUNC__
|
#ifdef __MINGW64_VERSION_MAJOR
|
||||||
|
#define NAZARA_COMPILER_MINGW_W64
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
#define NAZARA_COMPILER_MSVC
|
||||||
|
#define NAZARA_DEPRECATED(txt) __declspec(deprecated(txt))
|
||||||
|
#define NAZARA_FUNCTION __FUNCSIG__
|
||||||
#define NAZARA_THREADLOCAL __declspec(thread)
|
#define NAZARA_THREADLOCAL __declspec(thread)
|
||||||
#else
|
#else
|
||||||
#define NAZARA_COMPILER_UNKNOWN
|
#define NAZARA_COMPILER_UNKNOWN
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#ifdef NAZARA_RENDERER_OPENGL
|
#ifdef NAZARA_RENDERER_OPENGL
|
||||||
|
|
||||||
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||||
|
|
||||||
|
|
@ -19,7 +20,7 @@ class NAZARA_API NzContext : public NzResource
|
||||||
friend NzContextImpl;
|
friend NzContextImpl;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NzContext();
|
NzContext() = default;
|
||||||
~NzContext();
|
~NzContext();
|
||||||
|
|
||||||
bool Create(const NzContextParameters& parameters = NzContextParameters());
|
bool Create(const NzContextParameters& parameters = NzContextParameters());
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ NAZARA_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||||
NAZARA_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
|
NAZARA_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
|
||||||
NAZARA_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog;
|
NAZARA_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog;
|
||||||
NAZARA_API extern PFNGLGETERRORPROC glGetError;
|
NAZARA_API extern PFNGLGETERRORPROC glGetError;
|
||||||
|
NAZARA_API extern PFNGLGETFLOATVPROC glGetFloatv;
|
||||||
NAZARA_API extern PFNGLGETINTEGERVPROC glGetIntegerv;
|
NAZARA_API extern PFNGLGETINTEGERVPROC glGetIntegerv;
|
||||||
NAZARA_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
NAZARA_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
||||||
NAZARA_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
NAZARA_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
||||||
|
|
@ -168,10 +169,12 @@ NAZARA_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv;
|
||||||
NAZARA_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv;
|
NAZARA_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv;
|
||||||
NAZARA_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv;
|
NAZARA_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv;
|
||||||
NAZARA_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
NAZARA_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||||
|
NAZARA_API extern PFNGLLINEWIDTHPROC glLineWidth;
|
||||||
NAZARA_API extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
NAZARA_API extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||||
NAZARA_API extern PFNGLMAPBUFFERPROC glMapBuffer;
|
NAZARA_API extern PFNGLMAPBUFFERPROC glMapBuffer;
|
||||||
NAZARA_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
NAZARA_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
||||||
NAZARA_API extern PFNGLPIXELSTOREIPROC glPixelStorei;
|
NAZARA_API extern PFNGLPIXELSTOREIPROC glPixelStorei;
|
||||||
|
NAZARA_API extern PFNGLPOINTSIZEPROC glPointSize;
|
||||||
NAZARA_API extern PFNGLPOLYGONMODEPROC glPolygonMode;
|
NAZARA_API extern PFNGLPOLYGONMODEPROC glPolygonMode;
|
||||||
NAZARA_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d;
|
NAZARA_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d;
|
||||||
NAZARA_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f;
|
NAZARA_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f;
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,13 @@ class NAZARA_API NzRenderer
|
||||||
|
|
||||||
static void Enable(nzRendererParameter parameter, bool enable);
|
static void Enable(nzRendererParameter parameter, bool enable);
|
||||||
|
|
||||||
|
float GetLineWidth();
|
||||||
//static NzMatrix4f GetMatrix(nzMatrixCombination combination);
|
//static NzMatrix4f GetMatrix(nzMatrixCombination combination);
|
||||||
static NzMatrix4f GetMatrix(nzMatrixType type);
|
static NzMatrix4f GetMatrix(nzMatrixType type);
|
||||||
static unsigned int GetMaxAnisotropyLevel();
|
static unsigned int GetMaxAnisotropyLevel();
|
||||||
static unsigned int GetMaxRenderTargets();
|
static unsigned int GetMaxRenderTargets();
|
||||||
static unsigned int GetMaxTextureUnits();
|
static unsigned int GetMaxTextureUnits();
|
||||||
|
static float GetPointSize();
|
||||||
static NzShader* GetShader();
|
static NzShader* GetShader();
|
||||||
static NzRenderTarget* GetTarget();
|
static NzRenderTarget* GetTarget();
|
||||||
static NzRectui GetViewport();
|
static NzRectui GetViewport();
|
||||||
|
|
@ -59,7 +61,9 @@ class NAZARA_API NzRenderer
|
||||||
static void SetFaceCulling(nzFaceCulling cullingMode);
|
static void SetFaceCulling(nzFaceCulling cullingMode);
|
||||||
static void SetFaceFilling(nzFaceFilling fillingMode);
|
static void SetFaceFilling(nzFaceFilling fillingMode);
|
||||||
static bool SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
static bool SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
||||||
|
static void SetLineWidth(float size);
|
||||||
static void SetMatrix(nzMatrixType type, const NzMatrix4f& matrix);
|
static void SetMatrix(nzMatrixType type, const NzMatrix4f& matrix);
|
||||||
|
static void SetPointSize(float size);
|
||||||
static bool SetShader(NzShader* shader);
|
static bool SetShader(NzShader* shader);
|
||||||
static void SetStencilCompareFunction(nzRendererComparison compareFunc);
|
static void SetStencilCompareFunction(nzRendererComparison compareFunc);
|
||||||
static void SetStencilFailOperation(nzStencilOperation failOperation);
|
static void SetStencilFailOperation(nzStencilOperation failOperation);
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ class NAZARA_API NzShader : public NzResource, NzNonCopyable
|
||||||
|
|
||||||
bool IsCompiled() const;
|
bool IsCompiled() const;
|
||||||
bool IsLoaded(nzShaderType type) const;
|
bool IsLoaded(nzShaderType type) const;
|
||||||
|
bool IsValid() const;
|
||||||
|
|
||||||
bool Load(nzShaderType type, const NzString& source);
|
bool Load(nzShaderType type, const NzString& source);
|
||||||
bool LoadFromFile(nzShaderType type, const NzString& source);
|
bool LoadFromFile(nzShaderType type, const NzString& source);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class NAZARA_API NzAxisAlignedBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NzAxisAlignedBox();
|
NzAxisAlignedBox();
|
||||||
|
NzAxisAlignedBox(const NzCubef& cube);
|
||||||
NzAxisAlignedBox(const NzVector3f& vec1, const NzVector3f& vec2);
|
NzAxisAlignedBox(const NzVector3f& vec1, const NzVector3f& vec2);
|
||||||
NzAxisAlignedBox(nzExtend extend);
|
NzAxisAlignedBox(nzExtend extend);
|
||||||
|
|
||||||
|
|
@ -37,6 +38,10 @@ class NAZARA_API NzAxisAlignedBox
|
||||||
|
|
||||||
NzString ToString() const;
|
NzString ToString() const;
|
||||||
|
|
||||||
|
operator NzString() const;
|
||||||
|
|
||||||
|
static NzAxisAlignedBox Lerp(const NzAxisAlignedBox& from, const NzAxisAlignedBox& to, float interpolation);
|
||||||
|
|
||||||
static const NzAxisAlignedBox Infinite;
|
static const NzAxisAlignedBox Infinite;
|
||||||
static const NzAxisAlignedBox Null;
|
static const NzAxisAlignedBox Null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#define NAZARA_KEYBOARD_HPP
|
#define NAZARA_KEYBOARD_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Core/String.hpp>
|
||||||
|
|
||||||
class NAZARA_API NzKeyboard
|
class NAZARA_API NzKeyboard
|
||||||
{
|
{
|
||||||
|
|
@ -159,6 +160,7 @@ class NAZARA_API NzKeyboard
|
||||||
Count
|
Count
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static NzString GetKeyName(Key key);
|
||||||
static bool IsKeyPressed(Key key);
|
static bool IsKeyPressed(Key key);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEEK_END:
|
case SEEK_END:
|
||||||
stream->SetCursorPos(stream->GetSize()+offset);
|
stream->SetCursorPos(stream->GetSize() + offset); // L'offset est négatif ici
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
|
|
@ -95,11 +95,18 @@ namespace
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/LaurentGomila/SFML/issues/271
|
||||||
|
// http://www.mega-nerd.com/libsndfile/command.html#SFC_SET_SCALE_FLOAT_INT_READ
|
||||||
|
///FIXME: Seulement le Vorbis ?
|
||||||
|
if (infos.format & SF_FORMAT_VORBIS)
|
||||||
|
sf_command(file, SFC_SET_SCALE_FLOAT_INT_READ, nullptr, SF_TRUE);
|
||||||
|
|
||||||
unsigned int sampleCount = infos.frames*infos.channels;
|
unsigned int sampleCount = infos.frames*infos.channels;
|
||||||
nzInt16* samples = new nzInt16[sampleCount];
|
nzInt16* samples = new nzInt16[sampleCount];
|
||||||
if (sf_read_short(file, samples, sampleCount) != sampleCount)
|
if (sf_read_short(file, samples, sampleCount) != sampleCount)
|
||||||
{
|
{
|
||||||
NazaraError("Failed to read samples");
|
NazaraError("Failed to read samples");
|
||||||
|
|
||||||
delete[] samples;
|
delete[] samples;
|
||||||
sf_close(file);
|
sf_close(file);
|
||||||
|
|
||||||
|
|
@ -109,6 +116,8 @@ namespace
|
||||||
if (!soundBuffer->Create(format, infos.frames*infos.channels, infos.samplerate, samples))
|
if (!soundBuffer->Create(format, infos.frames*infos.channels, infos.samplerate, samples))
|
||||||
{
|
{
|
||||||
NazaraError("Failed to create sound buffer");
|
NazaraError("Failed to create sound buffer");
|
||||||
|
|
||||||
|
delete[] samples;
|
||||||
sf_close(file);
|
sf_close(file);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -123,13 +132,11 @@ namespace
|
||||||
void NzLoaders_sndfile_Register()
|
void NzLoaders_sndfile_Register()
|
||||||
{
|
{
|
||||||
NzSoundBufferLoader::RegisterLoader("aiff,au,avr,caf,flac,htk,ircam,mat4,mat5,mpc2k,nist,ogg,paf,pvf,raw,rf64,sd2,sds,svx,voc,w64,wav,wve",
|
NzSoundBufferLoader::RegisterLoader("aiff,au,avr,caf,flac,htk,ircam,mat4,mat5,mpc2k,nist,ogg,paf,pvf,raw,rf64,sd2,sds,svx,voc,w64,wav,wve",
|
||||||
NzLoader_sndfile_Check,
|
NzLoader_sndfile_Check, NzLoader_sndfile_Load);
|
||||||
NzLoader_sndfile_Load);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzLoaders_sndfile_Unregister()
|
void NzLoaders_sndfile_Unregister()
|
||||||
{
|
{
|
||||||
NzSoundBufferLoader::UnregisterLoader("aiff,au,avr,caf,flac,htk,ircam,mat4,mat5,mpc2k,nist,ogg,paf,pvf,raw,rf64,sd2,sds,svx,voc,w64,wav,wve",
|
NzSoundBufferLoader::UnregisterLoader("aiff,au,avr,caf,flac,htk,ircam,mat4,mat5,mpc2k,nist,ogg,paf,pvf,raw,rf64,sd2,sds,svx,voc,w64,wav,wve",
|
||||||
NzLoader_sndfile_Check,
|
NzLoader_sndfile_Check, NzLoader_sndfile_Load);
|
||||||
NzLoader_sndfile_Load);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,14 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// C'est malheureux mais le spécificateur %z de (f)printf n'est pas supporté partout
|
||||||
|
#ifdef NAZARA_COMPILER_MINGW
|
||||||
|
#define SIZE_T_SPECIFIER "%u"
|
||||||
|
#else
|
||||||
|
#define SIZE_T_SPECIFIER "%zu" // Standard
|
||||||
|
#endif
|
||||||
|
// Le seul fichier n'ayant pas à inclure Debug.hpp
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct Block
|
struct Block
|
||||||
|
|
@ -76,7 +84,7 @@ void* NzMemoryManager::Allocate(std::size_t size, bool multi, const char* file,
|
||||||
{
|
{
|
||||||
// Pas d'information de temps (Car nécessitant une allocation)
|
// Pas d'information de temps (Car nécessitant une allocation)
|
||||||
FILE* log = std::fopen(MLTFileName, "a");
|
FILE* log = std::fopen(MLTFileName, "a");
|
||||||
std::fprintf(log, "Failed to allocate memory (%d bytes)\n", size);
|
std::fprintf(log, "Failed to allocate memory (" SIZE_T_SPECIFIER " bytes)\n", size);
|
||||||
std::fclose(log);
|
std::fclose(log);
|
||||||
|
|
||||||
return nullptr; // Impossible d'envoyer une exception car cela allouerait de la mémoire avec new (boucle infinie)
|
return nullptr; // Impossible d'envoyer une exception car cela allouerait de la mémoire avec new (boucle infinie)
|
||||||
|
|
@ -126,9 +134,9 @@ void NzMemoryManager::Free(void* pointer, bool multi)
|
||||||
if (nextFreeFile)
|
if (nextFreeFile)
|
||||||
{
|
{
|
||||||
if (multi)
|
if (multi)
|
||||||
std::fprintf(log, "%s Warning: delete[] after new at %s:%d\n", time, nextFreeFile, nextFreeLine);
|
std::fprintf(log, "%s Warning: delete[] after new at %s:%u\n", time, nextFreeFile, nextFreeLine);
|
||||||
else
|
else
|
||||||
std::fprintf(log, "%s Warning: delete after new[] at %s:%d\n", time, nextFreeFile, nextFreeLine);
|
std::fprintf(log, "%s Warning: delete after new[] at %s:%u\n", time, nextFreeFile, nextFreeLine);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -224,24 +232,24 @@ void NzMemoryManager::Uninitialize()
|
||||||
std::fprintf(log, "%s ==============================\n\n", time);
|
std::fprintf(log, "%s ==============================\n\n", time);
|
||||||
std::fputs("Leak list:\n", log);
|
std::fputs("Leak list:\n", log);
|
||||||
|
|
||||||
|
std::size_t totalSize = 0;
|
||||||
Block* ptr = ptrList.next;
|
Block* ptr = ptrList.next;
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
unsigned int totalSize = 0;
|
|
||||||
while (ptr != &ptrList)
|
while (ptr != &ptrList)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
totalSize += ptr->size;
|
totalSize += ptr->size;
|
||||||
if (ptr->file)
|
if (ptr->file)
|
||||||
std::fprintf(log, "-0x%p -> %d bytes allocated at %s:%d\n", reinterpret_cast<char*>(ptr)+sizeof(Block), ptr->size, ptr->file, ptr->line);
|
std::fprintf(log, "-0x%p -> " SIZE_T_SPECIFIER " bytes allocated at %s:%u\n", reinterpret_cast<char*>(ptr)+sizeof(Block), ptr->size, ptr->file, ptr->line);
|
||||||
else
|
else
|
||||||
std::fprintf(log, "-0x%p -> %d bytes allocated at unknown position\n", reinterpret_cast<char*>(ptr)+sizeof(Block), ptr->size);
|
std::fprintf(log, "-0x%p -> " SIZE_T_SPECIFIER " bytes allocated at unknown position\n", reinterpret_cast<char*>(ptr)+sizeof(Block), ptr->size);
|
||||||
|
|
||||||
void* pointer = ptr;
|
void* pointer = ptr;
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
std::free(pointer);
|
std::free(pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::fprintf(log, "\n%d blocks leaked (%d bytes)", count, totalSize);
|
std::fprintf(log, "\n%u blocks leaked (" SIZE_T_SPECIFIER " bytes)", count, totalSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::free(time);
|
std::free(time);
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,6 @@ NzDirectoryImpl::NzDirectoryImpl(const NzDirectory* parent)
|
||||||
NazaraUnused(parent);
|
NazaraUnused(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NzDirectoryImpl::~NzDirectoryImpl()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzDirectoryImpl::Close()
|
void NzDirectoryImpl::Close()
|
||||||
{
|
{
|
||||||
FindClose(m_handle);
|
FindClose(m_handle);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class NzDirectoryImpl : NzNonCopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NzDirectoryImpl(const NzDirectory* parent);
|
NzDirectoryImpl(const NzDirectory* parent);
|
||||||
~NzDirectoryImpl();
|
~NzDirectoryImpl() = default;
|
||||||
|
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,6 @@ m_parent(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NzDynLibImpl::~NzDynLibImpl()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
NzDynLibFunc NzDynLibImpl::GetSymbol(const NzString& symbol) const
|
NzDynLibFunc NzDynLibImpl::GetSymbol(const NzString& symbol) const
|
||||||
{
|
{
|
||||||
NzDynLibFunc sym = reinterpret_cast<NzDynLibFunc>(GetProcAddress(m_handle, symbol.GetConstBuffer()));
|
NzDynLibFunc sym = reinterpret_cast<NzDynLibFunc>(GetProcAddress(m_handle, symbol.GetConstBuffer()));
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class NzDynLibImpl : NzNonCopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NzDynLibImpl(NzDynLib* m_parent);
|
NzDynLibImpl(NzDynLib* m_parent);
|
||||||
~NzDynLibImpl();
|
~NzDynLibImpl() = default;
|
||||||
|
|
||||||
NzDynLibFunc GetSymbol(const NzString& symbol) const;
|
NzDynLibFunc GetSymbol(const NzString& symbol) const;
|
||||||
bool Load(const NzString& libraryPath);
|
bool Load(const NzString& libraryPath);
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,6 @@ m_endOfFileUpdated(true)
|
||||||
NazaraUnused(parent);
|
NazaraUnused(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NzFileImpl::~NzFileImpl()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzFileImpl::Close()
|
void NzFileImpl::Close()
|
||||||
{
|
{
|
||||||
CloseHandle(m_handle);
|
CloseHandle(m_handle);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class NzFileImpl : NzNonCopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NzFileImpl(const NzFile* parent);
|
NzFileImpl(const NzFile* parent);
|
||||||
~NzFileImpl();
|
~NzFileImpl() = default;
|
||||||
|
|
||||||
void Close();
|
void Close();
|
||||||
bool EndOfFile() const;
|
bool EndOfFile() const;
|
||||||
|
|
|
||||||
|
|
@ -97,9 +97,9 @@ bool NzGLSLShader::Compile()
|
||||||
if (length > 1)
|
if (length > 1)
|
||||||
{
|
{
|
||||||
m_log.Clear(true);
|
m_log.Clear(true);
|
||||||
m_log.Reserve(length+19-1); // La taille retournée est celle du buffer (Avec caractère de fin)
|
m_log.Reserve(length+15-2); // La taille retournée est celle du buffer (Avec caractère de fin)
|
||||||
m_log.Prepend("Linkage error: ");
|
m_log.Prepend("Linkage error: ");
|
||||||
m_log.Resize(length+19-1); // Extension du buffer d'écriture pour ajouter le log
|
m_log.Resize(length+15-2); // Extension du buffer d'écriture pour ajouter le log
|
||||||
|
|
||||||
glGetProgramInfoLog(m_program, length-1, nullptr, &m_log[19]);
|
glGetProgramInfoLog(m_program, length-1, nullptr, &m_log[19]);
|
||||||
}
|
}
|
||||||
|
|
@ -264,9 +264,9 @@ bool NzGLSLShader::Load(nzShaderType type, const NzString& source)
|
||||||
if (length > 1)
|
if (length > 1)
|
||||||
{
|
{
|
||||||
m_log.Clear(true);
|
m_log.Clear(true);
|
||||||
m_log.Reserve(length+19-1); // La taille retournée est celle du buffer (Avec caractère de fin)
|
m_log.Reserve(length+19-2); // La taille retournée est celle du buffer (Avec caractère de fin)
|
||||||
m_log.Prepend("Compilation error: ");
|
m_log.Prepend("Compilation error: ");
|
||||||
m_log.Resize(length+19-1); // Extension du buffer d'écriture pour ajouter le log
|
m_log.Resize(length+19-2); // Extension du buffer d'écriture pour ajouter le log
|
||||||
|
|
||||||
glGetShaderInfoLog(shader, length-1, nullptr, &m_log[19]);
|
glGetShaderInfoLog(shader, length-1, nullptr, &m_log[19]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -262,10 +262,11 @@ namespace NzOpenGL
|
||||||
glGenTextures = reinterpret_cast<PFNGLGENTEXTURESPROC>(LoadEntry("glGenTextures"));
|
glGenTextures = reinterpret_cast<PFNGLGENTEXTURESPROC>(LoadEntry("glGenTextures"));
|
||||||
glGetBufferParameteriv = reinterpret_cast<PFNGLGETBUFFERPARAMETERIVPROC>(LoadEntry("glGetBufferParameteriv"));
|
glGetBufferParameteriv = reinterpret_cast<PFNGLGETBUFFERPARAMETERIVPROC>(LoadEntry("glGetBufferParameteriv"));
|
||||||
glGetError = reinterpret_cast<PFNGLGETERRORPROC>(LoadEntry("glGetError"));
|
glGetError = reinterpret_cast<PFNGLGETERRORPROC>(LoadEntry("glGetError"));
|
||||||
|
glGetFloatv = reinterpret_cast<PFNGLGETFLOATVPROC>(LoadEntry("glGetFloatv"));
|
||||||
|
glGetIntegerv = reinterpret_cast<PFNGLGETINTEGERVPROC>(LoadEntry("glGetIntegerv"));
|
||||||
glGetQueryiv = reinterpret_cast<PFNGLGETQUERYIVPROC>(LoadEntry("glGetQueryiv"));
|
glGetQueryiv = reinterpret_cast<PFNGLGETQUERYIVPROC>(LoadEntry("glGetQueryiv"));
|
||||||
glGetQueryObjectiv = reinterpret_cast<PFNGLGETQUERYOBJECTIVPROC>(LoadEntry("glGetQueryObjectiv"));
|
glGetQueryObjectiv = reinterpret_cast<PFNGLGETQUERYOBJECTIVPROC>(LoadEntry("glGetQueryObjectiv"));
|
||||||
glGetQueryObjectuiv = reinterpret_cast<PFNGLGETQUERYOBJECTUIVPROC>(LoadEntry("glGetQueryObjectuiv"));
|
glGetQueryObjectuiv = reinterpret_cast<PFNGLGETQUERYOBJECTUIVPROC>(LoadEntry("glGetQueryObjectuiv"));
|
||||||
glGetIntegerv = reinterpret_cast<PFNGLGETINTEGERVPROC>(LoadEntry("glGetIntegerv"));
|
|
||||||
glGetProgramiv = reinterpret_cast<PFNGLGETPROGRAMIVPROC>(LoadEntry("glGetProgramiv"));
|
glGetProgramiv = reinterpret_cast<PFNGLGETPROGRAMIVPROC>(LoadEntry("glGetProgramiv"));
|
||||||
glGetProgramInfoLog = reinterpret_cast<PFNGLGETPROGRAMINFOLOGPROC>(LoadEntry("glGetProgramInfoLog"));
|
glGetProgramInfoLog = reinterpret_cast<PFNGLGETPROGRAMINFOLOGPROC>(LoadEntry("glGetProgramInfoLog"));
|
||||||
glGetShaderInfoLog = reinterpret_cast<PFNGLGETSHADERINFOLOGPROC>(LoadEntry("glGetShaderInfoLog"));
|
glGetShaderInfoLog = reinterpret_cast<PFNGLGETSHADERINFOLOGPROC>(LoadEntry("glGetShaderInfoLog"));
|
||||||
|
|
@ -277,9 +278,11 @@ namespace NzOpenGL
|
||||||
glGetTexParameterfv = reinterpret_cast<PFNGLGETTEXPARAMETERFVPROC>(LoadEntry("glGetTexParameterfv"));
|
glGetTexParameterfv = reinterpret_cast<PFNGLGETTEXPARAMETERFVPROC>(LoadEntry("glGetTexParameterfv"));
|
||||||
glGetTexParameteriv = reinterpret_cast<PFNGLGETTEXPARAMETERIVPROC>(LoadEntry("glGetTexParameteriv"));
|
glGetTexParameteriv = reinterpret_cast<PFNGLGETTEXPARAMETERIVPROC>(LoadEntry("glGetTexParameteriv"));
|
||||||
glGetUniformLocation = reinterpret_cast<PFNGLGETUNIFORMLOCATIONPROC>(LoadEntry("glGetUniformLocation"));
|
glGetUniformLocation = reinterpret_cast<PFNGLGETUNIFORMLOCATIONPROC>(LoadEntry("glGetUniformLocation"));
|
||||||
|
glLineWidth = reinterpret_cast<PFNGLLINEWIDTHPROC>(LoadEntry("glLineWidth"));
|
||||||
glLinkProgram = reinterpret_cast<PFNGLLINKPROGRAMPROC>(LoadEntry("glLinkProgram"));
|
glLinkProgram = reinterpret_cast<PFNGLLINKPROGRAMPROC>(LoadEntry("glLinkProgram"));
|
||||||
glMapBuffer = reinterpret_cast<PFNGLMAPBUFFERPROC>(LoadEntry("glMapBuffer"));
|
glMapBuffer = reinterpret_cast<PFNGLMAPBUFFERPROC>(LoadEntry("glMapBuffer"));
|
||||||
glPixelStorei = reinterpret_cast<PFNGLPIXELSTOREIPROC>(LoadEntry("glPixelStorei"));
|
glPixelStorei = reinterpret_cast<PFNGLPIXELSTOREIPROC>(LoadEntry("glPixelStorei"));
|
||||||
|
glPointSize = reinterpret_cast<PFNGLPOINTSIZEPROC>(LoadEntry("glPointSize"));
|
||||||
glPolygonMode = reinterpret_cast<PFNGLPOLYGONMODEPROC>(LoadEntry("glPolygonMode"));
|
glPolygonMode = reinterpret_cast<PFNGLPOLYGONMODEPROC>(LoadEntry("glPolygonMode"));
|
||||||
glReadPixels = reinterpret_cast<PFNGLREADPIXELSPROC>(LoadEntry("glReadPixels"));
|
glReadPixels = reinterpret_cast<PFNGLREADPIXELSPROC>(LoadEntry("glReadPixels"));
|
||||||
glScissor = reinterpret_cast<PFNGLSCISSORPROC>(LoadEntry("glScissor"));
|
glScissor = reinterpret_cast<PFNGLSCISSORPROC>(LoadEntry("glScissor"));
|
||||||
|
|
@ -936,6 +939,7 @@ PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = nullptr;
|
||||||
PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv = nullptr;
|
PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv = nullptr;
|
||||||
PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog = nullptr;
|
PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog = nullptr;
|
||||||
PFNGLGETERRORPROC glGetError = nullptr;
|
PFNGLGETERRORPROC glGetError = nullptr;
|
||||||
|
PFNGLGETFLOATVPROC glGetFloatv = nullptr;
|
||||||
PFNGLGETINTEGERVPROC glGetIntegerv = nullptr;
|
PFNGLGETINTEGERVPROC glGetIntegerv = nullptr;
|
||||||
PFNGLGETPROGRAMIVPROC glGetProgramiv = nullptr;
|
PFNGLGETPROGRAMIVPROC glGetProgramiv = nullptr;
|
||||||
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = nullptr;
|
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = nullptr;
|
||||||
|
|
@ -953,10 +957,12 @@ PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv = nullptr;
|
||||||
PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv = nullptr;
|
PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv = nullptr;
|
||||||
PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv = nullptr;
|
PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv = nullptr;
|
||||||
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = nullptr;
|
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = nullptr;
|
||||||
|
PFNGLLINEWIDTHPROC glLineWidth = nullptr;
|
||||||
PFNGLLINKPROGRAMPROC glLinkProgram = nullptr;
|
PFNGLLINKPROGRAMPROC glLinkProgram = nullptr;
|
||||||
PFNGLMAPBUFFERPROC glMapBuffer = nullptr;
|
PFNGLMAPBUFFERPROC glMapBuffer = nullptr;
|
||||||
PFNGLMAPBUFFERRANGEPROC glMapBufferRange = nullptr;
|
PFNGLMAPBUFFERRANGEPROC glMapBufferRange = nullptr;
|
||||||
PFNGLPIXELSTOREIPROC glPixelStorei = nullptr;
|
PFNGLPIXELSTOREIPROC glPixelStorei = nullptr;
|
||||||
|
PFNGLPOINTSIZEPROC glPointSize = nullptr;
|
||||||
PFNGLPOLYGONMODEPROC glPolygonMode = nullptr;
|
PFNGLPOLYGONMODEPROC glPolygonMode = nullptr;
|
||||||
PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d = nullptr;
|
PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d = nullptr;
|
||||||
PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f = nullptr;
|
PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,14 @@ void NzRenderer::Enable(nzRendererParameter parameter, bool enable)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float NzRenderer::GetLineWidth()
|
||||||
|
{
|
||||||
|
float lineWidth;
|
||||||
|
glGetFloatv(GL_LINE_WIDTH, &lineWidth);
|
||||||
|
|
||||||
|
return lineWidth;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
NzMatrix4f NzRenderer::GetMatrix(nzMatrixCombination combination)
|
NzMatrix4f NzRenderer::GetMatrix(nzMatrixCombination combination)
|
||||||
{
|
{
|
||||||
|
|
@ -250,6 +258,14 @@ unsigned int NzRenderer::GetMaxTextureUnits()
|
||||||
return s_maxTextureUnit;
|
return s_maxTextureUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float NzRenderer::GetPointSize()
|
||||||
|
{
|
||||||
|
float pointSize;
|
||||||
|
glGetFloatv(GL_POINT_SIZE, &pointSize);
|
||||||
|
|
||||||
|
return pointSize;
|
||||||
|
}
|
||||||
|
|
||||||
NzShader* NzRenderer::GetShader()
|
NzShader* NzRenderer::GetShader()
|
||||||
{
|
{
|
||||||
return s_shader;
|
return s_shader;
|
||||||
|
|
@ -497,6 +513,19 @@ bool NzRenderer::SetIndexBuffer(const NzIndexBuffer* indexBuffer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NzRenderer::SetLineWidth(float width)
|
||||||
|
{
|
||||||
|
#if NAZARA_RENDERER_SAFE
|
||||||
|
if (width <= 0.f)
|
||||||
|
{
|
||||||
|
NazaraError("Width must be over zero");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
glLineWidth(width);
|
||||||
|
}
|
||||||
|
|
||||||
void NzRenderer::SetMatrix(nzMatrixType type, const NzMatrix4f& matrix)
|
void NzRenderer::SetMatrix(nzMatrixType type, const NzMatrix4f& matrix)
|
||||||
{
|
{
|
||||||
s_matrix[type] = matrix;
|
s_matrix[type] = matrix;
|
||||||
|
|
@ -514,6 +543,19 @@ void NzRenderer::SetMatrix(nzMatrixType type, const NzMatrix4f& matrix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NzRenderer::SetPointSize(float size)
|
||||||
|
{
|
||||||
|
#if NAZARA_RENDERER_SAFE
|
||||||
|
if (size <= 0.f)
|
||||||
|
{
|
||||||
|
NazaraError("Size must be over zero");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
glPointSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
bool NzRenderer::SetShader(NzShader* shader)
|
bool NzRenderer::SetShader(NzShader* shader)
|
||||||
{
|
{
|
||||||
if (s_shader == shader)
|
if (s_shader == shader)
|
||||||
|
|
@ -550,6 +592,10 @@ bool NzRenderer::SetShader(NzShader* shader)
|
||||||
s_matrixLocation[nzMatrixCombination_ViewProj] = shader->GetUniformLocation("ViewProjMatrix");
|
s_matrixLocation[nzMatrixCombination_ViewProj] = shader->GetUniformLocation("ViewProjMatrix");
|
||||||
s_matrixLocation[nzMatrixCombination_WorldView] = shader->GetUniformLocation("WorldViewMatrix");
|
s_matrixLocation[nzMatrixCombination_WorldView] = shader->GetUniformLocation("WorldViewMatrix");
|
||||||
s_matrixLocation[nzMatrixCombination_WorldViewProj] = shader->GetUniformLocation("WorldViewProjMatrix");
|
s_matrixLocation[nzMatrixCombination_WorldViewProj] = shader->GetUniformLocation("WorldViewProjMatrix");
|
||||||
|
|
||||||
|
///FIXME: Peut VRAIMENT être optimisé
|
||||||
|
for (unsigned int i = 0; i < totalMatrixCount; ++i)
|
||||||
|
s_matrixUpdated[i] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_shader = shader;
|
s_shader = shader;
|
||||||
|
|
@ -856,15 +902,15 @@ bool NzRenderer::EnsureStateUpdate()
|
||||||
NzHardwareBuffer* vertexBufferImpl = static_cast<NzHardwareBuffer*>(s_vertexBuffer->GetBuffer()->GetImpl());
|
NzHardwareBuffer* vertexBufferImpl = static_cast<NzHardwareBuffer*>(s_vertexBuffer->GetBuffer()->GetImpl());
|
||||||
vertexBufferImpl->Bind();
|
vertexBufferImpl->Bind();
|
||||||
|
|
||||||
const nzUInt8* buffer = reinterpret_cast<const nzUInt8*>(s_vertexBuffer->GetPointer());
|
const nzUInt8* buffer = static_cast<const nzUInt8*>(s_vertexBuffer->GetPointer());
|
||||||
|
|
||||||
unsigned int stride = s_vertexDeclaration->GetStride(nzElementStream_VertexData);
|
unsigned int stride = s_vertexDeclaration->GetStride(nzElementStream_VertexData);
|
||||||
for (unsigned int i = 0; i <= nzElementUsage_Max; ++i)
|
for (unsigned int i = 0; i <= nzElementUsage_Max; ++i)
|
||||||
{
|
{
|
||||||
const NzVertexElement* element = s_vertexDeclaration->GetElement(nzElementStream_VertexData, static_cast<nzElementUsage>(i));
|
nzElementUsage usage = static_cast<nzElementUsage>(i);
|
||||||
|
if (s_vertexDeclaration->HasElement(nzElementStream_VertexData, usage))
|
||||||
if (element)
|
|
||||||
{
|
{
|
||||||
|
const NzVertexElement* element = s_vertexDeclaration->GetElement(nzElementStream_VertexData, usage);
|
||||||
|
|
||||||
glEnableVertexAttribArray(NzOpenGL::AttributeIndex[i]);
|
glEnableVertexAttribArray(NzOpenGL::AttributeIndex[i]);
|
||||||
glVertexAttribPointer(NzOpenGL::AttributeIndex[i],
|
glVertexAttribPointer(NzOpenGL::AttributeIndex[i],
|
||||||
NzVertexDeclaration::GetElementCount(element->type),
|
NzVertexDeclaration::GetElementCount(element->type),
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,11 @@ bool NzShader::IsLoaded(nzShaderType type) const
|
||||||
return m_impl->IsLoaded(type);
|
return m_impl->IsLoaded(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NzShader::IsValid() const
|
||||||
|
{
|
||||||
|
return m_impl != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool NzShader::Load(nzShaderType type, const NzString& source)
|
bool NzShader::Load(nzShaderType type, const NzString& source)
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_RENDERER_SAFE
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,12 @@ m_extend(nzExtend_Null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NzAxisAlignedBox::NzAxisAlignedBox(const NzCubef& cube) :
|
||||||
|
m_extend(nzExtend_Finite),
|
||||||
|
m_cube(cube)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NzAxisAlignedBox::NzAxisAlignedBox(const NzVector3f& vec1, const NzVector3f& vec2) :
|
NzAxisAlignedBox::NzAxisAlignedBox(const NzVector3f& vec1, const NzVector3f& vec2) :
|
||||||
m_extend(nzExtend_Finite),
|
m_extend(nzExtend_Finite),
|
||||||
m_cube(vec1, vec2)
|
m_cube(vec1, vec2)
|
||||||
|
|
@ -37,7 +43,6 @@ void NzAxisAlignedBox::ExtendTo(const NzAxisAlignedBox& box)
|
||||||
switch (m_extend)
|
switch (m_extend)
|
||||||
{
|
{
|
||||||
case nzExtend_Finite:
|
case nzExtend_Finite:
|
||||||
{
|
|
||||||
switch (box.m_extend)
|
switch (box.m_extend)
|
||||||
{
|
{
|
||||||
case nzExtend_Finite:
|
case nzExtend_Finite:
|
||||||
|
|
@ -50,9 +55,8 @@ void NzAxisAlignedBox::ExtendTo(const NzAxisAlignedBox& box)
|
||||||
|
|
||||||
case nzExtend_Null:
|
case nzExtend_Null:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case nzExtend_Infinite:
|
case nzExtend_Infinite:
|
||||||
// Rien à faire
|
// Rien à faire
|
||||||
|
|
@ -63,7 +67,6 @@ void NzAxisAlignedBox::ExtendTo(const NzAxisAlignedBox& box)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void NzAxisAlignedBox::ExtendTo(const NzVector3f& vector)
|
void NzAxisAlignedBox::ExtendTo(const NzVector3f& vector)
|
||||||
{
|
{
|
||||||
|
|
@ -152,6 +155,66 @@ NzString NzAxisAlignedBox::ToString() const
|
||||||
return "NzAxisAlignedBox(ERROR)";
|
return "NzAxisAlignedBox(ERROR)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NzAxisAlignedBox::operator NzString() const
|
||||||
|
{
|
||||||
|
return ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
NzAxisAlignedBox NzAxisAlignedBox::Lerp(const NzAxisAlignedBox& from, const NzAxisAlignedBox& to, float interpolation)
|
||||||
|
{
|
||||||
|
#ifdef NAZARA_DEBUG
|
||||||
|
if (interpolation < 0.f || interpolation > 1.f)
|
||||||
|
{
|
||||||
|
NazaraError("Interpolation must be in range [0..1] (Got " + NzString::Number(interpolation) + ')');
|
||||||
|
return Null;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (NzNumberEquals(interpolation, 0.f))
|
||||||
|
return from;
|
||||||
|
|
||||||
|
if (NzNumberEquals(interpolation, 1.f))
|
||||||
|
return to;
|
||||||
|
|
||||||
|
switch (to.m_extend)
|
||||||
|
{
|
||||||
|
case nzExtend_Finite:
|
||||||
|
{
|
||||||
|
switch (from.m_extend)
|
||||||
|
{
|
||||||
|
case nzExtend_Finite:
|
||||||
|
return NzCubef::Lerp(from.m_cube, to.m_cube, interpolation);
|
||||||
|
|
||||||
|
case nzExtend_Infinite:
|
||||||
|
return Infinite;
|
||||||
|
|
||||||
|
case nzExtend_Null:
|
||||||
|
return from.m_cube * interpolation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case nzExtend_Infinite:
|
||||||
|
return Infinite; // Un petit peu d'infini est infini quand même ;)
|
||||||
|
|
||||||
|
case nzExtend_Null:
|
||||||
|
{
|
||||||
|
switch (from.m_extend)
|
||||||
|
{
|
||||||
|
case nzExtend_Finite:
|
||||||
|
return from.m_cube * (1.f - interpolation);
|
||||||
|
|
||||||
|
case nzExtend_Infinite:
|
||||||
|
return Infinite;
|
||||||
|
|
||||||
|
case nzExtend_Null:
|
||||||
|
return Null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Null;
|
||||||
|
}
|
||||||
|
|
||||||
const NzAxisAlignedBox NzAxisAlignedBox::Infinite(nzExtend_Infinite);
|
const NzAxisAlignedBox NzAxisAlignedBox::Infinite(nzExtend_Infinite);
|
||||||
const NzAxisAlignedBox NzAxisAlignedBox::Null(nzExtend_Null);
|
const NzAxisAlignedBox NzAxisAlignedBox::Null(nzExtend_Null);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,8 @@ bool NzImage::Convert(nzPixelFormat format)
|
||||||
for (unsigned int i = 0; i < m_sharedImage->levelCount; ++i)
|
for (unsigned int i = 0; i < m_sharedImage->levelCount; ++i)
|
||||||
{
|
{
|
||||||
unsigned int pixelsPerFace = width*height;
|
unsigned int pixelsPerFace = width*height;
|
||||||
nzUInt8* ptr = new nzUInt8[pixelsPerFace*depth*NzPixelFormat::GetBytesPerPixel(format)];
|
nzUInt8* face = new nzUInt8[pixelsPerFace*depth*NzPixelFormat::GetBytesPerPixel(format)];
|
||||||
|
nzUInt8* ptr = face;
|
||||||
nzUInt8* pixels = m_sharedImage->pixels[i];
|
nzUInt8* pixels = m_sharedImage->pixels[i];
|
||||||
unsigned int srcStride = pixelsPerFace * NzPixelFormat::GetBytesPerPixel(m_sharedImage->format);
|
unsigned int srcStride = pixelsPerFace * NzPixelFormat::GetBytesPerPixel(m_sharedImage->format);
|
||||||
unsigned int dstStride = pixelsPerFace * NzPixelFormat::GetBytesPerPixel(format);
|
unsigned int dstStride = pixelsPerFace * NzPixelFormat::GetBytesPerPixel(format);
|
||||||
|
|
@ -117,7 +118,7 @@ bool NzImage::Convert(nzPixelFormat format)
|
||||||
NazaraError("Failed to convert image");
|
NazaraError("Failed to convert image");
|
||||||
|
|
||||||
// Nettoyage de la mémoire
|
// Nettoyage de la mémoire
|
||||||
delete[] ptr; // Permet une optimisation de boucle (GCC)
|
delete[] face; // Permet une optimisation de boucle (GCC)
|
||||||
for (unsigned int j = 0; j < i; ++j)
|
for (unsigned int j = 0; j < i; ++j)
|
||||||
delete[] levels[j];
|
delete[] levels[j];
|
||||||
|
|
||||||
|
|
@ -130,7 +131,7 @@ bool NzImage::Convert(nzPixelFormat format)
|
||||||
ptr += dstStride;
|
ptr += dstStride;
|
||||||
}
|
}
|
||||||
|
|
||||||
levels[i] = ptr;
|
levels[i] = face;
|
||||||
|
|
||||||
if (width > 1)
|
if (width > 1)
|
||||||
width >>= 1;
|
width >>= 1;
|
||||||
|
|
@ -356,33 +357,39 @@ bool NzImage::Fill(const NzColor& color)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EnsureOwnership();
|
|
||||||
|
|
||||||
nzUInt8 bpp = NzPixelFormat::GetBytesPerPixel(m_sharedImage->format);
|
nzUInt8 bpp = NzPixelFormat::GetBytesPerPixel(m_sharedImage->format);
|
||||||
nzUInt8* pixels = new nzUInt8[bpp];
|
nzUInt8* colorBuffer = new nzUInt8[bpp];
|
||||||
if (!NzPixelFormat::Convert(nzPixelFormat_RGBA8, m_sharedImage->format, &color.r, pixels))
|
if (!NzPixelFormat::Convert(nzPixelFormat_RGBA8, m_sharedImage->format, &color.r, colorBuffer))
|
||||||
{
|
{
|
||||||
NazaraError("Failed to convert RGBA8 to " + NzPixelFormat::ToString(m_sharedImage->format));
|
NazaraError("Failed to convert RGBA8 to " + NzPixelFormat::ToString(m_sharedImage->format));
|
||||||
delete[] pixels;
|
delete[] colorBuffer;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nzUInt8** levels = new nzUInt8*[m_sharedImage->levelCount];
|
||||||
|
|
||||||
unsigned int width = m_sharedImage->width;
|
unsigned int width = m_sharedImage->width;
|
||||||
unsigned int height = m_sharedImage->height;
|
unsigned int height = m_sharedImage->height;
|
||||||
|
|
||||||
|
// Les images 3D et cubemaps sont stockés de la même façon
|
||||||
unsigned int depth = (m_sharedImage->type == nzImageType_Cubemap) ? 6 : m_sharedImage->depth;
|
unsigned int depth = (m_sharedImage->type == nzImageType_Cubemap) ? 6 : m_sharedImage->depth;
|
||||||
|
|
||||||
for (unsigned int level = 0; level < m_sharedImage->levelCount; ++level)
|
for (unsigned int i = 0; i < m_sharedImage->levelCount; ++i)
|
||||||
{
|
{
|
||||||
nzUInt8* ptr = &m_sharedImage->pixels[level][0];
|
unsigned int size = width*height*depth*bpp;
|
||||||
nzUInt8* end = &m_sharedImage->pixels[level][width*height*depth*bpp];
|
nzUInt8* face = new nzUInt8[size];
|
||||||
|
nzUInt8* ptr = face;
|
||||||
|
nzUInt8* end = &ptr[size];
|
||||||
|
|
||||||
while (ptr < end)
|
while (ptr < end)
|
||||||
{
|
{
|
||||||
std::memcpy(ptr, pixels, bpp);
|
std::memcpy(ptr, colorBuffer, bpp);
|
||||||
ptr += bpp;
|
ptr += bpp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
levels[i] = face;
|
||||||
|
|
||||||
if (width > 1U)
|
if (width > 1U)
|
||||||
width >>= 1;
|
width >>= 1;
|
||||||
|
|
||||||
|
|
@ -393,7 +400,12 @@ bool NzImage::Fill(const NzColor& color)
|
||||||
depth >>= 1;
|
depth >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] pixels;
|
delete[] colorBuffer;
|
||||||
|
|
||||||
|
SharedImage* newImage = new SharedImage(1, m_sharedImage->type, m_sharedImage->format, m_sharedImage->levelCount, levels, m_sharedImage->width, m_sharedImage->height, m_sharedImage->depth);
|
||||||
|
|
||||||
|
ReleaseImage();
|
||||||
|
m_sharedImage = newImage;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -562,7 +574,6 @@ bool NzImage::FlipHorizontally()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NzImage::FlipVertically()
|
bool NzImage::FlipVertically()
|
||||||
{
|
{
|
||||||
#if NAZARA_UTILITY_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@
|
||||||
|
|
||||||
#include <Nazara/Utility/Debug.hpp>
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
|
NzString NzKeyboard::GetKeyName(Key key)
|
||||||
|
{
|
||||||
|
return NzEventImpl::GetKeyName(key);
|
||||||
|
}
|
||||||
|
|
||||||
bool NzKeyboard::IsKeyPressed(Key key)
|
bool NzKeyboard::IsKeyPressed(Key key)
|
||||||
{
|
{
|
||||||
return NzEventImpl::IsKeyPressed(key);
|
return NzEventImpl::IsKeyPressed(key);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace
|
||||||
nzUInt8 padding[54];
|
nzUInt8 padding[54];
|
||||||
};
|
};
|
||||||
|
|
||||||
bool NzLoader_PCX_Check(NzInputStream& stream, const NzImageParams& parameters)
|
bool Check(NzInputStream& stream, const NzImageParams& parameters)
|
||||||
{
|
{
|
||||||
NazaraUnused(parameters);
|
NazaraUnused(parameters);
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ namespace
|
||||||
return manufacturer == 0x0a;
|
return manufacturer == 0x0a;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzLoader_PCX_Load(NzImage* image, NzInputStream& stream, const NzImageParams& parameters)
|
bool Load(NzImage* image, NzInputStream& stream, const NzImageParams& parameters)
|
||||||
{
|
{
|
||||||
NazaraUnused(parameters);
|
NazaraUnused(parameters);
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(NAZARA_BIG_ENDIAN)
|
#ifdef NAZARA_BIG_ENDIAN
|
||||||
// Les fichiers PCX sont en little endian
|
// Les fichiers PCX sont en little endian
|
||||||
NzByteSwap(&header.xmin, sizeof(nzUInt16));
|
NzByteSwap(&header.xmin, sizeof(nzUInt16));
|
||||||
NzByteSwap(&header.ymin, sizeof(nzUInt16));
|
NzByteSwap(&header.ymin, sizeof(nzUInt16));
|
||||||
|
|
@ -337,10 +337,10 @@ namespace
|
||||||
|
|
||||||
void NzLoaders_PCX_Register()
|
void NzLoaders_PCX_Register()
|
||||||
{
|
{
|
||||||
NzImageLoader::RegisterLoader("pcx", NzLoader_PCX_Check, NzLoader_PCX_Load);
|
NzImageLoader::RegisterLoader("pcx", Check, Load);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzLoaders_PCX_Unregister()
|
void NzLoaders_PCX_Unregister()
|
||||||
{
|
{
|
||||||
NzImageLoader::UnregisterLoader("pcx", NzLoader_PCX_Check, NzLoader_PCX_Load);
|
NzImageLoader::UnregisterLoader("pcx", Check, Load);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace
|
||||||
|
|
||||||
static stbi_io_callbacks callbacks = {Read, Skip, Eof};
|
static stbi_io_callbacks callbacks = {Read, Skip, Eof};
|
||||||
|
|
||||||
bool NzLoader_STB_Check(NzInputStream& stream, const NzImageParams& parameters)
|
bool Check(NzInputStream& stream, const NzImageParams& parameters)
|
||||||
{
|
{
|
||||||
NazaraUnused(parameters);
|
NazaraUnused(parameters);
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ namespace
|
||||||
return stbi_info_from_callbacks(&callbacks, &stream, &width, &height, &bpp);
|
return stbi_info_from_callbacks(&callbacks, &stream, &width, &height, &bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzLoader_STB_Load(NzImage* image, NzInputStream& stream, const NzImageParams& parameters)
|
bool Load(NzImage* image, NzInputStream& stream, const NzImageParams& parameters)
|
||||||
{
|
{
|
||||||
static const nzPixelFormat formats[4] =
|
static const nzPixelFormat formats[4] =
|
||||||
{
|
{
|
||||||
|
|
@ -117,10 +117,10 @@ namespace
|
||||||
|
|
||||||
void NzLoaders_STB_Register()
|
void NzLoaders_STB_Register()
|
||||||
{
|
{
|
||||||
NzImageLoader::RegisterLoader("bmp,gif,hdr,jpg,jpeg,pic,png,psd,tga", NzLoader_STB_Check, NzLoader_STB_Load);
|
NzImageLoader::RegisterLoader("bmp,gif,hdr,jpg,jpeg,pic,png,psd,tga", Check, Load);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzLoaders_STB_Unregister()
|
void NzLoaders_STB_Unregister()
|
||||||
{
|
{
|
||||||
NzImageLoader::UnregisterLoader("bmp,gif,hdr,jpg,jpeg,pic,png,psd,tga", NzLoader_STB_Check, NzLoader_STB_Load);
|
NzImageLoader::UnregisterLoader("bmp,gif,hdr,jpg,jpeg,pic,png,psd,tga", Check, Load);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,9 @@ void NzSubMesh::Animate(unsigned int frameA, unsigned int frameB, float interpol
|
||||||
NazaraError("Frame B is out of range (" + NzString::Number(frameB) + " >= " + NzString::Number(frameCount) + ')');
|
NazaraError("Frame B is out of range (" + NzString::Number(frameB) + " >= " + NzString::Number(frameCount) + ')');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NAZARA_DEBUG
|
||||||
if (interpolation < 0.f || interpolation > 1.f)
|
if (interpolation < 0.f || interpolation > 1.f)
|
||||||
{
|
{
|
||||||
NazaraError("Interpolation must be in range [0..1] (Got " + NzString::Number(interpolation) + ')');
|
NazaraError("Interpolation must be in range [0..1] (Got " + NzString::Number(interpolation) + ')');
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,6 @@ const NzVertexElement* NzVertexDeclaration::GetElement(nzElementStream stream, n
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int elementPos = m_sharedImpl->elementPos[stream][usage];
|
int elementPos = m_sharedImpl->elementPos[stream][usage];
|
||||||
|
|
||||||
#if NAZARA_UTILITY_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (elementPos == -1)
|
if (elementPos == -1)
|
||||||
{
|
{
|
||||||
|
|
@ -253,6 +252,10 @@ const NzVertexElement* NzVertexDeclaration::GetElement(nzElementStream stream, n
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (usageIndex == 0) // Si l'usage index vaut zéro, alors nous sommes certains d'être sur le bon élément (Majorité des cas)
|
||||||
|
return &m_sharedImpl->elements[elementPos];
|
||||||
|
else
|
||||||
|
{
|
||||||
elementPos += usageIndex;
|
elementPos += usageIndex;
|
||||||
|
|
||||||
#if NAZARA_UTILITY_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
|
@ -275,6 +278,7 @@ const NzVertexElement* NzVertexDeclaration::GetElement(nzElementStream stream, n
|
||||||
|
|
||||||
return &element;
|
return &element;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int NzVertexDeclaration::GetElementCount() const
|
unsigned int NzVertexDeclaration::GetElementCount() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,37 +8,9 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Nazara/Utility/Debug.hpp>
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
NzVector2i NzEventImpl::GetMousePosition()
|
namespace
|
||||||
{
|
{
|
||||||
POINT pos;
|
int vKeys[NzKeyboard::Count] = {
|
||||||
GetCursorPos(&pos);
|
|
||||||
|
|
||||||
return NzVector2i(pos.x, pos.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
NzVector2i NzEventImpl::GetMousePosition(const NzWindow& relativeTo)
|
|
||||||
{
|
|
||||||
HWND handle = reinterpret_cast<HWND>(relativeTo.GetHandle());
|
|
||||||
if (handle)
|
|
||||||
{
|
|
||||||
POINT pos;
|
|
||||||
GetCursorPos(&pos);
|
|
||||||
ScreenToClient(handle, &pos);
|
|
||||||
|
|
||||||
return NzVector2i(pos.x, pos.y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NazaraError("Window's handle is invalid");
|
|
||||||
|
|
||||||
// Attention que (-1, -1) est une position tout à fait valide et ne doit pas être utilisée pour tester l'erreur
|
|
||||||
return NzVector2i(-1, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzEventImpl::IsKeyPressed(NzKeyboard::Key key)
|
|
||||||
{
|
|
||||||
static int vKeys[NzKeyboard::Count] = {
|
|
||||||
// Lettres
|
// Lettres
|
||||||
0x41, // Key::A
|
0x41, // Key::A
|
||||||
0x42, // Key::B
|
0x42, // Key::B
|
||||||
|
|
@ -161,7 +133,7 @@ bool NzEventImpl::IsKeyPressed(NzKeyboard::Key key)
|
||||||
VK_BROWSER_SEARCH, // Key::Browser_Search
|
VK_BROWSER_SEARCH, // Key::Browser_Search
|
||||||
VK_BROWSER_STOP, // Key::Browser_Stop
|
VK_BROWSER_STOP, // Key::Browser_Stop
|
||||||
|
|
||||||
// Touches de contr
|
// Touches de contrôle
|
||||||
VK_MEDIA_NEXT_TRACK, // Key::Media_Next,
|
VK_MEDIA_NEXT_TRACK, // Key::Media_Next,
|
||||||
VK_MEDIA_PLAY_PAUSE, // Key::Media_PlayPause,
|
VK_MEDIA_PLAY_PAUSE, // Key::Media_PlayPause,
|
||||||
VK_MEDIA_PREV_TRACK, // Key::Media_Previous,
|
VK_MEDIA_PREV_TRACK, // Key::Media_Previous,
|
||||||
|
|
@ -177,7 +149,86 @@ bool NzEventImpl::IsKeyPressed(NzKeyboard::Key key)
|
||||||
VK_NUMLOCK, // Key::NumLock
|
VK_NUMLOCK, // Key::NumLock
|
||||||
VK_SCROLL // Key::ScrollLock
|
VK_SCROLL // Key::ScrollLock
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
NzString NzEventImpl::GetKeyName(NzKeyboard::Key key)
|
||||||
|
{
|
||||||
|
// http://www.ffuts.org/blog/mapvirtualkey-getkeynametext-and-a-story-of-how-to/
|
||||||
|
int vk = vKeys[key];
|
||||||
|
unsigned int code = MapVirtualKeyW(vk, 0) << 16;
|
||||||
|
|
||||||
|
///FIXME: Liste complète ?
|
||||||
|
switch (vk)
|
||||||
|
{
|
||||||
|
case VK_ATTN:
|
||||||
|
case VK_DOWN:
|
||||||
|
case VK_DELETE:
|
||||||
|
case VK_DIVIDE:
|
||||||
|
case VK_END:
|
||||||
|
case VK_HOME:
|
||||||
|
case VK_INSERT:
|
||||||
|
case VK_LEFT:
|
||||||
|
case VK_LWIN:
|
||||||
|
case VK_OEM_1:
|
||||||
|
case VK_OEM_2:
|
||||||
|
case VK_OEM_3:
|
||||||
|
case VK_OEM_4:
|
||||||
|
case VK_OEM_5:
|
||||||
|
case VK_OEM_6:
|
||||||
|
case VK_OEM_7:
|
||||||
|
case VK_OEM_CLEAR:
|
||||||
|
case VK_OEM_COMMA:
|
||||||
|
case VK_OEM_MINUS:
|
||||||
|
case VK_OEM_PERIOD:
|
||||||
|
case VK_OEM_PLUS:
|
||||||
|
case VK_PAUSE:
|
||||||
|
case VK_NEXT:
|
||||||
|
case VK_NUMLOCK:
|
||||||
|
case VK_PRIOR:
|
||||||
|
case VK_RIGHT:
|
||||||
|
case VK_RWIN:
|
||||||
|
case VK_UP:
|
||||||
|
code |= 0x1000000; // 24ème bit pour l'extension
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
wchar_t keyName[20]; // Je ne pense pas que ça dépassera 20 caractères
|
||||||
|
if (!GetKeyNameTextW(code, &keyName[0], 20))
|
||||||
|
return "Unknown";
|
||||||
|
|
||||||
|
return NzString::Unicode(keyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
NzVector2i NzEventImpl::GetMousePosition()
|
||||||
|
{
|
||||||
|
POINT pos;
|
||||||
|
GetCursorPos(&pos);
|
||||||
|
|
||||||
|
return NzVector2i(pos.x, pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
NzVector2i NzEventImpl::GetMousePosition(const NzWindow& relativeTo)
|
||||||
|
{
|
||||||
|
HWND handle = reinterpret_cast<HWND>(relativeTo.GetHandle());
|
||||||
|
if (handle)
|
||||||
|
{
|
||||||
|
POINT pos;
|
||||||
|
GetCursorPos(&pos);
|
||||||
|
ScreenToClient(handle, &pos);
|
||||||
|
|
||||||
|
return NzVector2i(pos.x, pos.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NazaraError("Window's handle is invalid");
|
||||||
|
|
||||||
|
// Attention que (-1, -1) est une position tout à fait valide et ne doit pas être utilisée pour tester l'erreur
|
||||||
|
return NzVector2i(-1, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NzEventImpl::IsKeyPressed(NzKeyboard::Key key)
|
||||||
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case NzKeyboard::CapsLock:
|
case NzKeyboard::CapsLock:
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,14 @@
|
||||||
#define NAZARA_INPUTIMPL_HPP
|
#define NAZARA_INPUTIMPL_HPP
|
||||||
|
|
||||||
#include <Nazara/Math/Vector2.hpp>
|
#include <Nazara/Math/Vector2.hpp>
|
||||||
|
#include <Nazara/Core/String.hpp>
|
||||||
#include <Nazara/Utility/Keyboard.hpp>
|
#include <Nazara/Utility/Keyboard.hpp>
|
||||||
#include <Nazara/Utility/Mouse.hpp>
|
#include <Nazara/Utility/Mouse.hpp>
|
||||||
|
|
||||||
class NzEventImpl
|
class NzEventImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static NzString GetKeyName(NzKeyboard::Key key);
|
||||||
static NzVector2i GetMousePosition();
|
static NzVector2i GetMousePosition();
|
||||||
static NzVector2i GetMousePosition(const NzWindow& relativeTo);
|
static NzVector2i GetMousePosition(const NzWindow& relativeTo);
|
||||||
static bool IsKeyPressed(NzKeyboard::Key key);
|
static bool IsKeyPressed(NzKeyboard::Key key);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue