Renamed (Oriented)Cube to (Oriented)Box
Also renamed BoundingBox to BoundingVolume Former-commit-id: 795c70c265ba17f6b96fc30799e89f140c52852b
This commit is contained in:
@@ -35,7 +35,7 @@ enum nzPlugin
|
||||
|
||||
enum nzPrimitiveType
|
||||
{
|
||||
nzPrimitiveType_Cube,
|
||||
nzPrimitiveType_Box,
|
||||
nzPrimitiveType_Plane,
|
||||
nzPrimitiveType_Sphere,
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ class NAZARA_API NzPrimitiveList
|
||||
NzPrimitiveList() = default;
|
||||
~NzPrimitiveList() = default;
|
||||
|
||||
void AddCube(const NzCubef& box, const NzVector3ui& subdivision = NzVector3ui(0U), const NzMatrix4f& matrix = NzMatrix4f::Identity());
|
||||
void AddCube(const NzCubef& box, const NzVector3ui& subdivision, const NzVector3f& position, const NzQuaternionf& rotation = NzQuaternionf::Identity());
|
||||
void AddBox(const NzBoxf& box, const NzVector3ui& subdivision = NzVector3ui(0U), const NzMatrix4f& matrix = NzMatrix4f::Identity());
|
||||
void AddBox(const NzBoxf& box, const NzVector3ui& subdivision, const NzVector3f& position, const NzQuaternionf& rotation = NzQuaternionf::Identity());
|
||||
void AddCubicSphere(float size, unsigned int subdivision = 4, const NzMatrix4f& matrix = NzMatrix4f::Identity());
|
||||
void AddCubicSphere(float size, unsigned int subdivision, const NzVector3f& position, const NzQuaternionf& rotation = NzQuaternionf::Identity());
|
||||
void AddIcoSphere(float size, unsigned int recursionLevel = 1, const NzMatrix4f& matrix = NzMatrix4f::Identity());
|
||||
|
||||
@@ -29,7 +29,7 @@ class NAZARA_API NzCamera : public NzSceneNode
|
||||
void EnsureViewMatrixUpdate() const;
|
||||
|
||||
float GetAspectRatio() const;
|
||||
const NzBoundingBoxf& GetBoundingBox() const override;
|
||||
const NzBoundingVolumef& GetBoundingVolume() const override;
|
||||
float GetFOV() const;
|
||||
const NzFrustumf& GetFrustum() const;
|
||||
const NzMatrix4f& GetProjectionMatrix() const;
|
||||
|
||||
@@ -25,9 +25,9 @@ class NAZARA_API NzLight : public NzSceneNode
|
||||
|
||||
void Apply(const NzShader* shader, unsigned int lightUnit) const;
|
||||
|
||||
const NzBoundingBoxf& GetBoundingBox() const;
|
||||
NzColor GetAmbientColor() const;
|
||||
float GetAttenuation() const;
|
||||
const NzBoundingVolumef& GetBoundingVolume() const;
|
||||
NzColor GetDiffuseColor() const;
|
||||
float GetInnerAngle() const;
|
||||
nzLightType GetLightType() const;
|
||||
@@ -50,15 +50,15 @@ class NAZARA_API NzLight : public NzSceneNode
|
||||
void Invalidate();
|
||||
void Register();
|
||||
void Unregister();
|
||||
void UpdateBoundingBox() const;
|
||||
void UpdateBoundingVolume() const;
|
||||
bool VisibilityTest(const NzFrustumf& frustum);
|
||||
|
||||
nzLightType m_type;
|
||||
mutable NzBoundingBoxf m_boundingBox;
|
||||
mutable NzBoundingVolumef m_boundingVolume;
|
||||
NzColor m_ambientColor;
|
||||
NzColor m_diffuseColor;
|
||||
NzColor m_specularColor;
|
||||
mutable bool m_boundingBoxUpdated;
|
||||
mutable bool m_boundingVolumeUpdated;
|
||||
float m_attenuation;
|
||||
float m_innerAngle;
|
||||
float m_outerAngle;
|
||||
|
||||
@@ -48,7 +48,7 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
||||
void EnableDraw(bool draw);
|
||||
|
||||
NzAnimation* GetAnimation() const;
|
||||
const NzBoundingBoxf& GetBoundingBox() const;
|
||||
const NzBoundingVolumef& GetBoundingVolume() const;
|
||||
NzMaterial* GetMaterial(const NzString& subMeshName) const;
|
||||
NzMaterial* GetMaterial(unsigned int matIndex) const;
|
||||
NzMaterial* GetMaterial(unsigned int skinIndex, const NzString& subMeshName) const;
|
||||
@@ -92,17 +92,17 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
||||
void Register() override;
|
||||
void Unregister() override;
|
||||
void Update() override;
|
||||
void UpdateBoundingBox() const;
|
||||
void UpdateBoundingVolume() const;
|
||||
bool VisibilityTest(const NzFrustumf& frustum) override;
|
||||
|
||||
std::vector<NzMaterialRef> m_materials;
|
||||
mutable NzBoundingBoxf m_boundingBox;
|
||||
NzSkeleton m_skeleton; // Uniquement pour les animations squelettiques
|
||||
NzAnimationRef m_animation;
|
||||
mutable NzBoundingVolumef m_boundingVolume;
|
||||
NzMeshRef m_mesh;
|
||||
NzSkeleton m_skeleton; // Uniquement pour les animations squelettiques
|
||||
const NzSequence* m_currentSequence;
|
||||
bool m_animationEnabled;
|
||||
mutable bool m_boundingBoxUpdated;
|
||||
mutable bool m_boundingVolumeUpdated;
|
||||
bool m_drawEnabled;
|
||||
float m_interpolation;
|
||||
unsigned int m_currentFrame;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Graphics/Scene.hpp>
|
||||
#include <Nazara/Math/BoundingBox.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <Nazara/Math/Frustum.hpp>
|
||||
#include <Nazara/Utility/Node.hpp>
|
||||
|
||||
@@ -25,7 +25,7 @@ class NAZARA_API NzSceneNode : public NzNode
|
||||
|
||||
virtual void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const = 0;
|
||||
|
||||
virtual const NzBoundingBoxf& GetBoundingBox() const = 0;
|
||||
virtual const NzBoundingVolumef& GetBoundingVolume() const = 0;
|
||||
nzNodeType GetNodeType() const final;
|
||||
NzScene* GetScene() const;
|
||||
virtual nzSceneNodeType GetSceneNodeType() const = 0;
|
||||
|
||||
@@ -19,7 +19,7 @@ class NAZARA_API NzSceneRoot : public NzSceneNode
|
||||
public:
|
||||
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
|
||||
|
||||
const NzBoundingBoxf& GetBoundingBox() const override;
|
||||
const NzBoundingVolumef& GetBoundingVolume() const override;
|
||||
nzSceneNodeType GetSceneNodeType() const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
// Copyright (C) 2013 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_BOUNDINGBOX_HPP
|
||||
#define NAZARA_BOUNDINGBOX_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Enums.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/OrientedCube.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template<typename T>
|
||||
class NzBoundingBox
|
||||
{
|
||||
public:
|
||||
NzBoundingBox();
|
||||
NzBoundingBox(nzExtend Extend);
|
||||
NzBoundingBox(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzBoundingBox(const NzCube<T>& Cube);
|
||||
NzBoundingBox(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> explicit NzBoundingBox(const NzBoundingBox<U>& box);
|
||||
NzBoundingBox(const NzBoundingBox& box) = default;
|
||||
~NzBoundingBox() = default;
|
||||
|
||||
bool IsFinite() const;
|
||||
bool IsInfinite() const;
|
||||
bool IsNull() const;
|
||||
|
||||
NzBoundingBox& MakeInfinite();
|
||||
NzBoundingBox& MakeNull();
|
||||
|
||||
NzBoundingBox& Set(nzExtend Extend);
|
||||
NzBoundingBox& Set(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzBoundingBox& Set(const NzBoundingBox<T>& box);
|
||||
NzBoundingBox& Set(const NzCube<T>& Cube);
|
||||
NzBoundingBox& Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> NzBoundingBox& Set(const NzBoundingBox<U>& box);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
void Update(const NzMatrix4<T>& transformMatrix);
|
||||
|
||||
NzBoundingBox operator*(T scalar) const;
|
||||
|
||||
NzBoundingBox& operator*=(T scalar);
|
||||
|
||||
bool operator==(const NzBoundingBox& box) const;
|
||||
bool operator!=(const NzBoundingBox& box) const;
|
||||
|
||||
static NzBoundingBox Infinite();
|
||||
static NzBoundingBox Lerp(const NzBoundingBox& from, const NzBoundingBox& to, T interpolation);
|
||||
static NzBoundingBox Null();
|
||||
|
||||
nzExtend extend;
|
||||
NzCube<T> aabb;
|
||||
NzOrientedCube<T> obb;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzBoundingBox<T>& box);
|
||||
|
||||
typedef NzBoundingBox<double> NzBoundingBoxd;
|
||||
typedef NzBoundingBox<float> NzBoundingBoxf;
|
||||
|
||||
#include <Nazara/Math/BoundingBox.inl>
|
||||
|
||||
#endif // NAZARA_BOUNDINGBOX_HPP
|
||||
70
include/Nazara/Math/BoundingVolume.hpp
Normal file
70
include/Nazara/Math/BoundingVolume.hpp
Normal file
@@ -0,0 +1,70 @@
|
||||
// Copyright (C) 2013 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_BOUNDINGVOLUME_HPP
|
||||
#define NAZARA_BOUNDINGVOLUME_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Enums.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/OrientedBox.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template<typename T>
|
||||
class NzBoundingVolume
|
||||
{
|
||||
public:
|
||||
NzBoundingVolume();
|
||||
NzBoundingVolume(nzExtend Extend);
|
||||
NzBoundingVolume(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzBoundingVolume(const NzBox<T>& box);
|
||||
NzBoundingVolume(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> explicit NzBoundingVolume(const NzBoundingVolume<U>& volume);
|
||||
NzBoundingVolume(const NzBoundingVolume& volume) = default;
|
||||
~NzBoundingVolume() = default;
|
||||
|
||||
bool IsFinite() const;
|
||||
bool IsInfinite() const;
|
||||
bool IsNull() const;
|
||||
|
||||
NzBoundingVolume& MakeInfinite();
|
||||
NzBoundingVolume& MakeNull();
|
||||
|
||||
NzBoundingVolume& Set(nzExtend Extend);
|
||||
NzBoundingVolume& Set(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzBoundingVolume& Set(const NzBoundingVolume<T>& volume);
|
||||
NzBoundingVolume& Set(const NzBox<T>& box);
|
||||
NzBoundingVolume& Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> NzBoundingVolume& Set(const NzBoundingVolume<U>& volume);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
void Update(const NzMatrix4<T>& transformMatrix);
|
||||
|
||||
NzBoundingVolume operator*(T scalar) const;
|
||||
|
||||
NzBoundingVolume& operator*=(T scalar);
|
||||
|
||||
bool operator==(const NzBoundingVolume& volume) const;
|
||||
bool operator!=(const NzBoundingVolume& volume) const;
|
||||
|
||||
static NzBoundingVolume Infinite();
|
||||
static NzBoundingVolume Lerp(const NzBoundingVolume& from, const NzBoundingVolume& to, T interpolation);
|
||||
static NzBoundingVolume Null();
|
||||
|
||||
nzExtend extend;
|
||||
NzBox<T> aabb;
|
||||
NzOrientedBox<T> obb;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzBoundingVolume<T>& volume);
|
||||
|
||||
typedef NzBoundingVolume<double> NzBoundingVolumed;
|
||||
typedef NzBoundingVolume<float> NzBoundingVolumef;
|
||||
|
||||
#include <Nazara/Math/BoundingVolume.inl>
|
||||
|
||||
#endif // NAZARA_BOUNDINGVOLUME_HPP
|
||||
@@ -12,62 +12,62 @@
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>::NzBoundingBox() :
|
||||
NzBoundingVolume<T>::NzBoundingVolume() :
|
||||
extend(nzExtend_Null)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>::NzBoundingBox(nzExtend Extend)
|
||||
NzBoundingVolume<T>::NzBoundingVolume(nzExtend Extend)
|
||||
{
|
||||
Set(Extend);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>::NzBoundingBox(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
NzBoundingVolume<T>::NzBoundingVolume(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
{
|
||||
Set(X, Y, Z, Width, Height, Depth);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>::NzBoundingBox(const NzCube<T>& Cube)
|
||||
NzBoundingVolume<T>::NzBoundingVolume(const NzBox<T>& box)
|
||||
{
|
||||
Set(Cube);
|
||||
Set(box);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>::NzBoundingBox(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
NzBoundingVolume<T>::NzBoundingVolume(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
{
|
||||
Set(vec1, vec2);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzBoundingBox<T>::NzBoundingBox(const NzBoundingBox<U>& box)
|
||||
NzBoundingVolume<T>::NzBoundingVolume(const NzBoundingVolume<U>& volume)
|
||||
{
|
||||
Set(box);
|
||||
Set(volume);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzBoundingBox<T>::IsFinite() const
|
||||
bool NzBoundingVolume<T>::IsFinite() const
|
||||
{
|
||||
return extend == nzExtend_Finite;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzBoundingBox<T>::IsInfinite() const
|
||||
bool NzBoundingVolume<T>::IsInfinite() const
|
||||
{
|
||||
return extend == nzExtend_Infinite;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzBoundingBox<T>::IsNull() const
|
||||
bool NzBoundingVolume<T>::IsNull() const
|
||||
{
|
||||
return extend == nzExtend_Null;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>& NzBoundingBox<T>::MakeInfinite()
|
||||
NzBoundingVolume<T>& NzBoundingVolume<T>::MakeInfinite()
|
||||
{
|
||||
extend = nzExtend_Infinite;
|
||||
|
||||
@@ -75,7 +75,7 @@ NzBoundingBox<T>& NzBoundingBox<T>::MakeInfinite()
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>& NzBoundingBox<T>::MakeNull()
|
||||
NzBoundingVolume<T>& NzBoundingVolume<T>::MakeNull()
|
||||
{
|
||||
extend = nzExtend_Null;
|
||||
|
||||
@@ -83,7 +83,7 @@ NzBoundingBox<T>& NzBoundingBox<T>::MakeNull()
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>& NzBoundingBox<T>::Set(nzExtend Extend)
|
||||
NzBoundingVolume<T>& NzBoundingVolume<T>::Set(nzExtend Extend)
|
||||
{
|
||||
extend = Extend;
|
||||
|
||||
@@ -91,7 +91,7 @@ NzBoundingBox<T>& NzBoundingBox<T>::Set(nzExtend Extend)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>& NzBoundingBox<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
NzBoundingVolume<T>& NzBoundingVolume<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
{
|
||||
obb.Set(X, Y, Z, Width, Height, Depth);
|
||||
extend = nzExtend_Finite;
|
||||
@@ -100,24 +100,24 @@ NzBoundingBox<T>& NzBoundingBox<T>::Set(T X, T Y, T Z, T Width, T Height, T Dept
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>& NzBoundingBox<T>::Set(const NzBoundingBox<T>& box)
|
||||
NzBoundingVolume<T>& NzBoundingVolume<T>::Set(const NzBoundingVolume<T>& volume)
|
||||
{
|
||||
obb.Set(box.obb); // Seul l'OBB est importante pour la suite
|
||||
obb.Set(volume.obb); // Seul l'OBB est importante pour la suite
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>& NzBoundingBox<T>::Set(const NzCube<T>& Cube)
|
||||
NzBoundingVolume<T>& NzBoundingVolume<T>::Set(const NzBox<T>& box)
|
||||
{
|
||||
obb.Set(Cube);
|
||||
obb.Set(box);
|
||||
extend = nzExtend_Finite;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>& NzBoundingBox<T>::Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
NzBoundingVolume<T>& NzBoundingVolume<T>::Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
{
|
||||
obb.Set(vec1, vec2);
|
||||
extend = nzExtend_Finite;
|
||||
@@ -127,53 +127,53 @@ NzBoundingBox<T>& NzBoundingBox<T>::Set(const NzVector3<T>& vec1, const NzVector
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzBoundingBox<T>& NzBoundingBox<T>::Set(const NzBoundingBox<U>& box)
|
||||
NzBoundingVolume<T>& NzBoundingVolume<T>::Set(const NzBoundingVolume<U>& volume)
|
||||
{
|
||||
obb.Set(box.obb);
|
||||
extend = box.extend;
|
||||
obb.Set(volume.obb);
|
||||
extend = volume.extend;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzBoundingBox<T>::ToString() const
|
||||
NzString NzBoundingVolume<T>::ToString() const
|
||||
{
|
||||
switch (extend)
|
||||
{
|
||||
case nzExtend_Finite:
|
||||
return "BoundingBox(localCube=" + obb.localCube.ToString() + ')';
|
||||
return "BoundingVolume(localBox=" + obb.localBox.ToString() + ')';
|
||||
|
||||
case nzExtend_Infinite:
|
||||
return "BoundingBox(Infinite)";
|
||||
return "BoundingVolume(Infinite)";
|
||||
|
||||
case nzExtend_Null:
|
||||
return "BoundingBox(Null)";
|
||||
return "BoundingVolume(Null)";
|
||||
}
|
||||
|
||||
// Si nous arrivons ici c'est que l'extend est invalide
|
||||
NazaraError("Invalid extend type (0x" + NzString::Number(extend, 16) + ')');
|
||||
return "BoundingBox(ERROR)";
|
||||
return "BoundingVolume(ERROR)";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzBoundingBox<T>::Update(const NzMatrix4<T>& transformMatrix)
|
||||
void NzBoundingVolume<T>::Update(const NzMatrix4<T>& transformMatrix)
|
||||
{
|
||||
aabb.Set(obb.localCube);
|
||||
aabb.Set(obb.localBox);
|
||||
aabb.Transform(transformMatrix);
|
||||
obb.Update(transformMatrix);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T> NzBoundingBox<T>::operator*(T scalar) const
|
||||
NzBoundingVolume<T> NzBoundingVolume<T>::operator*(T scalar) const
|
||||
{
|
||||
NzBoundingBox box(*this);
|
||||
box *= scalar;
|
||||
NzBoundingVolume volume(*this);
|
||||
volume *= scalar;
|
||||
|
||||
return box;
|
||||
return volume;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T>& NzBoundingBox<T>::operator*=(T scalar)
|
||||
NzBoundingVolume<T>& NzBoundingVolume<T>::operator*=(T scalar)
|
||||
{
|
||||
obb *= scalar;
|
||||
|
||||
@@ -181,31 +181,31 @@ NzBoundingBox<T>& NzBoundingBox<T>::operator*=(T scalar)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzBoundingBox<T>::operator==(const NzBoundingBox& box) const
|
||||
bool NzBoundingVolume<T>::operator==(const NzBoundingVolume& volume) const
|
||||
{
|
||||
if (extend == box.extend)
|
||||
return obb == box.obb;
|
||||
if (extend == volume.extend)
|
||||
return obb == volume.obb;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzBoundingBox<T>::operator!=(const NzBoundingBox& box) const
|
||||
bool NzBoundingVolume<T>::operator!=(const NzBoundingVolume& volume) const
|
||||
{
|
||||
return !operator==(box);
|
||||
return !operator==(volume);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T> NzBoundingBox<T>::Infinite()
|
||||
NzBoundingVolume<T> NzBoundingVolume<T>::Infinite()
|
||||
{
|
||||
NzBoundingBox box;
|
||||
box.MakeInfinite();
|
||||
NzBoundingVolume volume;
|
||||
volume.MakeInfinite();
|
||||
|
||||
return box;
|
||||
return volume;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T> NzBoundingBox<T>::Lerp(const NzBoundingBox& from, const NzBoundingBox& to, T interpolation)
|
||||
NzBoundingVolume<T> NzBoundingVolume<T>::Lerp(const NzBoundingVolume& from, const NzBoundingVolume& to, T interpolation)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (interpolation < 0.f || interpolation > 1.f)
|
||||
@@ -229,10 +229,10 @@ NzBoundingBox<T> NzBoundingBox<T>::Lerp(const NzBoundingBox& from, const NzBound
|
||||
{
|
||||
case nzExtend_Finite:
|
||||
{
|
||||
NzBoundingBox box;
|
||||
box.Set(NzOrientedCube<T>::Lerp(from.obb, to.obb, interpolation));
|
||||
NzBoundingVolume volume;
|
||||
volume.Set(NzOrientedBox<T>::Lerp(from.obb, to.obb, interpolation));
|
||||
|
||||
return box;
|
||||
return volume;
|
||||
}
|
||||
|
||||
case nzExtend_Infinite:
|
||||
@@ -271,23 +271,23 @@ NzBoundingBox<T> NzBoundingBox<T>::Lerp(const NzBoundingBox& from, const NzBound
|
||||
}
|
||||
|
||||
// Si nous arrivons ici c'est que l'extend est invalide
|
||||
NazaraError("Invalid extend type (To) (0x" + NzString::Number(from.extend, 16) + ')');
|
||||
NazaraError("Invalid extend type (To) (0x" + NzString::Number(to.extend, 16) + ')');
|
||||
return Null();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzBoundingBox<T> NzBoundingBox<T>::Null()
|
||||
NzBoundingVolume<T> NzBoundingVolume<T>::Null()
|
||||
{
|
||||
NzBoundingBox box;
|
||||
box.MakeNull();
|
||||
NzBoundingVolume volume;
|
||||
volume.MakeNull();
|
||||
|
||||
return box;
|
||||
return volume;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzBoundingBox<T>& box)
|
||||
std::ostream& operator<<(std::ostream& out, const NzBoundingVolume<T>& volume)
|
||||
{
|
||||
out << box.ToString();
|
||||
out << volume.ToString();
|
||||
return out;
|
||||
}
|
||||
|
||||
97
include/Nazara/Math/Box.hpp
Normal file
97
include/Nazara/Math/Box.hpp
Normal file
@@ -0,0 +1,97 @@
|
||||
// Copyright (C) 2013 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_BOX_HPP
|
||||
#define NAZARA_BOX_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Enums.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Math/Sphere.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template<typename T>
|
||||
class NzBox
|
||||
{
|
||||
public:
|
||||
NzBox() = default;
|
||||
NzBox(T Width, T Height, T Depth);
|
||||
NzBox(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzBox(const T box[6]);
|
||||
NzBox(const NzRect<T>& rect);
|
||||
NzBox(const NzVector3<T>& size);
|
||||
NzBox(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> explicit NzBox(const NzBox<U>& box);
|
||||
NzBox(const NzBox& box) = default;
|
||||
~NzBox() = default;
|
||||
|
||||
bool Contains(T X, T Y, T Z) const;
|
||||
bool Contains(const NzBox& box) const;
|
||||
bool Contains(const NzVector3<T>& point) const;
|
||||
|
||||
NzBox& ExtendTo(T X, T Y, T Z);
|
||||
NzBox& ExtendTo(const NzBox& box);
|
||||
NzBox& ExtendTo(const NzVector3<T>& point);
|
||||
|
||||
NzSphere<T> GetBoundingSphere() const;
|
||||
NzVector3<T> GetCorner(nzCorner corner) const;
|
||||
NzVector3<T> GetCenter() const;
|
||||
NzVector3<T> GetNegativeVertex(const NzVector3<T>& normal) const;
|
||||
NzVector3<T> GetPosition() const;
|
||||
NzVector3<T> GetPositiveVertex(const NzVector3<T>& normal) const;
|
||||
T GetRadius() const;
|
||||
NzVector3<T> GetSize() const;
|
||||
T GetSquaredRadius() const;
|
||||
|
||||
bool Intersect(const NzBox& box, NzBox* intersection = nullptr) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
NzBox& MakeZero();
|
||||
|
||||
NzBox& Set(T Width, T Height, T Depth);
|
||||
NzBox& Set(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzBox& Set(const T box[6]);
|
||||
NzBox& Set(const NzBox& box);
|
||||
NzBox& Set(const NzRect<T>& rect);
|
||||
NzBox& Set(const NzVector3<T>& size);
|
||||
NzBox& Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> NzBox& Set(const NzBox<U>& box);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
NzBox& Transform(const NzMatrix4<T>& matrix, bool applyTranslation = true);
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
NzBox operator*(T scalar) const;
|
||||
NzBox operator*(const NzVector3<T>& vec) const;
|
||||
|
||||
NzBox& operator*=(T scalar);
|
||||
NzBox& operator*=(const NzVector3<T>& vec);
|
||||
|
||||
bool operator==(const NzBox& box) const;
|
||||
bool operator!=(const NzBox& box) const;
|
||||
|
||||
static NzBox Lerp(const NzBox& from, const NzBox& to, T interpolation);
|
||||
static NzBox Zero();
|
||||
|
||||
T x, y, z, width, height, depth;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzBox<T>& box);
|
||||
|
||||
typedef NzBox<double> NzBoxd;
|
||||
typedef NzBox<float> NzBoxf;
|
||||
typedef NzBox<int> NzBoxi;
|
||||
typedef NzBox<unsigned int> NzBoxui;
|
||||
|
||||
#include <Nazara/Math/Box.inl>
|
||||
|
||||
#endif // NAZARA_BOX_HPP
|
||||
@@ -11,50 +11,50 @@
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube(T Width, T Height, T Depth)
|
||||
NzBox<T>::NzBox(T Width, T Height, T Depth)
|
||||
{
|
||||
Set(Width, Height, Depth);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
NzBox<T>::NzBox(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
{
|
||||
Set(X, Y, Z, Width, Height, Depth);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube(const NzRect<T>& rect)
|
||||
NzBox<T>::NzBox(const NzRect<T>& rect)
|
||||
{
|
||||
Set(rect);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube(const NzVector3<T>& size)
|
||||
NzBox<T>::NzBox(const NzVector3<T>& size)
|
||||
{
|
||||
Set(size);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
NzBox<T>::NzBox(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
{
|
||||
Set(vec1, vec2);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>::NzCube(const T vec[6])
|
||||
NzBox<T>::NzBox(const T vec[6])
|
||||
{
|
||||
Set(vec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzCube<T>::NzCube(const NzCube<U>& cube)
|
||||
NzBox<T>::NzBox(const NzBox<U>& box)
|
||||
{
|
||||
Set(cube);
|
||||
Set(box);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzCube<T>::Contains(T X, T Y, T Z) const
|
||||
bool NzBox<T>::Contains(T X, T Y, T Z) const
|
||||
{
|
||||
return X >= x && X < x+width &&
|
||||
Y >= y && Y < y+height &&
|
||||
@@ -62,20 +62,20 @@ bool NzCube<T>::Contains(T X, T Y, T Z) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzCube<T>::Contains(const NzVector3<T>& point) const
|
||||
bool NzBox<T>::Contains(const NzBox<T>& box) const
|
||||
{
|
||||
return Contains(box.x, box.y, box.z) &&
|
||||
Contains(box.x + box.width, box.y + box.height, box.z + box.depth);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzBox<T>::Contains(const NzVector3<T>& point) const
|
||||
{
|
||||
return Contains(point.x, point.y, point.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzCube<T>::Contains(const NzCube<T>& cube) const
|
||||
{
|
||||
return Contains(cube.x, cube.y, cube.z) &&
|
||||
Contains(cube.x + cube.width, cube.y + cube.height, cube.z + cube.depth);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::ExtendTo(T X, T Y, T Z)
|
||||
NzBox<T>& NzBox<T>::ExtendTo(T X, T Y, T Z)
|
||||
{
|
||||
width = std::max(x + width, X);
|
||||
height = std::max(y + height, Y);
|
||||
@@ -93,21 +93,15 @@ NzCube<T>& NzCube<T>::ExtendTo(T X, T Y, T Z)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::ExtendTo(const NzVector3<T>& point)
|
||||
NzBox<T>& NzBox<T>::ExtendTo(const NzBox& box)
|
||||
{
|
||||
return ExtendTo(point.x, point.y, point.z);
|
||||
}
|
||||
width = std::max(x + width, box.x + box.width);
|
||||
height = std::max(y + height, box.y + box.height);
|
||||
depth = std::max(z + depth, box.z + box.depth);
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::ExtendTo(const NzCube& cube)
|
||||
{
|
||||
width = std::max(x + width, cube.x + cube.width);
|
||||
height = std::max(y + height, cube.y + cube.height);
|
||||
depth = std::max(z + depth, cube.z + cube.depth);
|
||||
|
||||
x = std::min(x, cube.x);
|
||||
y = std::min(y, cube.y);
|
||||
z = std::min(z, cube.z);
|
||||
x = std::min(x, box.x);
|
||||
y = std::min(y, box.y);
|
||||
z = std::min(z, box.z);
|
||||
|
||||
width -= x;
|
||||
height -= y;
|
||||
@@ -117,7 +111,13 @@ NzCube<T>& NzCube<T>::ExtendTo(const NzCube& cube)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetCorner(nzCorner corner) const
|
||||
NzBox<T>& NzBox<T>::ExtendTo(const NzVector3<T>& point)
|
||||
{
|
||||
return ExtendTo(point.x, point.y, point.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzBox<T>::GetCorner(nzCorner corner) const
|
||||
{
|
||||
switch (corner)
|
||||
{
|
||||
@@ -151,19 +151,19 @@ NzVector3<T> NzCube<T>::GetCorner(nzCorner corner) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzSphere<T> NzCube<T>::GetBoundingSphere() const
|
||||
NzSphere<T> NzBox<T>::GetBoundingSphere() const
|
||||
{
|
||||
return NzSphere<T>(GetCenter(), GetRadius());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetCenter() const
|
||||
NzVector3<T> NzBox<T>::GetCenter() const
|
||||
{
|
||||
return GetPosition() + F(0.5)*GetSize();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetNegativeVertex(const NzVector3<T>& normal) const
|
||||
NzVector3<T> NzBox<T>::GetNegativeVertex(const NzVector3<T>& normal) const
|
||||
{
|
||||
NzVector3<T> neg(GetPosition());
|
||||
|
||||
@@ -180,13 +180,13 @@ NzVector3<T> NzCube<T>::GetNegativeVertex(const NzVector3<T>& normal) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetPosition() const
|
||||
NzVector3<T> NzBox<T>::GetPosition() const
|
||||
{
|
||||
return NzVector3<T>(x, y, z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetPositiveVertex(const NzVector3<T>& normal) const
|
||||
NzVector3<T> NzBox<T>::GetPositiveVertex(const NzVector3<T>& normal) const
|
||||
{
|
||||
NzVector3<T> pos(GetPosition());
|
||||
|
||||
@@ -203,35 +203,35 @@ NzVector3<T> NzCube<T>::GetPositiveVertex(const NzVector3<T>& normal) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzCube<T>::GetRadius() const
|
||||
T NzBox<T>::GetRadius() const
|
||||
{
|
||||
return std::sqrt(GetSquaredRadius());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetSize() const
|
||||
NzVector3<T> NzBox<T>::GetSize() const
|
||||
{
|
||||
return NzVector3<T>(width, height, depth);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzCube<T>::GetSquaredRadius() const
|
||||
T NzBox<T>::GetSquaredRadius() const
|
||||
{
|
||||
NzVector3<T> size(GetSize());
|
||||
size *= F(0.5); // La taille étant relative à la position (minimum) du cube et non pas à son centre
|
||||
size *= F(0.5); // La taille étant relative à la position (minimum) de la boite et non pas à son centre
|
||||
|
||||
return size.GetSquaredLength();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzCube<T>::Intersect(const NzCube& cube, NzCube* intersection) const
|
||||
bool NzBox<T>::Intersect(const NzBox& box, NzBox* intersection) const
|
||||
{
|
||||
T left = std::max(x, cube.x);
|
||||
T right = std::min(x + width, cube.x + cube.width);
|
||||
T top = std::max(y, cube.y);
|
||||
T bottom = std::min(y + height, cube.y + cube.height);
|
||||
T up = std::max(z, cube.z);
|
||||
T down = std::min(z + depth, cube.z + cube.depth);
|
||||
T left = std::max(x, box.x);
|
||||
T right = std::min(x + width, box.x + box.width);
|
||||
T top = std::max(y, box.y);
|
||||
T bottom = std::min(y + height, box.y + box.height);
|
||||
T up = std::max(z, box.z);
|
||||
T down = std::min(z + depth, box.z + box.depth);
|
||||
|
||||
if (left < right && top < bottom && up < down)
|
||||
{
|
||||
@@ -252,13 +252,13 @@ bool NzCube<T>::Intersect(const NzCube& cube, NzCube* intersection) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzCube<T>::IsValid() const
|
||||
bool NzBox<T>::IsValid() const
|
||||
{
|
||||
return width > F(0.0) && height > F(0.0) && depth > F(0.0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::MakeZero()
|
||||
NzBox<T>& NzBox<T>::MakeZero()
|
||||
{
|
||||
x = F(0.0);
|
||||
y = F(0.0);
|
||||
@@ -271,7 +271,7 @@ NzCube<T>& NzCube<T>::MakeZero()
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::Set(T Width, T Height, T Depth)
|
||||
NzBox<T>& NzBox<T>::Set(T Width, T Height, T Depth)
|
||||
{
|
||||
x = F(0.0);
|
||||
y = F(0.0);
|
||||
@@ -284,7 +284,7 @@ NzCube<T>& NzCube<T>::Set(T Width, T Height, T Depth)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
NzBox<T>& NzBox<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
@@ -297,28 +297,28 @@ NzCube<T>& NzCube<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::Set(const T cube[6])
|
||||
NzBox<T>& NzBox<T>::Set(const T box[6])
|
||||
{
|
||||
x = cube[0];
|
||||
y = cube[1];
|
||||
z = cube[2];
|
||||
width = cube[3];
|
||||
height = cube[4];
|
||||
depth = cube[5];
|
||||
x = box[0];
|
||||
y = box[1];
|
||||
z = box[2];
|
||||
width = box[3];
|
||||
height = box[4];
|
||||
depth = box[5];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::Set(const NzCube& cube)
|
||||
NzBox<T>& NzBox<T>::Set(const NzBox& box)
|
||||
{
|
||||
std::memcpy(this, &cube, sizeof(NzCube));
|
||||
std::memcpy(this, &box, sizeof(NzBox));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::Set(const NzRect<T>& rect)
|
||||
NzBox<T>& NzBox<T>::Set(const NzRect<T>& rect)
|
||||
{
|
||||
x = rect.x;
|
||||
y = rect.y;
|
||||
@@ -331,13 +331,13 @@ NzCube<T>& NzCube<T>::Set(const NzRect<T>& rect)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::Set(const NzVector3<T>& size)
|
||||
NzBox<T>& NzBox<T>::Set(const NzVector3<T>& size)
|
||||
{
|
||||
return Set(size.x, size.y, size.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
NzBox<T>& NzBox<T>::Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
{
|
||||
x = std::min(vec1.x, vec2.x);
|
||||
y = std::min(vec1.y, vec2.y);
|
||||
@@ -351,28 +351,28 @@ NzCube<T>& NzCube<T>::Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzCube<T>& NzCube<T>::Set(const NzCube<U>& cube)
|
||||
NzBox<T>& NzBox<T>::Set(const NzBox<U>& box)
|
||||
{
|
||||
x = F(cube.x);
|
||||
y = F(cube.y);
|
||||
z = F(cube.z);
|
||||
width = F(cube.width);
|
||||
height = F(cube.height);
|
||||
depth = F(cube.depth);
|
||||
x = F(box.x);
|
||||
y = F(box.y);
|
||||
z = F(box.z);
|
||||
width = F(box.width);
|
||||
height = F(box.height);
|
||||
depth = F(box.depth);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzCube<T>::ToString() const
|
||||
NzString NzBox<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Cube(" << x << ", " << y << ", " << z << ", " << width << ", " << height << ", " << depth << ')';
|
||||
return ss << "Box(" << x << ", " << y << ", " << z << ", " << width << ", " << height << ", " << depth << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::Transform(const NzMatrix4<T>& matrix, bool applyTranslation)
|
||||
NzBox<T>& NzBox<T>::Transform(const NzMatrix4<T>& matrix, bool applyTranslation)
|
||||
{
|
||||
NzVector3<T> center = matrix.Transform(GetCenter(), (applyTranslation) ? F(1.0) : F(0.0)); // Valeur multipliant la translation
|
||||
NzVector3<T> halfSize = GetSize() * F(0.5);
|
||||
@@ -385,7 +385,7 @@ NzCube<T>& NzCube<T>::Transform(const NzMatrix4<T>& matrix, bool applyTranslatio
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzCube<T>::operator[](unsigned int i)
|
||||
T& NzBox<T>::operator[](unsigned int i)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i >= 6)
|
||||
@@ -402,7 +402,7 @@ T& NzCube<T>::operator[](unsigned int i)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzCube<T>::operator[](unsigned int i) const
|
||||
T NzBox<T>::operator[](unsigned int i) const
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i >= 6)
|
||||
@@ -419,19 +419,19 @@ T NzCube<T>::operator[](unsigned int i) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T> NzCube<T>::operator*(T scalar) const
|
||||
NzBox<T> NzBox<T>::operator*(T scalar) const
|
||||
{
|
||||
return NzCube(x, y, z, width*scalar, height*scalar, depth*scalar);
|
||||
return NzBox(x, y, z, width*scalar, height*scalar, depth*scalar);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T> NzCube<T>::operator*(const NzVector3<T>& vec) const
|
||||
NzBox<T> NzBox<T>::operator*(const NzVector3<T>& vec) const
|
||||
{
|
||||
return NzCube(x, y, z, width*vec.x, height*vec.y, depth*vec.z);
|
||||
return NzBox(x, y, z, width*vec.x, height*vec.y, depth*vec.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::operator*=(T scalar)
|
||||
NzBox<T>& NzBox<T>::operator*=(T scalar)
|
||||
{
|
||||
width *= scalar;
|
||||
height *= scalar;
|
||||
@@ -439,7 +439,7 @@ NzCube<T>& NzCube<T>::operator*=(T scalar)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::operator*=(const NzVector3<T>& vec)
|
||||
NzBox<T>& NzBox<T>::operator*=(const NzVector3<T>& vec)
|
||||
{
|
||||
width *= vec.x;
|
||||
height *= vec.y;
|
||||
@@ -447,20 +447,20 @@ NzCube<T>& NzCube<T>::operator*=(const NzVector3<T>& vec)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzCube<T>::operator==(const NzCube& cube) const
|
||||
bool NzBox<T>::operator==(const NzBox& box) 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);
|
||||
return NzNumberEquals(x, box.x) && NzNumberEquals(y, box.y) && NzNumberEquals(z, box.z) &&
|
||||
NzNumberEquals(width, box.width) && NzNumberEquals(height, box.height) && NzNumberEquals(depth, box.depth);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzCube<T>::operator!=(const NzCube& cube) const
|
||||
bool NzBox<T>::operator!=(const NzBox& box) const
|
||||
{
|
||||
return !operator==(cube);
|
||||
return !operator==(box);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T> NzCube<T>::Lerp(const NzCube& from, const NzCube& to, T interpolation)
|
||||
NzBox<T> NzBox<T>::Lerp(const NzBox& from, const NzBox& to, T interpolation)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (interpolation < F(0.0) || interpolation > F(1.0))
|
||||
@@ -470,30 +470,30 @@ NzCube<T> NzCube<T>::Lerp(const NzCube& from, const NzCube& to, T interpolation)
|
||||
}
|
||||
#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);
|
||||
NzBox box;
|
||||
box.x = NzLerp(from.x, to.x, interpolation);
|
||||
box.y = NzLerp(from.y, to.y, interpolation);
|
||||
box.z = NzLerp(from.z, to.z, interpolation);
|
||||
box.width = NzLerp(from.width, to.width, interpolation);
|
||||
box.height = NzLerp(from.height, to.height, interpolation);
|
||||
box.depth = NzLerp(from.depth, to.depth, interpolation);
|
||||
|
||||
return cube;
|
||||
return box;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T> NzCube<T>::Zero()
|
||||
NzBox<T> NzBox<T>::Zero()
|
||||
{
|
||||
NzCube cube;
|
||||
cube.MakeZero();
|
||||
NzBox box;
|
||||
box.MakeZero();
|
||||
|
||||
return cube;
|
||||
return box;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzCube<T>& cube)
|
||||
std::ostream& operator<<(std::ostream& out, const NzBox<T>& box)
|
||||
{
|
||||
return out << cube.ToString();
|
||||
return out << box.ToString();
|
||||
}
|
||||
|
||||
#undef F
|
||||
@@ -1,97 +0,0 @@
|
||||
// Copyright (C) 2013 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CUBE_HPP
|
||||
#define NAZARA_CUBE_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Enums.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Math/Sphere.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template<typename T>
|
||||
class NzCube
|
||||
{
|
||||
public:
|
||||
NzCube() = default;
|
||||
NzCube(T Width, T Height, T Depth);
|
||||
NzCube(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzCube(const T cube[6]);
|
||||
NzCube(const NzRect<T>& rect);
|
||||
NzCube(const NzVector3<T>& size);
|
||||
NzCube(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> explicit NzCube(const NzCube<U>& cube);
|
||||
NzCube(const NzCube& cube) = default;
|
||||
~NzCube() = default;
|
||||
|
||||
bool Contains(T X, T Y, T Z) const;
|
||||
bool Contains(const NzVector3<T>& point) const;
|
||||
bool Contains(const NzCube& cube) const;
|
||||
|
||||
NzCube& ExtendTo(T X, T Y, T Z);
|
||||
NzCube& ExtendTo(const NzVector3<T>& point);
|
||||
NzCube& ExtendTo(const NzCube& cube);
|
||||
|
||||
NzSphere<T> GetBoundingSphere() const;
|
||||
NzVector3<T> GetCorner(nzCorner corner) const;
|
||||
NzVector3<T> GetCenter() const;
|
||||
NzVector3<T> GetNegativeVertex(const NzVector3<T>& normal) const;
|
||||
NzVector3<T> GetPosition() const;
|
||||
NzVector3<T> GetPositiveVertex(const NzVector3<T>& normal) const;
|
||||
T GetRadius() const;
|
||||
NzVector3<T> GetSize() const;
|
||||
T GetSquaredRadius() const;
|
||||
|
||||
bool Intersect(const NzCube& cube, NzCube* intersection = nullptr) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
NzCube& MakeZero();
|
||||
|
||||
NzCube& Set(T Width, T Height, T Depth);
|
||||
NzCube& Set(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzCube& Set(const T cube[6]);
|
||||
NzCube& Set(const NzCube& cube);
|
||||
NzCube& Set(const NzRect<T>& rect);
|
||||
NzCube& Set(const NzVector3<T>& size);
|
||||
NzCube& Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> NzCube& Set(const NzCube<U>& cube);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
NzCube& Transform(const NzMatrix4<T>& matrix, bool applyTranslation = true);
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
NzCube operator*(T scalar) const;
|
||||
NzCube operator*(const NzVector3<T>& vec) const;
|
||||
|
||||
NzCube& operator*=(T scalar);
|
||||
NzCube& operator*=(const NzVector3<T>& vec);
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzCube<T>& cube);
|
||||
|
||||
typedef NzCube<double> NzCubed;
|
||||
typedef NzCube<float> NzCubef;
|
||||
typedef NzCube<int> NzCubei;
|
||||
typedef NzCube<unsigned int> NzCubeui;
|
||||
|
||||
#include <Nazara/Math/Cube.inl>
|
||||
|
||||
#endif // NAZARA_CUBE_HPP
|
||||
@@ -8,10 +8,10 @@
|
||||
#define NAZARA_FRUSTUM_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/BoundingBox.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <Nazara/Math/Enums.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/OrientedCube.hpp>
|
||||
#include <Nazara/Math/OrientedBox.hpp>
|
||||
#include <Nazara/Math/Plane.hpp>
|
||||
#include <Nazara/Math/Sphere.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
@@ -27,9 +27,9 @@ class NzFrustum
|
||||
|
||||
NzFrustum& Build(T angle, T ratio, T zNear, T zFar, const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up = NzVector3<T>::Up());
|
||||
|
||||
bool Contains(const NzBoundingBox<T>& box) const;
|
||||
bool Contains(const NzCube<T>& cube) const;
|
||||
bool Contains(const NzOrientedCube<T>& orientedCube) const;
|
||||
bool Contains(const NzBoundingVolume<T>& volume) const;
|
||||
bool Contains(const NzBox<T>& box) const;
|
||||
bool Contains(const NzOrientedBox<T>& orientedBox) const;
|
||||
bool Contains(const NzSphere<T>& sphere) const;
|
||||
bool Contains(const NzVector3<T>& point) const;
|
||||
bool Contains(const NzVector3<T>* points, unsigned int pointCount) const;
|
||||
@@ -40,9 +40,9 @@ class NzFrustum
|
||||
const NzVector3<T>& GetCorner(nzCorner corner) const;
|
||||
const NzPlane<T>& GetPlane(nzFrustumPlane plane) const;
|
||||
|
||||
nzIntersectionSide Intersect(const NzBoundingBox<T>& box) const;
|
||||
nzIntersectionSide Intersect(const NzCube<T>& cube) const;
|
||||
nzIntersectionSide Intersect(const NzOrientedCube<T>& orientedCube) const;
|
||||
nzIntersectionSide Intersect(const NzBoundingVolume<T>& volume) const;
|
||||
nzIntersectionSide Intersect(const NzBox<T>& box) const;
|
||||
nzIntersectionSide Intersect(const NzOrientedBox<T>& orientedBox) const;
|
||||
nzIntersectionSide Intersect(const NzSphere<T>& sphere) const;
|
||||
nzIntersectionSide Intersect(const NzVector3<T>* points, unsigned int pointCount) const;
|
||||
|
||||
|
||||
@@ -66,20 +66,20 @@ NzFrustum<T>& NzFrustum<T>::Build(T angle, T ratio, T zNear, T zFar, const NzVec
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzFrustum<T>::Contains(const NzBoundingBox<T>& box) const
|
||||
bool NzFrustum<T>::Contains(const NzBoundingVolume<T>& volume) const
|
||||
{
|
||||
switch (box.extend)
|
||||
switch (volume.extend)
|
||||
{
|
||||
case nzExtend_Finite:
|
||||
{
|
||||
nzIntersectionSide side = Intersect(box.aabb);
|
||||
nzIntersectionSide side = Intersect(volume.aabb);
|
||||
switch (side)
|
||||
{
|
||||
case nzIntersectionSide_Inside:
|
||||
return true;
|
||||
|
||||
case nzIntersectionSide_Intersecting:
|
||||
return Contains(box.obb);
|
||||
return Contains(volume.obb);
|
||||
|
||||
case nzIntersectionSide_Outside:
|
||||
return false;
|
||||
@@ -96,17 +96,17 @@ bool NzFrustum<T>::Contains(const NzBoundingBox<T>& box) const
|
||||
return false;
|
||||
}
|
||||
|
||||
NazaraError("Invalid extend type (0x" + NzString::Number(box.extend, 16) + ')');
|
||||
NazaraError("Invalid extend type (0x" + NzString::Number(volume.extend, 16) + ')');
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzFrustum<T>::Contains(const NzCube<T>& cube) const
|
||||
bool NzFrustum<T>::Contains(const NzBox<T>& box) const
|
||||
{
|
||||
// http://www.lighthouse3d.com/tutorials/view-frustum-culling/geometric-approach-testing-boxes-ii/
|
||||
for(unsigned int i = 0; i <= nzFrustumPlane_Max; i++)
|
||||
{
|
||||
if (m_planes[i].Distance(cube.GetPositiveVertex(m_planes[i].normal)) < F(0.0))
|
||||
if (m_planes[i].Distance(box.GetPositiveVertex(m_planes[i].normal)) < F(0.0))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -114,9 +114,9 @@ bool NzFrustum<T>::Contains(const NzCube<T>& cube) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzFrustum<T>::Contains(const NzOrientedCube<T>& orientedCube) const
|
||||
bool NzFrustum<T>::Contains(const NzOrientedBox<T>& orientedbox) const
|
||||
{
|
||||
return Contains(&orientedCube[0], 8);
|
||||
return Contains(&orientedbox[0], 8);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -367,20 +367,20 @@ const NzPlane<T>& NzFrustum<T>::GetPlane(nzFrustumPlane plane) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
nzIntersectionSide NzFrustum<T>::Intersect(const NzBoundingBox<T>& box) const
|
||||
nzIntersectionSide NzFrustum<T>::Intersect(const NzBoundingVolume<T>& volume) const
|
||||
{
|
||||
switch (box.extend)
|
||||
switch (volume.extend)
|
||||
{
|
||||
case nzExtend_Finite:
|
||||
{
|
||||
nzIntersectionSide side = Intersect(box.aabb);
|
||||
nzIntersectionSide side = Intersect(volume.aabb);
|
||||
switch (side)
|
||||
{
|
||||
case nzIntersectionSide_Inside:
|
||||
return nzIntersectionSide_Inside;
|
||||
|
||||
case nzIntersectionSide_Intersecting:
|
||||
return Intersect(box.obb);
|
||||
return Intersect(volume.obb);
|
||||
|
||||
case nzIntersectionSide_Outside:
|
||||
return nzIntersectionSide_Outside;
|
||||
@@ -397,21 +397,21 @@ nzIntersectionSide NzFrustum<T>::Intersect(const NzBoundingBox<T>& box) const
|
||||
return nzIntersectionSide_Outside;
|
||||
}
|
||||
|
||||
NazaraError("Invalid extend type (0x" + NzString::Number(box.extend, 16) + ')');
|
||||
NazaraError("Invalid extend type (0x" + NzString::Number(volume.extend, 16) + ')');
|
||||
return nzIntersectionSide_Outside;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
nzIntersectionSide NzFrustum<T>::Intersect(const NzCube<T>& cube) const
|
||||
nzIntersectionSide NzFrustum<T>::Intersect(const NzBox<T>& box) const
|
||||
{
|
||||
// http://www.lighthouse3d.com/tutorials/view-frustum-culling/geometric-approach-testing-boxes-ii/
|
||||
nzIntersectionSide side = nzIntersectionSide_Inside;
|
||||
|
||||
for(unsigned int i = 0; i <= nzFrustumPlane_Max; i++)
|
||||
{
|
||||
if (m_planes[i].Distance(cube.GetPositiveVertex(m_planes[i].normal)) < F(0.0))
|
||||
if (m_planes[i].Distance(box.GetPositiveVertex(m_planes[i].normal)) < F(0.0))
|
||||
return nzIntersectionSide_Outside;
|
||||
else if (m_planes[i].Distance(cube.GetNegativeVertex(m_planes[i].normal)) < F(0.0))
|
||||
else if (m_planes[i].Distance(box.GetNegativeVertex(m_planes[i].normal)) < F(0.0))
|
||||
side = nzIntersectionSide_Intersecting;
|
||||
}
|
||||
|
||||
@@ -419,9 +419,9 @@ nzIntersectionSide NzFrustum<T>::Intersect(const NzCube<T>& cube) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
nzIntersectionSide NzFrustum<T>::Intersect(const NzOrientedCube<T>& orientedCube) const
|
||||
nzIntersectionSide NzFrustum<T>::Intersect(const NzOrientedBox<T>& orientedbox) const
|
||||
{
|
||||
return Intersect(&orientedCube[0], 8);
|
||||
return Intersect(&orientedbox[0], 8);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
73
include/Nazara/Math/OrientedBox.hpp
Normal file
73
include/Nazara/Math/OrientedBox.hpp
Normal file
@@ -0,0 +1,73 @@
|
||||
// Copyright (C) 2013 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ORIENTEDBOX_HPP
|
||||
#define NAZARA_ORIENTEDBOX_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template<typename T>
|
||||
class NzOrientedBox
|
||||
{
|
||||
public:
|
||||
NzOrientedBox() = default;
|
||||
NzOrientedBox(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzOrientedBox(const NzBox<T>& box);
|
||||
NzOrientedBox(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> explicit NzOrientedBox(const NzOrientedBox<U>& orientedBox);
|
||||
NzOrientedBox(const NzOrientedBox& orientedBox) = default;
|
||||
~NzOrientedBox() = default;
|
||||
|
||||
const NzVector3<T>& GetCorner(nzCorner corner) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
NzOrientedBox& MakeZero();
|
||||
|
||||
NzOrientedBox& Set(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzOrientedBox& Set(const NzBox<T>& box);
|
||||
NzOrientedBox& Set(const NzOrientedBox& orientedBox);
|
||||
NzOrientedBox& Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> NzOrientedBox& Set(const NzOrientedBox<U>& orientedBox);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
void Update(const NzMatrix4<T>& transformMatrix);
|
||||
|
||||
operator NzVector3<T>*();
|
||||
operator const NzVector3<T>*() const;
|
||||
|
||||
NzVector3<T>& operator()(unsigned int i);
|
||||
NzVector3<T> operator()(unsigned int i) const;
|
||||
|
||||
NzOrientedBox operator*(T scalar) const;
|
||||
|
||||
NzOrientedBox& operator*=(T scalar);
|
||||
|
||||
bool operator==(const NzOrientedBox& box) const;
|
||||
bool operator!=(const NzOrientedBox& box) const;
|
||||
|
||||
static NzOrientedBox Lerp(const NzOrientedBox& from, const NzOrientedBox& to, T interpolation);
|
||||
static NzOrientedBox Zero();
|
||||
|
||||
NzBox<T> localBox;
|
||||
|
||||
private:
|
||||
NzVector3<T> m_corners[nzCorner_Max+1]; // Ne peuvent pas être modifiés directement
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzOrientedBox<T>& orientedBox);
|
||||
|
||||
typedef NzOrientedBox<double> NzOrientedBoxd;
|
||||
typedef NzOrientedBox<float> NzOrientedBoxf;
|
||||
|
||||
#include <Nazara/Math/OrientedBox.inl>
|
||||
|
||||
#endif // NAZARA_ORIENTEDBOX_HPP
|
||||
234
include/Nazara/Math/OrientedBox.inl
Normal file
234
include/Nazara/Math/OrientedBox.inl
Normal file
@@ -0,0 +1,234 @@
|
||||
// Copyright (C) 2013 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <cstring>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T>::NzOrientedBox(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
{
|
||||
Set(X, Y, Z, Width, Height, Depth);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T>::NzOrientedBox(const NzBox<T>& box)
|
||||
{
|
||||
Set(box);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T>::NzOrientedBox(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
{
|
||||
Set(vec1, vec2);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzOrientedBox<T>::NzOrientedBox(const NzOrientedBox<U>& orientedBox)
|
||||
{
|
||||
Set(orientedBox);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const NzVector3<T>& NzOrientedBox<T>::GetCorner(nzCorner corner) const
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (corner > nzCorner_Max)
|
||||
{
|
||||
NazaraError("Corner not handled (0x" + NzString::Number(corner, 16) + ')');
|
||||
|
||||
static NzVector3<T> dummy;
|
||||
return dummy;
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_corners[corner];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzOrientedBox<T>::IsValid() const
|
||||
{
|
||||
return localBox.IsValid();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T>& NzOrientedBox<T>::MakeZero()
|
||||
{
|
||||
localBox.MakeZero();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T>& NzOrientedBox<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
{
|
||||
localBox.Set(X, Y, Z, Width, Height, Depth);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T>& NzOrientedBox<T>::Set(const NzBox<T>& box)
|
||||
{
|
||||
localBox.Set(box);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T>& NzOrientedBox<T>::Set(const NzOrientedBox& orientedBox)
|
||||
{
|
||||
std::memcpy(this, &orientedBox, sizeof(NzOrientedBox));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T>& NzOrientedBox<T>::Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
{
|
||||
localBox.Set(vec1, vec2);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzOrientedBox<T>& NzOrientedBox<T>::Set(const NzOrientedBox<U>& orientedBox)
|
||||
{
|
||||
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
|
||||
m_corners[i].Set(orientedBox.m_corners[i]);
|
||||
|
||||
localBox = orientedBox.localBox;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzOrientedBox<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "OrientedBox(FLB: " << m_corners[nzCorner_FarLeftBottom].ToString() << "\n"
|
||||
<< " FLT: " << m_corners[nzCorner_FarLeftTop].ToString() << "\n"
|
||||
<< " FRB: " << m_corners[nzCorner_FarRightBottom].ToString() << "\n"
|
||||
<< " FRT: " << m_corners[nzCorner_FarRightTop].ToString() << "\n"
|
||||
<< " NLB: " << m_corners[nzCorner_NearLeftBottom].ToString() << "\n"
|
||||
<< " NLT: " << m_corners[nzCorner_NearLeftTop].ToString() << "\n"
|
||||
<< " NRB: " << m_corners[nzCorner_NearRightBottom].ToString() << "\n"
|
||||
<< " NRT: " << m_corners[nzCorner_NearRightTop].ToString() << ")\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzOrientedBox<T>::Update(const NzMatrix4<T>& transformMatrix)
|
||||
{
|
||||
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
|
||||
m_corners[i] = transformMatrix.Transform(localBox.GetCorner(static_cast<nzCorner>(i)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T>::operator NzVector3<T>*()
|
||||
{
|
||||
return &m_corners[0];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T>::operator const NzVector3<T>*() const
|
||||
{
|
||||
return &m_corners[0];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>& NzOrientedBox<T>::operator()(unsigned int i)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i > nzCorner_Max)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << "Index out of range: (" << i << " >= 3)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::out_of_range(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return &m_corners[i];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzOrientedBox<T>::operator()(unsigned int i) const
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i > nzCorner_Max)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << "Index out of range: (" << i << " >= 3)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::out_of_range(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return &m_corners[i];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T> NzOrientedBox<T>::operator*(T scalar) const
|
||||
{
|
||||
NzOrientedBox box(*this);
|
||||
box *= scalar;
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T>& NzOrientedBox<T>::operator*=(T scalar)
|
||||
{
|
||||
localBox *= scalar;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzOrientedBox<T>::operator==(const NzOrientedBox& box) const
|
||||
{
|
||||
return localBox == box.localBox;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzOrientedBox<T>::operator!=(const NzOrientedBox& box) const
|
||||
{
|
||||
return !operator==(box);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T> NzOrientedBox<T>::Lerp(const NzOrientedBox& from, const NzOrientedBox& to, T interpolation)
|
||||
{
|
||||
NzOrientedBox orientedBox;
|
||||
orientedBox.Set(NzBox<T>::Lerp(from.localBox, to.localBox, interpolation));
|
||||
|
||||
return orientedBox;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedBox<T> NzOrientedBox<T>::Zero()
|
||||
{
|
||||
NzOrientedBox orientedBox;
|
||||
orientedBox.MakeZero();
|
||||
|
||||
return orientedBox;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzOrientedBox<T>& orientedBox)
|
||||
{
|
||||
return out << orientedBox.ToString();
|
||||
}
|
||||
|
||||
#undef F
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
@@ -1,73 +0,0 @@
|
||||
// Copyright (C) 2013 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ORIENTEDCUBE_HPP
|
||||
#define NAZARA_ORIENTEDCUBE_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
template<typename T>
|
||||
class NzOrientedCube
|
||||
{
|
||||
public:
|
||||
NzOrientedCube() = default;
|
||||
NzOrientedCube(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzOrientedCube(const NzCube<T>& cube);
|
||||
NzOrientedCube(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> explicit NzOrientedCube(const NzOrientedCube<U>& orientedCube);
|
||||
NzOrientedCube(const NzOrientedCube& orientedCube) = default;
|
||||
~NzOrientedCube() = default;
|
||||
|
||||
const NzVector3<T>& GetCorner(nzCorner corner) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
NzOrientedCube& MakeZero();
|
||||
|
||||
NzOrientedCube& Set(T X, T Y, T Z, T Width, T Height, T Depth);
|
||||
NzOrientedCube& Set(const NzCube<T>& cube);
|
||||
NzOrientedCube& Set(const NzOrientedCube& orientedCube);
|
||||
NzOrientedCube& Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
|
||||
template<typename U> NzOrientedCube& Set(const NzOrientedCube<U>& orientedCube);
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
void Update(const NzMatrix4<T>& transformMatrix);
|
||||
|
||||
operator NzVector3<T>*();
|
||||
operator const NzVector3<T>*() const;
|
||||
|
||||
NzVector3<T>& operator()(unsigned int i);
|
||||
NzVector3<T> operator()(unsigned int i) const;
|
||||
|
||||
NzOrientedCube operator*(T scalar) const;
|
||||
|
||||
NzOrientedCube& operator*=(T scalar);
|
||||
|
||||
bool operator==(const NzOrientedCube& cube) const;
|
||||
bool operator!=(const NzOrientedCube& cube) const;
|
||||
|
||||
static NzOrientedCube Lerp(const NzOrientedCube& from, const NzOrientedCube& to, T interpolation);
|
||||
static NzOrientedCube Zero();
|
||||
|
||||
NzCube<T> localCube;
|
||||
|
||||
private:
|
||||
NzVector3<T> m_corners[nzCorner_Max+1]; // Ne peuvent pas être modifiés directement
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzOrientedCube<T>& orientedCube);
|
||||
|
||||
typedef NzOrientedCube<double> NzOrientedCubed;
|
||||
typedef NzOrientedCube<float> NzOrientedCubef;
|
||||
|
||||
#include <Nazara/Math/OrientedCube.inl>
|
||||
|
||||
#endif // NAZARA_ORIENTEDCUBE_HPP
|
||||
@@ -1,234 +0,0 @@
|
||||
// Copyright (C) 2013 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <cstring>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
#define F(a) static_cast<T>(a)
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T>::NzOrientedCube(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
{
|
||||
Set(X, Y, Z, Width, Height, Depth);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T>::NzOrientedCube(const NzCube<T>& cube)
|
||||
{
|
||||
Set(cube);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T>::NzOrientedCube(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
{
|
||||
Set(vec1, vec2);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzOrientedCube<T>::NzOrientedCube(const NzOrientedCube<U>& orientedCube)
|
||||
{
|
||||
Set(orientedCube);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const NzVector3<T>& NzOrientedCube<T>::GetCorner(nzCorner corner) const
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (corner > nzCorner_Max)
|
||||
{
|
||||
NazaraError("Corner not handled (0x" + NzString::Number(corner, 16) + ')');
|
||||
|
||||
static NzVector3<T> dummy;
|
||||
return dummy;
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_corners[corner];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzOrientedCube<T>::IsValid() const
|
||||
{
|
||||
return localCube.IsValid();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T>& NzOrientedCube<T>::MakeZero()
|
||||
{
|
||||
localCube.MakeZero();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T>& NzOrientedCube<T>::Set(T X, T Y, T Z, T Width, T Height, T Depth)
|
||||
{
|
||||
localCube.Set(X, Y, Z, Width, Height, Depth);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T>& NzOrientedCube<T>::Set(const NzCube<T>& cube)
|
||||
{
|
||||
localCube.Set(cube);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T>& NzOrientedCube<T>::Set(const NzOrientedCube& orientedCube)
|
||||
{
|
||||
std::memcpy(this, &orientedCube, sizeof(NzOrientedCube));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T>& NzOrientedCube<T>::Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2)
|
||||
{
|
||||
localCube.Set(vec1, vec2);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzOrientedCube<T>& NzOrientedCube<T>::Set(const NzOrientedCube<U>& orientedCube)
|
||||
{
|
||||
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
|
||||
m_corners[i].Set(orientedCube.m_corners[i]);
|
||||
|
||||
localCube = orientedCube.localCube;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzOrientedCube<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "OrientedCube(FLB: " << m_corners[nzCorner_FarLeftBottom].ToString() << "\n"
|
||||
<< " FLT: " << m_corners[nzCorner_FarLeftTop].ToString() << "\n"
|
||||
<< " FRB: " << m_corners[nzCorner_FarRightBottom].ToString() << "\n"
|
||||
<< " FRT: " << m_corners[nzCorner_FarRightTop].ToString() << "\n"
|
||||
<< " NLB: " << m_corners[nzCorner_NearLeftBottom].ToString() << "\n"
|
||||
<< " NLT: " << m_corners[nzCorner_NearLeftTop].ToString() << "\n"
|
||||
<< " NRB: " << m_corners[nzCorner_NearRightBottom].ToString() << "\n"
|
||||
<< " NRT: " << m_corners[nzCorner_NearRightTop].ToString() << ")\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzOrientedCube<T>::Update(const NzMatrix4<T>& transformMatrix)
|
||||
{
|
||||
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
|
||||
m_corners[i] = transformMatrix.Transform(localCube.GetCorner(static_cast<nzCorner>(i)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T>::operator NzVector3<T>*()
|
||||
{
|
||||
return &m_corners[0];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T>::operator const NzVector3<T>*() const
|
||||
{
|
||||
return &m_corners[0];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>& NzOrientedCube<T>::operator()(unsigned int i)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i > nzCorner_Max)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << "Index out of range: (" << i << " >= 3)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::out_of_range(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return &m_corners[i];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzOrientedCube<T>::operator()(unsigned int i) const
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i > nzCorner_Max)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << "Index out of range: (" << i << " >= 3)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::out_of_range(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
|
||||
return &m_corners[i];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T> NzOrientedCube<T>::operator*(T scalar) const
|
||||
{
|
||||
NzOrientedCube box(*this);
|
||||
box *= scalar;
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T>& NzOrientedCube<T>::operator*=(T scalar)
|
||||
{
|
||||
localCube *= scalar;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzOrientedCube<T>::operator==(const NzOrientedCube& box) const
|
||||
{
|
||||
return localCube == box.localCube;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzOrientedCube<T>::operator!=(const NzOrientedCube& box) const
|
||||
{
|
||||
return !operator==(box);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T> NzOrientedCube<T>::Lerp(const NzOrientedCube& from, const NzOrientedCube& to, T interpolation)
|
||||
{
|
||||
NzOrientedCube orientedCube;
|
||||
orientedCube.Set(NzCube<T>::Lerp(from.localCube, to.localCube, interpolation));
|
||||
|
||||
return orientedCube;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzOrientedCube<T> NzOrientedCube<T>::Zero()
|
||||
{
|
||||
NzOrientedCube orientedCube;
|
||||
orientedCube.MakeZero();
|
||||
|
||||
return orientedCube;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzOrientedCube<T>& orientedCube)
|
||||
{
|
||||
return out << orientedCube.ToString();
|
||||
}
|
||||
|
||||
#undef F
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
@@ -24,7 +24,7 @@ class NzSphere
|
||||
~NzSphere() = default;
|
||||
|
||||
bool Contains(T X, T Y, T Z) const;
|
||||
//bool Contains(const NzCube<T>& cube) const;
|
||||
//bool Contains(const NzBox<T>& box) const;
|
||||
bool Contains(const NzVector3<T>& point) const;
|
||||
|
||||
T Distance(T X, T Y, T Z) const;
|
||||
@@ -37,7 +37,7 @@ class NzSphere
|
||||
NzVector3<T> GetPosition() const;
|
||||
NzVector3<T> GetPositiveVertex(const NzVector3<T>& normal) const;
|
||||
|
||||
//bool Intersect(const NzCube<T>& cube) const;
|
||||
//bool Intersect(const NzBox<T>& box) const;
|
||||
bool Intersect(const NzSphere& sphere) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
@@ -48,7 +48,7 @@ bool NzSphere<T>::Contains(T X, T Y, T Z) const
|
||||
}
|
||||
/*
|
||||
template<typename T>
|
||||
bool NzSphere<T>::Contains(const NzCube<T>& cube) const
|
||||
bool NzSphere<T>::Contains(const NzBox<T>& box) const
|
||||
{
|
||||
}
|
||||
*/
|
||||
@@ -113,7 +113,7 @@ NzVector3<T> NzSphere<T>::GetPositiveVertex(const NzVector3<T>& normal) const
|
||||
}
|
||||
/*
|
||||
template<typename T>
|
||||
bool NzSphere<T>::Intersect(const NzCube<T>& cube) const
|
||||
bool NzSphere<T>::Intersect(const NzBox<T>& box) const
|
||||
{
|
||||
|
||||
}
|
||||
@@ -165,7 +165,7 @@ NzSphere<T>& NzSphere<T>::Set(const NzVector3<T>& center, T Radius)
|
||||
}
|
||||
/*
|
||||
template<typename T>
|
||||
NzSphere<T>& NzCube<T>::Set(const NzCircle<T>& circle)
|
||||
NzSphere<T>& NzSphere<T>::Set(const NzCircle<T>& circle)
|
||||
{
|
||||
x = circle.x;
|
||||
y = circle.y;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
struct NewtonWorld;
|
||||
@@ -25,7 +25,7 @@ class NAZARA_API NzPhysWorld : NzNonCopyable
|
||||
unsigned int GetMemoryUsed() const;
|
||||
|
||||
void SetGravity(const NzVector3f& gravity);
|
||||
void SetSize(const NzCubef& cube);
|
||||
void SetSize(const NzBoxf& box);
|
||||
void SetSize(const NzVector3f& min, const NzVector3f& max);
|
||||
void SetSolverModel(unsigned int model);
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Math/BoundingBox.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Frustum.hpp>
|
||||
#include <Nazara/Math/OrientedCube.hpp>
|
||||
#include <Nazara/Math/OrientedBox.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
|
||||
class NzSkeleton;
|
||||
@@ -20,12 +20,12 @@ class NzSkeleton;
|
||||
class NAZARA_API NzDebugDrawer
|
||||
{
|
||||
public:
|
||||
static void Draw(const NzBoundingBoxf& box);
|
||||
static void Draw(const NzCubef& cube);
|
||||
static void Draw(const NzCubei& cube);
|
||||
static void Draw(const NzCubeui& cube);
|
||||
static void Draw(const NzBoundingVolumef& volume);
|
||||
static void Draw(const NzBoxf& box);
|
||||
static void Draw(const NzBoxi& box);
|
||||
static void Draw(const NzBoxui& box);
|
||||
static void Draw(const NzFrustumf& frustum);
|
||||
static void Draw(const NzOrientedCubef& orientedCube);
|
||||
static void Draw(const NzOrientedBoxf& orientedBox);
|
||||
static void Draw(const NzSkeleton* skeleton);
|
||||
//static void DrawNormals(const NzSubMesh* subMesh);
|
||||
//static void DrawTangents(const NzSubMesh* subMesh);
|
||||
|
||||
@@ -75,11 +75,11 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
||||
bool SetMipmapRange(nzUInt8 minLevel, nzUInt8 maxLevel);
|
||||
|
||||
bool Update(const NzImage& image, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzBoxui& box, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzCubeui& cube, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzCubeui& cube, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const NzImage& image, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const NzImage& image, const NzRectui& rect, nzUInt8 level = 0);
|
||||
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
|
||||
@@ -8,23 +8,24 @@
|
||||
#define NAZARA_ALGORITHM_UTILITY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
|
||||
NAZARA_API void NzComputeCubeIndexVertexCount(const NzVector3ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
NAZARA_API void NzComputeBoxIndexVertexCount(const NzVector3ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
NAZARA_API void NzComputeCubicSphereIndexVertexCount(unsigned int subdivision, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
NAZARA_API void NzComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
NAZARA_API void NzComputePlaneIndexVertexCount(const NzVector2ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
NAZARA_API void NzComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, unsigned int* indexCount, unsigned int* vertexCount);
|
||||
|
||||
///TODO: Itérateur sur les indices
|
||||
NAZARA_API void NzGenerateCube(const NzCubef& cube, const NzVector3ui& subdivision, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateCubicSphere(float size, unsigned int subdivision, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateIcoSphere(float size, unsigned int recursionLevel, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGeneratePlane(const NzVector2ui& subdivision, const NzVector3f& position, const NzVector3f& normal, const NzVector2f& size, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateUvSphere(float size, unsigned int sliceCount, unsigned int stackCount, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateBox(const NzBoxf& box, const NzVector3ui& subdivision, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateCubicSphere(float size, unsigned int subdivision, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateIcoSphere(float size, unsigned int recursionLevel, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGeneratePlane(const NzVector2ui& subdivision, const NzVector3f& position, const NzVector3f& normal, const NzVector2f& size, NzMeshVertex* vertices, nzUInt32* indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
NAZARA_API void NzGenerateUvSphere(float size, unsigned int sliceCount, unsigned int stackCount, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzBoxf* aabb = nullptr, unsigned int indexOffset = 0);
|
||||
|
||||
inline void NzTransformVertex(NzMeshVertex* vertex, const NzMatrix4f& matrix);
|
||||
inline void NzTransformVertices(NzMeshVertex* vertices, unsigned int vertexCount, const NzMatrix4f& matrix);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/CubemapParams.hpp>
|
||||
@@ -56,14 +56,14 @@ class NAZARA_API NzImage : public NzResource
|
||||
|
||||
bool Convert(nzPixelFormat format);
|
||||
|
||||
void Copy(const NzImage& source, const NzCubeui& srcCube, const NzVector3ui& dstPos);
|
||||
void Copy(const NzImage& source, const NzBoxui& srcBox, const NzVector3ui& dstPos);
|
||||
|
||||
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
|
||||
void Destroy();
|
||||
|
||||
bool Fill(const NzColor& color);
|
||||
bool Fill(const NzColor& color, const NzBoxui& box);
|
||||
bool Fill(const NzColor& color, const NzRectui& rect, unsigned int z = 0);
|
||||
bool Fill(const NzColor& color, const NzCubeui& cube);
|
||||
|
||||
bool FlipHorizontally();
|
||||
bool FlipVertically();
|
||||
@@ -101,8 +101,8 @@ class NAZARA_API NzImage : public NzResource
|
||||
bool SetPixelColor(const NzColor& color, unsigned int x, unsigned int y = 0, unsigned int z = 0);
|
||||
|
||||
void Update(const nzUInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
void Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
void Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
void Update(const nzUInt8* pixels, const NzCubeui& cube, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
|
||||
NzImage& operator=(const NzImage& image);
|
||||
NzImage& operator=(NzImage&& image) noexcept;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
@@ -65,7 +65,7 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
||||
void GenerateNormalsAndTangents();
|
||||
void GenerateTangents();
|
||||
|
||||
const NzCubef& GetAABB() const;
|
||||
const NzBoxf& GetAABB() const;
|
||||
NzString GetAnimation() const;
|
||||
nzAnimationType GetAnimationType() const;
|
||||
unsigned int GetJointCount() const;
|
||||
|
||||
@@ -40,7 +40,7 @@ class NAZARA_API NzSkeletalMesh final : public NzSubMesh
|
||||
bool Create(unsigned int vertexCount, unsigned int weightCount);
|
||||
void Destroy();
|
||||
|
||||
const NzCubef& GetAABB() const;
|
||||
const NzBoxf& GetAABB() const;
|
||||
nzAnimationType GetAnimationType() const final;
|
||||
void* GetBindPoseBuffer();
|
||||
const void* GetBindPoseBuffer() const;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#define NAZARA_SKELETON_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Utility/Joint.hpp>
|
||||
#include <vector>
|
||||
|
||||
@@ -26,7 +26,7 @@ class NAZARA_API NzSkeleton
|
||||
bool Create(unsigned int jointCount);
|
||||
void Destroy();
|
||||
|
||||
const NzCubef& GetAABB() const;
|
||||
const NzBoxf& GetAABB() const;
|
||||
NzJoint* GetJoint(const NzString& jointName);
|
||||
NzJoint* GetJoint(unsigned int index);
|
||||
const NzJoint* GetJoint(const NzString& jointName) const;
|
||||
|
||||
@@ -27,7 +27,7 @@ class NAZARA_API NzStaticMesh final : public NzSubMesh, NzResourceListener
|
||||
|
||||
bool GenerateAABB();
|
||||
|
||||
const NzCubef& GetAABB() const override;
|
||||
const NzBoxf& GetAABB() const override;
|
||||
nzAnimationType GetAnimationType() const final;
|
||||
const NzIndexBuffer* GetIndexBuffer() const override;
|
||||
NzVertexBuffer* GetVertexBuffer();
|
||||
@@ -37,13 +37,13 @@ class NAZARA_API NzStaticMesh final : public NzSubMesh, NzResourceListener
|
||||
bool IsAnimated() const final;
|
||||
bool IsValid() const;
|
||||
|
||||
void SetAABB(const NzCubef& aabb);
|
||||
void SetAABB(const NzBoxf& aabb);
|
||||
void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
||||
|
||||
private:
|
||||
void OnResourceReleased(const NzResource* resource, int index) override;
|
||||
|
||||
NzCubef m_aabb;
|
||||
NzBoxf m_aabb;
|
||||
const NzIndexBuffer* m_indexBuffer = nullptr;
|
||||
NzVertexBuffer* m_vertexBuffer = nullptr;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
@@ -34,7 +34,7 @@ class NAZARA_API NzSubMesh : public NzResource
|
||||
void GenerateNormalsAndTangents();
|
||||
void GenerateTangents();
|
||||
|
||||
virtual const NzCubef& GetAABB() const = 0;
|
||||
virtual const NzBoxf& GetAABB() const = 0;
|
||||
virtual nzAnimationType GetAnimationType() const = 0;
|
||||
virtual const NzIndexBuffer* GetIndexBuffer() const = 0;
|
||||
unsigned int GetMaterialIndex() const;
|
||||
|
||||
Reference in New Issue
Block a user