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