Rename and move loaders, expose parsers
Former-commit-id: 932ae2aab020f956d3fdb91107f6842ff292aa08
This commit is contained in:
79
include/Nazara/Utility/Formats/MD5AnimParser.hpp
Normal file
79
include/Nazara/Utility/Formats/MD5AnimParser.hpp
Normal file
@@ -0,0 +1,79 @@
|
||||
// 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/InputStream.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <vector>
|
||||
|
||||
class NAZARA_API NzMD5AnimParser
|
||||
{
|
||||
public:
|
||||
struct FrameJoint
|
||||
{
|
||||
NzQuaternionf orient;
|
||||
NzVector3f pos;
|
||||
};
|
||||
|
||||
struct Frame
|
||||
{
|
||||
std::vector<FrameJoint> joints;
|
||||
NzBoxf bounds;
|
||||
};
|
||||
|
||||
struct Joint
|
||||
{
|
||||
NzQuaternionf bindOrient;
|
||||
NzString name;
|
||||
NzVector3f bindPos;
|
||||
int parent;
|
||||
unsigned int flags;
|
||||
unsigned int index;
|
||||
};
|
||||
|
||||
NzMD5AnimParser(NzInputStream& stream);
|
||||
~NzMD5AnimParser();
|
||||
|
||||
nzTernary Check();
|
||||
|
||||
unsigned int GetAnimatedComponentCount() const;
|
||||
const Frame* GetFrames() const;
|
||||
unsigned int GetFrameCount() const;
|
||||
unsigned int GetFrameRate() const;
|
||||
const Joint* GetJoints() const;
|
||||
unsigned int GetJointCount() const;
|
||||
|
||||
bool Parse();
|
||||
|
||||
private:
|
||||
bool Advance(bool required = true);
|
||||
void Error(const NzString& message);
|
||||
bool ParseBaseframe();
|
||||
bool ParseBounds();
|
||||
bool ParseFrame();
|
||||
bool ParseHierarchy();
|
||||
void Warning(const NzString& message);
|
||||
void UnrecognizedLine(bool error = false);
|
||||
|
||||
std::vector<float> m_animatedComponents;
|
||||
std::vector<Frame> m_frames;
|
||||
std::vector<Joint> m_joints;
|
||||
NzInputStream& m_stream;
|
||||
NzString 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
|
||||
83
include/Nazara/Utility/Formats/MD5MeshParser.hpp
Normal file
83
include/Nazara/Utility/Formats/MD5MeshParser.hpp
Normal file
@@ -0,0 +1,83 @@
|
||||
// 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_MD5MESHPARSER_HPP
|
||||
#define NAZARA_FORMATS_MD5MESHPARSER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <vector>
|
||||
|
||||
class NAZARA_API NzMD5MeshParser
|
||||
{
|
||||
public:
|
||||
struct Joint
|
||||
{
|
||||
NzQuaternionf bindOrient;
|
||||
NzString name;
|
||||
NzVector3f bindPos;
|
||||
int parent;
|
||||
};
|
||||
|
||||
typedef NzVector3ui Triangle;
|
||||
|
||||
struct Vertex
|
||||
{
|
||||
NzVector2f uv;
|
||||
unsigned int startWeight;
|
||||
unsigned int weightCount;
|
||||
};
|
||||
|
||||
struct Weight
|
||||
{
|
||||
NzVector3f pos;
|
||||
float bias;
|
||||
unsigned int joint;
|
||||
};
|
||||
|
||||
struct Mesh
|
||||
{
|
||||
std::vector<Triangle> triangles;
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<Weight> weights;
|
||||
NzString shader;
|
||||
};
|
||||
|
||||
NzMD5MeshParser(NzInputStream& stream);
|
||||
~NzMD5MeshParser();
|
||||
|
||||
nzTernary Check();
|
||||
|
||||
const Joint* GetJoints() const;
|
||||
unsigned int GetJointCount() const;
|
||||
const Mesh* GetMeshes() const;
|
||||
unsigned int GetMeshCount() const;
|
||||
|
||||
bool Parse();
|
||||
|
||||
private:
|
||||
bool Advance(bool required = true);
|
||||
void Error(const NzString& message);
|
||||
bool ParseJoints();
|
||||
bool ParseMesh();
|
||||
void Warning(const NzString& message);
|
||||
void UnrecognizedLine(bool error = false);
|
||||
|
||||
std::vector<Joint> m_joints;
|
||||
std::vector<Mesh> m_meshes;
|
||||
NzInputStream& m_stream;
|
||||
NzString m_currentLine;
|
||||
bool m_keepLastLine;
|
||||
unsigned int m_lineCount;
|
||||
unsigned int m_meshIndex;
|
||||
unsigned int m_streamFlags;
|
||||
};
|
||||
|
||||
#endif // NAZARA_FORMATS_MD5MESHPARSER_HPP
|
||||
61
include/Nazara/Utility/Formats/MTLParser.hpp
Normal file
61
include/Nazara/Utility/Formats/MTLParser.hpp
Normal file
@@ -0,0 +1,61 @@
|
||||
// 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_MTLPARSER_HPP
|
||||
#define NAZARA_FORMATS_MTLPARSER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
class NAZARA_API NzMTLParser
|
||||
{
|
||||
public:
|
||||
struct Material
|
||||
{
|
||||
NzColor ambient = NzColor::White;
|
||||
NzColor diffuse = NzColor::White;
|
||||
NzColor specular = NzColor::White;
|
||||
NzString alphaMap;
|
||||
NzString ambientMap;
|
||||
NzString bumpMap;
|
||||
NzString decalMap;
|
||||
NzString diffuseMap;
|
||||
NzString displacementMap;
|
||||
NzString reflectionMap;
|
||||
NzString shininessMap;
|
||||
NzString specularMap;
|
||||
float alpha = 1.f;
|
||||
float refractionIndex = 1.f;
|
||||
float shininess = 1.f;
|
||||
unsigned int illumModel = 0;
|
||||
};
|
||||
|
||||
NzMTLParser(NzInputStream& stream$);
|
||||
~NzMTLParser();
|
||||
|
||||
const Material* GetMaterial(const NzString& materialName) const;
|
||||
const std::unordered_map<NzString, Material>& GetMaterials() const;
|
||||
|
||||
bool Parse();
|
||||
|
||||
private:
|
||||
bool Advance(bool required = true);
|
||||
void Error(const NzString& message);
|
||||
void Warning(const NzString& message);
|
||||
void UnrecognizedLine(bool error = false);
|
||||
|
||||
std::unordered_map<NzString, Material> m_materials;
|
||||
NzInputStream& m_stream;
|
||||
NzString m_currentLine;
|
||||
bool m_keepLastLine;
|
||||
unsigned int m_lineCount;
|
||||
unsigned int m_streamFlags;
|
||||
};
|
||||
|
||||
#endif // NAZARA_FORMATS_MTLPARSER_HPP
|
||||
75
include/Nazara/Utility/Formats/OBJParser.hpp
Normal file
75
include/Nazara/Utility/Formats/OBJParser.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// 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_OBJPARSER_HPP
|
||||
#define NAZARA_FORMATS_OBJPARSER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
#include <vector>
|
||||
|
||||
class NzOBJParser
|
||||
{
|
||||
public:
|
||||
struct FaceVertex
|
||||
{
|
||||
int normal;
|
||||
int position;
|
||||
int texCoord;
|
||||
};
|
||||
|
||||
struct Face
|
||||
{
|
||||
std::vector<FaceVertex> vertices;
|
||||
};
|
||||
|
||||
struct Mesh
|
||||
{
|
||||
std::vector<Face> faces;
|
||||
NzString name;
|
||||
unsigned int material;
|
||||
};
|
||||
|
||||
NzOBJParser(NzInputStream& stream$);
|
||||
~NzOBJParser();
|
||||
|
||||
const NzString* GetMaterials() const;
|
||||
unsigned int GetMaterialCount() const;
|
||||
const Mesh* GetMeshes() const;
|
||||
unsigned int GetMeshCount() const;
|
||||
const NzString& GetMtlLib() const;
|
||||
const NzVector3f* GetNormals() const;
|
||||
unsigned int GetNormalCount() const;
|
||||
const NzVector4f* GetPositions() const;
|
||||
unsigned int GetPositionCount() const;
|
||||
const NzVector3f* GetTexCoords() const;
|
||||
unsigned int GetTexCoordCount() const;
|
||||
|
||||
bool Parse();
|
||||
|
||||
private:
|
||||
bool Advance(bool required = true);
|
||||
void Error(const NzString& message);
|
||||
void Warning(const NzString& message);
|
||||
void UnrecognizedLine(bool error = false);
|
||||
|
||||
std::vector<Mesh> m_meshes;
|
||||
std::vector<NzString> m_materials;
|
||||
std::vector<NzVector3f> m_normals;
|
||||
std::vector<NzVector4f> m_positions;
|
||||
std::vector<NzVector3f> m_texCoords;
|
||||
NzInputStream& m_stream;
|
||||
NzString m_currentLine;
|
||||
NzString m_mtlLib;
|
||||
bool m_keepLastLine;
|
||||
unsigned int m_lineCount;
|
||||
unsigned int m_streamFlags;
|
||||
};
|
||||
|
||||
#endif // NAZARA_FORMATS_OBJPARSER_HPP
|
||||
Reference in New Issue
Block a user