2008-05-09 17:24:28 +00:00
|
|
|
/*
|
2008-05-22 10:20:31 +00:00
|
|
|
Open Asset Import Library (ASSIMP)
|
2008-05-09 17:24:28 +00:00
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the
|
|
|
|
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 Development Team.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2008-07-18 20:29:46 +00:00
|
|
|
// STL/CRT headers
|
2008-05-09 17:24:28 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <list>
|
|
|
|
|
2008-07-18 20:29:46 +00:00
|
|
|
// public ASSIMP headers
|
2008-05-09 17:24:28 +00:00
|
|
|
#include "../include/aiTypes.h"
|
|
|
|
#include "../include/aiMesh.h"
|
|
|
|
#include "../include/aiAnim.h"
|
|
|
|
|
|
|
|
// for some helper routines like IsSpace()
|
2008-08-28 17:35:36 +00:00
|
|
|
#include "ParsingUtils.h"
|
2008-07-18 20:29:46 +00:00
|
|
|
#include "qnan.h"
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
// ASE is quite similar to 3ds. We can reuse some structures
|
|
|
|
#include "3DSLoader.h"
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
namespace Assimp {
|
|
|
|
namespace ASE {
|
2008-05-09 17:24:28 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
using namespace D3DS;
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure representing an ASE material */
|
2008-10-31 19:32:00 +00:00
|
|
|
struct Material : public D3DS::Material
|
2008-05-09 17:24:28 +00:00
|
|
|
{
|
|
|
|
//! Default constructor
|
|
|
|
Material() : pcInstance(NULL), bNeed (false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//! Contains all sub materials of this material
|
|
|
|
std::vector<Material> avSubMaterials;
|
|
|
|
|
|
|
|
//! MaterialHelper object
|
|
|
|
MaterialHelper* pcInstance;
|
|
|
|
|
|
|
|
//! Can we remove this material?
|
|
|
|
bool bNeed;
|
|
|
|
};
|
2008-11-16 21:56:45 +00:00
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE file face */
|
2008-08-28 17:35:36 +00:00
|
|
|
struct Face : public FaceWithSmoothingGroup
|
2008-05-09 17:24:28 +00:00
|
|
|
{
|
|
|
|
//! Default constructor. Initializes everything with 0
|
|
|
|
Face()
|
|
|
|
{
|
|
|
|
mColorIndices[0] = mColorIndices[1] = mColorIndices[2] = 0;
|
|
|
|
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
|
|
|
|
{
|
|
|
|
amUVIndices[i][0] = amUVIndices[i][1] = amUVIndices[i][2] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
iMaterial = DEFAULT_MATINDEX;
|
|
|
|
iFace = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! 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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//! Indices into each list of texture coordinates
|
|
|
|
unsigned int amUVIndices[AI_MAX_NUMBER_OF_TEXTURECOORDS][3];
|
|
|
|
|
|
|
|
//! Index into the list of vertex colors
|
|
|
|
unsigned int mColorIndices[3];
|
|
|
|
|
|
|
|
//! (Sub)Material index to be assigned to this face
|
|
|
|
unsigned int iMaterial;
|
|
|
|
|
|
|
|
//! 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;
|
|
|
|
};
|
|
|
|
|
2008-05-28 21:05:05 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE file bone */
|
|
|
|
struct Bone
|
|
|
|
{
|
|
|
|
//! Constructor
|
|
|
|
Bone()
|
|
|
|
{
|
|
|
|
static int iCnt = 0;
|
2008-07-18 20:29:46 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// Generate a default name for the bone
|
2008-07-18 20:29:46 +00:00
|
|
|
char szTemp[128];
|
|
|
|
::sprintf(szTemp,"UNNAMED_%i",iCnt++);
|
|
|
|
mName = szTemp;
|
2008-05-28 21:05:05 +00:00
|
|
|
}
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
//! Construction from an existing name
|
|
|
|
Bone( const std::string& name)
|
|
|
|
: mName (name)
|
|
|
|
{}
|
|
|
|
|
2008-05-28 21:05:05 +00:00
|
|
|
//! Name of the bone
|
|
|
|
std::string mName;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE file bone vertex */
|
|
|
|
struct BoneVertex
|
|
|
|
{
|
|
|
|
//! Bone and corresponding vertex weight.
|
|
|
|
//! -1 for unrequired bones ....
|
|
|
|
std::vector<std::pair<int,float> > mBoneWeights;
|
|
|
|
|
|
|
|
//! Position of the bone vertex.
|
|
|
|
//! MUST be identical to the vertex position
|
|
|
|
//aiVector3D mPosition;
|
|
|
|
};
|
|
|
|
|
2008-07-18 20:29:46 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE file animation */
|
|
|
|
struct Animation
|
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
TRACK = 0x0,
|
|
|
|
BEZIER = 0x1,
|
|
|
|
TCB = 0x2
|
|
|
|
} mRotationType, mScalingType, mPositionType;
|
|
|
|
|
|
|
|
Animation()
|
|
|
|
: mRotationType (TRACK)
|
|
|
|
, mScalingType (TRACK)
|
|
|
|
, mPositionType (TRACK)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//! List of track rotation keyframes
|
2008-07-18 20:29:46 +00:00
|
|
|
std::vector< aiQuatKey > akeyRotations;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
//! List of track position keyframes
|
2008-07-18 20:29:46 +00:00
|
|
|
std::vector< aiVectorKey > akeyPositions;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
//! List of track scaling keyframes
|
|
|
|
std::vector< aiVectorKey > akeyScaling;
|
|
|
|
|
2008-07-18 20:29:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent the inheritance information of an ASE node */
|
|
|
|
struct InheritanceInfo
|
|
|
|
{
|
|
|
|
//! Default constructor
|
|
|
|
InheritanceInfo()
|
|
|
|
{
|
|
|
|
// set the inheritance flag for all axes by default to true
|
|
|
|
for (unsigned int i = 0; i < 3;++i)
|
|
|
|
abInheritPosition[i] = abInheritRotation[i] = abInheritScaling[i] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! 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];
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
2008-10-22 20:06:16 +00:00
|
|
|
/** Represents an ASE file node. Base class for mesh, light and cameras */
|
|
|
|
struct BaseNode
|
2008-07-18 20:29:46 +00:00
|
|
|
{
|
2008-10-22 20:06:16 +00:00
|
|
|
enum Type {Light, Camera, Mesh, Dummy} mType;
|
2008-07-18 20:29:46 +00:00
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
//! Constructor. Creates a default name for the node
|
|
|
|
BaseNode(Type _mType)
|
|
|
|
: mType (_mType)
|
|
|
|
, mProcessed (false)
|
|
|
|
{
|
|
|
|
// generate a default name for the node
|
|
|
|
static int iCnt = 0;
|
|
|
|
char szTemp[128]; // should be sufficiently large
|
|
|
|
::sprintf(szTemp,"UNNAMED_%i",iCnt++);
|
|
|
|
mName = szTemp;
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
|
|
|
|
// Set mTargetPosition to qnan
|
|
|
|
const float qnan = std::numeric_limits<float>::quiet_NaN();
|
|
|
|
mTargetPosition.x = qnan;
|
2008-10-22 20:06:16 +00:00
|
|
|
}
|
2008-07-18 20:29:46 +00:00
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
//! Name of the mesh
|
|
|
|
std::string mName;
|
2008-07-18 20:29:46 +00:00
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
//! Name of the parent of the node
|
|
|
|
//! "" if there is no parent ...
|
|
|
|
std::string mParent;
|
2008-07-18 20:29:46 +00:00
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
//! Transformation matrix of the node
|
|
|
|
aiMatrix4x4 mTransform;
|
2008-07-18 20:29:46 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
//! Target position (target lights and cameras)
|
|
|
|
aiVector3D mTargetPosition;
|
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
//! Specifies which axes transformations a node inherits
|
|
|
|
//! from its parent ...
|
|
|
|
InheritanceInfo inherit;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
//! Animation channels for the node
|
|
|
|
Animation mAnim;
|
|
|
|
|
|
|
|
//! Needed for lights and cameras: target animation channel
|
|
|
|
//! Should contain position keys only.
|
|
|
|
Animation mTargetAnim;
|
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
bool mProcessed;
|
2008-07-18 20:29:46 +00:00
|
|
|
};
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE file mesh */
|
2008-10-22 20:06:16 +00:00
|
|
|
struct Mesh : public MeshWithSmoothingGroups<ASE::Face>, public BaseNode
|
2008-05-09 17:24:28 +00:00
|
|
|
{
|
2008-10-22 20:06:16 +00:00
|
|
|
//! Constructor.
|
|
|
|
Mesh()
|
|
|
|
: BaseNode (BaseNode::Mesh)
|
|
|
|
, bSkip (false)
|
2008-05-09 17:24:28 +00:00
|
|
|
{
|
|
|
|
// use 2 texture vertex components by default
|
|
|
|
for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c)
|
|
|
|
this->mNumUVComponents[c] = 2;
|
2008-05-23 22:38:35 +00:00
|
|
|
|
|
|
|
// setup the default material index by default
|
|
|
|
iMaterialIndex = Face::DEFAULT_MATINDEX;
|
2008-05-09 17:24:28 +00:00
|
|
|
}
|
2008-05-28 21:05:05 +00:00
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! List of all texture coordinate sets
|
|
|
|
std::vector<aiVector3D> amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
|
|
|
|
|
|
|
//! List of all vertex color sets.
|
|
|
|
std::vector<aiColor4D> mVertexColors;
|
|
|
|
|
2008-05-28 21:05:05 +00:00
|
|
|
//! List of all bone vertices
|
|
|
|
std::vector<BoneVertex> mBoneVertices;
|
|
|
|
|
|
|
|
//! List of all bones
|
|
|
|
std::vector<Bone> mBones;
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Material index of the mesh
|
|
|
|
unsigned int iMaterialIndex;
|
|
|
|
|
|
|
|
//! Number of vertex components for each UVW set
|
|
|
|
unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
2008-05-30 23:01:25 +00:00
|
|
|
|
|
|
|
//! used internally
|
|
|
|
bool bSkip;
|
2008-10-22 20:06:16 +00:00
|
|
|
};
|
2008-07-18 20:29:46 +00:00
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE light source */
|
|
|
|
struct Light : public BaseNode
|
|
|
|
{
|
|
|
|
enum LightType
|
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
OMNI,
|
|
|
|
TARGET,
|
|
|
|
FREE,
|
|
|
|
DIRECTIONAL
|
2008-10-22 20:06:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//! Constructor.
|
|
|
|
Light()
|
|
|
|
: BaseNode (BaseNode::Light)
|
|
|
|
, mLightType (OMNI)
|
|
|
|
, mColor (1.f,1.f,1.f)
|
|
|
|
, mIntensity (1.f) // light is white by default
|
2008-10-31 19:32:00 +00:00
|
|
|
, mAngle (45.f)
|
|
|
|
, mFalloff (0.f)
|
2008-10-22 20:06:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LightType mLightType;
|
|
|
|
aiColor3D mColor;
|
|
|
|
float mIntensity;
|
2008-10-31 19:32:00 +00:00
|
|
|
float mAngle; // in degrees
|
|
|
|
float mFalloff;
|
2008-10-22 20:06:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE camera */
|
|
|
|
struct Camera : public BaseNode
|
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
enum CameraType
|
|
|
|
{
|
|
|
|
FREE,
|
|
|
|
TARGET
|
|
|
|
};
|
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
//! Constructor
|
|
|
|
Camera()
|
2008-10-31 19:32:00 +00:00
|
|
|
: BaseNode (BaseNode::Camera)
|
|
|
|
, mFOV (0.75f) // in radians
|
|
|
|
, mNear (0.1f)
|
|
|
|
, mFar (1000.f) // could be zero
|
|
|
|
, mCameraType (FREE)
|
2008-10-22 20:06:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
float mFOV, mNear, mFar;
|
2008-10-31 19:32:00 +00:00
|
|
|
CameraType mCameraType;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent an ASE helper object (dummy) */
|
|
|
|
struct Dummy : public BaseNode
|
|
|
|
{
|
|
|
|
//! Constructor
|
|
|
|
Dummy()
|
|
|
|
: BaseNode (BaseNode::Dummy)
|
|
|
|
{
|
|
|
|
}
|
2008-05-09 17:24:28 +00:00
|
|
|
};
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +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
|
|
|
|
#define AI_ASE_IS_NEW_FILE_FORMAT() (iFileFormat >= 200)
|
|
|
|
#define AI_ASE_IS_OLD_FILE_FORMAT() (iFileFormat < 200)
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------
|
2008-05-09 17:24:28 +00:00
|
|
|
/** \brief Class to parse ASE files
|
|
|
|
*/
|
|
|
|
class Parser
|
|
|
|
{
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
Parser() {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// -------------------------------------------------------------------
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Construct a parser from a given input file which is
|
|
|
|
//! guaranted to be terminated with zero.
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +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.
|
|
|
|
Parser (const char* szFile, unsigned int fileFormatDefault);
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parses the file into the parsers internal representation
|
|
|
|
void Parse();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the *SCENE block in a file
|
|
|
|
void ParseLV1SceneBlock();
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the *MESH_SOFTSKINVERTS block in a file
|
|
|
|
void ParseLV1SoftSkinBlock();
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the *MATERIAL_LIST block in a file
|
|
|
|
void ParseLV1MaterialListBlock();
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
//! Parse a *<xxx>OBJECT block in a file
|
|
|
|
//! \param mesh Node to be filled
|
|
|
|
void ParseLV1ObjectBlock(BaseNode& mesh);
|
2008-10-22 20:06:16 +00:00
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MATERIAL blocks in a material list
|
|
|
|
//! \param mat Material structure to be filled
|
|
|
|
void ParseLV2MaterialBlock(Material& mat);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *NODE_TM block in a file
|
2008-10-22 20:06:16 +00:00
|
|
|
//! \param mesh Node (!) object to be filled
|
|
|
|
void ParseLV2NodeTransformBlock(BaseNode& mesh);
|
2008-05-09 17:24:28 +00:00
|
|
|
|
2008-07-18 20:29:46 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *TM_ANIMATION block in a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
2008-10-31 19:32:00 +00:00
|
|
|
void ParseLV2AnimationBlock(BaseNode& mesh);
|
|
|
|
void ParseLV3PosAnimationBlock(ASE::Animation& anim);
|
|
|
|
void ParseLV3ScaleAnimationBlock(ASE::Animation& anim);
|
|
|
|
void ParseLV3RotAnimationBlock(ASE::Animation& anim);
|
2008-07-18 20:29:46 +00:00
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH block in a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
void ParseLV2MeshBlock(Mesh& mesh);
|
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *LIGHT_SETTINGS block in a file
|
|
|
|
//! \param light Light object to be filled
|
|
|
|
void ParseLV2LightSettingsBlock(Light& light);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *CAMERA_SETTINGS block in a file
|
|
|
|
//! \param cam Camera object to be filled
|
|
|
|
void ParseLV2CameraSettingsBlock(Camera& cam);
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the *MAP_XXXXXX blocks in a material
|
|
|
|
//! \param map Texture structure to be filled
|
|
|
|
void ParseLV3MapBlock(Texture& map);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! 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(
|
|
|
|
unsigned int iNumVertices,Mesh& mesh);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! 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(
|
|
|
|
unsigned int iNumFaces,Mesh& mesh);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! 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(
|
|
|
|
unsigned int iNumVertices,Mesh& mesh, unsigned int iChannel = 0);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! 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(
|
|
|
|
unsigned int iNumFaces,Mesh& mesh, unsigned int iChannel = 0);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! 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(
|
|
|
|
unsigned int iChannel, Mesh& mesh);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! 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(
|
|
|
|
unsigned int iNumVertices, Mesh& mesh);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! 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(
|
|
|
|
unsigned int iNumFaces, Mesh& mesh);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_NORMALS block in a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
void ParseLV3MeshNormalListBlock(Mesh& mesh);
|
|
|
|
|
2008-05-28 21:05:05 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_WEIGHTSblock in a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
void ParseLV3MeshWeightsBlock(Mesh& mesh);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the bone list of a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
//! \param iNumBones Number of bones in the mesh
|
|
|
|
void ParseLV4MeshBones(unsigned int iNumBones,Mesh& mesh);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse the bone vertices list of a file
|
|
|
|
//! \param mesh Mesh object to be filled
|
|
|
|
//! \param iNumVertices Number of vertices to be parsed
|
|
|
|
void ParseLV4MeshBonesVertices(unsigned int iNumVertices,Mesh& mesh);
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_FACE block in a file
|
|
|
|
//! \param out receive the face data
|
|
|
|
void ParseLV4MeshFace(ASE::Face& out);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! 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
|
|
|
|
void ParseLV4MeshFloatTriple(float* apOut, unsigned int& rIndexOut);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_VERT block in a file
|
|
|
|
//! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...)
|
|
|
|
//! \param apOut Output buffer (3 floats)
|
|
|
|
void ParseLV4MeshFloatTriple(float* apOut);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_TFACE block in a file
|
|
|
|
//! (also works for MESH_CFACE)
|
|
|
|
//! \param apOut Output buffer (3 ints)
|
|
|
|
//! \param rIndexOut Output index
|
|
|
|
void ParseLV4MeshLongTriple(unsigned int* apOut, unsigned int& rIndexOut);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a *MESH_TFACE block in a file
|
|
|
|
//! (also works for MESH_CFACE)
|
|
|
|
//! \param apOut Output buffer (3 ints)
|
|
|
|
void ParseLV4MeshLongTriple(unsigned int* apOut);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a single float element
|
|
|
|
//! \param fOut Output float
|
|
|
|
void ParseLV4MeshFloat(float& fOut);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! Parse a single int element
|
|
|
|
//! \param iOut Output integer
|
|
|
|
void ParseLV4MeshLong(unsigned int& iOut);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
//! 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
|
|
|
|
void LogWarning(const char* szWarn);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2008-06-01 12:46:17 +00:00
|
|
|
//! Output a message to the logger
|
|
|
|
//! \param szWarn Message
|
|
|
|
void LogInfo(const char* szWarn);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Output an error to the logger
|
|
|
|
//! \param szWarn Error message
|
|
|
|
void LogError(const char* szWarn);
|
|
|
|
|
2008-05-28 21:05:05 +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.
|
|
|
|
//! \return false if an error occured
|
2008-06-01 14:03:45 +00:00
|
|
|
bool ParseString(std::string& out,const char* szName);
|
2008-05-28 21:05:05 +00:00
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
//! Pointer to current data
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
const char* filePtr;
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
//! background color to be passed to the viewer
|
|
|
|
//! QNAN if none was found
|
|
|
|
aiColor3D m_clrBackground;
|
|
|
|
|
|
|
|
//! Base ambient color to be passed to all materials
|
|
|
|
//! QNAN if none was found
|
|
|
|
aiColor3D m_clrAmbient;
|
|
|
|
|
|
|
|
//! List of all materials found in the file
|
|
|
|
std::vector<Material> m_vMaterials;
|
|
|
|
|
|
|
|
//! List of all meshes found in the file
|
|
|
|
std::vector<Mesh> m_vMeshes;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
//! List of all dummies found in the file
|
|
|
|
std::vector<Dummy> m_vDummies;
|
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
//! List of all lights found in the file
|
|
|
|
std::vector<Light> m_vLights;
|
|
|
|
|
|
|
|
//! List of all cameras found in the file
|
|
|
|
std::vector<Camera> m_vCameras;
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Current line in the file
|
|
|
|
unsigned int iLineNumber;
|
2008-07-18 20:29:46 +00:00
|
|
|
|
|
|
|
//! First frame
|
|
|
|
unsigned int iFirstFrame;
|
|
|
|
|
|
|
|
//! Last frame
|
|
|
|
unsigned int iLastFrame;
|
|
|
|
|
|
|
|
//! Frame speed - frames per second
|
|
|
|
unsigned int iFrameSpeed;
|
|
|
|
|
|
|
|
//! Ticks per frame
|
|
|
|
unsigned int iTicksPerFrame;
|
2008-07-30 23:00:25 +00:00
|
|
|
|
|
|
|
//! true if the last character read was an end-line character
|
|
|
|
bool bLastWasEndLine;
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
|
|
|
|
//! File format version
|
|
|
|
unsigned int iFileFormat;
|
2008-05-09 17:24:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-08-17 15:04:10 +00:00
|
|
|
} // Namespace ASE
|
|
|
|
} // Namespace ASSIMP
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
#endif // !! include guard
|