next warnings.
parent
22118dff1d
commit
6e13381bdb
|
@ -45,14 +45,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef AI_3DSFILEHELPER_H_INC
|
#ifndef AI_3DSFILEHELPER_H_INC
|
||||||
#define AI_3DSFILEHELPER_H_INC
|
#define AI_3DSFILEHELPER_H_INC
|
||||||
|
|
||||||
#include <assimp/SpatialSort.h>
|
|
||||||
#include <assimp/SmoothingGroups.h>
|
#include <assimp/SmoothingGroups.h>
|
||||||
|
#include <assimp/SpatialSort.h>
|
||||||
#include <assimp/StringUtils.h>
|
#include <assimp/StringUtils.h>
|
||||||
#include <assimp/qnan.h>
|
#include <assimp/anim.h>
|
||||||
#include <assimp/material.h>
|
|
||||||
#include <assimp/camera.h>
|
#include <assimp/camera.h>
|
||||||
#include <assimp/light.h>
|
#include <assimp/light.h>
|
||||||
#include <assimp/anim.h>
|
#include <assimp/material.h>
|
||||||
|
#include <assimp/qnan.h>
|
||||||
#include <stdio.h> //sprintf
|
#include <stdio.h> //sprintf
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
@ -81,11 +81,9 @@ public:
|
||||||
uint32_t Size;
|
uint32_t Size;
|
||||||
} PACK_STRUCT;
|
} PACK_STRUCT;
|
||||||
|
|
||||||
|
|
||||||
//! Used for shading field in material3ds structure
|
//! Used for shading field in material3ds structure
|
||||||
//! From AutoDesk 3ds SDK
|
//! From AutoDesk 3ds SDK
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
// translated to gouraud shading with wireframe active
|
// translated to gouraud shading with wireframe active
|
||||||
Wire = 0x0,
|
Wire = 0x0,
|
||||||
|
|
||||||
|
@ -109,8 +107,7 @@ public:
|
||||||
} shadetype3ds;
|
} shadetype3ds;
|
||||||
|
|
||||||
// Flags for animated keys
|
// Flags for animated keys
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
KEY_USE_TENS = 0x1,
|
KEY_USE_TENS = 0x1,
|
||||||
KEY_USE_CONT = 0x2,
|
KEY_USE_CONT = 0x2,
|
||||||
KEY_USE_BIAS = 0x4,
|
KEY_USE_BIAS = 0x4,
|
||||||
|
@ -118,8 +115,7 @@ public:
|
||||||
KEY_USE_EASE_FROM = 0x10
|
KEY_USE_EASE_FROM = 0x10
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
|
|
||||||
// ********************************************************************
|
// ********************************************************************
|
||||||
// Basic chunks which can be found everywhere in the file
|
// Basic chunks which can be found everywhere in the file
|
||||||
|
@ -322,28 +318,30 @@ public:
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure representing a 3ds mesh face */
|
/** Helper structure representing a 3ds mesh face */
|
||||||
struct Face : public FaceWithSmoothingGroup
|
struct Face : public FaceWithSmoothingGroup {
|
||||||
{
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#pragma warning(disable : 4315 )
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure representing a texture */
|
/** Helper structure representing a texture */
|
||||||
struct Texture {
|
struct Texture {
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
Texture() AI_NO_EXCEPT
|
Texture() AI_NO_EXCEPT
|
||||||
: mOffsetU (0.0)
|
: mTextureBlend(0.0f),
|
||||||
, mOffsetV (0.0)
|
mMapName(),
|
||||||
, mScaleU (1.0)
|
mOffsetU(0.0),
|
||||||
, mScaleV (1.0)
|
mOffsetV(0.0),
|
||||||
, mRotation (0.0)
|
mScaleU(1.0),
|
||||||
, mMapMode (aiTextureMapMode_Wrap)
|
mScaleV(1.0),
|
||||||
, bPrivate()
|
mRotation(0.0),
|
||||||
, iUVSrc (0) {
|
mMapMode(aiTextureMapMode_Wrap),
|
||||||
|
bPrivate(),
|
||||||
|
iUVSrc(0) {
|
||||||
mTextureBlend = get_qnan();
|
mTextureBlend = get_qnan();
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture(Texture &&other) AI_NO_EXCEPT :
|
Texture(Texture &&other) AI_NO_EXCEPT : mTextureBlend(std::move(other.mTextureBlend)),
|
||||||
mTextureBlend(std::move(other.mTextureBlend)),
|
|
||||||
mMapName(std::move(mMapName)),
|
mMapName(std::move(mMapName)),
|
||||||
mOffsetU(std::move(mOffsetU)),
|
mOffsetU(std::move(mOffsetU)),
|
||||||
mOffsetV(std::move(mOffsetV)),
|
mOffsetV(std::move(mOffsetV)),
|
||||||
|
@ -353,7 +351,26 @@ struct Texture {
|
||||||
mMapMode(std::move(mMapMode)),
|
mMapMode(std::move(mMapMode)),
|
||||||
bPrivate(std::move(bPrivate)),
|
bPrivate(std::move(bPrivate)),
|
||||||
iUVSrc(std::move(iUVSrc)) {
|
iUVSrc(std::move(iUVSrc)) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture &operator=(Texture &&other) AI_NO_EXCEPT {
|
||||||
|
if (this == &other) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
mTextureBlend = std::move(other.mTextureBlend);
|
||||||
|
mMapName = std::move(other.mMapName);
|
||||||
|
mOffsetU = std::move(other.mOffsetU);
|
||||||
|
mOffsetV = std::move(other.mOffsetV);
|
||||||
|
mScaleU = std::move(other.mScaleU);
|
||||||
|
mScaleV = std::move(other.mScaleV);
|
||||||
|
mRotation = std::move(other.mRotation);
|
||||||
|
mMapMode = std::move(other.mMapMode);
|
||||||
|
bPrivate = std::move(other.bPrivate);
|
||||||
|
iUVSrc = std::move(other.iUVSrc);
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Specifies the blend factor for the texture
|
//! Specifies the blend factor for the texture
|
||||||
|
@ -381,55 +398,48 @@ struct Texture {
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure representing a 3ds material */
|
/** Helper structure representing a 3ds material */
|
||||||
struct Material
|
struct Material {
|
||||||
{
|
|
||||||
//! Default constructor has been deleted
|
//! Default constructor has been deleted
|
||||||
Material() = delete;
|
Material() = delete;
|
||||||
|
|
||||||
|
|
||||||
//! Constructor with explicit name
|
//! Constructor with explicit name
|
||||||
explicit Material(const std::string &name)
|
explicit Material(const std::string &name) :
|
||||||
: mName(name)
|
mName(name), mDiffuse(ai_real(0.6), ai_real(0.6), ai_real(0.6)) // FIX ... we won't want object to be black
|
||||||
, mDiffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) // FIX ... we won't want object to be black
|
,
|
||||||
, mSpecularExponent ( ai_real( 0.0 ) )
|
mSpecularExponent(ai_real(0.0)),
|
||||||
, mShininessStrength ( ai_real( 1.0 ) )
|
mShininessStrength(ai_real(1.0)),
|
||||||
, mShading(Discreet3DS::Gouraud)
|
mShading(Discreet3DS::Gouraud),
|
||||||
, mTransparency ( ai_real( 1.0 ) )
|
mTransparency(ai_real(1.0)),
|
||||||
, mBumpHeight ( ai_real( 1.0 ) )
|
mBumpHeight(ai_real(1.0)),
|
||||||
, mTwoSided (false)
|
mTwoSided(false) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Material(const Material &other) = default;
|
Material(const Material &other) = default;
|
||||||
Material &operator=(const Material &other) = default;
|
Material &operator=(const Material &other) = default;
|
||||||
|
|
||||||
|
|
||||||
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
||||||
Material(Material &&other) AI_NO_EXCEPT
|
Material(Material &&other) AI_NO_EXCEPT
|
||||||
: mName(std::move(other.mName))
|
: mName(std::move(other.mName)),
|
||||||
, mDiffuse(std::move(other.mDiffuse))
|
mDiffuse(std::move(other.mDiffuse)),
|
||||||
, mSpecularExponent(std::move(other.mSpecularExponent))
|
mSpecularExponent(std::move(other.mSpecularExponent)),
|
||||||
, mShininessStrength(std::move(other.mShininessStrength))
|
mShininessStrength(std::move(other.mShininessStrength)),
|
||||||
, mSpecular(std::move(other.mSpecular))
|
mSpecular(std::move(other.mSpecular)),
|
||||||
, mAmbient(std::move(other.mAmbient))
|
mAmbient(std::move(other.mAmbient)),
|
||||||
, mShading(std::move(other.mShading))
|
mShading(std::move(other.mShading)),
|
||||||
, mTransparency(std::move(other.mTransparency))
|
mTransparency(std::move(other.mTransparency)),
|
||||||
, sTexDiffuse(std::move(other.sTexDiffuse))
|
sTexDiffuse(std::move(other.sTexDiffuse)),
|
||||||
, sTexOpacity(std::move(other.sTexOpacity))
|
sTexOpacity(std::move(other.sTexOpacity)),
|
||||||
, sTexSpecular(std::move(other.sTexSpecular))
|
sTexSpecular(std::move(other.sTexSpecular)),
|
||||||
, sTexReflective(std::move(other.sTexReflective))
|
sTexReflective(std::move(other.sTexReflective)),
|
||||||
, sTexBump(std::move(other.sTexBump))
|
sTexBump(std::move(other.sTexBump)),
|
||||||
, sTexEmissive(std::move(other.sTexEmissive))
|
sTexEmissive(std::move(other.sTexEmissive)),
|
||||||
, sTexShininess(std::move(other.sTexShininess))
|
sTexShininess(std::move(other.sTexShininess)),
|
||||||
, mBumpHeight(std::move(other.mBumpHeight))
|
mBumpHeight(std::move(other.mBumpHeight)),
|
||||||
, mEmissive(std::move(other.mEmissive))
|
mEmissive(std::move(other.mEmissive)),
|
||||||
, sTexAmbient(std::move(other.sTexAmbient))
|
sTexAmbient(std::move(other.sTexAmbient)),
|
||||||
, mTwoSided(std::move(other.mTwoSided))
|
mTwoSided(std::move(other.mTwoSided)) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Material &operator=(Material &&other) AI_NO_EXCEPT {
|
Material &operator=(Material &&other) AI_NO_EXCEPT {
|
||||||
if (this == &other) {
|
if (this == &other) {
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -458,10 +468,8 @@ struct Material
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual ~Material() {}
|
virtual ~Material() {}
|
||||||
|
|
||||||
|
|
||||||
//! Name of the material
|
//! Name of the material
|
||||||
std::string mName;
|
std::string mName;
|
||||||
//! Diffuse color of the material
|
//! Diffuse color of the material
|
||||||
|
@ -505,18 +513,15 @@ struct Material
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure to represent a 3ds file mesh */
|
/** Helper structure to represent a 3ds file mesh */
|
||||||
struct Mesh : public MeshWithSmoothingGroups<D3DS::Face>
|
struct Mesh : public MeshWithSmoothingGroups<D3DS::Face> {
|
||||||
{
|
|
||||||
//! Default constructor has been deleted
|
//! Default constructor has been deleted
|
||||||
Mesh() = delete;
|
Mesh() = delete;
|
||||||
|
|
||||||
//! Constructor with explicit name
|
//! Constructor with explicit name
|
||||||
explicit Mesh(const std::string &name)
|
explicit Mesh(const std::string &name) :
|
||||||
: mName(name)
|
mName(name) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Name of the mesh
|
//! Name of the mesh
|
||||||
std::string mName;
|
std::string mName;
|
||||||
|
|
||||||
|
@ -533,53 +538,39 @@ struct Mesh : public MeshWithSmoothingGroups<D3DS::Face>
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Float key - quite similar to aiVectorKey and aiQuatKey. Both are in the
|
/** Float key - quite similar to aiVectorKey and aiQuatKey. Both are in the
|
||||||
C-API, so it would be difficult to make them a template. */
|
C-API, so it would be difficult to make them a template. */
|
||||||
struct aiFloatKey
|
struct aiFloatKey {
|
||||||
{
|
|
||||||
double mTime; ///< The time of this key
|
double mTime; ///< The time of this key
|
||||||
ai_real mValue; ///< The value of this key
|
ai_real mValue; ///< The value of this key
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
// time is not compared
|
// time is not compared
|
||||||
bool operator == (const aiFloatKey& o) const
|
bool operator==(const aiFloatKey &o) const { return o.mValue == this->mValue; }
|
||||||
{return o.mValue == this->mValue;}
|
|
||||||
|
|
||||||
bool operator != (const aiFloatKey& o) const
|
bool operator!=(const aiFloatKey &o) const { return o.mValue != this->mValue; }
|
||||||
{return o.mValue != this->mValue;}
|
|
||||||
|
|
||||||
// Only time is compared. This operator is defined
|
// Only time is compared. This operator is defined
|
||||||
// for use with std::sort
|
// for use with std::sort
|
||||||
bool operator < (const aiFloatKey& o) const
|
bool operator<(const aiFloatKey &o) const { return mTime < o.mTime; }
|
||||||
{return mTime < o.mTime;}
|
|
||||||
|
|
||||||
bool operator > (const aiFloatKey& o) const
|
bool operator>(const aiFloatKey &o) const { return mTime > o.mTime; }
|
||||||
{return mTime > o.mTime;}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure to represent a 3ds file node */
|
/** Helper structure to represent a 3ds file node */
|
||||||
struct Node
|
struct Node {
|
||||||
{
|
|
||||||
Node() = delete;
|
Node() = delete;
|
||||||
|
|
||||||
explicit Node(const std::string &name)
|
explicit Node(const std::string &name) :
|
||||||
: mParent(NULL)
|
mParent(NULL), mName(name), mInstanceNumber(0), mHierarchyPos(0), mHierarchyIndex(0), mInstanceCount(1) {
|
||||||
, mName(name)
|
|
||||||
, mInstanceNumber(0)
|
|
||||||
, mHierarchyPos (0)
|
|
||||||
, mHierarchyIndex (0)
|
|
||||||
, mInstanceCount (1)
|
|
||||||
{
|
|
||||||
aRotationKeys.reserve(20);
|
aRotationKeys.reserve(20);
|
||||||
aPositionKeys.reserve(20);
|
aPositionKeys.reserve(20);
|
||||||
aScalingKeys.reserve(20);
|
aScalingKeys.reserve(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Node() {
|
||||||
~Node()
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < mChildren.size(); ++i)
|
for (unsigned int i = 0; i < mChildren.size(); ++i)
|
||||||
delete mChildren[i];
|
delete mChildren[i];
|
||||||
}
|
}
|
||||||
|
@ -614,7 +605,6 @@ struct Node
|
||||||
//! Scaling keys loaded from the file
|
//! Scaling keys loaded from the file
|
||||||
std::vector<aiVectorKey> aScalingKeys;
|
std::vector<aiVectorKey> aScalingKeys;
|
||||||
|
|
||||||
|
|
||||||
// For target lights (spot lights and directional lights):
|
// For target lights (spot lights and directional lights):
|
||||||
// The position of the target
|
// The position of the target
|
||||||
std::vector<aiVectorKey> aTargetPositionKeys;
|
std::vector<aiVectorKey> aTargetPositionKeys;
|
||||||
|
@ -630,8 +620,7 @@ struct Node
|
||||||
|
|
||||||
//! Add a child node, setup the right parent node for it
|
//! Add a child node, setup the right parent node for it
|
||||||
//! \param pc Node to be 'adopted'
|
//! \param pc Node to be 'adopted'
|
||||||
inline Node& push_back(Node* pc)
|
inline Node &push_back(Node *pc) {
|
||||||
{
|
|
||||||
mChildren.push_back(pc);
|
mChildren.push_back(pc);
|
||||||
pc->mParent = this;
|
pc->mParent = this;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -639,8 +628,7 @@ struct Node
|
||||||
};
|
};
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Helper structure analogue to aiScene */
|
/** Helper structure analogue to aiScene */
|
||||||
struct Scene
|
struct Scene {
|
||||||
{
|
|
||||||
//! List of all materials loaded
|
//! List of all materials loaded
|
||||||
//! NOTE: 3ds references materials globally
|
//! NOTE: 3ds references materials globally
|
||||||
std::vector<Material> mMaterials;
|
std::vector<Material> mMaterials;
|
||||||
|
@ -659,7 +647,6 @@ struct Scene
|
||||||
// Node* pcRootNode;
|
// Node* pcRootNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // end of namespace D3DS
|
} // end of namespace D3DS
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
|
|
@ -158,13 +158,13 @@ void Discreet3DSImporter::SetupProperties(const Importer* /*pImp*/)
|
||||||
void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
aiScene* pScene, IOSystem* pIOHandler)
|
||||||
{
|
{
|
||||||
StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
|
StreamReaderLE theStream(pIOHandler->Open(pFile,"rb"));
|
||||||
|
|
||||||
// We should have at least one chunk
|
// We should have at least one chunk
|
||||||
if (stream.GetRemainingSize() < 16) {
|
if (theStream.GetRemainingSize() < 16) {
|
||||||
throw DeadlyImportError("3DS file is either empty or corrupt: " + pFile);
|
throw DeadlyImportError("3DS file is either empty or corrupt: " + pFile);
|
||||||
}
|
}
|
||||||
this->stream = &stream;
|
this->stream = &theStream;
|
||||||
|
|
||||||
// Allocate our temporary 3DS representation
|
// Allocate our temporary 3DS representation
|
||||||
D3DS::Scene _scene;
|
D3DS::Scene _scene;
|
||||||
|
@ -599,16 +599,19 @@ void Discreet3DSImporter::InverseNodeSearch(D3DS::Node* pcNode,D3DS::Node* pcCur
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Find a node with a specific name in the import hierarchy
|
// Find a node with a specific name in the import hierarchy
|
||||||
D3DS::Node* FindNode(D3DS::Node* root, const std::string& name)
|
D3DS::Node* FindNode(D3DS::Node* root, const std::string& name) {
|
||||||
{
|
if (root->mName == name) {
|
||||||
if (root->mName == name)
|
|
||||||
return root;
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
for (std::vector<D3DS::Node*>::iterator it = root->mChildren.begin();it != root->mChildren.end(); ++it) {
|
for (std::vector<D3DS::Node*>::iterator it = root->mChildren.begin();it != root->mChildren.end(); ++it) {
|
||||||
D3DS::Node* nd;
|
D3DS::Node *nd = FindNode(*it, name);
|
||||||
if (( nd = FindNode(*it,name)))
|
if (nullptr != nd) {
|
||||||
return nd;
|
return nd;
|
||||||
}
|
}
|
||||||
return NULL;
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -44,25 +44,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/** @file Implementation of the AC3D importer class */
|
/** @file Implementation of the AC3D importer class */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_AC_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_AC_IMPORTER
|
||||||
|
|
||||||
// internal headers
|
// internal headers
|
||||||
#include "ACLoader.h"
|
#include "ACLoader.h"
|
||||||
#include <assimp/ParsingUtils.h>
|
|
||||||
#include <assimp/fast_atof.h>
|
|
||||||
#include <assimp/Subdivision.h>
|
|
||||||
#include "Common/Importer.h"
|
#include "Common/Importer.h"
|
||||||
#include <assimp/BaseImporter.h>
|
#include <assimp/BaseImporter.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/ParsingUtils.h>
|
||||||
|
#include <assimp/Subdivision.h>
|
||||||
|
#include <assimp/config.h>
|
||||||
|
#include <assimp/fast_atof.h>
|
||||||
|
#include <assimp/importerdesc.h>
|
||||||
#include <assimp/light.h>
|
#include <assimp/light.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
|
||||||
#include <assimp/material.h>
|
#include <assimp/material.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/config.h>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/importerdesc.h>
|
#include <assimp/Importer.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
@ -83,8 +81,7 @@ static const aiImporterDesc desc = {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// skip to the next token
|
// skip to the next token
|
||||||
#define AI_AC_SKIP_TO_NEXT_TOKEN() \
|
#define AI_AC_SKIP_TO_NEXT_TOKEN() \
|
||||||
if (!SkipSpaces(&buffer)) \
|
if (!SkipSpaces(&buffer)) { \
|
||||||
{ \
|
|
||||||
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF/EOL"); \
|
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF/EOL"); \
|
||||||
continue; \
|
continue; \
|
||||||
}
|
}
|
||||||
|
@ -97,10 +94,8 @@ static const aiImporterDesc desc = {
|
||||||
} \
|
} \
|
||||||
++buffer; \
|
++buffer; \
|
||||||
const char *sz = buffer; \
|
const char *sz = buffer; \
|
||||||
while ('\"' != *buffer) \
|
while ('\"' != *buffer) { \
|
||||||
{ \
|
if (IsLineEnd(*buffer)) { \
|
||||||
if (IsLineEnd( *buffer )) \
|
|
||||||
{ \
|
|
||||||
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF/EOL in string"); \
|
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF/EOL in string"); \
|
||||||
out = "ERROR"; \
|
out = "ERROR"; \
|
||||||
break; \
|
break; \
|
||||||
|
@ -111,54 +106,46 @@ static const aiImporterDesc desc = {
|
||||||
out = std::string(sz, (unsigned int)(buffer - sz)); \
|
out = std::string(sz, (unsigned int)(buffer - sz)); \
|
||||||
++buffer;
|
++buffer;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// read 1 to n floats prefixed with an optional predefined identifier
|
// read 1 to n floats prefixed with an optional predefined identifier
|
||||||
#define AI_AC_CHECKED_LOAD_FLOAT_ARRAY(name, name_length, num, out) \
|
#define AI_AC_CHECKED_LOAD_FLOAT_ARRAY(name, name_length, num, out) \
|
||||||
AI_AC_SKIP_TO_NEXT_TOKEN(); \
|
AI_AC_SKIP_TO_NEXT_TOKEN(); \
|
||||||
if (name_length) \
|
if (name_length) { \
|
||||||
{ \
|
if (strncmp(buffer, name, name_length) || !IsSpace(buffer[name_length])) { \
|
||||||
if (strncmp(buffer,name,name_length) || !IsSpace(buffer[name_length])) \
|
|
||||||
{ \
|
|
||||||
ASSIMP_LOG_ERROR("AC3D: Unexpexted token. " name " was expected."); \
|
ASSIMP_LOG_ERROR("AC3D: Unexpexted token. " name " was expected."); \
|
||||||
continue; \
|
continue; \
|
||||||
} \
|
} \
|
||||||
buffer += name_length + 1; \
|
buffer += name_length + 1; \
|
||||||
} \
|
} \
|
||||||
for (unsigned int i = 0; i < num;++i) \
|
for (unsigned int _i = 0; _i < num; ++_i) { \
|
||||||
{ \
|
|
||||||
AI_AC_SKIP_TO_NEXT_TOKEN(); \
|
AI_AC_SKIP_TO_NEXT_TOKEN(); \
|
||||||
buffer = fast_atoreal_move<float>(buffer,((float*)out)[i]); \
|
buffer = fast_atoreal_move<float>(buffer, ((float *)out)[_i]); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
AC3DImporter::AC3DImporter()
|
AC3DImporter::AC3DImporter() :
|
||||||
: buffer(),
|
buffer(),
|
||||||
configSplitBFCull(),
|
configSplitBFCull(),
|
||||||
configEvalSubdivision(),
|
configEvalSubdivision(),
|
||||||
mNumMeshes(),
|
mNumMeshes(),
|
||||||
mLights(),
|
mLights(),
|
||||||
lights(),
|
mLightsCounter(0),
|
||||||
groups(),
|
mGroupsCounter(0),
|
||||||
polys(),
|
mPolysCounter(0),
|
||||||
worlds()
|
mWorldsCounter(0) {
|
||||||
{
|
|
||||||
// nothing to be done here
|
// nothing to be done here
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor, private as well
|
// Destructor, private as well
|
||||||
AC3DImporter::~AC3DImporter()
|
AC3DImporter::~AC3DImporter() {
|
||||||
{
|
|
||||||
// nothing to be done here
|
// nothing to be done here
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool AC3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
bool AC3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const {
|
||||||
{
|
|
||||||
std::string extension = GetExtension(pFile);
|
std::string extension = GetExtension(pFile);
|
||||||
|
|
||||||
// fixme: are acc and ac3d *really* used? Some sources say they are
|
// fixme: are acc and ac3d *really* used? Some sources say they are
|
||||||
|
@ -174,23 +161,20 @@ bool AC3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Loader meta information
|
// Loader meta information
|
||||||
const aiImporterDesc* AC3DImporter::GetInfo () const
|
const aiImporterDesc *AC3DImporter::GetInfo() const {
|
||||||
{
|
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Get a pointer to the next line from the file
|
// Get a pointer to the next line from the file
|
||||||
bool AC3DImporter::GetNextLine( )
|
bool AC3DImporter::GetNextLine() {
|
||||||
{
|
|
||||||
SkipLine(&buffer);
|
SkipLine(&buffer);
|
||||||
return SkipSpaces(&buffer);
|
return SkipSpaces(&buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Parse an object section in an AC file
|
// Parse an object section in an AC file
|
||||||
void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
|
void AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
|
||||||
{
|
|
||||||
if (!TokenMatch(buffer, "OBJECT", 6))
|
if (!TokenMatch(buffer, "OBJECT", 6))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -202,8 +186,7 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
|
||||||
Object &obj = objects.back();
|
Object &obj = objects.back();
|
||||||
|
|
||||||
aiLight *light = NULL;
|
aiLight *light = NULL;
|
||||||
if (!ASSIMP_strincmp(buffer,"light",5))
|
if (!ASSIMP_strincmp(buffer, "light", 5)) {
|
||||||
{
|
|
||||||
// This is a light source. Add it to the list
|
// This is a light source. Add it to the list
|
||||||
mLights->push_back(light = new aiLight());
|
mLights->push_back(light = new aiLight());
|
||||||
|
|
||||||
|
@ -219,83 +202,57 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
|
||||||
|
|
||||||
ASSIMP_LOG_DEBUG("AC3D: Light source encountered");
|
ASSIMP_LOG_DEBUG("AC3D: Light source encountered");
|
||||||
obj.type = Object::Light;
|
obj.type = Object::Light;
|
||||||
}
|
} else if (!ASSIMP_strincmp(buffer, "group", 5)) {
|
||||||
else if (!ASSIMP_strincmp(buffer,"group",5))
|
|
||||||
{
|
|
||||||
obj.type = Object::Group;
|
obj.type = Object::Group;
|
||||||
}
|
} else if (!ASSIMP_strincmp(buffer, "world", 5)) {
|
||||||
else if (!ASSIMP_strincmp(buffer,"world",5))
|
|
||||||
{
|
|
||||||
obj.type = Object::World;
|
obj.type = Object::World;
|
||||||
}
|
} else
|
||||||
else obj.type = Object::Poly;
|
obj.type = Object::Poly;
|
||||||
while (GetNextLine())
|
while (GetNextLine()) {
|
||||||
{
|
if (TokenMatch(buffer, "kids", 4)) {
|
||||||
if (TokenMatch(buffer,"kids",4))
|
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
unsigned int num = strtoul10(buffer, &buffer);
|
unsigned int num = strtoul10(buffer, &buffer);
|
||||||
GetNextLine();
|
GetNextLine();
|
||||||
if (num)
|
if (num) {
|
||||||
{
|
|
||||||
// load the children of this object recursively
|
// load the children of this object recursively
|
||||||
obj.children.reserve(num);
|
obj.children.reserve(num);
|
||||||
for (unsigned int i = 0; i < num; ++i)
|
for (unsigned int i = 0; i < num; ++i)
|
||||||
LoadObjectSection(obj.children);
|
LoadObjectSection(obj.children);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
} else if (TokenMatch(buffer, "name", 4)) {
|
||||||
else if (TokenMatch(buffer,"name",4))
|
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
AI_AC_GET_STRING(obj.name);
|
AI_AC_GET_STRING(obj.name);
|
||||||
|
|
||||||
// If this is a light source, we'll also need to store
|
// If this is a light source, we'll also need to store
|
||||||
// the name of the node in it.
|
// the name of the node in it.
|
||||||
if (light)
|
if (light) {
|
||||||
{
|
|
||||||
light->mName.Set(obj.name);
|
light->mName.Set(obj.name);
|
||||||
}
|
}
|
||||||
}
|
} else if (TokenMatch(buffer, "texture", 7)) {
|
||||||
else if (TokenMatch(buffer,"texture",7))
|
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
AI_AC_GET_STRING(obj.texture);
|
AI_AC_GET_STRING(obj.texture);
|
||||||
}
|
} else if (TokenMatch(buffer, "texrep", 6)) {
|
||||||
else if (TokenMatch(buffer,"texrep",6))
|
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 2, &obj.texRepeat);
|
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 2, &obj.texRepeat);
|
||||||
if (!obj.texRepeat.x || !obj.texRepeat.y)
|
if (!obj.texRepeat.x || !obj.texRepeat.y)
|
||||||
obj.texRepeat = aiVector2D(1.f, 1.f);
|
obj.texRepeat = aiVector2D(1.f, 1.f);
|
||||||
}
|
} else if (TokenMatch(buffer, "texoff", 6)) {
|
||||||
else if (TokenMatch(buffer,"texoff",6))
|
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 2, &obj.texOffset);
|
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 2, &obj.texOffset);
|
||||||
}
|
} else if (TokenMatch(buffer, "rot", 3)) {
|
||||||
else if (TokenMatch(buffer,"rot",3))
|
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 9, &obj.rotation);
|
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 9, &obj.rotation);
|
||||||
}
|
} else if (TokenMatch(buffer, "loc", 3)) {
|
||||||
else if (TokenMatch(buffer,"loc",3))
|
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 3, &obj.translation);
|
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 3, &obj.translation);
|
||||||
}
|
} else if (TokenMatch(buffer, "subdiv", 6)) {
|
||||||
else if (TokenMatch(buffer,"subdiv",6))
|
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
obj.subDiv = strtoul10(buffer, &buffer);
|
obj.subDiv = strtoul10(buffer, &buffer);
|
||||||
}
|
} else if (TokenMatch(buffer, "crease", 6)) {
|
||||||
else if (TokenMatch(buffer,"crease",6))
|
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
obj.crease = fast_atof(buffer);
|
obj.crease = fast_atof(buffer);
|
||||||
}
|
} else if (TokenMatch(buffer, "numvert", 7)) {
|
||||||
else if (TokenMatch(buffer,"numvert",7))
|
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
|
|
||||||
unsigned int t = strtoul10(buffer, &buffer);
|
unsigned int t = strtoul10(buffer, &buffer);
|
||||||
|
@ -303,15 +260,11 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
|
||||||
throw DeadlyImportError("AC3D: Too many vertices, would run out of memory");
|
throw DeadlyImportError("AC3D: Too many vertices, would run out of memory");
|
||||||
}
|
}
|
||||||
obj.vertices.reserve(t);
|
obj.vertices.reserve(t);
|
||||||
for (unsigned int i = 0; i < t;++i)
|
for (unsigned int i = 0; i < t; ++i) {
|
||||||
{
|
if (!GetNextLine()) {
|
||||||
if (!GetNextLine())
|
|
||||||
{
|
|
||||||
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: not all vertices have been parsed yet");
|
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: not all vertices have been parsed yet");
|
||||||
break;
|
break;
|
||||||
}
|
} else if (!IsNumeric(*buffer)) {
|
||||||
else if (!IsNumeric(*buffer))
|
|
||||||
{
|
|
||||||
ASSIMP_LOG_ERROR("AC3D: Unexpected token: not all vertices have been parsed yet");
|
ASSIMP_LOG_ERROR("AC3D: Unexpected token: not all vertices have been parsed yet");
|
||||||
--buffer; // make sure the line is processed a second time
|
--buffer; // make sure the line is processed a second time
|
||||||
break;
|
break;
|
||||||
|
@ -320,24 +273,19 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
|
||||||
aiVector3D &v = obj.vertices.back();
|
aiVector3D &v = obj.vertices.back();
|
||||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 3, &v.x);
|
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 3, &v.x);
|
||||||
}
|
}
|
||||||
}
|
} else if (TokenMatch(buffer, "numsurf", 7)) {
|
||||||
else if (TokenMatch(buffer,"numsurf",7))
|
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
|
|
||||||
bool Q3DWorkAround = false;
|
bool Q3DWorkAround = false;
|
||||||
|
|
||||||
const unsigned int t = strtoul10(buffer, &buffer);
|
const unsigned int t = strtoul10(buffer, &buffer);
|
||||||
obj.surfaces.reserve(t);
|
obj.surfaces.reserve(t);
|
||||||
for (unsigned int i = 0; i < t;++i)
|
for (unsigned int i = 0; i < t; ++i) {
|
||||||
{
|
|
||||||
GetNextLine();
|
GetNextLine();
|
||||||
if (!TokenMatch(buffer,"SURF",4))
|
if (!TokenMatch(buffer, "SURF", 4)) {
|
||||||
{
|
|
||||||
// FIX: this can occur for some files - Quick 3D for
|
// FIX: this can occur for some files - Quick 3D for
|
||||||
// example writes no surf chunks
|
// example writes no surf chunks
|
||||||
if (!Q3DWorkAround)
|
if (!Q3DWorkAround) {
|
||||||
{
|
|
||||||
ASSIMP_LOG_WARN("AC3D: SURF token was expected");
|
ASSIMP_LOG_WARN("AC3D: SURF token was expected");
|
||||||
ASSIMP_LOG_DEBUG("Continuing with Quick3D Workaround enabled");
|
ASSIMP_LOG_DEBUG("Continuing with Quick3D Workaround enabled");
|
||||||
}
|
}
|
||||||
|
@ -351,24 +299,17 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
|
||||||
Surface &surf = obj.surfaces.back();
|
Surface &surf = obj.surfaces.back();
|
||||||
surf.flags = strtoul_cppstyle(buffer);
|
surf.flags = strtoul_cppstyle(buffer);
|
||||||
|
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
if (!GetNextLine()) {
|
||||||
if(!GetNextLine())
|
|
||||||
{
|
|
||||||
throw DeadlyImportError("AC3D: Unexpected EOF: surface is incomplete");
|
throw DeadlyImportError("AC3D: Unexpected EOF: surface is incomplete");
|
||||||
}
|
}
|
||||||
if (TokenMatch(buffer,"mat",3))
|
if (TokenMatch(buffer, "mat", 3)) {
|
||||||
{
|
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
surf.mat = strtoul10(buffer);
|
surf.mat = strtoul10(buffer);
|
||||||
}
|
} else if (TokenMatch(buffer, "refs", 4)) {
|
||||||
else if (TokenMatch(buffer,"refs",4))
|
|
||||||
{
|
|
||||||
// --- see fix notes above
|
// --- see fix notes above
|
||||||
if (Q3DWorkAround)
|
if (Q3DWorkAround) {
|
||||||
{
|
if (!surf.entries.empty()) {
|
||||||
if (!surf.entries.empty())
|
|
||||||
{
|
|
||||||
buffer -= 6;
|
buffer -= 6;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -380,10 +321,8 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
|
||||||
|
|
||||||
obj.numRefs += m;
|
obj.numRefs += m;
|
||||||
|
|
||||||
for (unsigned int k = 0; k < m; ++k)
|
for (unsigned int k = 0; k < m; ++k) {
|
||||||
{
|
if (!GetNextLine()) {
|
||||||
if(!GetNextLine())
|
|
||||||
{
|
|
||||||
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: surface references are incomplete");
|
ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: surface references are incomplete");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -394,9 +333,7 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
|
||||||
SkipSpaces(&buffer);
|
SkipSpaces(&buffer);
|
||||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 2, &entry.second);
|
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("", 0, 2, &entry.second);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
--buffer; // make sure the line is processed a second time
|
--buffer; // make sure the line is processed a second time
|
||||||
break;
|
break;
|
||||||
|
@ -412,24 +349,20 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
|
||||||
// Convert a material from AC3DImporter::Material to aiMaterial
|
// Convert a material from AC3DImporter::Material to aiMaterial
|
||||||
void AC3DImporter::ConvertMaterial(const Object &object,
|
void AC3DImporter::ConvertMaterial(const Object &object,
|
||||||
const Material &matSrc,
|
const Material &matSrc,
|
||||||
aiMaterial& matDest)
|
aiMaterial &matDest) {
|
||||||
{
|
|
||||||
aiString s;
|
aiString s;
|
||||||
|
|
||||||
if (matSrc.name.length())
|
if (matSrc.name.length()) {
|
||||||
{
|
|
||||||
s.Set(matSrc.name);
|
s.Set(matSrc.name);
|
||||||
matDest.AddProperty(&s, AI_MATKEY_NAME);
|
matDest.AddProperty(&s, AI_MATKEY_NAME);
|
||||||
}
|
}
|
||||||
if (object.texture.length())
|
if (object.texture.length()) {
|
||||||
{
|
|
||||||
s.Set(object.texture);
|
s.Set(object.texture);
|
||||||
matDest.AddProperty(&s, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
matDest.AddProperty(&s, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
|
|
||||||
// UV transformation
|
// UV transformation
|
||||||
if (1.f != object.texRepeat.x || 1.f != object.texRepeat.y ||
|
if (1.f != object.texRepeat.x || 1.f != object.texRepeat.y ||
|
||||||
object.texOffset.x || object.texOffset.y)
|
object.texOffset.x || object.texOffset.y) {
|
||||||
{
|
|
||||||
aiUVTransform transform;
|
aiUVTransform transform;
|
||||||
transform.mScaling = object.texRepeat;
|
transform.mScaling = object.texRepeat;
|
||||||
transform.mTranslation = object.texOffset;
|
transform.mTranslation = object.texOffset;
|
||||||
|
@ -443,12 +376,11 @@ void AC3DImporter::ConvertMaterial(const Object& object,
|
||||||
matDest.AddProperty<aiColor3D>(&matSrc.spec, 1, AI_MATKEY_COLOR_SPECULAR);
|
matDest.AddProperty<aiColor3D>(&matSrc.spec, 1, AI_MATKEY_COLOR_SPECULAR);
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
if (matSrc.shin)
|
if (matSrc.shin) {
|
||||||
{
|
|
||||||
n = aiShadingMode_Phong;
|
n = aiShadingMode_Phong;
|
||||||
matDest.AddProperty<float>(&matSrc.shin, 1, AI_MATKEY_SHININESS);
|
matDest.AddProperty<float>(&matSrc.shin, 1, AI_MATKEY_SHININESS);
|
||||||
}
|
} else
|
||||||
else n = aiShadingMode_Gouraud;
|
n = aiShadingMode_Gouraud;
|
||||||
matDest.AddProperty<int>(&n, 1, AI_MATKEY_SHADING_MODEL);
|
matDest.AddProperty<int>(&n, 1, AI_MATKEY_SHADING_MODEL);
|
||||||
|
|
||||||
float f = 1.f - matSrc.trans;
|
float f = 1.f - matSrc.trans;
|
||||||
|
@ -461,14 +393,11 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
std::vector<aiMesh *> &meshes,
|
std::vector<aiMesh *> &meshes,
|
||||||
std::vector<aiMaterial *> &outMaterials,
|
std::vector<aiMaterial *> &outMaterials,
|
||||||
const std::vector<Material> &materials,
|
const std::vector<Material> &materials,
|
||||||
aiNode* parent)
|
aiNode *parent) {
|
||||||
{
|
|
||||||
aiNode *node = new aiNode();
|
aiNode *node = new aiNode();
|
||||||
node->mParent = parent;
|
node->mParent = parent;
|
||||||
if (object.vertices.size())
|
if (object.vertices.size()) {
|
||||||
{
|
if (!object.surfaces.size() || !object.numRefs) {
|
||||||
if (!object.surfaces.size() || !object.numRefs)
|
|
||||||
{
|
|
||||||
/* " An object with 7 vertices (no surfaces, no materials defined).
|
/* " An object with 7 vertices (no surfaces, no materials defined).
|
||||||
This is a good way of getting point data into AC3D.
|
This is a good way of getting point data into AC3D.
|
||||||
The Vertex->create convex-surface/object can be used on these
|
The Vertex->create convex-surface/object can be used on these
|
||||||
|
@ -488,8 +417,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
aiFace *faces = mesh->mFaces = new aiFace[mesh->mNumFaces];
|
aiFace *faces = mesh->mFaces = new aiFace[mesh->mNumFaces];
|
||||||
aiVector3D *verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices];
|
aiVector3D *verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mesh->mNumVertices;++i,++faces,++verts)
|
for (unsigned int i = 0; i < mesh->mNumVertices; ++i, ++faces, ++verts) {
|
||||||
{
|
|
||||||
*verts = object.vertices[i];
|
*verts = object.vertices[i];
|
||||||
faces->mNumIndices = 1;
|
faces->mNumIndices = 1;
|
||||||
faces->mIndices = new unsigned int[1];
|
faces->mIndices = new unsigned int[1];
|
||||||
|
@ -502,9 +430,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
mesh->mMaterialIndex = 0;
|
mesh->mMaterialIndex = 0;
|
||||||
outMaterials.push_back(new aiMaterial());
|
outMaterials.push_back(new aiMaterial());
|
||||||
ConvertMaterial(object, materials[0], *outMaterials.back());
|
ConvertMaterial(object, materials[0], *outMaterials.back());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// need to generate one or more meshes for this object.
|
// need to generate one or more meshes for this object.
|
||||||
// find out how many different materials we have
|
// find out how many different materials we have
|
||||||
typedef std::pair<unsigned int, unsigned int> IntPair;
|
typedef std::pair<unsigned int, unsigned int> IntPair;
|
||||||
|
@ -514,25 +440,21 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
std::vector<Surface>::iterator it, end = object.surfaces.end();
|
std::vector<Surface>::iterator it, end = object.surfaces.end();
|
||||||
std::vector<Surface::SurfaceEntry>::iterator it2, end2;
|
std::vector<Surface::SurfaceEntry>::iterator it2, end2;
|
||||||
|
|
||||||
for (it = object.surfaces.begin(); it != end; ++it)
|
for (it = object.surfaces.begin(); it != end; ++it) {
|
||||||
{
|
|
||||||
unsigned int idx = (*it).mat;
|
unsigned int idx = (*it).mat;
|
||||||
if (idx >= needMat.size())
|
if (idx >= needMat.size()) {
|
||||||
{
|
|
||||||
ASSIMP_LOG_ERROR("AC3D: material index is out of range");
|
ASSIMP_LOG_ERROR("AC3D: material index is out of range");
|
||||||
idx = 0;
|
idx = 0;
|
||||||
}
|
}
|
||||||
if ((*it).entries.empty())
|
if ((*it).entries.empty()) {
|
||||||
{
|
|
||||||
ASSIMP_LOG_WARN("AC3D: surface her zero vertex references");
|
ASSIMP_LOG_WARN("AC3D: surface her zero vertex references");
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate all vertex indices to make sure we won't crash here
|
// validate all vertex indices to make sure we won't crash here
|
||||||
for (it2 = (*it).entries.begin(),
|
for (it2 = (*it).entries.begin(),
|
||||||
end2 = (*it).entries.end(); it2 != end2; ++it2)
|
end2 = (*it).entries.end();
|
||||||
{
|
it2 != end2; ++it2) {
|
||||||
if ((*it2).first >= object.vertices.size())
|
if ((*it2).first >= object.vertices.size()) {
|
||||||
{
|
|
||||||
ASSIMP_LOG_WARN("AC3D: Invalid vertex reference");
|
ASSIMP_LOG_WARN("AC3D: Invalid vertex reference");
|
||||||
(*it2).first = 0;
|
(*it2).first = 0;
|
||||||
}
|
}
|
||||||
|
@ -540,8 +462,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
|
|
||||||
if (!needMat[idx].first) ++node->mNumMeshes;
|
if (!needMat[idx].first) ++node->mNumMeshes;
|
||||||
|
|
||||||
switch ((*it).flags & 0xf)
|
switch ((*it).flags & 0xf) {
|
||||||
{
|
|
||||||
// closed line
|
// closed line
|
||||||
case 0x1:
|
case 0x1:
|
||||||
|
|
||||||
|
@ -559,8 +480,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
// 0 == polygon, else unknown
|
// 0 == polygon, else unknown
|
||||||
default:
|
default:
|
||||||
|
|
||||||
if ((*it).flags & 0xf)
|
if ((*it).flags & 0xf) {
|
||||||
{
|
|
||||||
ASSIMP_LOG_WARN("AC3D: The type flag of a surface is unknown");
|
ASSIMP_LOG_WARN("AC3D: The type flag of a surface is unknown");
|
||||||
(*it).flags &= ~(0xf);
|
(*it).flags &= ~(0xf);
|
||||||
}
|
}
|
||||||
|
@ -575,8 +495,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
unsigned int mat = 0;
|
unsigned int mat = 0;
|
||||||
const size_t oldm = meshes.size();
|
const size_t oldm = meshes.size();
|
||||||
for (MatTable::const_iterator cit = needMat.begin(), cend = needMat.end();
|
for (MatTable::const_iterator cit = needMat.begin(), cend = needMat.end();
|
||||||
cit != cend; ++cit, ++mat)
|
cit != cend; ++cit, ++mat) {
|
||||||
{
|
|
||||||
if (!(*cit).first) continue;
|
if (!(*cit).first) continue;
|
||||||
|
|
||||||
// allocate a new aiMesh object
|
// allocate a new aiMesh object
|
||||||
|
@ -609,28 +528,22 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
// allocate UV coordinates, but only if the texture name for the
|
// allocate UV coordinates, but only if the texture name for the
|
||||||
// surface is not empty
|
// surface is not empty
|
||||||
aiVector3D *uv = NULL;
|
aiVector3D *uv = NULL;
|
||||||
if(object.texture.length())
|
if (object.texture.length()) {
|
||||||
{
|
|
||||||
uv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
|
uv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
|
||||||
mesh->mNumUVComponents[0] = 2;
|
mesh->mNumUVComponents[0] = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (it = object.surfaces.begin(); it != end; ++it)
|
for (it = object.surfaces.begin(); it != end; ++it) {
|
||||||
{
|
if (mat == (*it).mat) {
|
||||||
if (mat == (*it).mat)
|
|
||||||
{
|
|
||||||
const Surface &src = *it;
|
const Surface &src = *it;
|
||||||
|
|
||||||
// closed polygon
|
// closed polygon
|
||||||
unsigned int type = (*it).flags & 0xf;
|
unsigned int type = (*it).flags & 0xf;
|
||||||
if (!type)
|
if (!type) {
|
||||||
{
|
|
||||||
aiFace &face = *faces++;
|
aiFace &face = *faces++;
|
||||||
if((face.mNumIndices = (unsigned int)src.entries.size()))
|
if ((face.mNumIndices = (unsigned int)src.entries.size())) {
|
||||||
{
|
|
||||||
face.mIndices = new unsigned int[face.mNumIndices];
|
face.mIndices = new unsigned int[face.mNumIndices];
|
||||||
for (unsigned int i = 0; i < face.mNumIndices;++i,++vertices)
|
for (unsigned int i = 0; i < face.mNumIndices; ++i, ++vertices) {
|
||||||
{
|
|
||||||
const Surface::SurfaceEntry &entry = src.entries[i];
|
const Surface::SurfaceEntry &entry = src.entries[i];
|
||||||
face.mIndices[i] = cur++;
|
face.mIndices[i] = cur++;
|
||||||
|
|
||||||
|
@ -640,27 +553,22 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
}
|
}
|
||||||
*vertices = object.vertices[entry.first] + object.translation;
|
*vertices = object.vertices[entry.first] + object.translation;
|
||||||
|
|
||||||
|
|
||||||
// copy texture coordinates
|
// copy texture coordinates
|
||||||
if (uv)
|
if (uv) {
|
||||||
{
|
|
||||||
uv->x = entry.second.x;
|
uv->x = entry.second.x;
|
||||||
uv->y = entry.second.y;
|
uv->y = entry.second.y;
|
||||||
++uv;
|
++uv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
it2 = (*it).entries.begin();
|
it2 = (*it).entries.begin();
|
||||||
|
|
||||||
// either a closed or an unclosed line
|
// either a closed or an unclosed line
|
||||||
unsigned int tmp = (unsigned int)(*it).entries.size();
|
unsigned int tmp = (unsigned int)(*it).entries.size();
|
||||||
if (0x2 == type) --tmp;
|
if (0x2 == type) --tmp;
|
||||||
for (unsigned int m = 0; m < tmp;++m)
|
for (unsigned int m = 0; m < tmp; ++m) {
|
||||||
{
|
|
||||||
aiFace &face = *faces++;
|
aiFace &face = *faces++;
|
||||||
|
|
||||||
face.mNumIndices = 2;
|
face.mNumIndices = 2;
|
||||||
|
@ -676,26 +584,22 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
*vertices++ = object.vertices[(*it2).first];
|
*vertices++ = object.vertices[(*it2).first];
|
||||||
|
|
||||||
// copy texture coordinates
|
// copy texture coordinates
|
||||||
if (uv)
|
if (uv) {
|
||||||
{
|
|
||||||
uv->x = (*it2).second.x;
|
uv->x = (*it2).second.x;
|
||||||
uv->y = (*it2).second.y;
|
uv->y = (*it2).second.y;
|
||||||
++uv;
|
++uv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (0x1 == type && tmp - 1 == m) {
|
||||||
if (0x1 == type && tmp-1 == m)
|
|
||||||
{
|
|
||||||
// if this is a closed line repeat its beginning now
|
// if this is a closed line repeat its beginning now
|
||||||
it2 = (*it).entries.begin();
|
it2 = (*it).entries.begin();
|
||||||
}
|
} else
|
||||||
else ++it2;
|
++it2;
|
||||||
|
|
||||||
// second point
|
// second point
|
||||||
*vertices++ = object.vertices[(*it2).first];
|
*vertices++ = object.vertices[(*it2).first];
|
||||||
|
|
||||||
if (uv)
|
if (uv) {
|
||||||
{
|
|
||||||
uv->x = (*it2).second.x;
|
uv->x = (*it2).second.x;
|
||||||
uv->y = (*it2).second.y;
|
uv->y = (*it2).second.y;
|
||||||
++uv;
|
++uv;
|
||||||
|
@ -719,10 +623,8 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
std::copy(cpy.begin(), cpy.end(), meshes.begin() + oldm);
|
std::copy(cpy.begin(), cpy.end(), meshes.begin() + oldm);
|
||||||
|
|
||||||
// previous meshes are deleted vy Subdivide().
|
// previous meshes are deleted vy Subdivide().
|
||||||
}
|
} else {
|
||||||
else {
|
ASSIMP_LOG_INFO("AC3D: Letting the subdivision surface untouched due to my configuration: " + object.name);
|
||||||
ASSIMP_LOG_INFO("AC3D: Letting the subdivision surface untouched due to my configuration: "
|
|
||||||
+object.name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -730,47 +632,41 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
|
|
||||||
if (object.name.length())
|
if (object.name.length())
|
||||||
node->mName.Set(object.name);
|
node->mName.Set(object.name);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// generate a name depending on the type of the node
|
// generate a name depending on the type of the node
|
||||||
switch (object.type)
|
switch (object.type) {
|
||||||
{
|
|
||||||
case Object::Group:
|
case Object::Group:
|
||||||
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACGroup_%i",groups++);
|
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACGroup_%i", mGroupsCounter++);
|
||||||
break;
|
break;
|
||||||
case Object::Poly:
|
case Object::Poly:
|
||||||
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACPoly_%i",polys++);
|
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACPoly_%i", mPolysCounter++);
|
||||||
break;
|
break;
|
||||||
case Object::Light:
|
case Object::Light:
|
||||||
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACLight_%i",lights++);
|
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACLight_%i", mLightsCounter++);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// there shouldn't be more than one world, but we don't care
|
// there shouldn't be more than one world, but we don't care
|
||||||
case Object::World:
|
case Object::World:
|
||||||
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACWorld_%i",worlds++);
|
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACWorld_%i", mWorldsCounter++);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// setup the local transformation matrix of the object
|
// setup the local transformation matrix of the object
|
||||||
// compute the transformation offset to the parent node
|
// compute the transformation offset to the parent node
|
||||||
node->mTransformation = aiMatrix4x4(object.rotation);
|
node->mTransformation = aiMatrix4x4(object.rotation);
|
||||||
|
|
||||||
if (object.type == Object::Group || !object.numRefs)
|
if (object.type == Object::Group || !object.numRefs) {
|
||||||
{
|
|
||||||
node->mTransformation.a4 = object.translation.x;
|
node->mTransformation.a4 = object.translation.x;
|
||||||
node->mTransformation.b4 = object.translation.y;
|
node->mTransformation.b4 = object.translation.y;
|
||||||
node->mTransformation.c4 = object.translation.z;
|
node->mTransformation.c4 = object.translation.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add children to the object
|
// add children to the object
|
||||||
if (object.children.size())
|
if (object.children.size()) {
|
||||||
{
|
|
||||||
node->mNumChildren = (unsigned int)object.children.size();
|
node->mNumChildren = (unsigned int)object.children.size();
|
||||||
node->mChildren = new aiNode *[node->mNumChildren];
|
node->mChildren = new aiNode *[node->mNumChildren];
|
||||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
for (unsigned int i = 0; i < node->mNumChildren; ++i) {
|
||||||
{
|
|
||||||
node->mChildren[i] = ConvertObjectSection(object.children[i], meshes, outMaterials, materials, node);
|
node->mChildren[i] = ConvertObjectSection(object.children[i], meshes, outMaterials, materials, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -779,8 +675,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void AC3DImporter::SetupProperties(const Importer* pImp)
|
void AC3DImporter::SetupProperties(const Importer *pImp) {
|
||||||
{
|
|
||||||
configSplitBFCull = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_AC_SEPARATE_BFCULL, 1) ? true : false;
|
configSplitBFCull = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_AC_SEPARATE_BFCULL, 1) ? true : false;
|
||||||
configEvalSubdivision = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_AC_EVAL_SUBDIVISION, 1) ? true : false;
|
configEvalSubdivision = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_AC_EVAL_SUBDIVISION, 1) ? true : false;
|
||||||
}
|
}
|
||||||
|
@ -788,8 +683,7 @@ void AC3DImporter::SetupProperties(const Importer* pImp)
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void AC3DImporter::InternReadFile(const std::string &pFile,
|
void AC3DImporter::InternReadFile(const std::string &pFile,
|
||||||
aiScene* pScene, IOSystem* pIOHandler)
|
aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
{
|
|
||||||
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
|
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
|
@ -803,7 +697,7 @@ void AC3DImporter::InternReadFile( const std::string& pFile,
|
||||||
buffer = &mBuffer2[0];
|
buffer = &mBuffer2[0];
|
||||||
mNumMeshes = 0;
|
mNumMeshes = 0;
|
||||||
|
|
||||||
lights = polys = worlds = groups = 0;
|
mLightsCounter = mPolysCounter = mWorldsCounter = mGroupsCounter = 0;
|
||||||
|
|
||||||
if (::strncmp(buffer, "AC3D", 4)) {
|
if (::strncmp(buffer, "AC3D", 4)) {
|
||||||
throw DeadlyImportError("AC3D: No valid AC3D file, magic sequence not found");
|
throw DeadlyImportError("AC3D: No valid AC3D file, magic sequence not found");
|
||||||
|
@ -824,10 +718,8 @@ void AC3DImporter::InternReadFile( const std::string& pFile,
|
||||||
std::vector<aiLight *> lights;
|
std::vector<aiLight *> lights;
|
||||||
mLights = &lights;
|
mLights = &lights;
|
||||||
|
|
||||||
while (GetNextLine())
|
while (GetNextLine()) {
|
||||||
{
|
if (TokenMatch(buffer, "MATERIAL", 8)) {
|
||||||
if (TokenMatch(buffer,"MATERIAL",8))
|
|
||||||
{
|
|
||||||
materials.push_back(Material());
|
materials.push_back(Material());
|
||||||
Material &mat = materials.back();
|
Material &mat = materials.back();
|
||||||
|
|
||||||
|
@ -835,8 +727,7 @@ void AC3DImporter::InternReadFile( const std::string& pFile,
|
||||||
// Format: (name) rgb %f %f %f amb %f %f %f emis %f %f %f spec %f %f %f shi %d trans %f
|
// Format: (name) rgb %f %f %f amb %f %f %f emis %f %f %f spec %f %f %f shi %d trans %f
|
||||||
|
|
||||||
AI_AC_SKIP_TO_NEXT_TOKEN();
|
AI_AC_SKIP_TO_NEXT_TOKEN();
|
||||||
if ('\"' == *buffer)
|
if ('\"' == *buffer) {
|
||||||
{
|
|
||||||
AI_AC_GET_STRING(mat.name);
|
AI_AC_GET_STRING(mat.name);
|
||||||
AI_AC_SKIP_TO_NEXT_TOKEN();
|
AI_AC_SKIP_TO_NEXT_TOKEN();
|
||||||
}
|
}
|
||||||
|
@ -851,12 +742,10 @@ void AC3DImporter::InternReadFile( const std::string& pFile,
|
||||||
LoadObjectSection(rootObjects);
|
LoadObjectSection(rootObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rootObjects.empty() || !mNumMeshes)
|
if (rootObjects.empty() || !mNumMeshes) {
|
||||||
{
|
|
||||||
throw DeadlyImportError("AC3D: No meshes have been loaded");
|
throw DeadlyImportError("AC3D: No meshes have been loaded");
|
||||||
}
|
}
|
||||||
if (materials.empty())
|
if (materials.empty()) {
|
||||||
{
|
|
||||||
ASSIMP_LOG_WARN("AC3D: No material has been found");
|
ASSIMP_LOG_WARN("AC3D: No material has been found");
|
||||||
materials.push_back(Material());
|
materials.push_back(Material());
|
||||||
}
|
}
|
||||||
|
@ -872,8 +761,7 @@ void AC3DImporter::InternReadFile( const std::string& pFile,
|
||||||
Object *root;
|
Object *root;
|
||||||
if (1 == rootObjects.size())
|
if (1 == rootObjects.size())
|
||||||
root = &rootObjects[0];
|
root = &rootObjects[0];
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
root = new Object();
|
root = new Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,8 +773,7 @@ void AC3DImporter::InternReadFile( const std::string& pFile,
|
||||||
pScene->mRootNode->mName.Set("<AC3DWorld>");
|
pScene->mRootNode->mName.Set("<AC3DWorld>");
|
||||||
|
|
||||||
// copy meshes
|
// copy meshes
|
||||||
if (meshes.empty())
|
if (meshes.empty()) {
|
||||||
{
|
|
||||||
throw DeadlyImportError("An unknown error occurred during converting");
|
throw DeadlyImportError("An unknown error occurred during converting");
|
||||||
}
|
}
|
||||||
pScene->mNumMeshes = (unsigned int)meshes.size();
|
pScene->mNumMeshes = (unsigned int)meshes.size();
|
||||||
|
@ -900,8 +787,7 @@ void AC3DImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// copy lights
|
// copy lights
|
||||||
pScene->mNumLights = (unsigned int)lights.size();
|
pScene->mNumLights = (unsigned int)lights.size();
|
||||||
if (lights.size())
|
if (lights.size()) {
|
||||||
{
|
|
||||||
pScene->mLights = new aiLight *[lights.size()];
|
pScene->mLights = new aiLight *[lights.size()];
|
||||||
::memcpy(pScene->mLights, &lights[0], lights.size() * sizeof(void *));
|
::memcpy(pScene->mLights, &lights[0], lights.size() * sizeof(void *));
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,7 +268,7 @@ private:
|
||||||
std::vector<aiLight*>* mLights;
|
std::vector<aiLight*>* mLights;
|
||||||
|
|
||||||
// name counters
|
// name counters
|
||||||
unsigned int lights, groups, polys, worlds;
|
unsigned int mLightsCounter, mGroupsCounter, mPolysCounter, mWorldsCounter;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
|
@ -465,7 +465,7 @@ std::list<unsigned int> mesh_idx;
|
||||||
{
|
{
|
||||||
auto VertexIndex_GetMinimal = [](const std::list<SComplexFace>& pFaceList, const size_t* pBiggerThan) -> size_t
|
auto VertexIndex_GetMinimal = [](const std::list<SComplexFace>& pFaceList, const size_t* pBiggerThan) -> size_t
|
||||||
{
|
{
|
||||||
size_t rv;
|
size_t rv=0;
|
||||||
|
|
||||||
if(pBiggerThan != nullptr)
|
if(pBiggerThan != nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,11 +118,11 @@ void HMPImporter::InternReadFile( const std::string& pFile,
|
||||||
aiScene* _pScene, IOSystem* _pIOHandler)
|
aiScene* _pScene, IOSystem* _pIOHandler)
|
||||||
{
|
{
|
||||||
pScene = _pScene;
|
pScene = _pScene;
|
||||||
pIOHandler = _pIOHandler;
|
mIOHandler = _pIOHandler;
|
||||||
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
|
std::unique_ptr<IOStream> file(mIOHandler->Open(pFile));
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
if( file.get() == NULL)
|
if( file.get() == nullptr)
|
||||||
throw DeadlyImportError( "Failed to open HMP file " + pFile + ".");
|
throw DeadlyImportError( "Failed to open HMP file " + pFile + ".");
|
||||||
|
|
||||||
// Check whether the HMP file is large enough to contain
|
// Check whether the HMP file is large enough to contain
|
||||||
|
|
|
@ -185,10 +185,12 @@ void AnimResolver::UpdateAnimRangeSetup()
|
||||||
for (unsigned int i = 0; i < num; ++i) {
|
for (unsigned int i = 0; i < num; ++i) {
|
||||||
m = n+old_size*(i+1);
|
m = n+old_size*(i+1);
|
||||||
std::copy(n,n+old_size,m);
|
std::copy(n,n+old_size,m);
|
||||||
|
const bool res = ((*it).pre == LWO::PrePostBehaviour_Oscillate);
|
||||||
if ((*it).pre == LWO::PrePostBehaviour_Oscillate && (reverse = !reverse))
|
reverse = !reverse;
|
||||||
|
if (res && reverse ) {
|
||||||
std::reverse(m,m+old_size-1);
|
std::reverse(m,m+old_size-1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// update time values
|
// update time values
|
||||||
n = (*it).keys.end() - (old_size+1);
|
n = (*it).keys.end() - (old_size+1);
|
||||||
|
@ -533,7 +535,7 @@ void AnimResolver::GetKeys(std::vector<aiVectorKey>& out,
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Extract animation channel
|
// Extract animation channel
|
||||||
void AnimResolver::ExtractAnimChannel(aiNodeAnim** out, unsigned int flags /*= 0*/)
|
void AnimResolver::ExtractAnimChannel(aiNodeAnim** out, unsigned int /*= 0*/)
|
||||||
{
|
{
|
||||||
*out = NULL;
|
*out = NULL;
|
||||||
|
|
||||||
|
|
|
@ -49,17 +49,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef ASSIMP_BUILD_NO_MDL_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_MDL_IMPORTER
|
||||||
|
|
||||||
#include "MDL/MDLLoader.h"
|
#include "MDL/MDLLoader.h"
|
||||||
#include "MDL/MDLDefaultColorMap.h"
|
|
||||||
#include "MD2/MD2FileData.h"
|
#include "MD2/MD2FileData.h"
|
||||||
#include "MDL/HalfLife/HL1MDLLoader.h"
|
#include "MDL/HalfLife/HL1MDLLoader.h"
|
||||||
|
#include "MDL/MDLDefaultColorMap.h"
|
||||||
|
|
||||||
#include <assimp/qnan.h>
|
|
||||||
#include <assimp/StringUtils.h>
|
#include <assimp/StringUtils.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/importerdesc.h>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/qnan.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/importerdesc.h>
|
#include <assimp/IOSystem.hpp>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -91,13 +91,8 @@ static const aiImporterDesc desc = {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
MDLImporter::MDLImporter()
|
MDLImporter::MDLImporter() :
|
||||||
: configFrameID()
|
configFrameID(), mBuffer(), iGSFileVersion(), mIOHandler(nullptr), pScene(), iFileSize() {
|
||||||
, mBuffer()
|
|
||||||
, iGSFileVersion()
|
|
||||||
, pIOHandler()
|
|
||||||
, pScene()
|
|
||||||
, iFileSize() {
|
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,8 +125,7 @@ bool MDLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Setup configuration properties
|
// Setup configuration properties
|
||||||
void MDLImporter::SetupProperties(const Importer* pImp)
|
void MDLImporter::SetupProperties(const Importer *pImp) {
|
||||||
{
|
|
||||||
configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MDL_KEYFRAME, -1);
|
configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_MDL_KEYFRAME, -1);
|
||||||
|
|
||||||
// The
|
// The
|
||||||
|
@ -159,22 +153,20 @@ void MDLImporter::SetupProperties(const Importer* pImp)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Get a list of all supported extensions
|
// Get a list of all supported extensions
|
||||||
const aiImporterDesc* MDLImporter::GetInfo () const
|
const aiImporterDesc *MDLImporter::GetInfo() const {
|
||||||
{
|
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void MDLImporter::InternReadFile(const std::string &pFile,
|
void MDLImporter::InternReadFile(const std::string &pFile,
|
||||||
aiScene* _pScene, IOSystem* _pIOHandler)
|
aiScene *_pScene, IOSystem *pIOHandler) {
|
||||||
{
|
|
||||||
pScene = _pScene;
|
pScene = _pScene;
|
||||||
pIOHandler = _pIOHandler;
|
mIOHandler = pIOHandler;
|
||||||
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile));
|
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile));
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
if( file.get() == NULL) {
|
if (file.get() == nullptr) {
|
||||||
throw DeadlyImportError("Failed to open MDL file " + pFile + ".");
|
throw DeadlyImportError("Failed to open MDL file " + pFile + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +183,7 @@ void MDLImporter::InternReadFile( const std::string& pFile,
|
||||||
delete[] mBuffer;
|
delete[] mBuffer;
|
||||||
mBuffer = nullptr;
|
mBuffer = nullptr;
|
||||||
}
|
}
|
||||||
AI_DEBUG_INVALIDATE_PTR(pIOHandler);
|
AI_DEBUG_INVALIDATE_PTR(mIOHandler);
|
||||||
AI_DEBUG_INVALIDATE_PTR(pScene);
|
AI_DEBUG_INVALIDATE_PTR(pScene);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -246,23 +238,18 @@ void MDLImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
// IDST/IDSQ Format (CS:S/HL^2, etc ...)
|
// IDST/IDSQ Format (CS:S/HL^2, etc ...)
|
||||||
else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord ||
|
else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord ||
|
||||||
AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord)
|
AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord) {
|
||||||
{
|
|
||||||
iGSFileVersion = 0;
|
iGSFileVersion = 0;
|
||||||
|
|
||||||
HalfLife::HalfLifeMDLBaseHeader *pHeader = (HalfLife::HalfLifeMDLBaseHeader *)mBuffer;
|
HalfLife::HalfLifeMDLBaseHeader *pHeader = (HalfLife::HalfLifeMDLBaseHeader *)mBuffer;
|
||||||
if (pHeader->version == AI_MDL_HL1_VERSION)
|
if (pHeader->version == AI_MDL_HL1_VERSION) {
|
||||||
{
|
|
||||||
ASSIMP_LOG_DEBUG("MDL subtype: Half-Life 1/Goldsrc Engine, magic word is IDST/IDSQ");
|
ASSIMP_LOG_DEBUG("MDL subtype: Half-Life 1/Goldsrc Engine, magic word is IDST/IDSQ");
|
||||||
InternReadFile_HL1(pFile, iMagicWord);
|
InternReadFile_HL1(pFile, iMagicWord);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ASSIMP_LOG_DEBUG("MDL subtype: Source(tm) Engine, magic word is IDST/IDSQ");
|
ASSIMP_LOG_DEBUG("MDL subtype: Source(tm) Engine, magic word is IDST/IDSQ");
|
||||||
InternReadFile_HL2();
|
InternReadFile_HL2();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// print the magic word to the log file
|
// print the magic word to the log file
|
||||||
throw DeadlyImportError("Unknown MDL subformat " + pFile +
|
throw DeadlyImportError("Unknown MDL subformat " + pFile +
|
||||||
". Magic word (" + std::string((char *)&iMagicWord, 4) + ") is not known");
|
". Magic word (" + std::string((char *)&iMagicWord, 4) + ") is not known");
|
||||||
|
@ -281,10 +268,8 @@ void MDLImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Check whether we're still inside the valid file range
|
// Check whether we're still inside the valid file range
|
||||||
void MDLImporter::SizeCheck(const void* szPos)
|
void MDLImporter::SizeCheck(const void *szPos) {
|
||||||
{
|
if (!szPos || (const unsigned char *)szPos > this->mBuffer + this->iFileSize) {
|
||||||
if (!szPos || (const unsigned char*)szPos > this->mBuffer + this->iFileSize)
|
|
||||||
{
|
|
||||||
throw DeadlyImportError("Invalid MDL file. The file is too small "
|
throw DeadlyImportError("Invalid MDL file. The file is too small "
|
||||||
"or contains invalid data.");
|
"or contains invalid data.");
|
||||||
}
|
}
|
||||||
|
@ -292,22 +277,25 @@ void MDLImporter::SizeCheck(const void* szPos)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Just for debugging purposes
|
// Just for debugging purposes
|
||||||
void MDLImporter::SizeCheck(const void* szPos, const char* szFile, unsigned int iLine)
|
void MDLImporter::SizeCheck(const void *szPos, const char *szFile, unsigned int iLine) {
|
||||||
{
|
|
||||||
ai_assert(NULL != szFile);
|
ai_assert(NULL != szFile);
|
||||||
if (!szPos || (const unsigned char*)szPos > mBuffer + iFileSize)
|
if (!szPos || (const unsigned char *)szPos > mBuffer + iFileSize) {
|
||||||
{
|
|
||||||
// remove a directory if there is one
|
// remove a directory if there is one
|
||||||
const char *szFilePtr = ::strrchr(szFile, '\\');
|
const char *szFilePtr = ::strrchr(szFile, '\\');
|
||||||
if (!szFilePtr) {
|
if (!szFilePtr) {
|
||||||
if(!(szFilePtr = ::strrchr(szFile,'/')))
|
szFilePtr = ::strrchr(szFile, '/');
|
||||||
|
if (nullptr == szFilePtr) {
|
||||||
szFilePtr = szFile;
|
szFilePtr = szFile;
|
||||||
}
|
}
|
||||||
if (szFilePtr)++szFilePtr;
|
}
|
||||||
|
if (szFilePtr) {
|
||||||
|
++szFilePtr;
|
||||||
|
}
|
||||||
|
|
||||||
char szBuffer[1024];
|
char szBuffer[1024];
|
||||||
::sprintf(szBuffer, "Invalid MDL file. The file is too small "
|
::sprintf(szBuffer, "Invalid MDL file. The file is too small "
|
||||||
"or contains invalid data (File: %s Line: %u)",szFilePtr,iLine);
|
"or contains invalid data (File: %s Line: %u)",
|
||||||
|
szFilePtr, iLine);
|
||||||
|
|
||||||
throw DeadlyImportError(szBuffer);
|
throw DeadlyImportError(szBuffer);
|
||||||
}
|
}
|
||||||
|
@ -315,8 +303,7 @@ void MDLImporter::SizeCheck(const void* szPos, const char* szFile, unsigned int
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Validate a quake file header
|
// Validate a quake file header
|
||||||
void MDLImporter::ValidateHeader_Quake1(const MDL::Header* pcHeader)
|
void MDLImporter::ValidateHeader_Quake1(const MDL::Header *pcHeader) {
|
||||||
{
|
|
||||||
// some values may not be NULL
|
// some values may not be NULL
|
||||||
if (!pcHeader->num_frames)
|
if (!pcHeader->num_frames)
|
||||||
throw DeadlyImportError("[Quake 1 MDL] There are no frames in the file");
|
throw DeadlyImportError("[Quake 1 MDL] There are no frames in the file");
|
||||||
|
@ -328,8 +315,7 @@ void MDLImporter::ValidateHeader_Quake1(const MDL::Header* pcHeader)
|
||||||
throw DeadlyImportError("[Quake 1 MDL] There are no triangles in the file");
|
throw DeadlyImportError("[Quake 1 MDL] There are no triangles in the file");
|
||||||
|
|
||||||
// check whether the maxima are exceeded ...however, this applies for Quake 1 MDLs only
|
// check whether the maxima are exceeded ...however, this applies for Quake 1 MDLs only
|
||||||
if (!this->iGSFileVersion)
|
if (!this->iGSFileVersion) {
|
||||||
{
|
|
||||||
if (pcHeader->num_verts > AI_MDL_MAX_VERTS)
|
if (pcHeader->num_verts > AI_MDL_MAX_VERTS)
|
||||||
ASSIMP_LOG_WARN("Quake 1 MDL model has more than AI_MDL_MAX_VERTS vertices");
|
ASSIMP_LOG_WARN("Quake 1 MDL model has more than AI_MDL_MAX_VERTS vertices");
|
||||||
|
|
||||||
|
@ -350,8 +336,7 @@ void MDLImporter::ValidateHeader_Quake1(const MDL::Header* pcHeader)
|
||||||
|
|
||||||
#ifdef AI_BUILD_BIG_ENDIAN
|
#ifdef AI_BUILD_BIG_ENDIAN
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void FlipQuakeHeader(BE_NCONST MDL::Header* pcHeader)
|
void FlipQuakeHeader(BE_NCONST MDL::Header *pcHeader) {
|
||||||
{
|
|
||||||
AI_SWAP4(pcHeader->ident);
|
AI_SWAP4(pcHeader->ident);
|
||||||
AI_SWAP4(pcHeader->version);
|
AI_SWAP4(pcHeader->version);
|
||||||
AI_SWAP4(pcHeader->boundingradius);
|
AI_SWAP4(pcHeader->boundingradius);
|
||||||
|
@ -360,8 +345,7 @@ void FlipQuakeHeader(BE_NCONST MDL::Header* pcHeader)
|
||||||
AI_SWAP4(pcHeader->num_skins);
|
AI_SWAP4(pcHeader->num_skins);
|
||||||
AI_SWAP4(pcHeader->num_tris);
|
AI_SWAP4(pcHeader->num_tris);
|
||||||
AI_SWAP4(pcHeader->num_verts);
|
AI_SWAP4(pcHeader->num_verts);
|
||||||
for (unsigned int i = 0; i < 3;++i)
|
for (unsigned int i = 0; i < 3; ++i) {
|
||||||
{
|
|
||||||
AI_SWAP4(pcHeader->scale[i]);
|
AI_SWAP4(pcHeader->scale[i]);
|
||||||
AI_SWAP4(pcHeader->translate[i]);
|
AI_SWAP4(pcHeader->translate[i]);
|
||||||
}
|
}
|
||||||
|
@ -450,15 +434,13 @@ void MDLImporter::InternReadFile_Quake1() {
|
||||||
VALIDATE_FILE_SIZE((const unsigned char *)(pcVertices + pcHeader->num_verts));
|
VALIDATE_FILE_SIZE((const unsigned char *)(pcVertices + pcHeader->num_verts));
|
||||||
|
|
||||||
#ifdef AI_BUILD_BIG_ENDIAN
|
#ifdef AI_BUILD_BIG_ENDIAN
|
||||||
for (int i = 0; i<pcHeader->num_verts;++i)
|
for (int i = 0; i < pcHeader->num_verts; ++i) {
|
||||||
{
|
|
||||||
AI_SWAP4(pcTexCoords[i].onseam);
|
AI_SWAP4(pcTexCoords[i].onseam);
|
||||||
AI_SWAP4(pcTexCoords[i].s);
|
AI_SWAP4(pcTexCoords[i].s);
|
||||||
AI_SWAP4(pcTexCoords[i].t);
|
AI_SWAP4(pcTexCoords[i].t);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i<pcHeader->num_tris;++i)
|
for (int i = 0; i < pcHeader->num_tris; ++i) {
|
||||||
{
|
|
||||||
AI_SWAP4(pcTriangles[i].facesfront);
|
AI_SWAP4(pcTriangles[i].facesfront);
|
||||||
AI_SWAP4(pcTriangles[i].vertex[0]);
|
AI_SWAP4(pcTriangles[i].vertex[0]);
|
||||||
AI_SWAP4(pcTriangles[i].vertex[1]);
|
AI_SWAP4(pcTriangles[i].vertex[1]);
|
||||||
|
@ -492,20 +474,17 @@ void MDLImporter::InternReadFile_Quake1() {
|
||||||
|
|
||||||
// now iterate through all triangles
|
// now iterate through all triangles
|
||||||
unsigned int iCurrent = 0;
|
unsigned int iCurrent = 0;
|
||||||
for (unsigned int i = 0; i < (unsigned int) pcHeader->num_tris;++i)
|
for (unsigned int i = 0; i < (unsigned int)pcHeader->num_tris; ++i) {
|
||||||
{
|
|
||||||
pcMesh->mFaces[i].mIndices = new unsigned int[3];
|
pcMesh->mFaces[i].mIndices = new unsigned int[3];
|
||||||
pcMesh->mFaces[i].mNumIndices = 3;
|
pcMesh->mFaces[i].mNumIndices = 3;
|
||||||
|
|
||||||
unsigned int iTemp = iCurrent;
|
unsigned int iTemp = iCurrent;
|
||||||
for (unsigned int c = 0; c < 3;++c,++iCurrent)
|
for (unsigned int c = 0; c < 3; ++c, ++iCurrent) {
|
||||||
{
|
|
||||||
pcMesh->mFaces[i].mIndices[c] = iCurrent;
|
pcMesh->mFaces[i].mIndices[c] = iCurrent;
|
||||||
|
|
||||||
// read vertices
|
// read vertices
|
||||||
unsigned int iIndex = pcTriangles->vertex[c];
|
unsigned int iIndex = pcTriangles->vertex[c];
|
||||||
if (iIndex >= (unsigned int)pcHeader->num_verts)
|
if (iIndex >= (unsigned int)pcHeader->num_verts) {
|
||||||
{
|
|
||||||
iIndex = pcHeader->num_verts - 1;
|
iIndex = pcHeader->num_verts - 1;
|
||||||
ASSIMP_LOG_WARN("Index overflow in Q1-MDL vertex list.");
|
ASSIMP_LOG_WARN("Index overflow in Q1-MDL vertex list.");
|
||||||
}
|
}
|
||||||
|
@ -537,7 +516,6 @@ void MDLImporter::InternReadFile_Quake1() {
|
||||||
// Scale s and t to range from 0.0 to 1.0
|
// Scale s and t to range from 0.0 to 1.0
|
||||||
pcMesh->mTextureCoords[0][iCurrent].x = (s + 0.5f) / pcHeader->skinwidth;
|
pcMesh->mTextureCoords[0][iCurrent].x = (s + 0.5f) / pcHeader->skinwidth;
|
||||||
pcMesh->mTextureCoords[0][iCurrent].y = 1.0f - (t + 0.5f) / pcHeader->skinheight;
|
pcMesh->mTextureCoords[0][iCurrent].y = 1.0f - (t + 0.5f) / pcHeader->skinheight;
|
||||||
|
|
||||||
}
|
}
|
||||||
pcMesh->mFaces[i].mIndices[0] = iTemp + 2;
|
pcMesh->mFaces[i].mIndices[0] = iTemp + 2;
|
||||||
pcMesh->mFaces[i].mIndices[1] = iTemp + 1;
|
pcMesh->mFaces[i].mIndices[1] = iTemp + 1;
|
||||||
|
@ -549,8 +527,7 @@ void MDLImporter::InternReadFile_Quake1() {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Setup material properties for Quake and older GameStudio files
|
// Setup material properties for Quake and older GameStudio files
|
||||||
void MDLImporter::SetupMaterialProperties_3DGS_MDL5_Quake1( )
|
void MDLImporter::SetupMaterialProperties_3DGS_MDL5_Quake1() {
|
||||||
{
|
|
||||||
const MDL::Header *const pcHeader = (const MDL::Header *)this->mBuffer;
|
const MDL::Header *const pcHeader = (const MDL::Header *)this->mBuffer;
|
||||||
|
|
||||||
// allocate ONE material
|
// allocate ONE material
|
||||||
|
@ -573,8 +550,7 @@ void MDLImporter::SetupMaterialProperties_3DGS_MDL5_Quake1( )
|
||||||
|
|
||||||
pScene->mTextures = NULL;
|
pScene->mTextures = NULL;
|
||||||
pScene->mNumTextures = 0;
|
pScene->mNumTextures = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
clr.b = clr.a = clr.g = clr.r = 1.0f;
|
clr.b = clr.a = clr.g = clr.r = 1.0f;
|
||||||
aiString szString;
|
aiString szString;
|
||||||
::memcpy(szString.data, AI_MAKE_EMBEDDED_TEXNAME(0), 3);
|
::memcpy(szString.data, AI_MAKE_EMBEDDED_TEXNAME(0), 3);
|
||||||
|
@ -586,15 +562,16 @@ void MDLImporter::SetupMaterialProperties_3DGS_MDL5_Quake1( )
|
||||||
pcHelper->AddProperty<aiColor4D>(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
|
pcHelper->AddProperty<aiColor4D>(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||||
pcHelper->AddProperty<aiColor4D>(&clr, 1, AI_MATKEY_COLOR_SPECULAR);
|
pcHelper->AddProperty<aiColor4D>(&clr, 1, AI_MATKEY_COLOR_SPECULAR);
|
||||||
|
|
||||||
clr.r *= 0.05f;clr.g *= 0.05f;
|
clr.r *= 0.05f;
|
||||||
clr.b *= 0.05f;clr.a = 1.0f;
|
clr.g *= 0.05f;
|
||||||
|
clr.b *= 0.05f;
|
||||||
|
clr.a = 1.0f;
|
||||||
pcHelper->AddProperty<aiColor4D>(&clr, 1, AI_MATKEY_COLOR_AMBIENT);
|
pcHelper->AddProperty<aiColor4D>(&clr, 1, AI_MATKEY_COLOR_AMBIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Read a MDL 3,4,5 file
|
// Read a MDL 3,4,5 file
|
||||||
void MDLImporter::InternReadFile_3DGS_MDL345( )
|
void MDLImporter::InternReadFile_3DGS_MDL345() {
|
||||||
{
|
|
||||||
ai_assert(NULL != pScene);
|
ai_assert(NULL != pScene);
|
||||||
|
|
||||||
// the header of MDL 3/4/5 is nearly identical to the original Quake1 header
|
// the header of MDL 3/4/5 is nearly identical to the original Quake1 header
|
||||||
|
@ -618,19 +595,16 @@ void MDLImporter::InternReadFile_3DGS_MDL345( )
|
||||||
AI_SWAP4(pcSkin->group);
|
AI_SWAP4(pcSkin->group);
|
||||||
// create one output image
|
// create one output image
|
||||||
unsigned int iSkip = i ? UINT_MAX : 0;
|
unsigned int iSkip = i ? UINT_MAX : 0;
|
||||||
if (5 <= iGSFileVersion)
|
if (5 <= iGSFileVersion) {
|
||||||
{
|
|
||||||
// MDL5 format could contain MIPmaps
|
// MDL5 format could contain MIPmaps
|
||||||
CreateTexture_3DGS_MDL5((unsigned char *)pcSkin + sizeof(uint32_t),
|
CreateTexture_3DGS_MDL5((unsigned char *)pcSkin + sizeof(uint32_t),
|
||||||
pcSkin->group, &iSkip);
|
pcSkin->group, &iSkip);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
CreateTexture_3DGS_MDL4((unsigned char *)pcSkin + sizeof(uint32_t),
|
CreateTexture_3DGS_MDL4((unsigned char *)pcSkin + sizeof(uint32_t),
|
||||||
pcSkin->group, &iSkip);
|
pcSkin->group, &iSkip);
|
||||||
}
|
}
|
||||||
// need to skip one image
|
// need to skip one image
|
||||||
szCurrent += iSkip + sizeof(uint32_t);
|
szCurrent += iSkip + sizeof(uint32_t);
|
||||||
|
|
||||||
}
|
}
|
||||||
// get a pointer to the texture coordinates
|
// get a pointer to the texture coordinates
|
||||||
BE_NCONST MDL::TexCoord_MDL3 *pcTexCoords = (BE_NCONST MDL::TexCoord_MDL3 *)szCurrent;
|
BE_NCONST MDL::TexCoord_MDL3 *pcTexCoords = (BE_NCONST MDL::TexCoord_MDL3 *)szCurrent;
|
||||||
|
@ -816,8 +790,7 @@ void MDLImporter::InternReadFile_3DGS_MDL345( )
|
||||||
void MDLImporter::ImportUVCoordinate_3DGS_MDL345(
|
void MDLImporter::ImportUVCoordinate_3DGS_MDL345(
|
||||||
aiVector3D &vOut,
|
aiVector3D &vOut,
|
||||||
const MDL::TexCoord_MDL3 *pcSrc,
|
const MDL::TexCoord_MDL3 *pcSrc,
|
||||||
unsigned int iIndex)
|
unsigned int iIndex) {
|
||||||
{
|
|
||||||
ai_assert(NULL != pcSrc);
|
ai_assert(NULL != pcSrc);
|
||||||
const MDL::Header *const pcHeader = (const MDL::Header *)this->mBuffer;
|
const MDL::Header *const pcHeader = (const MDL::Header *)this->mBuffer;
|
||||||
|
|
||||||
|
@ -843,8 +816,7 @@ void MDLImporter::ImportUVCoordinate_3DGS_MDL345(
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Compute UV coordinates for a MDL5 file
|
// Compute UV coordinates for a MDL5 file
|
||||||
void MDLImporter::CalculateUVCoordinates_MDL5()
|
void MDLImporter::CalculateUVCoordinates_MDL5() {
|
||||||
{
|
|
||||||
const MDL::Header *const pcHeader = (const MDL::Header *)this->mBuffer;
|
const MDL::Header *const pcHeader = (const MDL::Header *)this->mBuffer;
|
||||||
if (pcHeader->num_skins && this->pScene->mNumTextures) {
|
if (pcHeader->num_skins && this->pScene->mNumTextures) {
|
||||||
const aiTexture *pcTex = this->pScene->mTextures[0];
|
const aiTexture *pcTex = this->pScene->mTextures[0];
|
||||||
|
@ -859,8 +831,7 @@ void MDLImporter::CalculateUVCoordinates_MDL5()
|
||||||
piPtr += 3;
|
piPtr += 3;
|
||||||
iHeight = (unsigned int)*piPtr++;
|
iHeight = (unsigned int)*piPtr++;
|
||||||
iWidth = (unsigned int)*piPtr;
|
iWidth = (unsigned int)*piPtr;
|
||||||
if (!iHeight || !iWidth)
|
if (!iHeight || !iWidth) {
|
||||||
{
|
|
||||||
ASSIMP_LOG_WARN("Either the width or the height of the "
|
ASSIMP_LOG_WARN("Either the width or the height of the "
|
||||||
"embedded DDS texture is zero. Unable to compute final texture "
|
"embedded DDS texture is zero. Unable to compute final texture "
|
||||||
"coordinates. The texture coordinates remain in their original "
|
"coordinates. The texture coordinates remain in their original "
|
||||||
|
@ -868,8 +839,7 @@ void MDLImporter::CalculateUVCoordinates_MDL5()
|
||||||
iWidth = 1;
|
iWidth = 1;
|
||||||
iHeight = 1;
|
iHeight = 1;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
iWidth = pcTex->mWidth;
|
iWidth = pcTex->mWidth;
|
||||||
iHeight = pcTex->mHeight;
|
iHeight = pcTex->mHeight;
|
||||||
}
|
}
|
||||||
|
@ -878,8 +848,7 @@ void MDLImporter::CalculateUVCoordinates_MDL5()
|
||||||
const float fWidth = (float)iWidth;
|
const float fWidth = (float)iWidth;
|
||||||
const float fHeight = (float)iHeight;
|
const float fHeight = (float)iHeight;
|
||||||
aiMesh *pcMesh = this->pScene->mMeshes[0];
|
aiMesh *pcMesh = this->pScene->mMeshes[0];
|
||||||
for (unsigned int i = 0; i < pcMesh->mNumVertices;++i)
|
for (unsigned int i = 0; i < pcMesh->mNumVertices; ++i) {
|
||||||
{
|
|
||||||
pcMesh->mTextureCoords[0][i].x /= fWidth;
|
pcMesh->mTextureCoords[0][i].x /= fWidth;
|
||||||
pcMesh->mTextureCoords[0][i].y /= fHeight;
|
pcMesh->mTextureCoords[0][i].y /= fHeight;
|
||||||
pcMesh->mTextureCoords[0][i].y = 1.0f - pcMesh->mTextureCoords[0][i].y; // DX to OGL
|
pcMesh->mTextureCoords[0][i].y = 1.0f - pcMesh->mTextureCoords[0][i].y; // DX to OGL
|
||||||
|
@ -890,8 +859,7 @@ void MDLImporter::CalculateUVCoordinates_MDL5()
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Validate the header of a MDL7 file
|
// Validate the header of a MDL7 file
|
||||||
void MDLImporter::ValidateHeader_3DGS_MDL7(const MDL::Header_MDL7* pcHeader)
|
void MDLImporter::ValidateHeader_3DGS_MDL7(const MDL::Header_MDL7 *pcHeader) {
|
||||||
{
|
|
||||||
ai_assert(NULL != pcHeader);
|
ai_assert(NULL != pcHeader);
|
||||||
|
|
||||||
// There are some fixed sizes ...
|
// There are some fixed sizes ...
|
||||||
|
@ -916,8 +884,7 @@ void MDLImporter::ValidateHeader_3DGS_MDL7(const MDL::Header_MDL7* pcHeader)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// resolve bone animation matrices
|
// resolve bone animation matrices
|
||||||
void MDLImporter::CalcAbsBoneMatrices_3DGS_MDL7(MDL::IntBone_MDL7** apcOutBones)
|
void MDLImporter::CalcAbsBoneMatrices_3DGS_MDL7(MDL::IntBone_MDL7 **apcOutBones) {
|
||||||
{
|
|
||||||
const MDL::Header_MDL7 *pcHeader = (const MDL::Header_MDL7 *)this->mBuffer;
|
const MDL::Header_MDL7 *pcHeader = (const MDL::Header_MDL7 *)this->mBuffer;
|
||||||
const MDL::Bone_MDL7 *pcBones = (const MDL::Bone_MDL7 *)(pcHeader + 1);
|
const MDL::Bone_MDL7 *pcBones = (const MDL::Bone_MDL7 *)(pcHeader + 1);
|
||||||
ai_assert(NULL != apcOutBones);
|
ai_assert(NULL != apcOutBones);
|
||||||
|
@ -979,8 +946,7 @@ void MDLImporter::CalcAbsBoneMatrices_3DGS_MDL7(MDL::IntBone_MDL7** apcOutBones)
|
||||||
// no real name for our poor bone is specified :-(
|
// no real name for our poor bone is specified :-(
|
||||||
pcOutBone->mName.length = ai_snprintf(pcOutBone->mName.data, MAXLEN,
|
pcOutBone->mName.length = ai_snprintf(pcOutBone->mName.data, MAXLEN,
|
||||||
"UnnamedBone_%i", iBone);
|
"UnnamedBone_%i", iBone);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Make sure we won't run over the buffer's end if there is no
|
// Make sure we won't run over the buffer's end if there is no
|
||||||
// terminal 0 character (however the documentation says there
|
// terminal 0 character (however the documentation says there
|
||||||
// should be one)
|
// should be one)
|
||||||
|
@ -1005,15 +971,13 @@ void MDLImporter::CalcAbsBoneMatrices_3DGS_MDL7(MDL::IntBone_MDL7** apcOutBones)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// read bones from a MDL7 file
|
// read bones from a MDL7 file
|
||||||
MDL::IntBone_MDL7** MDLImporter::LoadBones_3DGS_MDL7()
|
MDL::IntBone_MDL7 **MDLImporter::LoadBones_3DGS_MDL7() {
|
||||||
{
|
|
||||||
const MDL::Header_MDL7 *pcHeader = (const MDL::Header_MDL7 *)this->mBuffer;
|
const MDL::Header_MDL7 *pcHeader = (const MDL::Header_MDL7 *)this->mBuffer;
|
||||||
if (pcHeader->bones_num) {
|
if (pcHeader->bones_num) {
|
||||||
// validate the size of the bone data structure in the file
|
// validate the size of the bone data structure in the file
|
||||||
if (AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS != pcHeader->bone_stc_size &&
|
if (AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS != pcHeader->bone_stc_size &&
|
||||||
AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS != pcHeader->bone_stc_size &&
|
AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS != pcHeader->bone_stc_size &&
|
||||||
AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE != pcHeader->bone_stc_size)
|
AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE != pcHeader->bone_stc_size) {
|
||||||
{
|
|
||||||
ASSIMP_LOG_WARN("Unknown size of bone data structure");
|
ASSIMP_LOG_WARN("Unknown size of bone data structure");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1032,8 +996,7 @@ MDL::IntBone_MDL7** MDLImporter::LoadBones_3DGS_MDL7()
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// read faces from a MDL7 file
|
// read faces from a MDL7 file
|
||||||
void MDLImporter::ReadFaces_3DGS_MDL7(const MDL::IntGroupInfo_MDL7 &groupInfo,
|
void MDLImporter::ReadFaces_3DGS_MDL7(const MDL::IntGroupInfo_MDL7 &groupInfo,
|
||||||
MDL::IntGroupData_MDL7& groupData)
|
MDL::IntGroupData_MDL7 &groupData) {
|
||||||
{
|
|
||||||
const MDL::Header_MDL7 *pcHeader = (const MDL::Header_MDL7 *)this->mBuffer;
|
const MDL::Header_MDL7 *pcHeader = (const MDL::Header_MDL7 *)this->mBuffer;
|
||||||
MDL::Triangle_MDL7 *pcGroupTris = groupInfo.pcGroupTris;
|
MDL::Triangle_MDL7 *pcGroupTris = groupInfo.pcGroupTris;
|
||||||
|
|
||||||
|
@ -1051,7 +1014,7 @@ void MDLImporter::ReadFaces_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInfo,
|
||||||
unsigned int iIndex = pcGroupTris->v_index[c];
|
unsigned int iIndex = pcGroupTris->v_index[c];
|
||||||
if (iIndex > (unsigned int)groupInfo.pcGroup->numverts) {
|
if (iIndex > (unsigned int)groupInfo.pcGroup->numverts) {
|
||||||
// (we might need to read this section a second time - to process frame vertices correctly)
|
// (we might need to read this section a second time - to process frame vertices correctly)
|
||||||
pcGroupTris->v_index[c] = iIndex = groupInfo.pcGroup->numverts-1;
|
pcGroupTris->v_index[c] = (uint16_t) (iIndex = groupInfo.pcGroup->numverts - 1 );
|
||||||
ASSIMP_LOG_WARN("Index overflow in MDL7 vertex list");
|
ASSIMP_LOG_WARN("Index overflow in MDL7 vertex list");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,7 +1029,8 @@ void MDLImporter::ReadFaces_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInfo,
|
||||||
// if we have bones, save the index
|
// if we have bones, save the index
|
||||||
if (!groupData.aiBones.empty()) {
|
if (!groupData.aiBones.empty()) {
|
||||||
groupData.aiBones[iOutIndex] = _AI_MDL7_ACCESS_VERT(groupInfo.pcGroupVerts,
|
groupData.aiBones[iOutIndex] = _AI_MDL7_ACCESS_VERT(groupInfo.pcGroupVerts,
|
||||||
iIndex,pcHeader->mainvertex_stc_size).vertindex;
|
iIndex, pcHeader->mainvertex_stc_size)
|
||||||
|
.vertindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now read the normal vector
|
// now read the normal vector
|
||||||
|
@ -1079,12 +1043,13 @@ void MDLImporter::ReadFaces_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInfo,
|
||||||
AI_SWAP4(vNormal.y);
|
AI_SWAP4(vNormal.y);
|
||||||
vNormal.z = _AI_MDL7_ACCESS_VERT(groupInfo.pcGroupVerts, iIndex, pcHeader->mainvertex_stc_size).norm[2];
|
vNormal.z = _AI_MDL7_ACCESS_VERT(groupInfo.pcGroupVerts, iIndex, pcHeader->mainvertex_stc_size).norm[2];
|
||||||
AI_SWAP4(vNormal.z);
|
AI_SWAP4(vNormal.z);
|
||||||
}
|
} else if (AI_MDL7_FRAMEVERTEX120503_STCSIZE <= pcHeader->mainvertex_stc_size) {
|
||||||
else if (AI_MDL7_FRAMEVERTEX120503_STCSIZE <= pcHeader->mainvertex_stc_size) {
|
|
||||||
// read the normal vector from Quake2's smart table
|
// read the normal vector from Quake2's smart table
|
||||||
aiVector3D &vNormal = groupData.vNormals[iOutIndex];
|
aiVector3D &vNormal = groupData.vNormals[iOutIndex];
|
||||||
MD2::LookupNormalIndex(_AI_MDL7_ACCESS_VERT(groupInfo.pcGroupVerts, iIndex,
|
MD2::LookupNormalIndex(_AI_MDL7_ACCESS_VERT(groupInfo.pcGroupVerts, iIndex,
|
||||||
pcHeader->mainvertex_stc_size) .norm162index,vNormal);
|
pcHeader->mainvertex_stc_size)
|
||||||
|
.norm162index,
|
||||||
|
vNormal);
|
||||||
}
|
}
|
||||||
// validate and process the first uv coordinate set
|
// validate and process the first uv coordinate set
|
||||||
if (pcHeader->triangle_stc_size >= AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV) {
|
if (pcHeader->triangle_stc_size >= AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV) {
|
||||||
|
@ -1158,8 +1123,7 @@ bool MDLImporter::ProcessFrames_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInf
|
||||||
MDL::IntGroupData_MDL7 &groupData,
|
MDL::IntGroupData_MDL7 &groupData,
|
||||||
MDL::IntSharedData_MDL7 &shared,
|
MDL::IntSharedData_MDL7 &shared,
|
||||||
const unsigned char *szCurrent,
|
const unsigned char *szCurrent,
|
||||||
const unsigned char** szCurrentOut)
|
const unsigned char **szCurrentOut) {
|
||||||
{
|
|
||||||
ai_assert(nullptr != szCurrent);
|
ai_assert(nullptr != szCurrent);
|
||||||
ai_assert(nullptr != szCurrentOut);
|
ai_assert(nullptr != szCurrentOut);
|
||||||
|
|
||||||
|
@ -1219,11 +1183,12 @@ bool MDLImporter::ProcessFrames_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInf
|
||||||
AI_SWAP4(vNormal.y);
|
AI_SWAP4(vNormal.y);
|
||||||
vNormal.z = _AI_MDL7_ACCESS_VERT(pcFrameVertices, qq, pcHeader->framevertex_stc_size).norm[2];
|
vNormal.z = _AI_MDL7_ACCESS_VERT(pcFrameVertices, qq, pcHeader->framevertex_stc_size).norm[2];
|
||||||
AI_SWAP4(vNormal.z);
|
AI_SWAP4(vNormal.z);
|
||||||
}
|
} else if (AI_MDL7_FRAMEVERTEX120503_STCSIZE <= pcHeader->mainvertex_stc_size) {
|
||||||
else if (AI_MDL7_FRAMEVERTEX120503_STCSIZE <= pcHeader->mainvertex_stc_size) {
|
|
||||||
// read the normal vector from Quake2's smart table
|
// read the normal vector from Quake2's smart table
|
||||||
MD2::LookupNormalIndex(_AI_MDL7_ACCESS_VERT(pcFrameVertices, qq,
|
MD2::LookupNormalIndex(_AI_MDL7_ACCESS_VERT(pcFrameVertices, qq,
|
||||||
pcHeader->framevertex_stc_size) .norm162index,vNormal);
|
pcHeader->framevertex_stc_size)
|
||||||
|
.norm162index,
|
||||||
|
vNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: O(n^2) at the moment ...
|
// FIXME: O(n^2) at the moment ...
|
||||||
|
@ -1241,7 +1206,8 @@ bool MDLImporter::ProcessFrames_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInf
|
||||||
}
|
}
|
||||||
// get the next triangle in the list
|
// get the next triangle in the list
|
||||||
pcGroupTris = (BE_NCONST MDL::Triangle_MDL7 *)((const char *)
|
pcGroupTris = (BE_NCONST MDL::Triangle_MDL7 *)((const char *)
|
||||||
pcGroupTris + pcHeader->triangle_stc_size);
|
pcGroupTris +
|
||||||
|
pcHeader->triangle_stc_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1260,8 +1226,7 @@ bool MDLImporter::ProcessFrames_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInf
|
||||||
void MDLImporter::SortByMaterials_3DGS_MDL7(
|
void MDLImporter::SortByMaterials_3DGS_MDL7(
|
||||||
const MDL::IntGroupInfo_MDL7 &groupInfo,
|
const MDL::IntGroupInfo_MDL7 &groupInfo,
|
||||||
MDL::IntGroupData_MDL7 &groupData,
|
MDL::IntGroupData_MDL7 &groupData,
|
||||||
MDL::IntSplitGroupData_MDL7& splitGroupData)
|
MDL::IntSplitGroupData_MDL7 &splitGroupData) {
|
||||||
{
|
|
||||||
const unsigned int iNumMaterials = (unsigned int)splitGroupData.shared.pcMats.size();
|
const unsigned int iNumMaterials = (unsigned int)splitGroupData.shared.pcMats.size();
|
||||||
if (!groupData.bNeed2UV) {
|
if (!groupData.bNeed2UV) {
|
||||||
// if we don't need a second set of texture coordinates there is no reason to keep it in memory ...
|
// if we don't need a second set of texture coordinates there is no reason to keep it in memory ...
|
||||||
|
@ -1284,13 +1249,10 @@ void MDLImporter::SortByMaterials_3DGS_MDL7(
|
||||||
// one skin assigned. No warning in this case
|
// one skin assigned. No warning in this case
|
||||||
if (0xFFFFFFFF != groupData.pcFaces[iFace].iMatIndex[0])
|
if (0xFFFFFFFF != groupData.pcFaces[iFace].iMatIndex[0])
|
||||||
ASSIMP_LOG_WARN("Index overflow in MDL7 material list [#0]");
|
ASSIMP_LOG_WARN("Index overflow in MDL7 material list [#0]");
|
||||||
|
} else
|
||||||
|
splitGroupData.aiSplit[groupData.pcFaces[iFace].iMatIndex[0]]->push_back(iFace);
|
||||||
}
|
}
|
||||||
else splitGroupData.aiSplit[groupData.pcFaces[iFace].
|
} else {
|
||||||
iMatIndex[0]]->push_back(iFace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// we need to build combined materials for each combination of
|
// we need to build combined materials for each combination of
|
||||||
std::vector<MDL::IntMaterial_MDL7> avMats;
|
std::vector<MDL::IntMaterial_MDL7> avMats;
|
||||||
avMats.reserve(iNumMaterials * 2);
|
avMats.reserve(iNumMaterials * 2);
|
||||||
|
@ -1358,8 +1320,7 @@ void MDLImporter::SortByMaterials_3DGS_MDL7(
|
||||||
splitGroupData.shared.pcMats.resize(avMats.size());
|
splitGroupData.shared.pcMats.resize(avMats.size());
|
||||||
for (unsigned int o = 0; o < avMats.size(); ++o)
|
for (unsigned int o = 0; o < avMats.size(); ++o)
|
||||||
splitGroupData.shared.pcMats[o] = avMats[o].pcMat;
|
splitGroupData.shared.pcMats[o] = avMats[o].pcMat;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// This might result in redundant materials ...
|
// This might result in redundant materials ...
|
||||||
splitGroupData.shared.pcMats.resize(iNumMaterials + avMats.size());
|
splitGroupData.shared.pcMats.resize(iNumMaterials + avMats.size());
|
||||||
for (unsigned int o = iNumMaterials; o < avMats.size(); ++o)
|
for (unsigned int o = iNumMaterials; o < avMats.size(); ++o)
|
||||||
|
@ -1375,8 +1336,7 @@ void MDLImporter::SortByMaterials_3DGS_MDL7(
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Read a MDL7 file
|
// Read a MDL7 file
|
||||||
void MDLImporter::InternReadFile_3DGS_MDL7( )
|
void MDLImporter::InternReadFile_3DGS_MDL7() {
|
||||||
{
|
|
||||||
ai_assert(NULL != pScene);
|
ai_assert(NULL != pScene);
|
||||||
|
|
||||||
MDL::IntSharedData_MDL7 sharedData;
|
MDL::IntSharedData_MDL7 sharedData;
|
||||||
|
@ -1454,7 +1414,8 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
||||||
// read all skins
|
// read all skins
|
||||||
sharedData.pcMats.reserve(sharedData.pcMats.size() + groupInfo.pcGroup->numskins);
|
sharedData.pcMats.reserve(sharedData.pcMats.size() + groupInfo.pcGroup->numskins);
|
||||||
sharedData.abNeedMaterials.resize(sharedData.abNeedMaterials.size() +
|
sharedData.abNeedMaterials.resize(sharedData.abNeedMaterials.size() +
|
||||||
groupInfo.pcGroup->numskins,false);
|
groupInfo.pcGroup->numskins,
|
||||||
|
false);
|
||||||
|
|
||||||
for (unsigned int iSkin = 0; iSkin < (unsigned int)groupInfo.pcGroup->numskins; ++iSkin) {
|
for (unsigned int iSkin = 0; iSkin < (unsigned int)groupInfo.pcGroup->numskins; ++iSkin) {
|
||||||
ParseSkinLump_3DGS_MDL7(szCurrent, &szCurrent, sharedData.pcMats);
|
ParseSkinLump_3DGS_MDL7(szCurrent, &szCurrent, sharedData.pcMats);
|
||||||
|
@ -1508,8 +1469,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
||||||
|
|
||||||
MDL::IntSplitGroupData_MDL7 splitGroupData(sharedData, avOutList[iGroup]);
|
MDL::IntSplitGroupData_MDL7 splitGroupData(sharedData, avOutList[iGroup]);
|
||||||
MDL::IntGroupData_MDL7 groupData;
|
MDL::IntGroupData_MDL7 groupData;
|
||||||
if (groupInfo.pcGroup->numtris && groupInfo.pcGroup->numverts)
|
if (groupInfo.pcGroup->numtris && groupInfo.pcGroup->numverts) {
|
||||||
{
|
|
||||||
// build output vectors
|
// build output vectors
|
||||||
const unsigned int iNumVertices = groupInfo.pcGroup->numtris * 3;
|
const unsigned int iNumVertices = groupInfo.pcGroup->numtris * 3;
|
||||||
groupData.vPositions.resize(iNumVertices);
|
groupData.vPositions.resize(iNumVertices);
|
||||||
|
@ -1541,8 +1501,8 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
||||||
if (!splitGroupData.aiSplit[qq]->empty())
|
if (!splitGroupData.aiSplit[qq]->empty())
|
||||||
sharedData.abNeedMaterials[qq] = true;
|
sharedData.abNeedMaterials[qq] = true;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else ASSIMP_LOG_WARN("[3DGS MDL7] Mesh group consists of 0 "
|
ASSIMP_LOG_WARN("[3DGS MDL7] Mesh group consists of 0 "
|
||||||
"vertices or faces. It will be skipped.");
|
"vertices or faces. It will be skipped.");
|
||||||
|
|
||||||
// process all frames and generate output meshes
|
// process all frames and generate output meshes
|
||||||
|
@ -1557,7 +1517,8 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
||||||
for (uint32_t i = 0; i < pcHeader->groups_num; ++i)
|
for (uint32_t i = 0; i < pcHeader->groups_num; ++i)
|
||||||
pScene->mNumMeshes += (unsigned int)avOutList[i].size();
|
pScene->mNumMeshes += (unsigned int)avOutList[i].size();
|
||||||
|
|
||||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; {
|
pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
|
||||||
|
{
|
||||||
unsigned int p = 0, q = 0;
|
unsigned int p = 0, q = 0;
|
||||||
for (uint32_t i = 0; i < pcHeader->groups_num; ++i) {
|
for (uint32_t i = 0; i < pcHeader->groups_num; ++i) {
|
||||||
for (unsigned int a = 0; a < avOutList[i].size(); ++a) {
|
for (unsigned int a = 0; a < avOutList[i].size(); ++a) {
|
||||||
|
@ -1600,8 +1561,8 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
||||||
pcOldRoot->mChildren[0] = NULL;
|
pcOldRoot->mChildren[0] = NULL;
|
||||||
delete pcOldRoot;
|
delete pcOldRoot;
|
||||||
pScene->mRootNode->mParent = NULL;
|
pScene->mRootNode->mParent = NULL;
|
||||||
}
|
} else
|
||||||
else pScene->mRootNode->mName.Set("<mesh_root>");
|
pScene->mRootNode->mName.Set("<mesh_root>");
|
||||||
|
|
||||||
delete[] avOutList;
|
delete[] avOutList;
|
||||||
delete[] aszGroupNameBuffer;
|
delete[] aszGroupNameBuffer;
|
||||||
|
@ -1622,7 +1583,8 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
||||||
|
|
||||||
// add bones to the nodegraph
|
// add bones to the nodegraph
|
||||||
AddBonesToNodeGraph_3DGS_MDL7((const Assimp::MDL::IntBone_MDL7 **)
|
AddBonesToNodeGraph_3DGS_MDL7((const Assimp::MDL::IntBone_MDL7 **)
|
||||||
sharedData.apcOutBones,pc,0xffff);
|
sharedData.apcOutBones,
|
||||||
|
pc, 0xffff);
|
||||||
|
|
||||||
// this steps build a valid output animation
|
// this steps build a valid output animation
|
||||||
BuildOutputAnims_3DGS_MDL7((const Assimp::MDL::IntBone_MDL7 **)
|
BuildOutputAnims_3DGS_MDL7((const Assimp::MDL::IntBone_MDL7 **)
|
||||||
|
@ -1632,19 +1594,16 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Copy materials
|
// Copy materials
|
||||||
void MDLImporter::CopyMaterials_3DGS_MDL7(MDL::IntSharedData_MDL7 &shared)
|
void MDLImporter::CopyMaterials_3DGS_MDL7(MDL::IntSharedData_MDL7 &shared) {
|
||||||
{
|
|
||||||
pScene->mNumMaterials = (unsigned int)shared.pcMats.size();
|
pScene->mNumMaterials = (unsigned int)shared.pcMats.size();
|
||||||
pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials];
|
pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials];
|
||||||
for (unsigned int i = 0; i < pScene->mNumMaterials; ++i)
|
for (unsigned int i = 0; i < pScene->mNumMaterials; ++i)
|
||||||
pScene->mMaterials[i] = shared.pcMats[i];
|
pScene->mMaterials[i] = shared.pcMats[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Process material references
|
// Process material references
|
||||||
void MDLImporter::HandleMaterialReferences_3DGS_MDL7()
|
void MDLImporter::HandleMaterialReferences_3DGS_MDL7() {
|
||||||
{
|
|
||||||
// search for referrer materials
|
// search for referrer materials
|
||||||
for (unsigned int i = 0; i < pScene->mNumMaterials; ++i) {
|
for (unsigned int i = 0; i < pScene->mNumMaterials; ++i) {
|
||||||
int iIndex = 0;
|
int iIndex = 0;
|
||||||
|
@ -1675,16 +1634,14 @@ void MDLImporter::HandleMaterialReferences_3DGS_MDL7()
|
||||||
void MDLImporter::ParseBoneTrafoKeys_3DGS_MDL7(
|
void MDLImporter::ParseBoneTrafoKeys_3DGS_MDL7(
|
||||||
const MDL::IntGroupInfo_MDL7 &groupInfo,
|
const MDL::IntGroupInfo_MDL7 &groupInfo,
|
||||||
IntFrameInfo_MDL7 &frame,
|
IntFrameInfo_MDL7 &frame,
|
||||||
MDL::IntSharedData_MDL7& shared)
|
MDL::IntSharedData_MDL7 &shared) {
|
||||||
{
|
|
||||||
const MDL::Header_MDL7 *const pcHeader = (const MDL::Header_MDL7 *)this->mBuffer;
|
const MDL::Header_MDL7 *const pcHeader = (const MDL::Header_MDL7 *)this->mBuffer;
|
||||||
|
|
||||||
// only the first group contains bone animation keys
|
// only the first group contains bone animation keys
|
||||||
if (frame.pcFrame->transmatrix_count) {
|
if (frame.pcFrame->transmatrix_count) {
|
||||||
if (!groupInfo.iIndex) {
|
if (!groupInfo.iIndex) {
|
||||||
// skip all frames vertices. We can't support them
|
// skip all frames vertices. We can't support them
|
||||||
const MDL::BoneTransform_MDL7* pcBoneTransforms = (const MDL::BoneTransform_MDL7*)
|
const MDL::BoneTransform_MDL7 *pcBoneTransforms = (const MDL::BoneTransform_MDL7 *)(((const char *)frame.pcFrame) + pcHeader->frame_stc_size +
|
||||||
(((const char*)frame.pcFrame) + pcHeader->frame_stc_size +
|
|
||||||
frame.pcFrame->vertices_count * pcHeader->framevertex_stc_size);
|
frame.pcFrame->vertices_count * pcHeader->framevertex_stc_size);
|
||||||
|
|
||||||
// read all transformation matrices
|
// read all transformation matrices
|
||||||
|
@ -1692,16 +1649,13 @@ void MDLImporter::ParseBoneTrafoKeys_3DGS_MDL7(
|
||||||
if (pcBoneTransforms->bone_index >= pcHeader->bones_num) {
|
if (pcBoneTransforms->bone_index >= pcHeader->bones_num) {
|
||||||
ASSIMP_LOG_WARN("Index overflow in frame area. "
|
ASSIMP_LOG_WARN("Index overflow in frame area. "
|
||||||
"Unable to parse this bone transformation");
|
"Unable to parse this bone transformation");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
AddAnimationBoneTrafoKey_3DGS_MDL7(frame.iIndex,
|
AddAnimationBoneTrafoKey_3DGS_MDL7(frame.iIndex,
|
||||||
pcBoneTransforms, shared.apcOutBones);
|
pcBoneTransforms, shared.apcOutBones);
|
||||||
}
|
}
|
||||||
pcBoneTransforms = (const MDL::BoneTransform_MDL7*)(
|
pcBoneTransforms = (const MDL::BoneTransform_MDL7 *)((const char *)pcBoneTransforms + pcHeader->bonetrans_stc_size);
|
||||||
(const char*)pcBoneTransforms + pcHeader->bonetrans_stc_size);
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ASSIMP_LOG_WARN("Ignoring animation keyframes in groups != 0");
|
ASSIMP_LOG_WARN("Ignoring animation keyframes in groups != 0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1710,8 +1664,7 @@ void MDLImporter::ParseBoneTrafoKeys_3DGS_MDL7(
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Attach bones to the output nodegraph
|
// Attach bones to the output nodegraph
|
||||||
void MDLImporter::AddBonesToNodeGraph_3DGS_MDL7(const MDL::IntBone_MDL7 **apcBones,
|
void MDLImporter::AddBonesToNodeGraph_3DGS_MDL7(const MDL::IntBone_MDL7 **apcBones,
|
||||||
aiNode* pcParent,uint16_t iParentIndex)
|
aiNode *pcParent, uint16_t iParentIndex) {
|
||||||
{
|
|
||||||
ai_assert(NULL != apcBones && NULL != pcParent);
|
ai_assert(NULL != apcBones && NULL != pcParent);
|
||||||
|
|
||||||
// get a pointer to the header ...
|
// get a pointer to the header ...
|
||||||
|
@ -1742,8 +1695,7 @@ void MDLImporter::AddBonesToNodeGraph_3DGS_MDL7(const MDL::IntBone_MDL7** apcBon
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Build output animations
|
// Build output animations
|
||||||
void MDLImporter::BuildOutputAnims_3DGS_MDL7(
|
void MDLImporter::BuildOutputAnims_3DGS_MDL7(
|
||||||
const MDL::IntBone_MDL7** apcBonesOut)
|
const MDL::IntBone_MDL7 **apcBonesOut) {
|
||||||
{
|
|
||||||
ai_assert(NULL != apcBonesOut);
|
ai_assert(NULL != apcBonesOut);
|
||||||
const MDL::Header_MDL7 *const pcHeader = (const MDL::Header_MDL7 *)mBuffer;
|
const MDL::Header_MDL7 *const pcHeader = (const MDL::Header_MDL7 *)mBuffer;
|
||||||
|
|
||||||
|
@ -1755,7 +1707,9 @@ void MDLImporter::BuildOutputAnims_3DGS_MDL7(
|
||||||
// get the last frame ... (needn't be equal to pcHeader->frames_num)
|
// get the last frame ... (needn't be equal to pcHeader->frames_num)
|
||||||
for (size_t qq = 0; qq < apcBonesOut[i]->pkeyPositions.size(); ++qq) {
|
for (size_t qq = 0; qq < apcBonesOut[i]->pkeyPositions.size(); ++qq) {
|
||||||
pcAnim->mDuration = std::max(pcAnim->mDuration, (double)
|
pcAnim->mDuration = std::max(pcAnim->mDuration, (double)
|
||||||
apcBonesOut[i]->pkeyPositions[qq].mTime);
|
apcBonesOut[i]
|
||||||
|
->pkeyPositions[qq]
|
||||||
|
.mTime);
|
||||||
}
|
}
|
||||||
++pcAnim->mNumChannels;
|
++pcAnim->mNumChannels;
|
||||||
}
|
}
|
||||||
|
@ -1793,15 +1747,14 @@ void MDLImporter::BuildOutputAnims_3DGS_MDL7(
|
||||||
pScene->mNumAnimations = 1;
|
pScene->mNumAnimations = 1;
|
||||||
pScene->mAnimations = new aiAnimation *[1];
|
pScene->mAnimations = new aiAnimation *[1];
|
||||||
pScene->mAnimations[0] = pcAnim;
|
pScene->mAnimations[0] = pcAnim;
|
||||||
}
|
} else
|
||||||
else delete pcAnim;
|
delete pcAnim;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void MDLImporter::AddAnimationBoneTrafoKey_3DGS_MDL7(unsigned int iTrafo,
|
void MDLImporter::AddAnimationBoneTrafoKey_3DGS_MDL7(unsigned int iTrafo,
|
||||||
const MDL::BoneTransform_MDL7 *pcBoneTransforms,
|
const MDL::BoneTransform_MDL7 *pcBoneTransforms,
|
||||||
MDL::IntBone_MDL7** apcBonesOut)
|
MDL::IntBone_MDL7 **apcBonesOut) {
|
||||||
{
|
|
||||||
ai_assert(NULL != pcBoneTransforms);
|
ai_assert(NULL != pcBoneTransforms);
|
||||||
ai_assert(NULL != apcBonesOut);
|
ai_assert(NULL != apcBonesOut);
|
||||||
|
|
||||||
|
@ -1844,8 +1797,7 @@ void MDLImporter::AddAnimationBoneTrafoKey_3DGS_MDL7(unsigned int iTrafo,
|
||||||
// Construct output meshes
|
// Construct output meshes
|
||||||
void MDLImporter::GenerateOutputMeshes_3DGS_MDL7(
|
void MDLImporter::GenerateOutputMeshes_3DGS_MDL7(
|
||||||
MDL::IntGroupData_MDL7 &groupData,
|
MDL::IntGroupData_MDL7 &groupData,
|
||||||
MDL::IntSplitGroupData_MDL7& splitGroupData)
|
MDL::IntSplitGroupData_MDL7 &splitGroupData) {
|
||||||
{
|
|
||||||
const MDL::IntSharedData_MDL7 &shared = splitGroupData.shared;
|
const MDL::IntSharedData_MDL7 &shared = splitGroupData.shared;
|
||||||
|
|
||||||
// get a pointer to the header ...
|
// get a pointer to the header ...
|
||||||
|
@ -1910,7 +1862,7 @@ void MDLImporter::GenerateOutputMeshes_3DGS_MDL7(
|
||||||
std::vector<std::vector<unsigned int>> aaiVWeightList;
|
std::vector<std::vector<unsigned int>> aaiVWeightList;
|
||||||
aaiVWeightList.resize(iNumOutBones);
|
aaiVWeightList.resize(iNumOutBones);
|
||||||
|
|
||||||
int iCurrent = 0;
|
int iCurrentWeight = 0;
|
||||||
for (unsigned int iFace = 0; iFace < pcMesh->mNumFaces; ++iFace) {
|
for (unsigned int iFace = 0; iFace < pcMesh->mNumFaces; ++iFace) {
|
||||||
unsigned int iSrcFace = splitGroupData.aiSplit[i]->operator[](iFace);
|
unsigned int iSrcFace = splitGroupData.aiSplit[i]->operator[](iFace);
|
||||||
const MDL::IntFace_MDL7 &oldFace = groupData.pcFaces[iSrcFace];
|
const MDL::IntFace_MDL7 &oldFace = groupData.pcFaces[iSrcFace];
|
||||||
|
@ -1924,9 +1876,9 @@ void MDLImporter::GenerateOutputMeshes_3DGS_MDL7(
|
||||||
"The bone index of a vertex exceeds the allowed range. ");
|
"The bone index of a vertex exceeds the allowed range. ");
|
||||||
iBone = iNumOutBones - 1;
|
iBone = iNumOutBones - 1;
|
||||||
}
|
}
|
||||||
aaiVWeightList[ iBone ].push_back ( iCurrent );
|
aaiVWeightList[iBone].push_back(iCurrentWeight);
|
||||||
}
|
}
|
||||||
++iCurrent;
|
++iCurrentWeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// now check which bones are required ...
|
// now check which bones are required ...
|
||||||
|
@ -1937,8 +1889,7 @@ void MDLImporter::GenerateOutputMeshes_3DGS_MDL7(
|
||||||
}
|
}
|
||||||
pcMesh->mBones = new aiBone *[pcMesh->mNumBones];
|
pcMesh->mBones = new aiBone *[pcMesh->mNumBones];
|
||||||
iCurrent = 0;
|
iCurrent = 0;
|
||||||
for (std::vector<std::vector<unsigned int> >::const_iterator k = aaiVWeightList.begin();k!= aaiVWeightList.end();++k,++iCurrent)
|
for (std::vector<std::vector<unsigned int>>::const_iterator k = aaiVWeightList.begin(); k != aaiVWeightList.end(); ++k, ++iCurrent) {
|
||||||
{
|
|
||||||
if ((*k).empty())
|
if ((*k).empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1968,8 +1919,7 @@ void MDLImporter::GenerateOutputMeshes_3DGS_MDL7(
|
||||||
void MDLImporter::JoinSkins_3DGS_MDL7(
|
void MDLImporter::JoinSkins_3DGS_MDL7(
|
||||||
aiMaterial *pcMat1,
|
aiMaterial *pcMat1,
|
||||||
aiMaterial *pcMat2,
|
aiMaterial *pcMat2,
|
||||||
aiMaterial* pcMatOut)
|
aiMaterial *pcMatOut) {
|
||||||
{
|
|
||||||
ai_assert(NULL != pcMat1 && NULL != pcMat2 && NULL != pcMatOut);
|
ai_assert(NULL != pcMat1 && NULL != pcMat2 && NULL != pcMatOut);
|
||||||
|
|
||||||
// first create a full copy of the first skin property set
|
// first create a full copy of the first skin property set
|
||||||
|
@ -1991,8 +1941,7 @@ void MDLImporter::JoinSkins_3DGS_MDL7(
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Read a Half-life 1 MDL
|
// Read a Half-life 1 MDL
|
||||||
void MDLImporter::InternReadFile_HL1(const std::string& pFile, const uint32_t iMagicWord)
|
void MDLImporter::InternReadFile_HL1(const std::string &pFile, const uint32_t iMagicWord) {
|
||||||
{
|
|
||||||
// We can't correctly load an MDL from a MDL "sequence" file.
|
// We can't correctly load an MDL from a MDL "sequence" file.
|
||||||
if (iMagicWord == AI_MDL_MAGIC_NUMBER_BE_HL2b || iMagicWord == AI_MDL_MAGIC_NUMBER_LE_HL2b)
|
if (iMagicWord == AI_MDL_MAGIC_NUMBER_BE_HL2b || iMagicWord == AI_MDL_MAGIC_NUMBER_LE_HL2b)
|
||||||
throw DeadlyImportError("Impossible to properly load a model from an MDL sequence file.");
|
throw DeadlyImportError("Impossible to properly load a model from an MDL sequence file.");
|
||||||
|
@ -2000,7 +1949,7 @@ void MDLImporter::InternReadFile_HL1(const std::string& pFile, const uint32_t iM
|
||||||
// Read the MDL file.
|
// Read the MDL file.
|
||||||
HalfLife::HL1MDLLoader loader(
|
HalfLife::HL1MDLLoader loader(
|
||||||
pScene,
|
pScene,
|
||||||
pIOHandler,
|
mIOHandler,
|
||||||
mBuffer,
|
mBuffer,
|
||||||
pFile,
|
pFile,
|
||||||
mHL1ImportSettings);
|
mHL1ImportSettings);
|
||||||
|
@ -2008,8 +1957,7 @@ void MDLImporter::InternReadFile_HL1(const std::string& pFile, const uint32_t iM
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Read a half-life 2 MDL
|
// Read a half-life 2 MDL
|
||||||
void MDLImporter::InternReadFile_HL2( )
|
void MDLImporter::InternReadFile_HL2() {
|
||||||
{
|
|
||||||
//const MDL::Header_HL2* pcHeader = (const MDL::Header_HL2*)this->mBuffer;
|
//const MDL::Header_HL2* pcHeader = (const MDL::Header_HL2*)this->mBuffer;
|
||||||
throw DeadlyImportError("HL2 MDLs are not implemented");
|
throw DeadlyImportError("HL2 MDLs are not implemented");
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -58,7 +57,6 @@ struct aiTexture;
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
|
|
||||||
using namespace MDL;
|
using namespace MDL;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
@ -436,7 +434,7 @@ protected:
|
||||||
unsigned int iGSFileVersion;
|
unsigned int iGSFileVersion;
|
||||||
|
|
||||||
/** Output I/O handler. used to load external lmp files */
|
/** Output I/O handler. used to load external lmp files */
|
||||||
IOSystem* pIOHandler;
|
IOSystem* mIOHandler;
|
||||||
|
|
||||||
/** Output scene to be filled */
|
/** Output scene to be filled */
|
||||||
aiScene* pScene;
|
aiScene* pScene;
|
||||||
|
|
|
@ -561,7 +561,8 @@ uint32_t Assimp::ComputeMaterialHash(const aiMaterial* mat, bool includeMatName
|
||||||
|
|
||||||
// Exclude all properties whose first character is '?' from the hash
|
// Exclude all properties whose first character is '?' from the hash
|
||||||
// See doc for aiMaterialProperty.
|
// See doc for aiMaterialProperty.
|
||||||
if ((prop = mat->mProperties[i]) && (includeMatName || prop->mKey.data[0] != '?')) {
|
prop = mat->mProperties[ i ];
|
||||||
|
if ( nullptr != prop && (includeMatName || prop->mKey.data[0] != '?')) {
|
||||||
|
|
||||||
hash = SuperFastHash(prop->mKey.data,(unsigned int)prop->mKey.length,hash);
|
hash = SuperFastHash(prop->mKey.data,(unsigned int)prop->mKey.length,hash);
|
||||||
hash = SuperFastHash(prop->mData,prop->mDataLength,hash);
|
hash = SuperFastHash(prop->mData,prop->mDataLength,hash);
|
||||||
|
|
|
@ -575,7 +575,8 @@ void SplitLargeMeshesProcess_Vertex::SplitMesh(
|
||||||
for (unsigned int k = 0; k < pMesh->mNumBones;++k) {
|
for (unsigned int k = 0; k < pMesh->mNumBones;++k) {
|
||||||
// check whether the bone is existing
|
// check whether the bone is existing
|
||||||
BoneWeightList* pcWeightList;
|
BoneWeightList* pcWeightList;
|
||||||
if ((pcWeightList = (BoneWeightList*)pcMesh->mBones[k])) {
|
pcWeightList = (BoneWeightList *)pcMesh->mBones[k];
|
||||||
|
if (nullptr != pcWeightList) {
|
||||||
aiBone *pcOldBone = pMesh->mBones[k];
|
aiBone *pcOldBone = pMesh->mBones[k];
|
||||||
aiBone* pcOut( nullptr );
|
aiBone* pcOut( nullptr );
|
||||||
*ppCurrent++ = pcOut = new aiBone();
|
*ppCurrent++ = pcOut = new aiBone();
|
||||||
|
|
|
@ -125,7 +125,8 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||||
* type (e.g. if mirroring is active there IS a difference between
|
* type (e.g. if mirroring is active there IS a difference between
|
||||||
* offset 2 and 3)
|
* offset 2 and 3)
|
||||||
*/
|
*/
|
||||||
if ((rounded = (int)info.mTranslation.x)) {
|
rounded = (int)info.mTranslation.x;
|
||||||
|
if (rounded) {
|
||||||
float out = 0.0f;
|
float out = 0.0f;
|
||||||
szTemp[0] = 0;
|
szTemp[0] = 0;
|
||||||
if (aiTextureMapMode_Wrap == info.mapU) {
|
if (aiTextureMapMode_Wrap == info.mapU) {
|
||||||
|
@ -158,7 +159,8 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||||
* type (e.g. if mirroring is active there IS a difference between
|
* type (e.g. if mirroring is active there IS a difference between
|
||||||
* offset 2 and 3)
|
* offset 2 and 3)
|
||||||
*/
|
*/
|
||||||
if ((rounded = (int)info.mTranslation.y)) {
|
rounded = (int)info.mTranslation.y;
|
||||||
|
if (rounded) {
|
||||||
float out = 0.0f;
|
float out = 0.0f;
|
||||||
szTemp[0] = 0;
|
szTemp[0] = 0;
|
||||||
if (aiTextureMapMode_Wrap == info.mapV) {
|
if (aiTextureMapMode_Wrap == info.mapV) {
|
||||||
|
|
Loading…
Reference in New Issue