2015-05-19 03:48:29 +00:00
|
|
|
/*
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
2022-01-10 20:13:43 +00:00
|
|
|
Copyright (c) 2006-2022, assimp team
|
2018-01-28 18:42:05 +00:00
|
|
|
|
2017-05-09 17:57:36 +00:00
|
|
|
|
2015-05-19 03:48:29 +00:00
|
|
|
All rights reserved.
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the
|
2015-05-19 03:48:29 +00:00
|
|
|
following conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
|
|
|
|
|
|
|
* Neither the name of the assimp team, nor the names of its
|
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
|
|
|
written permission of the assimp team.
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
2015-05-19 03:48:29 +00:00
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
2015-05-19 03:52:10 +00:00
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
2015-05-19 03:48:29 +00:00
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
2015-05-19 03:52:10 +00:00
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
2015-05-19 03:48:29 +00:00
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
2015-05-19 03:52:10 +00:00
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
2015-05-19 03:48:29 +00:00
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
#pragma once
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
/** @file MD5Parser.h
|
|
|
|
* @brief Definition of the .MD5 parser class.
|
|
|
|
* http://www.modwiki.net/wiki/MD5_(file_format)
|
|
|
|
*/
|
|
|
|
#ifndef AI_MD5PARSER_H_INCLUDED
|
|
|
|
#define AI_MD5PARSER_H_INCLUDED
|
|
|
|
|
2016-06-06 20:04:29 +00:00
|
|
|
#include <assimp/types.h>
|
2018-01-06 00:18:33 +00:00
|
|
|
#include <assimp/ParsingUtils.h>
|
2015-05-19 03:48:29 +00:00
|
|
|
#include <vector>
|
2022-09-20 19:03:58 +00:00
|
|
|
#include <cstdint>
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
struct aiFace;
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
namespace Assimp {
|
|
|
|
namespace MD5 {
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Represents a single element in a MD5 file
|
2015-05-19 03:52:10 +00:00
|
|
|
*
|
2015-05-19 03:48:29 +00:00
|
|
|
* Elements are always contained in sections.
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
struct Element {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Points to the starting point of the element
|
|
|
|
//! Whitespace at the beginning and at the end have been removed,
|
|
|
|
//! Elements are terminated with \0
|
|
|
|
char* szStart;
|
|
|
|
|
|
|
|
//! Original line number (can be used in error messages
|
|
|
|
//! if a parsing error occurs)
|
|
|
|
unsigned int iLineNumber;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
using ElementList = std::vector<Element>;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Represents a section of a MD5 file (such as the mesh or the joints section)
|
2015-05-19 03:52:10 +00:00
|
|
|
*
|
2015-05-19 03:48:29 +00:00
|
|
|
* A section is always enclosed in { and } brackets.
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
struct Section {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Original line number (can be used in error messages
|
|
|
|
//! if a parsing error occurs)
|
|
|
|
unsigned int iLineNumber;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all elements which have been parsed in this section.
|
|
|
|
ElementList mElements;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Name of the section
|
|
|
|
std::string mName;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! For global elements: the value of the element as string
|
|
|
|
//! Iif !length() the section is not a global element
|
|
|
|
std::string mGlobalValue;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
using SectionList = std::vector<Section>;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Basic information about a joint
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
struct BaseJointDescription {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Name of the bone
|
|
|
|
aiString mName;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Parent index of the bone
|
|
|
|
int mParentIndex;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Represents a bone (joint) descriptor in a MD5Mesh file
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
struct BoneDesc : BaseJointDescription {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Absolute position of the bone
|
|
|
|
aiVector3D mPositionXYZ;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Absolute rotation of the bone
|
|
|
|
aiVector3D mRotationQuat;
|
|
|
|
aiQuaternion mRotationQuatConverted;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Absolute transformation of the bone
|
|
|
|
//! (temporary)
|
|
|
|
aiMatrix4x4 mTransform;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Inverse transformation of the bone
|
|
|
|
//! (temporary)
|
|
|
|
aiMatrix4x4 mInvTransform;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Internal
|
|
|
|
unsigned int mMap;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
using BoneList = std::vector<BoneDesc>;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Represents a bone (joint) descriptor in a MD5Anim file
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
struct AnimBoneDesc : BaseJointDescription {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Flags (AI_MD5_ANIMATION_FLAG_xxx)
|
|
|
|
unsigned int iFlags;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index of the first key that corresponds to this anim bone
|
|
|
|
unsigned int iFirstKeyIndex;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
using AnimBoneList = std::vector< AnimBoneDesc >;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Represents a base frame descriptor in a MD5Anim file
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
struct BaseFrameDesc {
|
2015-05-19 03:57:13 +00:00
|
|
|
aiVector3D vPositionXYZ;
|
|
|
|
aiVector3D vRotationQuat;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
using BaseFrameList = std::vector<BaseFrameDesc>;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Represents a camera animation frame in a MDCamera file
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
struct CameraAnimFrameDesc : BaseFrameDesc {
|
2015-05-19 03:57:13 +00:00
|
|
|
float fFOV;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
using CameraFrameList = std::vector<CameraAnimFrameDesc>;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Represents a frame descriptor in a MD5Anim file
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
struct FrameDesc {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index of the frame
|
|
|
|
unsigned int iIndex;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Animation keyframes - a large blob of data at first
|
|
|
|
std::vector< float > mValues;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
using FrameList = std::vector<FrameDesc>;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Represents a vertex descriptor in a MD5 file
|
|
|
|
*/
|
2018-09-21 14:07:09 +00:00
|
|
|
struct VertexDesc {
|
2018-09-21 14:25:27 +00:00
|
|
|
VertexDesc() AI_NO_EXCEPT
|
2022-09-20 19:03:58 +00:00
|
|
|
: mFirstWeight(0), mNumWeights(0) {
|
2018-09-21 14:07:09 +00:00
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
|
|
|
//! UV coordinate of the vertex
|
2015-05-19 03:57:13 +00:00
|
|
|
aiVector2D mUV;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index of the first weight of the vertex in
|
|
|
|
//! the vertex weight list
|
|
|
|
unsigned int mFirstWeight;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of weights assigned to this vertex
|
|
|
|
unsigned int mNumWeights;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
using VertexList = std::vector<VertexDesc>;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Represents a vertex weight descriptor in a MD5 file
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
struct WeightDesc {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index of the bone to which this weight refers
|
|
|
|
unsigned int mBone;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! The weight value
|
|
|
|
float mWeight;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! The offset position of this weight
|
|
|
|
// ! (in the coordinate system defined by the parent bone)
|
|
|
|
aiVector3D vOffsetPosition;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
using WeightList = std::vector<WeightDesc>;
|
|
|
|
using FaceList = std::vector<aiFace>;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Represents a mesh in a MD5 file
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
struct MeshDesc {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Weights of the mesh
|
|
|
|
WeightList mWeights;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Vertices of the mesh
|
|
|
|
VertexList mVertices;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Faces of the mesh
|
|
|
|
FaceList mFaces;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Name of the shader (=texture) to be assigned to the mesh
|
|
|
|
aiString mShader;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
using MeshList = std::vector<MeshDesc>;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Convert a quaternion to its usual representation
|
|
|
|
inline void ConvertQuaternion (const aiVector3D& in, aiQuaternion& out) {
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
out.x = in.x;
|
|
|
|
out.y = in.y;
|
|
|
|
out.z = in.z;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const float t = 1.0f - (in.x*in.x) - (in.y*in.y) - (in.z*in.z);
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
if (t < 0.0f) {
|
2015-05-19 03:57:13 +00:00
|
|
|
out.w = 0.0f;
|
2022-09-20 19:03:58 +00:00
|
|
|
} else {
|
|
|
|
out.w = std::sqrt (t);
|
|
|
|
}
|
2015-08-18 08:36:32 +00:00
|
|
|
|
|
|
|
// Assimp convention.
|
|
|
|
out.w *= -1.f;
|
2015-05-19 03:48:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Parses the data sections of a MD5 mesh file
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
class MD5MeshParser {
|
2015-05-19 03:48:29 +00:00
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** Constructs a new MD5MeshParser instance from an existing
|
|
|
|
* preparsed list of file sections.
|
|
|
|
*
|
|
|
|
* @param mSections List of file sections (output of MD5Parser)
|
|
|
|
*/
|
2015-10-29 12:04:23 +00:00
|
|
|
explicit MD5MeshParser(SectionList& mSections);
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all meshes
|
|
|
|
MeshList mMeshes;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all joints
|
|
|
|
BoneList mJoints;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// remove this flag if you need to the bounding box data
|
|
|
|
#define AI_MD5_PARSE_NO_BOUNDS
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Parses the data sections of a MD5 animation file
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
class MD5AnimParser {
|
2015-05-19 03:48:29 +00:00
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** Constructs a new MD5AnimParser instance from an existing
|
|
|
|
* preparsed list of file sections.
|
|
|
|
*
|
|
|
|
* @param mSections List of file sections (output of MD5Parser)
|
|
|
|
*/
|
2015-10-29 12:04:23 +00:00
|
|
|
explicit MD5AnimParser(SectionList& mSections);
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Output frame rate
|
|
|
|
float fFrameRate;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of animation bones
|
|
|
|
AnimBoneList mAnimatedBones;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of base frames
|
|
|
|
BaseFrameList mBaseFrames;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of animation frames
|
|
|
|
FrameList mFrames;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of animated components
|
|
|
|
unsigned int mNumAnimatedComponents;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Parses the data sections of a MD5 camera animation file
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
class MD5CameraParser {
|
2015-05-19 03:48:29 +00:00
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** Constructs a new MD5CameraParser instance from an existing
|
|
|
|
* preparsed list of file sections.
|
|
|
|
*
|
|
|
|
* @param mSections List of file sections (output of MD5Parser)
|
|
|
|
*/
|
2015-10-29 12:04:23 +00:00
|
|
|
explicit MD5CameraParser(SectionList& mSections);
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Output frame rate
|
|
|
|
float fFrameRate;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of cuts
|
|
|
|
std::vector<unsigned int> cuts;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Frames
|
|
|
|
CameraFrameList frames;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Parses the block structure of MD5MESH and MD5ANIM files (but does no
|
|
|
|
* further processing)
|
|
|
|
*/
|
2022-09-20 19:03:58 +00:00
|
|
|
class MD5Parser {
|
2015-05-19 03:48:29 +00:00
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** Constructs a new MD5Parser instance from an existing buffer.
|
|
|
|
*
|
|
|
|
* @param buffer File buffer
|
|
|
|
* @param fileSize Length of the file in bytes (excluding a terminal 0)
|
|
|
|
*/
|
|
|
|
MD5Parser(char* buffer, unsigned int fileSize);
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** Report a specific error message and throw an exception
|
|
|
|
* @param error Error message to be reported
|
2016-04-03 00:38:00 +00:00
|
|
|
* @param line Index of the line where the error occurred
|
2015-05-19 03:57:13 +00:00
|
|
|
*/
|
|
|
|
AI_WONT_RETURN static void ReportError (const char* error, unsigned int line) AI_WONT_RETURN_SUFFIX;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** Report a specific warning
|
|
|
|
* @param warn Warn message to be reported
|
2016-04-03 00:38:00 +00:00
|
|
|
* @param line Index of the line where the error occurred
|
2015-05-19 03:57:13 +00:00
|
|
|
*/
|
|
|
|
static void ReportWarning (const char* warn, unsigned int line);
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
|
2023-04-01 10:35:57 +00:00
|
|
|
AI_WONT_RETURN void ReportError (const char* error) AI_WONT_RETURN_SUFFIX;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
void ReportWarning (const char* warn) {
|
|
|
|
return ReportWarning(warn, lineNumber);
|
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all sections which have been read
|
|
|
|
SectionList mSections;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** Parses a file section. The current file pointer must be outside
|
|
|
|
* of a section.
|
|
|
|
* @param out Receives the section data
|
|
|
|
* @return true if the end of the file has been reached
|
|
|
|
* @throws ImportErrorException if an error occurs
|
|
|
|
*/
|
|
|
|
bool ParseSection(Section& out);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** Parses the file header
|
|
|
|
* @throws ImportErrorException if an error occurs
|
|
|
|
*/
|
|
|
|
void ParseHeader();
|
|
|
|
|
2022-09-20 19:03:58 +00:00
|
|
|
bool SkipLine(const char* in, const char** out);
|
|
|
|
bool SkipLine( );
|
2023-01-16 08:12:35 +00:00
|
|
|
bool SkipSpacesAndLineEnd( const char* in, const char** out);
|
2022-09-20 19:03:58 +00:00
|
|
|
bool SkipSpacesAndLineEnd();
|
|
|
|
bool SkipSpaces();
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
char* buffer;
|
2022-09-20 19:03:58 +00:00
|
|
|
char* bufferEnd;
|
2015-05-19 03:57:13 +00:00
|
|
|
unsigned int fileSize;
|
|
|
|
unsigned int lineNumber;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
2022-09-20 19:03:58 +00:00
|
|
|
|
2023-04-01 10:35:57 +00:00
|
|
|
inline void MD5Parser::ReportError(const char* error) {
|
|
|
|
ReportError(error, lineNumber);
|
|
|
|
}
|
2022-09-20 19:03:58 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
inline bool MD5Parser::SkipLine(const char* in, const char** out) {
|
|
|
|
++lineNumber;
|
|
|
|
return Assimp::SkipLine(in ,out);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
inline bool MD5Parser::SkipLine( ) {
|
|
|
|
return SkipLine(buffer,(const char**)&buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
inline bool MD5Parser::SkipSpacesAndLineEnd( const char* in, const char** out) {
|
|
|
|
bool bHad = false;
|
|
|
|
bool running = true;
|
|
|
|
while (running) {
|
|
|
|
if( *in == '\r' || *in == '\n') {
|
|
|
|
// we open files in binary mode, so there could be \r\n sequences ...
|
|
|
|
if (!bHad) {
|
|
|
|
bHad = true;
|
|
|
|
++lineNumber;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*in == '\t' || *in == ' ')bHad = false;
|
|
|
|
else break;
|
|
|
|
++in;
|
|
|
|
if (in == bufferEnd) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*out = in;
|
|
|
|
return *in != '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
inline bool MD5Parser::SkipSpacesAndLineEnd() {
|
|
|
|
return SkipSpacesAndLineEnd(buffer,(const char**)&buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
inline bool MD5Parser::SkipSpaces() {
|
|
|
|
return Assimp::SkipSpaces((const char**)&buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Assimp
|
|
|
|
} // namespace MD5
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
#endif // AI_MD5PARSER_H_INCLUDED
|