Switch from Nz prefix to namespace Nz

What a huge commit


Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
Lynix
2015-09-25 19:20:05 +02:00
parent c214251ecf
commit df8da275c4
609 changed files with 68265 additions and 66534 deletions

View File

@@ -6,87 +6,93 @@
#include <Nazara/Utility/Formats/MD5AnimParser.hpp>
#include <Nazara/Utility/Debug.hpp>
namespace
namespace Nz
{
bool IsSupported(const NzString& extension)
namespace
{
return (extension == "md5anim");
}
nzTernary Check(NzInputStream& stream, const NzAnimationParams& parameters)
{
NazaraUnused(parameters);
NzMD5AnimParser parser(stream);
return parser.Check();
}
bool Load(NzAnimation* animation, NzInputStream& stream, const NzAnimationParams& parameters)
{
///TODO: Utiliser les paramètres
NzMD5AnimParser parser(stream);
if (!parser.Parse())
bool IsSupported(const String& extension)
{
NazaraError("MD5Anim parser failed");
return false;
return (extension == "md5anim");
}
const NzMD5AnimParser::Frame* frames = parser.GetFrames();
unsigned int frameCount = parser.GetFrameCount();
unsigned int frameRate = parser.GetFrameRate();
const NzMD5AnimParser::Joint* joints = parser.GetJoints();
unsigned int jointCount = parser.GetJointCount();
// À ce stade, nous sommes censés avoir assez d'informations pour créer l'animation
animation->CreateSkeletal(frameCount, jointCount);
NzSequence sequence;
sequence.firstFrame = 0;
sequence.frameCount = frameCount;
sequence.frameRate = frameRate;
sequence.name = stream.GetPath().SubStringFrom(NAZARA_DIRECTORY_SEPARATOR, -1, true);
animation->AddSequence(sequence);
NzSequenceJoint* sequenceJoints = animation->GetSequenceJoints();
// Pour que le squelette soit correctement aligné, il faut appliquer un quaternion "de correction" aux joints à la base du squelette
NzQuaternionf rotationQuat = NzQuaternionf::RotationBetween(NzVector3f::UnitX(), NzVector3f::Forward()) *
NzQuaternionf::RotationBetween(NzVector3f::UnitZ(), NzVector3f::Up());
for (unsigned int i = 0; i < jointCount; ++i)
Ternary Check(InputStream& stream, const AnimationParams& parameters)
{
int parent = joints[i].parent;
for (unsigned int j = 0; j < frameCount; ++j)
NazaraUnused(parameters);
MD5AnimParser parser(stream);
return parser.Check();
}
bool Load(Animation* animation, InputStream& stream, const AnimationParams& parameters)
{
///TODO: Utiliser les paramètres
MD5AnimParser parser(stream);
if (!parser.Parse())
{
NzSequenceJoint& sequenceJoint = sequenceJoints[j*jointCount + i];
if (parent >= 0)
{
sequenceJoint.position = frames[j].joints[i].pos;
sequenceJoint.rotation = frames[j].joints[i].orient;
}
else
{
sequenceJoint.position = rotationQuat * frames[j].joints[i].pos;
sequenceJoint.rotation = rotationQuat * frames[j].joints[i].orient;
}
sequenceJoint.scale.Set(1.f);
NazaraError("MD5Anim parser failed");
return false;
}
const MD5AnimParser::Frame* frames = parser.GetFrames();
unsigned int frameCount = parser.GetFrameCount();
unsigned int frameRate = parser.GetFrameRate();
const MD5AnimParser::Joint* joints = parser.GetJoints();
unsigned int jointCount = parser.GetJointCount();
// À ce stade, nous sommes censés avoir assez d'informations pour créer l'animation
animation->CreateSkeletal(frameCount, jointCount);
Sequence sequence;
sequence.firstFrame = 0;
sequence.frameCount = frameCount;
sequence.frameRate = frameRate;
sequence.name = stream.GetPath().SubStringFrom(NAZARA_DIRECTORY_SEPARATOR, -1, true);
animation->AddSequence(sequence);
SequenceJoint* sequenceJoints = animation->GetSequenceJoints();
// Pour que le squelette soit correctement aligné, il faut appliquer un quaternion "de correction" aux joints à la base du squelette
Quaternionf rotationQuat = Quaternionf::RotationBetween(Vector3f::UnitX(), Vector3f::Forward()) *
Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up());
for (unsigned int i = 0; i < jointCount; ++i)
{
int parent = joints[i].parent;
for (unsigned int j = 0; j < frameCount; ++j)
{
SequenceJoint& sequenceJoint = sequenceJoints[j*jointCount + i];
if (parent >= 0)
{
sequenceJoint.position = frames[j].joints[i].pos;
sequenceJoint.rotation = frames[j].joints[i].orient;
}
else
{
sequenceJoint.position = rotationQuat * frames[j].joints[i].pos;
sequenceJoint.rotation = rotationQuat * frames[j].joints[i].orient;
}
sequenceJoint.scale.Set(1.f);
}
}
return true;
}
}
namespace Loaders
{
void RegisterMD5Anim()
{
AnimationLoader::RegisterLoader(IsSupported, Check, Load);
}
return true;
void UnregisterMD5Anim()
{
AnimationLoader::UnregisterLoader(IsSupported, Check, Load);
}
}
}
void NzLoaders_MD5Anim_Register()
{
NzAnimationLoader::RegisterLoader(IsSupported, Check, Load);
}
void NzLoaders_MD5Anim_Unregister()
{
NzAnimationLoader::UnregisterLoader(IsSupported, Check, Load);
}