Files
NazaraEngine/include/Nazara/Utility/Formats/MD5AnimParser.hpp
Lynix 68d67cc9da Utility: First code cleaning pass
Former-commit-id: a73d38ce2db2e780ad5b02cdae1c590606081650 [formerly 3d21c0fa44481bf91418a15012fa187a210fc9ad] [formerly b80263df8e91b85f3fd091724c54dec7f05bc535 [formerly 7dcaabaabf74fbdf840289bfc435fdd8e88969d7]]
Former-commit-id: a669a933edd2364d9ee487c7d1bb38e28ad87a2d [formerly b8c5c09df10ce2f831635f460393216799d44056]
Former-commit-id: 6bbd5af22e30cc7fd4b4478162ae89e69b3d274e
2016-09-04 20:39:34 +02:00

83 lines
1.8 KiB
C++

// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_FORMATS_MD5ANIMPARSER_HPP
#define NAZARA_FORMATS_MD5ANIMPARSER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Stream.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Utility/Animation.hpp>
#include <vector>
namespace Nz
{
class NAZARA_UTILITY_API MD5AnimParser
{
public:
struct FrameJoint
{
Quaternionf orient;
Vector3f pos;
};
struct Frame
{
std::vector<FrameJoint> joints;
Boxf bounds;
};
struct Joint
{
Int32 parent;
Quaternionf bindOrient;
String name;
Vector3f bindPos;
UInt32 flags;
UInt32 index;
};
MD5AnimParser(Stream& stream);
~MD5AnimParser();
Ternary Check();
UInt32 GetAnimatedComponentCount() const;
const Frame* GetFrames() const;
UInt32 GetFrameCount() const;
UInt32 GetFrameRate() const;
const Joint* GetJoints() const;
UInt32 GetJointCount() const;
bool Parse();
private:
bool Advance(bool required = true);
void Error(const String& message);
bool ParseBaseframe();
bool ParseBounds();
bool ParseFrame();
bool ParseHierarchy();
void Warning(const String& message);
void UnrecognizedLine(bool error = false);
std::vector<float> m_animatedComponents;
std::vector<Frame> m_frames;
std::vector<Joint> m_joints;
Stream& m_stream;
String m_currentLine;
bool m_keepLastLine;
unsigned int m_frameIndex;
unsigned int m_frameRate;
unsigned int m_lineCount;
unsigned int m_streamFlags;
};
}
#endif // NAZARA_FORMATS_MD5ANIMPARSER_HPP