Big skeletal animation update
Added MeshInfos demo Added MD5Mesh/MD5Anim loader support Added Node class Fixed ResourceParams not being exported Added support for skeletal animation (Animation/Mesh/Joint/SkeletalMesh/Skeleton) Meshes are now only stored with VertexStruct_XYZ_Normal_UV_Tangent type Moved Sequence declaration to Sequence.hpp -Animation: Renamed Create to Create[Keyframe|Skeletal] -AxisAlignedBox: Added Contains method Added GetCorner method Added GetCube method Added Transform method -Cube/Rect: Added GetPosition method Added GetSize method (Almost) Fixed ExtendTo method Fixed GetCenter method -File: Added GetDirectory static function Added GetPath method Renamed GetDirectoryPath method to GetDirectory -Math module: Fixed constructor/methods taking a non-const array GetNormal/Normalize methods now takes an optionnal integer pointer (returning length) Made all classes default constructor trivial Inverse, MakeIdentity, MakeZero, Normalize, Set methods now returns reference to object -Matrix4: Modified methods to avoid copies Removed COW (Too much overhead) Removed Concatenate[Affine] static function -Mesh: Renamed Create to Create[Keyframe|Skeletal|Static] Renamed Skin to Material -MeshParams: No longer takes declaration argument Renamed loadAnimations to animated Storage default to BufferStorage_Hardware if supported and BufferStorage_Software otherwise -OpenGL: Added glGetBooleanv function Added glIsEnabled function -Quaternion: Added ComputeW method Added Conjugate method -Renderer: Added IsEnabled static function Fixed GetLineWidth function not being static Removed SetVertexDeclaration -RenderWindow: Made CopyTo[Image|Texture] method constant -Resource Fixed RemoveResourceListener crash -ResourceLoader: Loaders are now used in a LIFO context -Stream: Renamed GetLine method to ReadLine -String: Fixed Simplified -Utility module Added configuration define for strict resource parsing -VertexBuffer Now takes a VertexDeclaration pointer -VertexDeclaration No longer throw an error when getting a non-existing element Former-commit-id: f7358c1231d6af48b799d2f24f077a001e16785b
This commit is contained in:
@@ -38,6 +38,24 @@ bool NzAxisAlignedBox::Contains(const NzAxisAlignedBox& box)
|
||||
return m_cube.Contains(box.m_cube);
|
||||
}
|
||||
|
||||
bool NzAxisAlignedBox::Contains(const NzVector3f& vector)
|
||||
{
|
||||
switch (m_extend)
|
||||
{
|
||||
case nzExtend_Finite:
|
||||
return m_cube.Contains(vector);
|
||||
|
||||
case nzExtend_Infinite:
|
||||
return true;
|
||||
|
||||
case nzExtend_Null:
|
||||
return false;
|
||||
}
|
||||
|
||||
NazaraError("Extend type not handled (0x" + NzString::Number(m_extend, 16) + ')');
|
||||
return false;
|
||||
}
|
||||
|
||||
void NzAxisAlignedBox::ExtendTo(const NzAxisAlignedBox& box)
|
||||
{
|
||||
switch (m_extend)
|
||||
@@ -81,17 +99,50 @@ void NzAxisAlignedBox::ExtendTo(const NzVector3f& vector)
|
||||
break;
|
||||
|
||||
case nzExtend_Null:
|
||||
// Nous étendons l'AABB en la construisant de l'origine jusqu'au vecteur
|
||||
m_cube.x = 0.f;
|
||||
m_cube.y = 0.f;
|
||||
m_cube.z = 0.f;
|
||||
m_cube.width = std::fabs(vector.x);
|
||||
m_cube.height = std::fabs(vector.y);
|
||||
m_cube.depth = std::fabs(vector.z);
|
||||
m_extend = nzExtend_Finite;
|
||||
m_cube.Set(vector, vector);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NzVector3f NzAxisAlignedBox::GetCorner(nzCorner corner) const
|
||||
{
|
||||
switch (corner)
|
||||
{
|
||||
case nzCorner_FarLeftBottom:
|
||||
return NzVector3f(m_cube.x, m_cube.y, m_cube.z);
|
||||
|
||||
case nzCorner_FarLeftTop:
|
||||
return NzVector3f(m_cube.x, m_cube.y+m_cube.height, m_cube.z);
|
||||
|
||||
case nzCorner_FarRightBottom:
|
||||
return NzVector3f(m_cube.x+m_cube.width, m_cube.y, m_cube.z);
|
||||
|
||||
case nzCorner_FarRightTop:
|
||||
return NzVector3f(m_cube.x+m_cube.width, m_cube.y+m_cube.height, m_cube.z);
|
||||
|
||||
case nzCorner_NearLeftBottom:
|
||||
return NzVector3f(m_cube.x, m_cube.y, m_cube.z+m_cube.depth);
|
||||
|
||||
case nzCorner_NearLeftTop:
|
||||
return NzVector3f(m_cube.x, m_cube.y+m_cube.height, m_cube.z+m_cube.depth);
|
||||
|
||||
case nzCorner_NearRightBottom:
|
||||
return NzVector3f(m_cube.x+m_cube.width, m_cube.y, m_cube.z+m_cube.depth);
|
||||
|
||||
case nzCorner_NearRightTop:
|
||||
return NzVector3f(m_cube.x+m_cube.width, m_cube.y+m_cube.height, m_cube.z+m_cube.depth);
|
||||
}
|
||||
|
||||
NazaraError("Corner not handled (0x" + NzString::Number(corner, 16) + ')');
|
||||
return NzVector3f();
|
||||
}
|
||||
|
||||
NzCubef NzAxisAlignedBox::GetCube() const
|
||||
{
|
||||
return m_cube;
|
||||
}
|
||||
|
||||
nzExtend NzAxisAlignedBox::GetExtend() const
|
||||
{
|
||||
return m_extend;
|
||||
@@ -99,12 +150,12 @@ nzExtend NzAxisAlignedBox::GetExtend() const
|
||||
|
||||
NzVector3f NzAxisAlignedBox::GetMaximum() const
|
||||
{
|
||||
return NzVector3f(m_cube.x+m_cube.width, m_cube.y+m_cube.height, m_cube.z+m_cube.depth);
|
||||
return m_cube.GetPosition() + m_cube.GetSize();
|
||||
}
|
||||
|
||||
NzVector3f NzAxisAlignedBox::GetMinimum() const
|
||||
{
|
||||
return NzVector3f(m_cube.x, m_cube.y, m_cube.z);
|
||||
return m_cube.GetPosition();
|
||||
}
|
||||
|
||||
bool NzAxisAlignedBox::IsFinite() const
|
||||
@@ -155,6 +206,22 @@ NzString NzAxisAlignedBox::ToString() const
|
||||
return "NzAxisAlignedBox(ERROR)";
|
||||
}
|
||||
|
||||
void NzAxisAlignedBox::Transform(const NzMatrix4f& matrix)
|
||||
{
|
||||
if (m_extend != nzExtend_Finite)
|
||||
return;
|
||||
|
||||
NzVector3f center = matrix.Transform(m_cube.GetCenter(), 0.f); // 0.f pour annuler la translation
|
||||
NzVector3f halfSize = m_cube.GetSize() * 0.5f;
|
||||
|
||||
halfSize.Set(std::fabs(matrix(0,0))*halfSize.x + std::fabs(matrix(1,0))*halfSize.y + std::fabs(matrix(2,0))*halfSize.z,
|
||||
std::fabs(matrix(0,1))*halfSize.x + std::fabs(matrix(1,1))*halfSize.y + std::fabs(matrix(2,1))*halfSize.z,
|
||||
std::fabs(matrix(0,2))*halfSize.x + std::fabs(matrix(1,2))*halfSize.y + std::fabs(matrix(2,2))*halfSize.z);
|
||||
|
||||
|
||||
m_cube.Set(center - halfSize, center + halfSize);
|
||||
}
|
||||
|
||||
NzAxisAlignedBox::operator NzString() const
|
||||
{
|
||||
return ToString();
|
||||
|
||||
Reference in New Issue
Block a user