2015-05-19 03:48:29 +00:00
|
|
|
/*
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
2021-02-28 11:17:54 +00:00
|
|
|
Copyright (c) 2006-2021, 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.
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file Defines the helper data structures for importing ASE files */
|
|
|
|
#ifndef AI_ASEFILEHELPER_H_INC
|
|
|
|
#define AI_ASEFILEHELPER_H_INC
|
|
|
|
|
|
|
|
// public ASSIMP headers
|
2016-06-06 20:04:29 +00:00
|
|
|
#include <assimp/anim.h>
|
2020-06-23 19:05:42 +00:00
|
|
|
#include <assimp/mesh.h>
|
|
|
|
#include <assimp/types.h>
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2017-06-26 20:01:15 +00:00
|
|
|
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
|
|
|
|
2015-05-19 03:48:29 +00:00
|
|
|
// for some helper routines like IsSpace()
|
2018-01-06 00:18:33 +00:00
|
|
|
#include <assimp/ParsingUtils.h>
|
|
|
|
#include <assimp/qnan.h>
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ASE is quite similar to 3ds. We can reuse some structures
|
2020-05-02 13:14:38 +00:00
|
|
|
#include "AssetLib/3DS/3DSLoader.h"
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2020-06-23 19:05:42 +00:00
|
|
|
namespace Assimp {
|
|
|
|
namespace ASE {
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
using namespace D3DS;
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure representing an ASE material */
|
2020-06-23 19:05:42 +00:00
|
|
|
struct Material : public D3DS::Material {
|
2018-01-23 18:20:37 +00:00
|
|
|
//! Default constructor has been deleted
|
|
|
|
Material() = delete;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2018-01-23 17:43:15 +00:00
|
|
|
//! Constructor with explicit name
|
2020-06-23 19:05:42 +00:00
|
|
|
explicit Material(const std::string &name) :
|
|
|
|
D3DS::Material(name),
|
|
|
|
pcInstance(nullptr),
|
|
|
|
bNeed(false) {
|
2018-09-21 17:26:41 +00:00
|
|
|
// empty
|
|
|
|
}
|
2018-01-23 17:43:15 +00:00
|
|
|
|
2020-06-23 19:05:42 +00:00
|
|
|
Material(const Material &other) = default;
|
2020-03-21 07:56:49 +00:00
|
|
|
|
|
|
|
Material &operator=(const Material &other) {
|
|
|
|
if (this == &other) {
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
avSubMaterials = other.avSubMaterials;
|
|
|
|
pcInstance = other.pcInstance;
|
|
|
|
bNeed = other.bNeed;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
2018-01-24 10:25:30 +00:00
|
|
|
|
|
|
|
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
2018-09-21 14:25:27 +00:00
|
|
|
Material(Material &&other) AI_NO_EXCEPT
|
2020-06-23 19:05:42 +00:00
|
|
|
: D3DS::Material(std::move(other)),
|
|
|
|
avSubMaterials(std::move(other.avSubMaterials)),
|
|
|
|
pcInstance(std::move(other.pcInstance)),
|
|
|
|
bNeed(std::move(other.bNeed)) {
|
2018-01-24 10:25:30 +00:00
|
|
|
other.pcInstance = nullptr;
|
|
|
|
}
|
|
|
|
|
2020-06-23 19:05:42 +00:00
|
|
|
Material &operator=(Material &&other) AI_NO_EXCEPT {
|
2018-01-24 10:25:30 +00:00
|
|
|
if (this == &other) {
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-03-21 07:56:49 +00:00
|
|
|
//D3DS::Material::operator=(std::move(other));
|
2018-01-24 10:25:30 +00:00
|
|
|
|
|
|
|
avSubMaterials = std::move(other.avSubMaterials);
|
|
|
|
pcInstance = std::move(other.pcInstance);
|
|
|
|
bNeed = std::move(other.bNeed);
|
|
|
|
|
|
|
|
other.pcInstance = nullptr;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2018-01-23 17:33:50 +00:00
|
|
|
~Material() {}
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Contains all sub materials of this material
|
|
|
|
std::vector<Material> avSubMaterials;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! aiMaterial object
|
2020-06-23 19:05:42 +00:00
|
|
|
aiMaterial *pcInstance;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Can we remove this material?
|
|
|
|
bool bNeed;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE file face */
|
2018-09-21 14:07:09 +00:00
|
|
|
struct Face : public FaceWithSmoothingGroup {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Default constructor. Initializes everything with 0
|
2018-09-21 14:25:27 +00:00
|
|
|
Face() AI_NO_EXCEPT
|
2020-06-23 19:05:42 +00:00
|
|
|
: iMaterial(DEFAULT_MATINDEX),
|
|
|
|
iFace(0) {
|
2018-09-21 14:07:09 +00:00
|
|
|
// empty
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! special value to indicate that no material index has
|
|
|
|
//! been assigned to a face. The default material index
|
|
|
|
//! will replace this value later.
|
|
|
|
static const unsigned int DEFAULT_MATINDEX = 0xFFFFFFFF;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Indices into each list of texture coordinates
|
|
|
|
unsigned int amUVIndices[AI_MAX_NUMBER_OF_TEXTURECOORDS][3];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index into the list of vertex colors
|
|
|
|
unsigned int mColorIndices[3];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! (Sub)Material index to be assigned to this face
|
|
|
|
unsigned int iMaterial;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Index of the face. It is not specified whether it is
|
|
|
|
//! a requirement of the file format that all faces are
|
|
|
|
//! written in sequential order, so we have to expect this case
|
|
|
|
unsigned int iFace;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE file bone */
|
2018-09-21 17:26:41 +00:00
|
|
|
struct Bone {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Constructor
|
2018-01-27 15:43:04 +00:00
|
|
|
Bone() = delete;
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
//! Construction from an existing name
|
2020-06-23 19:05:42 +00:00
|
|
|
explicit Bone(const std::string &name) :
|
|
|
|
mName(name) {
|
2018-09-21 17:26:41 +00:00
|
|
|
// empty
|
|
|
|
}
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
//! Name of the bone
|
|
|
|
std::string mName;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE file bone vertex */
|
2018-09-21 17:26:41 +00:00
|
|
|
struct BoneVertex {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Bone and corresponding vertex weight.
|
|
|
|
//! -1 for unrequired bones ....
|
2020-06-23 19:05:42 +00:00
|
|
|
std::vector<std::pair<int, float>> mBoneWeights;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE file animation */
|
2018-09-21 17:26:41 +00:00
|
|
|
struct Animation {
|
|
|
|
enum Type {
|
2020-06-23 19:05:42 +00:00
|
|
|
TRACK = 0x0,
|
|
|
|
BEZIER = 0x1,
|
|
|
|
TCB = 0x2
|
|
|
|
} mRotationType,
|
|
|
|
mScalingType, mPositionType;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2018-09-21 14:25:27 +00:00
|
|
|
Animation() AI_NO_EXCEPT
|
2020-06-23 19:05:42 +00:00
|
|
|
: mRotationType(TRACK),
|
|
|
|
mScalingType(TRACK),
|
|
|
|
mPositionType(TRACK) {
|
2019-05-05 11:39:10 +00:00
|
|
|
// empty
|
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of track rotation keyframes
|
2020-06-23 19:05:42 +00:00
|
|
|
std::vector<aiQuatKey> akeyRotations;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of track position keyframes
|
2020-06-23 19:05:42 +00:00
|
|
|
std::vector<aiVectorKey> akeyPositions;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of track scaling keyframes
|
2020-06-23 19:05:42 +00:00
|
|
|
std::vector<aiVectorKey> akeyScaling;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent the inheritance information of an ASE node */
|
2018-09-21 14:07:09 +00:00
|
|
|
struct InheritanceInfo {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Default constructor
|
2018-09-21 17:26:41 +00:00
|
|
|
InheritanceInfo() AI_NO_EXCEPT {
|
2020-06-23 19:05:42 +00:00
|
|
|
for (size_t i = 0; i < 3; ++i) {
|
2018-09-21 17:26:41 +00:00
|
|
|
abInheritPosition[i] = abInheritRotation[i] = abInheritScaling[i] = true;
|
|
|
|
}
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Inherit the parent's position?, axis order is x,y,z
|
|
|
|
bool abInheritPosition[3];
|
|
|
|
|
|
|
|
//! Inherit the parent's rotation?, axis order is x,y,z
|
|
|
|
bool abInheritRotation[3];
|
|
|
|
|
|
|
|
//! Inherit the parent's scaling?, axis order is x,y,z
|
|
|
|
bool abInheritScaling[3];
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Represents an ASE file node. Base class for mesh, light and cameras */
|
2018-09-21 17:26:41 +00:00
|
|
|
struct BaseNode {
|
|
|
|
enum Type {
|
2020-06-23 19:05:42 +00:00
|
|
|
Light,
|
|
|
|
Camera,
|
|
|
|
Mesh,
|
2018-09-21 17:26:41 +00:00
|
|
|
Dummy
|
|
|
|
} mType;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2018-01-27 15:59:09 +00:00
|
|
|
//! Construction from an existing name
|
2020-06-23 19:05:42 +00:00
|
|
|
BaseNode(Type _mType, const std::string &name) :
|
|
|
|
mType(_mType), mName(name), mProcessed(false) {
|
2015-05-19 03:57:13 +00:00
|
|
|
// Set mTargetPosition to qnan
|
2016-07-15 05:38:29 +00:00
|
|
|
const ai_real qnan = get_qnan();
|
2015-05-19 03:57:13 +00:00
|
|
|
mTargetPosition.x = qnan;
|
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Name of the mesh
|
|
|
|
std::string mName;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Name of the parent of the node
|
|
|
|
//! "" if there is no parent ...
|
|
|
|
std::string mParent;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Transformation matrix of the node
|
|
|
|
aiMatrix4x4 mTransform;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Target position (target lights and cameras)
|
|
|
|
aiVector3D mTargetPosition;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Specifies which axes transformations a node inherits
|
|
|
|
//! from its parent ...
|
|
|
|
InheritanceInfo inherit;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Animation channels for the node
|
|
|
|
Animation mAnim;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Needed for lights and cameras: target animation channel
|
|
|
|
//! Should contain position keys only.
|
|
|
|
Animation mTargetAnim;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
bool mProcessed;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE file mesh */
|
2018-09-21 14:07:09 +00:00
|
|
|
struct Mesh : public MeshWithSmoothingGroups<ASE::Face>, public BaseNode {
|
2018-01-27 16:09:23 +00:00
|
|
|
//! Default constructor has been deleted
|
|
|
|
Mesh() = delete;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2018-01-27 16:03:57 +00:00
|
|
|
//! Construction from an existing name
|
2020-06-23 19:05:42 +00:00
|
|
|
explicit Mesh(const std::string &name) :
|
|
|
|
BaseNode(BaseNode::Mesh, name), mVertexColors(), mBoneVertices(), mBones(), iMaterialIndex(Face::DEFAULT_MATINDEX), bSkip(false) {
|
|
|
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++c) {
|
2018-09-21 17:26:41 +00:00
|
|
|
this->mNumUVComponents[c] = 2;
|
|
|
|
}
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all texture coordinate sets
|
|
|
|
std::vector<aiVector3D> amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all vertex color sets.
|
|
|
|
std::vector<aiColor4D> mVertexColors;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all bone vertices
|
|
|
|
std::vector<BoneVertex> mBoneVertices;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all bones
|
|
|
|
std::vector<Bone> mBones;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Material index of the mesh
|
|
|
|
unsigned int iMaterialIndex;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Number of vertex components for each UVW set
|
|
|
|
unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! used internally
|
|
|
|
bool bSkip;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE light source */
|
2020-06-23 19:05:42 +00:00
|
|
|
struct Light : public BaseNode {
|
|
|
|
enum LightType {
|
2015-05-19 03:57:13 +00:00
|
|
|
OMNI,
|
|
|
|
TARGET,
|
|
|
|
FREE,
|
|
|
|
DIRECTIONAL
|
|
|
|
};
|
|
|
|
|
2018-01-27 16:19:44 +00:00
|
|
|
//! Default constructor has been deleted
|
|
|
|
Light() = delete;
|
2018-01-27 16:14:01 +00:00
|
|
|
|
|
|
|
//! Construction from an existing name
|
2020-06-23 19:05:42 +00:00
|
|
|
explicit Light(const std::string &name) :
|
|
|
|
BaseNode(BaseNode::Light, name), mLightType(OMNI), mColor(1.f, 1.f, 1.f), mIntensity(1.f) // light is white by default
|
|
|
|
,
|
|
|
|
mAngle(45.f),
|
|
|
|
mFalloff(0.f) {
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LightType mLightType;
|
|
|
|
aiColor3D mColor;
|
2016-07-15 05:38:29 +00:00
|
|
|
ai_real mIntensity;
|
|
|
|
ai_real mAngle; // in degrees
|
|
|
|
ai_real mFalloff;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE camera */
|
2020-06-23 19:05:42 +00:00
|
|
|
struct Camera : public BaseNode {
|
|
|
|
enum CameraType {
|
2015-05-19 03:57:13 +00:00
|
|
|
FREE,
|
|
|
|
TARGET
|
|
|
|
};
|
|
|
|
|
2018-01-27 16:29:29 +00:00
|
|
|
//! Default constructor has been deleted
|
|
|
|
Camera() = delete;
|
2015-05-19 03:57:13 +00:00
|
|
|
|
2018-01-27 16:25:01 +00:00
|
|
|
//! Construction from an existing name
|
2020-06-23 19:05:42 +00:00
|
|
|
explicit Camera(const std::string &name) :
|
|
|
|
BaseNode(BaseNode::Camera, name), mFOV(0.75f) // in radians
|
|
|
|
,
|
|
|
|
mNear(0.1f),
|
|
|
|
mFar(1000.f) // could be zero
|
|
|
|
,
|
|
|
|
mCameraType(FREE) {
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
|
|
|
|
2016-07-15 05:38:29 +00:00
|
|
|
ai_real mFOV, mNear, mFar;
|
2015-05-19 03:57:13 +00:00
|
|
|
CameraType mCameraType;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE helper object (dummy) */
|
2018-09-21 14:07:09 +00:00
|
|
|
struct Dummy : public BaseNode {
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Constructor
|
2018-09-21 14:25:27 +00:00
|
|
|
Dummy() AI_NO_EXCEPT
|
2020-06-23 19:05:42 +00:00
|
|
|
: BaseNode(BaseNode::Dummy, "DUMMY") {
|
2018-09-21 14:07:09 +00:00
|
|
|
// empty
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Parameters to Parser::Parse()
|
|
|
|
#define AI_ASE_NEW_FILE_FORMAT 200
|
|
|
|
#define AI_ASE_OLD_FILE_FORMAT 110
|
|
|
|
|
|
|
|
// Internally we're a little bit more tolerant
|
2015-05-19 03:57:13 +00:00
|
|
|
#define AI_ASE_IS_NEW_FILE_FORMAT() (iFileFormat >= 200)
|
|
|
|
#define AI_ASE_IS_OLD_FILE_FORMAT() (iFileFormat < 200)
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
/** \brief Class to parse ASE files
|
|
|
|
*/
|
2018-09-21 14:07:09 +00:00
|
|
|
class Parser {
|
2015-05-19 03:48:29 +00:00
|
|
|
private:
|
2018-09-21 14:25:27 +00:00
|
|
|
Parser() AI_NO_EXCEPT {
|
2018-09-21 14:07:09 +00:00
|
|
|
// empty
|
|
|
|
}
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Construct a parser from a given input file which is
|
2018-05-13 14:35:03 +00:00
|
|
|
//! guaranteed to be terminated with zero.
|
2015-05-19 03:57:13 +00:00
|
|
|
//! @param szFile Input file
|
|
|
|
//! @param fileFormatDefault Assumed file format version. If the
|
|
|
|
//! file format is specified in the file the new value replaces
|
|
|
|
//! the default value.
|
2020-06-23 19:05:42 +00:00
|
|
|
Parser(const char *szFile, unsigned int fileFormatDefault);
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parses the file into the parsers internal representation
|
|
|
|
void Parse();
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
private:
|
2015-05-19 03:57:13 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the *SCENE block in a file
|
|
|
|
void ParseLV1SceneBlock();
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the *MESH_SOFTSKINVERTS block in a file
|
|
|
|
void ParseLV1SoftSkinBlock();
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the *MATERIAL_LIST block in a file
|
|
|
|
void ParseLV1MaterialListBlock();
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *<xxx>OBJECT block in a file
|
|
|
|
//! \param mesh Node to be filled
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV1ObjectBlock(BaseNode &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MATERIAL blocks in a material list
|
|
|
|
//! \param mat Material structure to be filled
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV2MaterialBlock(Material &mat);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *NODE_TM block in a file
|
|
|
|
//! \param mesh Node (!) object to be filled
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV2NodeTransformBlock(BaseNode &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *TM_ANIMATION block in a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV2AnimationBlock(BaseNode &mesh);
|
|
|
|
void ParseLV3PosAnimationBlock(ASE::Animation &anim);
|
|
|
|
void ParseLV3ScaleAnimationBlock(ASE::Animation &anim);
|
|
|
|
void ParseLV3RotAnimationBlock(ASE::Animation &anim);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH block in a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV2MeshBlock(Mesh &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *LIGHT_SETTINGS block in a file
|
|
|
|
//! \param light Light object to be filled
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV2LightSettingsBlock(Light &light);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *CAMERA_SETTINGS block in a file
|
|
|
|
//! \param cam Camera object to be filled
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV2CameraSettingsBlock(Camera &cam);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the *MAP_XXXXXX blocks in a material
|
|
|
|
//! \param map Texture structure to be filled
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV3MapBlock(Texture &map);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_VERTEX_LIST block in a file
|
|
|
|
//! \param iNumVertices Value of *MESH_NUMVERTEX, if present.
|
|
|
|
//! Otherwise zero. This is used to check the consistency of the file.
|
|
|
|
//! A warning is sent to the logger if the validations fails.
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
void ParseLV3MeshVertexListBlock(
|
2020-06-23 19:05:42 +00:00
|
|
|
unsigned int iNumVertices, Mesh &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_FACE_LIST block in a file
|
|
|
|
//! \param iNumFaces Value of *MESH_NUMFACES, if present.
|
|
|
|
//! Otherwise zero. This is used to check the consistency of the file.
|
|
|
|
//! A warning is sent to the logger if the validations fails.
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
void ParseLV3MeshFaceListBlock(
|
2020-06-23 19:05:42 +00:00
|
|
|
unsigned int iNumFaces, Mesh &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_TVERT_LIST block in a file
|
|
|
|
//! \param iNumVertices Value of *MESH_NUMTVERTEX, if present.
|
|
|
|
//! Otherwise zero. This is used to check the consistency of the file.
|
|
|
|
//! A warning is sent to the logger if the validations fails.
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
//! \param iChannel Output UVW channel
|
|
|
|
void ParseLV3MeshTListBlock(
|
2020-06-23 19:05:42 +00:00
|
|
|
unsigned int iNumVertices, Mesh &mesh, unsigned int iChannel = 0);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_TFACELIST block in a file
|
|
|
|
//! \param iNumFaces Value of *MESH_NUMTVFACES, if present.
|
|
|
|
//! Otherwise zero. This is used to check the consistency of the file.
|
|
|
|
//! A warning is sent to the logger if the validations fails.
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
//! \param iChannel Output UVW channel
|
|
|
|
void ParseLV3MeshTFaceListBlock(
|
2020-06-23 19:05:42 +00:00
|
|
|
unsigned int iNumFaces, Mesh &mesh, unsigned int iChannel = 0);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse an additional mapping channel
|
|
|
|
//! (specified via *MESH_MAPPINGCHANNEL)
|
|
|
|
//! \param iChannel Channel index to be filled
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
void ParseLV3MappingChannel(
|
2020-06-23 19:05:42 +00:00
|
|
|
unsigned int iChannel, Mesh &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_CVERTLIST block in a file
|
|
|
|
//! \param iNumVertices Value of *MESH_NUMCVERTEX, if present.
|
|
|
|
//! Otherwise zero. This is used to check the consistency of the file.
|
|
|
|
//! A warning is sent to the logger if the validations fails.
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
void ParseLV3MeshCListBlock(
|
2020-06-23 19:05:42 +00:00
|
|
|
unsigned int iNumVertices, Mesh &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_CFACELIST block in a file
|
|
|
|
//! \param iNumFaces Value of *MESH_NUMCVFACES, if present.
|
|
|
|
//! Otherwise zero. This is used to check the consistency of the file.
|
|
|
|
//! A warning is sent to the logger if the validations fails.
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
void ParseLV3MeshCFaceListBlock(
|
2020-06-23 19:05:42 +00:00
|
|
|
unsigned int iNumFaces, Mesh &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_NORMALS block in a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV3MeshNormalListBlock(Mesh &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_WEIGHTSblock in a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV3MeshWeightsBlock(Mesh &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the bone list of a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
//! \param iNumBones Number of bones in the mesh
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV4MeshBones(unsigned int iNumBones, Mesh &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the bone vertices list of a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
//! \param iNumVertices Number of vertices to be parsed
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV4MeshBonesVertices(unsigned int iNumVertices, Mesh &mesh);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_FACE block in a file
|
|
|
|
//! \param out receive the face data
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV4MeshFace(ASE::Face &out);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_VERT block in a file
|
|
|
|
//! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...)
|
|
|
|
//! \param apOut Output buffer (3 floats)
|
|
|
|
//! \param rIndexOut Output index
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_VERT block in a file
|
|
|
|
//! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...)
|
|
|
|
//! \param apOut Output buffer (3 floats)
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV4MeshFloatTriple(ai_real *apOut);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_TFACE block in a file
|
|
|
|
//! (also works for MESH_CFACE)
|
|
|
|
//! \param apOut Output buffer (3 ints)
|
|
|
|
//! \param rIndexOut Output index
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV4MeshLongTriple(unsigned int *apOut, unsigned int &rIndexOut);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_TFACE block in a file
|
|
|
|
//! (also works for MESH_CFACE)
|
|
|
|
//! \param apOut Output buffer (3 ints)
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV4MeshLongTriple(unsigned int *apOut);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a single float element
|
|
|
|
//! \param fOut Output float
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV4MeshFloat(ai_real &fOut);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a single int element
|
|
|
|
//! \param iOut Output integer
|
2020-06-23 19:05:42 +00:00
|
|
|
void ParseLV4MeshLong(unsigned int &iOut);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Skip everything to the next: '*' or '\0'
|
|
|
|
bool SkipToNextToken();
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Skip the current section until the token after the closing }.
|
|
|
|
//! This function handles embedded subsections correctly
|
|
|
|
bool SkipSection();
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Output a warning to the logger
|
|
|
|
//! \param szWarn Warn message
|
2020-06-23 19:05:42 +00:00
|
|
|
void LogWarning(const char *szWarn);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Output a message to the logger
|
|
|
|
//! \param szWarn Message
|
2020-06-23 19:05:42 +00:00
|
|
|
void LogInfo(const char *szWarn);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Output an error to the logger
|
|
|
|
//! \param szWarn Error message
|
2020-06-23 19:05:42 +00:00
|
|
|
AI_WONT_RETURN void LogError(const char *szWarn) AI_WONT_RETURN_SUFFIX;
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a string, enclosed in double quotation marks
|
|
|
|
//! \param out Output string
|
|
|
|
//! \param szName Name of the enclosing element -> used in error
|
|
|
|
//! messages.
|
2016-04-03 00:38:00 +00:00
|
|
|
//! \return false if an error occurred
|
2020-06-23 19:05:42 +00:00
|
|
|
bool ParseString(std::string &out, const char *szName);
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
public:
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Pointer to current data
|
2020-06-23 19:05:42 +00:00
|
|
|
const char *filePtr;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! background color to be passed to the viewer
|
|
|
|
//! QNAN if none was found
|
|
|
|
aiColor3D m_clrBackground;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Base ambient color to be passed to all materials
|
|
|
|
//! QNAN if none was found
|
|
|
|
aiColor3D m_clrAmbient;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all materials found in the file
|
|
|
|
std::vector<Material> m_vMaterials;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all meshes found in the file
|
|
|
|
std::vector<Mesh> m_vMeshes;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all dummies found in the file
|
|
|
|
std::vector<Dummy> m_vDummies;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all lights found in the file
|
|
|
|
std::vector<Light> m_vLights;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! List of all cameras found in the file
|
|
|
|
std::vector<Camera> m_vCameras;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Current line in the file
|
|
|
|
unsigned int iLineNumber;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! First frame
|
|
|
|
unsigned int iFirstFrame;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Last frame
|
|
|
|
unsigned int iLastFrame;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Frame speed - frames per second
|
|
|
|
unsigned int iFrameSpeed;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! Ticks per frame
|
|
|
|
unsigned int iTicksPerFrame;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! true if the last character read was an end-line character
|
|
|
|
bool bLastWasEndLine;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
//! File format version
|
|
|
|
unsigned int iFileFormat;
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace ASE
|
2020-06-23 19:05:42 +00:00
|
|
|
} // namespace Assimp
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2017-06-26 20:01:15 +00:00
|
|
|
#endif // ASSIMP_BUILD_NO_3DS_IMPORTER
|
|
|
|
|
2015-05-19 03:48:29 +00:00
|
|
|
#endif // !! include guard
|