Merge branch 'master' into decltype
commit
6dec8ad5f3
|
@ -527,12 +527,12 @@ ENDIF()
|
||||||
MARK_AS_ADVANCED ( ASSIMP_BUILD_ARCHITECTURE ASSIMP_BUILD_COMPILER )
|
MARK_AS_ADVANCED ( ASSIMP_BUILD_ARCHITECTURE ASSIMP_BUILD_COMPILER )
|
||||||
|
|
||||||
SET ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER OFF CACHE BOOL
|
SET ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER OFF CACHE BOOL
|
||||||
"Build the C4D importer, which relies on the non-free Melange SDK."
|
"Build the C4D importer, which relies on the non-free Cineware SDK."
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||||
IF ( MSVC )
|
IF ( MSVC )
|
||||||
SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/includes")
|
SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Cineware/includes")
|
||||||
|
|
||||||
# pick the correct prebuilt library
|
# pick the correct prebuilt library
|
||||||
IF(MSVC15)
|
IF(MSVC15)
|
||||||
|
@ -551,22 +551,23 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
|
||||||
)
|
)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/libraries/win")
|
SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Cineware/libraries/win")
|
||||||
|
|
||||||
SET(C4D_DEBUG_LIBRARIES
|
SET(C4D_DEBUG_LIBRARIES
|
||||||
"${C4D_LIB_BASE_PATH}/melangelib${C4D_LIB_POSTFIX}/melangelib_debug.lib"
|
"${C4D_LIB_BASE_PATH}/cinewarelib${C4D_LIB_POSTFIX}/cinewarelib_debug.lib"
|
||||||
"${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_debug.lib"
|
"${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_debug.lib"
|
||||||
)
|
)
|
||||||
SET(C4D_RELEASE_LIBRARIES
|
SET(C4D_RELEASE_LIBRARIES
|
||||||
"${C4D_LIB_BASE_PATH}/melangelib${C4D_LIB_POSTFIX}/melangelib_release.lib"
|
"${C4D_LIB_BASE_PATH}/cinewarelib${C4D_LIB_POSTFIX}/cinewarelib_release.lib"
|
||||||
"${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_release.lib"
|
"${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_release.lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
# winsock and winmm are necessary dependencies of melange (this is undocumented, but true.)
|
# winsock and winmm are necessary (and undocumented) dependencies of Cineware SDK because
|
||||||
|
# it can be used to communicate with a running Cinema 4D instance
|
||||||
SET(C4D_EXTRA_LIBRARIES WSock32.lib Winmm.lib)
|
SET(C4D_EXTRA_LIBRARIES WSock32.lib Winmm.lib)
|
||||||
ELSE ()
|
ELSE ()
|
||||||
MESSAGE( FATAL_ERROR
|
MESSAGE( FATAL_ERROR
|
||||||
"C4D is currently only available on Windows with melange SDK installed in contrib/Melange"
|
"C4D is currently only available on Windows with Cineware SDK installed in contrib/Cineware"
|
||||||
)
|
)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
ELSE ()
|
ELSE ()
|
||||||
|
|
|
@ -66,9 +66,9 @@ Open Asset Import Library is implemented in C++. The directory structure looks l
|
||||||
|
|
||||||
The source code is organized in the following way:
|
The source code is organized in the following way:
|
||||||
|
|
||||||
code/Common The base implementation for importers and the infrastructure
|
code/Common The base implementation for importers and the infrastructure
|
||||||
code/PostProcessing The post-processing steps
|
code/PostProcessing The post-processing steps
|
||||||
code/<FormatName> Implementation for import and export for the format
|
code/AssetLib/<FormatName> Implementation for import and export for the format
|
||||||
|
|
||||||
### Where to get help ###
|
### Where to get help ###
|
||||||
For more information, visit [our website](http://assimp.org/). Or check out the `./doc`- folder, which contains the official documentation in HTML format.
|
For more information, visit [our website](http://assimp.org/). Or check out the `./doc`- folder, which contains the official documentation in HTML format.
|
||||||
|
|
|
@ -268,7 +268,8 @@ void AMFImporter::ParseFile(const std::string &pFile, IOSystem *pIOHandler) {
|
||||||
mXmlParser = new XmlParser();
|
mXmlParser = new XmlParser();
|
||||||
if (!mXmlParser->parse(file.get())) {
|
if (!mXmlParser->parse(file.get())) {
|
||||||
delete mXmlParser;
|
delete mXmlParser;
|
||||||
throw DeadlyImportError("Failed to create XML reader for file" + pFile + ".");
|
mXmlParser = nullptr;
|
||||||
|
throw DeadlyImportError("Failed to create XML reader for file ", pFile, ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start reading, search for root tag <amf>
|
// Start reading, search for root tag <amf>
|
||||||
|
|
|
@ -498,6 +498,12 @@ void Parser::ParseLV1MaterialListBlock() {
|
||||||
ParseLV2MaterialBlock(sMat);
|
ParseLV2MaterialBlock(sMat);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if( iDepth == 1 ){
|
||||||
|
// CRUDE HACK: support missing brace after "Ascii Scene Exporter v2.51"
|
||||||
|
LogWarning("Missing closing brace in material list");
|
||||||
|
--filePtr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
AI_ASE_HANDLE_TOP_LEVEL_SECTION();
|
AI_ASE_HANDLE_TOP_LEVEL_SECTION();
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ void DNAParser::Parse() {
|
||||||
|
|
||||||
ASSIMP_LOG_DEBUG_F("BlenderDNA: Got ", dna.structures.size(), " structures with totally ", fields, " fields");
|
ASSIMP_LOG_DEBUG_F("BlenderDNA: Got ", dna.structures.size(), " structures with totally ", fields, " fields");
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_BLENDER_DEBUG
|
#if ASSIMP_BUILD_BLENDER_DEBUG_DNA
|
||||||
dna.DumpToFile();
|
dna.DumpToFile();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ void DNAParser::Parse() {
|
||||||
dna.RegisterConverters();
|
dna.RegisterConverters();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_BLENDER_DEBUG
|
#if ASSIMP_BUILD_BLENDER_DEBUG_DNA
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -237,7 +237,7 @@ void DNA ::DumpToFile() {
|
||||||
|
|
||||||
ASSIMP_LOG_INFO("BlenderDNA: Dumped dna to dna.txt");
|
ASSIMP_LOG_INFO("BlenderDNA: Dumped dna to dna.txt");
|
||||||
}
|
}
|
||||||
#endif
|
#endif // ASSIMP_BUILD_BLENDER_DEBUG_DNA
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
/*static*/ void DNA ::ExtractArraySize(
|
/*static*/ void DNA ::ExtractArraySize(
|
||||||
|
|
|
@ -59,6 +59,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define ASSIMP_BUILD_BLENDER_DEBUG
|
#define ASSIMP_BUILD_BLENDER_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// set this to non-zero to dump BlenderDNA stuff to dna.txt.
|
||||||
|
// you could set it on the assimp build command line too without touching it here.
|
||||||
|
// !!! please make sure this is set to 0 in the repo !!!
|
||||||
|
#ifndef ASSIMP_BUILD_BLENDER_DEBUG_DNA
|
||||||
|
#define ASSIMP_BUILD_BLENDER_DEBUG_DNA 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// #define ASSIMP_BUILD_BLENDER_NO_STATS
|
// #define ASSIMP_BUILD_BLENDER_NO_STATS
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
@ -495,7 +502,7 @@ public:
|
||||||
const Structure &structure,
|
const Structure &structure,
|
||||||
const FileDatabase &db) const;
|
const FileDatabase &db) const;
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_BLENDER_DEBUG
|
#if ASSIMP_BUILD_BLENDER_DEBUG_DNA
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
/** Dump the DNA to a text file. This is for debugging purposes.
|
/** Dump the DNA to a text file. This is for debugging purposes.
|
||||||
* The output file is `dna.txt` in the current working folder*/
|
* The output file is `dna.txt` in the current working folder*/
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2021, 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,
|
||||||
|
@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "C4DImporter.h"
|
#include "C4DImporter.h"
|
||||||
#include <assimp/TinyFormatter.h>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
|
@ -65,7 +64,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "c4d_file.h"
|
#include "c4d_file.h"
|
||||||
#include "default_alien_overloads.h"
|
#include "default_alien_overloads.h"
|
||||||
|
|
||||||
using namespace melange;
|
namespace {
|
||||||
|
|
||||||
|
aiString aiStringFrom(cineware::String const & cinestring) {
|
||||||
|
aiString result;
|
||||||
|
cinestring.GetCString(result.data, MAXLEN-1);
|
||||||
|
result.length = static_cast<ai_uint32>(cinestring.GetLength());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
using namespace cineware;
|
||||||
|
|
||||||
// overload this function and fill in your own unique data
|
// overload this function and fill in your own unique data
|
||||||
void GetWriterInfo(int &id, String &appname) {
|
void GetWriterInfo(int &id, String &appname) {
|
||||||
|
@ -73,9 +84,6 @@ void GetWriterInfo(int &id, String &appname) {
|
||||||
appname = "Open Asset Import Library";
|
appname = "Open Asset Import Library";
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace Assimp;
|
|
||||||
using namespace Assimp::Formatter;
|
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
template<> const char* LogFunctions<C4DImporter>::Prefix() {
|
template<> const char* LogFunctions<C4DImporter>::Prefix() {
|
||||||
static auto prefix = "C4D: ";
|
static auto prefix = "C4D: ";
|
||||||
|
@ -97,17 +105,6 @@ static const aiImporterDesc desc = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
C4DImporter::C4DImporter()
|
|
||||||
: BaseImporter() {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
C4DImporter::~C4DImporter() {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool C4DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
|
bool C4DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
|
||||||
const std::string& extension = GetExtension(pFile);
|
const std::string& extension = GetExtension(pFile);
|
||||||
|
@ -125,11 +122,6 @@ const aiImporterDesc* C4DImporter::GetInfo () const {
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void C4DImporter::SetupProperties(const Importer* /*pImp*/) {
|
|
||||||
// nothing to be done for the moment
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
|
@ -199,8 +191,8 @@ void C4DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader) {
|
bool C4DImporter::ReadShader(aiMaterial* out, BaseShader* shader) {
|
||||||
// based on Melange sample code (C4DImportExport.cpp)
|
// based on Cineware sample code (C4DImportExport.cpp)
|
||||||
while(shader) {
|
while(shader) {
|
||||||
if(shader->GetType() == Xlayer) {
|
if(shader->GetType() == Xlayer) {
|
||||||
BaseContainer* container = shader->GetDataInstance();
|
BaseContainer* container = shader->GetDataInstance();
|
||||||
|
@ -242,9 +234,7 @@ bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader) {
|
||||||
lsl = lsl->GetNext();
|
lsl = lsl->GetNext();
|
||||||
}
|
}
|
||||||
} else if ( shader->GetType() == Xbitmap ) {
|
} else if ( shader->GetType() == Xbitmap ) {
|
||||||
aiString path;
|
auto const path = aiStringFrom(shader->GetFileName().GetString());
|
||||||
shader->GetFileName().GetString().GetCString(path.data, MAXLEN-1);
|
|
||||||
path.length = ::strlen(path.data);
|
|
||||||
out->AddProperty(&path, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
out->AddProperty(&path, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -257,18 +247,15 @@ bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void C4DImporter::ReadMaterials(melange::BaseMaterial* mat) {
|
void C4DImporter::ReadMaterials(BaseMaterial* mat) {
|
||||||
// based on Melange sample code
|
// based on Cineware sample code
|
||||||
while (mat) {
|
while (mat) {
|
||||||
const String& name = mat->GetName();
|
|
||||||
if (mat->GetType() == Mmaterial) {
|
if (mat->GetType() == Mmaterial) {
|
||||||
aiMaterial* out = new aiMaterial();
|
aiMaterial* out = new aiMaterial();
|
||||||
material_mapping[mat] = static_cast<unsigned int>(materials.size());
|
material_mapping[mat] = static_cast<unsigned int>(materials.size());
|
||||||
materials.push_back(out);
|
materials.push_back(out);
|
||||||
|
|
||||||
aiString ai_name;
|
auto const ai_name = aiStringFrom(mat->GetName());
|
||||||
name.GetCString(ai_name.data, MAXLEN-1);
|
|
||||||
ai_name.length = ::strlen(ai_name.data);
|
|
||||||
out->AddProperty(&ai_name, AI_MATKEY_NAME);
|
out->AddProperty(&ai_name, AI_MATKEY_NAME);
|
||||||
|
|
||||||
Material& m = dynamic_cast<Material&>(*mat);
|
Material& m = dynamic_cast<Material&>(*mat);
|
||||||
|
@ -305,19 +292,15 @@ void C4DImporter::RecurseHierarchy(BaseObject* object, aiNode* parent) {
|
||||||
ai_assert(parent != nullptr );
|
ai_assert(parent != nullptr );
|
||||||
std::vector<aiNode*> nodes;
|
std::vector<aiNode*> nodes;
|
||||||
|
|
||||||
// based on Melange sample code
|
// based on Cineware sample code
|
||||||
while (object) {
|
while (object) {
|
||||||
const String& name = object->GetName();
|
|
||||||
const LONG type = object->GetType();
|
const LONG type = object->GetType();
|
||||||
const Matrix& ml = object->GetMl();
|
const Matrix& ml = object->GetMl();
|
||||||
|
|
||||||
aiString string;
|
|
||||||
name.GetCString(string.data, MAXLEN-1);
|
|
||||||
string.length = ::strlen(string.data);
|
|
||||||
aiNode* const nd = new aiNode();
|
aiNode* const nd = new aiNode();
|
||||||
|
|
||||||
nd->mParent = parent;
|
nd->mParent = parent;
|
||||||
nd->mName = string;
|
nd->mName = aiStringFrom(object->GetName());
|
||||||
|
|
||||||
nd->mTransformation.a1 = ml.v1.x;
|
nd->mTransformation.a1 = ml.v1.x;
|
||||||
nd->mTransformation.b1 = ml.v1.y;
|
nd->mTransformation.b1 = ml.v1.y;
|
||||||
|
@ -370,7 +353,7 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object) {
|
||||||
ai_assert(object != nullptr);
|
ai_assert(object != nullptr);
|
||||||
ai_assert( object->GetType() == Opolygon );
|
ai_assert( object->GetType() == Opolygon );
|
||||||
|
|
||||||
// based on Melange sample code
|
// based on Cineware sample code
|
||||||
PolygonObject* const polyObject = dynamic_cast<PolygonObject*>(object);
|
PolygonObject* const polyObject = dynamic_cast<PolygonObject*>(object);
|
||||||
ai_assert(polyObject != nullptr);
|
ai_assert(polyObject != nullptr);
|
||||||
|
|
||||||
|
@ -618,4 +601,3 @@ unsigned int C4DImporter::ResolveMaterial(PolygonObject* obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ASSIMP_BUILD_NO_C4D_IMPORTER
|
#endif // ASSIMP_BUILD_NO_C4D_IMPORTER
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2021, 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,
|
||||||
|
@ -56,8 +56,8 @@ struct aiMaterial;
|
||||||
|
|
||||||
struct aiImporterDesc;
|
struct aiImporterDesc;
|
||||||
|
|
||||||
namespace melange {
|
namespace cineware {
|
||||||
class BaseObject; // c4d_file.h
|
class BaseObject;
|
||||||
class PolygonObject;
|
class PolygonObject;
|
||||||
class BaseMaterial;
|
class BaseMaterial;
|
||||||
class BaseShader;
|
class BaseShader;
|
||||||
|
@ -71,43 +71,34 @@ namespace Assimp {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
/** Importer class to load Cinema4D files using the Melange library to be obtained from
|
/** Importer class to load Cinema4D files using the Cineware library to be obtained from
|
||||||
* www.plugincafe.com
|
* https://developers.maxon.net
|
||||||
*
|
*
|
||||||
* Note that Melange is not free software. */
|
* Note that Cineware is not free software. */
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
class C4DImporter : public BaseImporter, public LogFunctions<C4DImporter> {
|
class C4DImporter : public BaseImporter, public LogFunctions<C4DImporter> {
|
||||||
public:
|
public:
|
||||||
C4DImporter();
|
bool CanRead( const std::string& pFile, IOSystem*, bool checkSig) const override;
|
||||||
~C4DImporter();
|
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
|
|
||||||
bool checkSig) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// --------------------
|
const aiImporterDesc* GetInfo () const override;
|
||||||
const aiImporterDesc* GetInfo () const;
|
|
||||||
|
|
||||||
// --------------------
|
void InternReadFile( const std::string& pFile, aiScene*, IOSystem* ) override;
|
||||||
void SetupProperties(const Importer* pImp);
|
|
||||||
|
|
||||||
// --------------------
|
|
||||||
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
|
||||||
IOSystem* pIOHandler);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void ReadMaterials(melange::BaseMaterial* mat);
|
void ReadMaterials(cineware::BaseMaterial* mat);
|
||||||
void RecurseHierarchy(melange::BaseObject* object, aiNode* parent);
|
void RecurseHierarchy(cineware::BaseObject* object, aiNode* parent);
|
||||||
aiMesh* ReadMesh(melange::BaseObject* object);
|
aiMesh* ReadMesh(cineware::BaseObject* object);
|
||||||
unsigned int ResolveMaterial(melange::PolygonObject* obj);
|
unsigned int ResolveMaterial(cineware::PolygonObject* obj);
|
||||||
|
|
||||||
bool ReadShader(aiMaterial* out, melange::BaseShader* shader);
|
bool ReadShader(aiMaterial* out, cineware::BaseShader* shader);
|
||||||
|
|
||||||
std::vector<aiMesh*> meshes;
|
std::vector<aiMesh*> meshes;
|
||||||
std::vector<aiMaterial*> materials;
|
std::vector<aiMaterial*> materials;
|
||||||
|
|
||||||
typedef std::map<melange::BaseMaterial*, unsigned int> MaterialMap;
|
typedef std::map<cineware::BaseMaterial*, unsigned int> MaterialMap;
|
||||||
MaterialMap material_mapping;
|
MaterialMap material_mapping;
|
||||||
|
|
||||||
}; // !class C4DImporter
|
}; // !class C4DImporter
|
||||||
|
|
|
@ -294,21 +294,17 @@ void ExportSceneM3D(
|
||||||
// Worker function for exporting a scene to ASCII A3D.
|
// Worker function for exporting a scene to ASCII A3D.
|
||||||
// Prototyped and registered in Exporter.cpp
|
// Prototyped and registered in Exporter.cpp
|
||||||
void ExportSceneM3DA(
|
void ExportSceneM3DA(
|
||||||
const char *,
|
const char *pFile,
|
||||||
IOSystem *,
|
IOSystem *pIOSystem,
|
||||||
const aiScene *,
|
const aiScene *pScene,
|
||||||
const ExportProperties *
|
const ExportProperties *pProperties
|
||||||
|
|
||||||
) {
|
) {
|
||||||
#ifdef M3D_ASCII
|
|
||||||
// initialize the exporter
|
// initialize the exporter
|
||||||
M3DExporter exporter(pScene, pProperties);
|
M3DExporter exporter(pScene, pProperties);
|
||||||
|
|
||||||
// perform ascii export
|
// perform ascii export
|
||||||
exporter.doExport(pFile, pIOSystem, true);
|
exporter.doExport(pFile, pIOSystem, true);
|
||||||
#else
|
|
||||||
throw DeadlyExportError("Assimp configured without M3D_ASCII support");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -95,10 +95,7 @@ static const aiImporterDesc desc = {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
"m3d"
|
"m3d a3d"
|
||||||
#ifdef M3D_ASCII
|
|
||||||
" a3d"
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
@ -118,9 +115,7 @@ bool M3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
const std::string extension = GetExtension(pFile);
|
const std::string extension = GetExtension(pFile);
|
||||||
|
|
||||||
if (extension == "m3d"
|
if (extension == "m3d"
|
||||||
#ifdef M3D_ASCII
|
|
||||||
|| extension == "a3d"
|
|| extension == "a3d"
|
||||||
#endif
|
|
||||||
)
|
)
|
||||||
return true;
|
return true;
|
||||||
else if (!extension.length() || checkSig) {
|
else if (!extension.length() || checkSig) {
|
||||||
|
@ -140,9 +135,7 @@ bool M3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !memcmp(data, "3DMO", 4) /* bin */
|
return !memcmp(data, "3DMO", 4) /* bin */
|
||||||
#ifdef M3D_ASCII
|
|
||||||
|| !memcmp(data, "3dmo", 4) /* ASCII */
|
|| !memcmp(data, "3dmo", 4) /* ASCII */
|
||||||
#endif
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -175,12 +168,10 @@ void M3DImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSys
|
||||||
if (!memcmp(buffer.data(), "3DMO", 4) && memcmp(buffer.data() + 4, &fileSize, 4)) {
|
if (!memcmp(buffer.data(), "3DMO", 4) && memcmp(buffer.data() + 4, &fileSize, 4)) {
|
||||||
throw DeadlyImportError("Bad binary header in file ", file, ".");
|
throw DeadlyImportError("Bad binary header in file ", file, ".");
|
||||||
}
|
}
|
||||||
#ifdef M3D_ASCII
|
|
||||||
// make sure there's a terminator zero character, as input must be ASCIIZ
|
// make sure there's a terminator zero character, as input must be ASCIIZ
|
||||||
if (!memcmp(buffer.data(), "3dmo", 4)) {
|
if (!memcmp(buffer.data(), "3dmo", 4)) {
|
||||||
buffer.push_back(0);
|
buffer.push_back(0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Get the path for external assets
|
// Get the path for external assets
|
||||||
std::string folderName("./");
|
std::string folderName("./");
|
||||||
|
|
|
@ -54,7 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// Assimp specific M3D configuration. Comment out these defines to remove functionality
|
// Assimp specific M3D configuration. Comment out these defines to remove functionality
|
||||||
//#define ASSIMP_USE_M3D_READFILECB
|
//#define ASSIMP_USE_M3D_READFILECB
|
||||||
//#define M3D_ASCII
|
|
||||||
|
|
||||||
#include "m3d.h"
|
#include "m3d.h"
|
||||||
|
|
||||||
|
|
|
@ -231,14 +231,9 @@ enum {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t format;
|
uint8_t format;
|
||||||
uint8_t id;
|
uint8_t id;
|
||||||
#ifdef M3D_ASCII
|
|
||||||
#define M3D_PROPERTYDEF(f, i, n) \
|
#define M3D_PROPERTYDEF(f, i, n) \
|
||||||
{ (f), (i), (char *)(n) }
|
{ (f), (i), (char *)(n) }
|
||||||
char *key;
|
char *key;
|
||||||
#else
|
|
||||||
#define M3D_PROPERTYDEF(f, i, n) \
|
|
||||||
{ (f), (i) }
|
|
||||||
#endif
|
|
||||||
} m3dpd_t;
|
} m3dpd_t;
|
||||||
|
|
||||||
/* material property types */
|
/* material property types */
|
||||||
|
@ -376,18 +371,11 @@ enum {
|
||||||
|
|
||||||
#define M3D_CMDMAXARG 8 /* if you increase this, add more arguments to the macro below */
|
#define M3D_CMDMAXARG 8 /* if you increase this, add more arguments to the macro below */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#ifdef M3D_ASCII
|
|
||||||
#define M3D_CMDDEF(t, n, p, a, b, c, d, e, f, g, h) \
|
#define M3D_CMDDEF(t, n, p, a, b, c, d, e, f, g, h) \
|
||||||
{ \
|
{ \
|
||||||
(char *)(n), (p), { (a), (b), (c), (d), (e), (f), (g), (h) } \
|
(char *)(n), (p), { (a), (b), (c), (d), (e), (f), (g), (h) } \
|
||||||
}
|
}
|
||||||
char *key;
|
char *key;
|
||||||
#else
|
|
||||||
#define M3D_CMDDEF(t, n, p, a, b, c, d, e, f, g, h) \
|
|
||||||
{ \
|
|
||||||
(p), { (a), (b), (c), (d), (e), (f), (g), (h) } \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
uint8_t p;
|
uint8_t p;
|
||||||
uint8_t a[M3D_CMDMAXARG];
|
uint8_t a[M3D_CMDMAXARG];
|
||||||
} m3dcd_t;
|
} m3dcd_t;
|
||||||
|
@ -2059,15 +2047,13 @@ unsigned char *_m3dstbi_zlib_compress(unsigned char *data, int data_len, int *ou
|
||||||
|
|
||||||
#define M3D_CHUNKMAGIC(m, a, b, c, d) ((m)[0] == (a) && (m)[1] == (b) && (m)[2] == (c) && (m)[3] == (d))
|
#define M3D_CHUNKMAGIC(m, a, b, c, d) ((m)[0] == (a) && (m)[1] == (b) && (m)[2] == (c) && (m)[3] == (d))
|
||||||
|
|
||||||
#ifdef M3D_ASCII
|
|
||||||
#include <locale.h> /* sprintf and strtod cares about number locale */
|
#include <locale.h> /* sprintf and strtod cares about number locale */
|
||||||
#include <stdio.h> /* get sprintf */
|
#include <stdio.h> /* get sprintf */
|
||||||
#endif
|
|
||||||
#ifdef M3D_PROFILING
|
#ifdef M3D_PROFILING
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(M3D_NOIMPORTER) && defined(M3D_ASCII)
|
#if !defined(M3D_NOIMPORTER)
|
||||||
/* helper functions for the ASCII parser */
|
/* helper functions for the ASCII parser */
|
||||||
static char *_m3d_findarg(char *s) {
|
static char *_m3d_findarg(char *s) {
|
||||||
while (s && *s && *s != ' ' && *s != '\t' && *s != '\r' && *s != '\n')
|
while (s && *s && *s != ' ' && *s != '\t' && *s != '\r' && *s != '\n')
|
||||||
|
@ -2118,7 +2104,7 @@ static char *_m3d_getfloat(char *s, M3D_FLOAT *ret) {
|
||||||
return _m3d_findarg(e);
|
return _m3d_findarg(e);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !defined(M3D_NODUP) && (!defined(M3D_NOIMPORTER) || defined(M3D_ASCII) || defined(M3D_EXPORTER))
|
#if !defined(M3D_NODUP) && (!defined(M3D_NOIMPORTER) || defined(M3D_EXPORTER))
|
||||||
/* helper function to create safe strings */
|
/* helper function to create safe strings */
|
||||||
char *_m3d_safestr(char *in, int morelines) {
|
char *_m3d_safestr(char *in, int morelines) {
|
||||||
char *out, *o, *i = in;
|
char *out, *o, *i = in;
|
||||||
|
@ -2426,21 +2412,17 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
|
||||||
#ifndef M3D_NOWEIGHTS
|
#ifndef M3D_NOWEIGHTS
|
||||||
m3ds_t *sk;
|
m3ds_t *sk;
|
||||||
#endif
|
#endif
|
||||||
#ifdef M3D_ASCII
|
|
||||||
m3ds_t s;
|
m3ds_t s;
|
||||||
M3D_INDEX bi[M3D_BONEMAXLEVEL + 1], level;
|
M3D_INDEX bi[M3D_BONEMAXLEVEL + 1], level;
|
||||||
const char *ol;
|
const char *ol;
|
||||||
char *ptr, *pe, *fn;
|
char *ptr, *pe, *fn;
|
||||||
#endif
|
|
||||||
#ifdef M3D_PROFILING
|
#ifdef M3D_PROFILING
|
||||||
struct timeval tv0, tv1, tvd;
|
struct timeval tv0, tv1, tvd;
|
||||||
gettimeofday(&tv0, NULL);
|
gettimeofday(&tv0, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!data || (!M3D_CHUNKMAGIC(data, '3', 'D', 'M', 'O')
|
if (!data || (!M3D_CHUNKMAGIC(data, '3', 'D', 'M', 'O')
|
||||||
#ifdef M3D_ASCII
|
|
||||||
&& !M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o')
|
&& !M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o')
|
||||||
#endif
|
|
||||||
))
|
))
|
||||||
return NULL;
|
return NULL;
|
||||||
model = (m3d_t *)M3D_MALLOC(sizeof(m3d_t));
|
model = (m3d_t *)M3D_MALLOC(sizeof(m3d_t));
|
||||||
|
@ -2457,7 +2439,6 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
|
||||||
model->texture = mtllib->texture;
|
model->texture = mtllib->texture;
|
||||||
model->flags |= M3D_FLG_MTLLIB;
|
model->flags |= M3D_FLG_MTLLIB;
|
||||||
}
|
}
|
||||||
#ifdef M3D_ASCII
|
|
||||||
/* ASCII variant? */
|
/* ASCII variant? */
|
||||||
if (M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o')) {
|
if (M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o')) {
|
||||||
model->errcode = M3D_ERR_BADFILE;
|
model->errcode = M3D_ERR_BADFILE;
|
||||||
|
@ -3034,7 +3015,6 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
|
||||||
setlocale(LC_NUMERIC, ol);
|
setlocale(LC_NUMERIC, ol);
|
||||||
goto postprocess;
|
goto postprocess;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* Binary variant */
|
/* Binary variant */
|
||||||
if (!M3D_CHUNKMAGIC(data + 8, 'H', 'E', 'A', 'D')) {
|
if (!M3D_CHUNKMAGIC(data + 8, 'H', 'E', 'A', 'D')) {
|
||||||
buff = (unsigned char *)stbi_zlib_decode_malloc_guesssize_headerflag((const char *)data + 8, ((m3dchunk_t *)data)->length - 8,
|
buff = (unsigned char *)stbi_zlib_decode_malloc_guesssize_headerflag((const char *)data + 8, ((m3dchunk_t *)data)->length - 8,
|
||||||
|
@ -3698,9 +3678,7 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* calculate normals, normalize skin weights, create bone/vertex cross-references and calculate transform matrices */
|
/* calculate normals, normalize skin weights, create bone/vertex cross-references and calculate transform matrices */
|
||||||
#ifdef M3D_ASCII
|
|
||||||
postprocess:
|
postprocess:
|
||||||
#endif
|
|
||||||
if (model) {
|
if (model) {
|
||||||
M3D_LOG("Post-process");
|
M3D_LOG("Post-process");
|
||||||
#ifdef M3D_PROFILING
|
#ifdef M3D_PROFILING
|
||||||
|
@ -3989,7 +3967,6 @@ void m3d_free(m3d_t *model) {
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
||||||
if (!model) return;
|
if (!model) return;
|
||||||
#ifdef M3D_ASCII
|
|
||||||
/* if model imported from ASCII, we have to free all strings as well */
|
/* if model imported from ASCII, we have to free all strings as well */
|
||||||
if (model->flags & M3D_FLG_FREESTR) {
|
if (model->flags & M3D_FLG_FREESTR) {
|
||||||
if (model->name) M3D_FREE(model->name);
|
if (model->name) M3D_FREE(model->name);
|
||||||
|
@ -4047,7 +4024,6 @@ void m3d_free(m3d_t *model) {
|
||||||
if (model->preview.data)
|
if (model->preview.data)
|
||||||
M3D_FREE(model->preview.data);
|
M3D_FREE(model->preview.data);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (model->flags & M3D_FLG_FREERAW) M3D_FREE(model->raw);
|
if (model->flags & M3D_FLG_FREERAW) M3D_FREE(model->raw);
|
||||||
|
|
||||||
if (model->tmap) M3D_FREE(model->tmap);
|
if (model->tmap) M3D_FREE(model->tmap);
|
||||||
|
@ -4315,7 +4291,6 @@ static void _m3d_round(int quality, m3dv_t *src, m3dv_t *dst) {
|
||||||
if (dst->w == (M3D_FLOAT)-0.0) dst->w = (M3D_FLOAT)0.0;
|
if (dst->w == (M3D_FLOAT)-0.0) dst->w = (M3D_FLOAT)0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef M3D_ASCII
|
|
||||||
/* add a bone to ascii output */
|
/* add a bone to ascii output */
|
||||||
static char *_m3d_prtbone(char *ptr, m3db_t *bone, M3D_INDEX numbone, M3D_INDEX parent, uint32_t level, M3D_INDEX *vrtxidx) {
|
static char *_m3d_prtbone(char *ptr, m3db_t *bone, M3D_INDEX numbone, M3D_INDEX parent, uint32_t level, M3D_INDEX *vrtxidx) {
|
||||||
uint32_t i, j;
|
uint32_t i, j;
|
||||||
|
@ -4334,16 +4309,13 @@ static char *_m3d_prtbone(char *ptr, m3db_t *bone, M3D_INDEX numbone, M3D_INDEX
|
||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to encode an in-memory model into on storage Model 3D format
|
* Function to encode an in-memory model into on storage Model 3D format
|
||||||
*/
|
*/
|
||||||
unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size) {
|
unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size) {
|
||||||
#ifdef M3D_ASCII
|
|
||||||
const char *ol;
|
const char *ol;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
#endif
|
|
||||||
char vc_s, vi_s, si_s, ci_s, ti_s, bi_s, nb_s, sk_s, fc_s, hi_s, fi_s;
|
char vc_s, vi_s, si_s, ci_s, ti_s, bi_s, nb_s, sk_s, fc_s, hi_s, fi_s;
|
||||||
char *sn = NULL, *sl = NULL, *sa = NULL, *sd = NULL;
|
char *sn = NULL, *sl = NULL, *sa = NULL, *sd = NULL;
|
||||||
unsigned char *out = NULL, *z = NULL, weights[M3D_NUMBONE], *norm = NULL;
|
unsigned char *out = NULL, *z = NULL, weights[M3D_NUMBONE], *norm = NULL;
|
||||||
|
@ -4369,9 +4341,7 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
model->errcode = M3D_SUCCESS;
|
model->errcode = M3D_SUCCESS;
|
||||||
#ifdef M3D_ASCII
|
|
||||||
if (flags & M3D_EXP_ASCII) quality = M3D_EXP_DOUBLE;
|
if (flags & M3D_EXP_ASCII) quality = M3D_EXP_DOUBLE;
|
||||||
#endif
|
|
||||||
vrtxidx = (M3D_INDEX *)M3D_MALLOC(model->numvertex * sizeof(M3D_INDEX));
|
vrtxidx = (M3D_INDEX *)M3D_MALLOC(model->numvertex * sizeof(M3D_INDEX));
|
||||||
if (!vrtxidx) goto memerr;
|
if (!vrtxidx) goto memerr;
|
||||||
memset(vrtxidx, 255, model->numvertex * sizeof(M3D_INDEX));
|
memset(vrtxidx, 255, model->numvertex * sizeof(M3D_INDEX));
|
||||||
|
@ -4800,7 +4770,6 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
}
|
}
|
||||||
|
|
||||||
M3D_LOG("Serializing model");
|
M3D_LOG("Serializing model");
|
||||||
#ifdef M3D_ASCII
|
|
||||||
if (flags & M3D_EXP_ASCII) {
|
if (flags & M3D_EXP_ASCII) {
|
||||||
/* use CRLF to make model creators on Win happy... */
|
/* use CRLF to make model creators on Win happy... */
|
||||||
sd = _m3d_safestr(model->desc, 1);
|
sd = _m3d_safestr(model->desc, 1);
|
||||||
|
@ -5073,7 +5042,7 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
ptr += sprintf(ptr, "\r\n");
|
ptr += sprintf(ptr, "\r\n");
|
||||||
}
|
}
|
||||||
/* mathematical shapes face */
|
/* mathematical shapes face */
|
||||||
if (model->numshape !(flags & M3D_EXP_NOFACE)) {
|
if (model->numshape && (!(flags & M3D_EXP_NOFACE))) {
|
||||||
for (j = 0; j < model->numshape; j++) {
|
for (j = 0; j < model->numshape; j++) {
|
||||||
sn = _m3d_safestr(model->shape[j].name, 0);
|
sn = _m3d_safestr(model->shape[j].name, 0);
|
||||||
if (!sn) {
|
if (!sn) {
|
||||||
|
@ -5287,7 +5256,6 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
if (!out) goto memerr;
|
if (!out) goto memerr;
|
||||||
out[len] = 0;
|
out[len] = 0;
|
||||||
} else
|
} else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* stricly only use LF (newline) in binary */
|
/* stricly only use LF (newline) in binary */
|
||||||
sd = _m3d_safestr(model->desc, 3);
|
sd = _m3d_safestr(model->desc, 3);
|
||||||
|
|
|
@ -427,10 +427,6 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
aiVector3D& vNormal = pcMesh->mNormals[iCurrent];
|
aiVector3D& vNormal = pcMesh->mNormals[iCurrent];
|
||||||
LookupNormalIndex(pcVerts[iIndex].lightNormalIndex,vNormal);
|
LookupNormalIndex(pcVerts[iIndex].lightNormalIndex,vNormal);
|
||||||
|
|
||||||
// flip z and y to become right-handed
|
|
||||||
std::swap((float&)vNormal.z,(float&)vNormal.y);
|
|
||||||
std::swap((float&)vec.z,(float&)vec.y);
|
|
||||||
|
|
||||||
if (m_pcHeader->numTexCoords) {
|
if (m_pcHeader->numTexCoords) {
|
||||||
// validate texture coordinates
|
// validate texture coordinates
|
||||||
iIndex = pcTriangles[i].textureIndices[c];
|
iIndex = pcTriangles[i].textureIndices[c];
|
||||||
|
@ -448,7 +444,15 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
pScene->mMeshes[0]->mFaces[i].mIndices[c] = iCurrent;
|
pScene->mMeshes[0]->mFaces[i].mIndices[c] = iCurrent;
|
||||||
}
|
}
|
||||||
|
// flip the face order
|
||||||
|
std::swap( pScene->mMeshes[0]->mFaces[i].mIndices[0], pScene->mMeshes[0]->mFaces[i].mIndices[2] );
|
||||||
}
|
}
|
||||||
|
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||||
|
pScene->mRootNode->mTransformation = aiMatrix4x4(
|
||||||
|
1.f, 0.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 1.f, 0.f,
|
||||||
|
0.f, -1.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 0.f, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_MD2_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_MD2_IMPORTER
|
||||||
|
|
|
@ -869,7 +869,7 @@ void HL1MDLLoader::read_meshes() {
|
||||||
scene_mesh->mNormals[v] = bind_pose_normals[pTrivert->normindex];
|
scene_mesh->mNormals[v] = bind_pose_normals[pTrivert->normindex];
|
||||||
scene_mesh->mTextureCoords[0][v] = aiVector3D(
|
scene_mesh->mTextureCoords[0][v] = aiVector3D(
|
||||||
pTrivert->s * texcoords_s_scale,
|
pTrivert->s * texcoords_s_scale,
|
||||||
pTrivert->t * texcoords_t_scale, 0);
|
pTrivert->t * -texcoords_t_scale, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add face and indices.
|
// Add face and indices.
|
||||||
|
@ -880,9 +880,9 @@ void HL1MDLLoader::read_meshes() {
|
||||||
aiFace *face = &scene_mesh->mFaces[f];
|
aiFace *face = &scene_mesh->mFaces[f];
|
||||||
face->mNumIndices = 3;
|
face->mNumIndices = 3;
|
||||||
face->mIndices = new unsigned int[3];
|
face->mIndices = new unsigned int[3];
|
||||||
face->mIndices[0] = mesh_faces[f].v0;
|
face->mIndices[0] = mesh_faces[f].v2;
|
||||||
face->mIndices[1] = mesh_faces[f].v1;
|
face->mIndices[1] = mesh_faces[f].v1;
|
||||||
face->mIndices[2] = mesh_faces[f].v2;
|
face->mIndices[2] = mesh_faces[f].v0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add mesh bones.
|
// Add mesh bones.
|
||||||
|
|
|
@ -199,6 +199,7 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
||||||
const uint32_t iMagicWord = *((uint32_t *)mBuffer);
|
const uint32_t iMagicWord = *((uint32_t *)mBuffer);
|
||||||
|
|
||||||
// Determine the file subtype and call the appropriate member function
|
// Determine the file subtype and call the appropriate member function
|
||||||
|
bool is_half_life = false;
|
||||||
|
|
||||||
// Original Quake1 format
|
// Original Quake1 format
|
||||||
if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) {
|
if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) {
|
||||||
|
@ -240,6 +241,7 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
||||||
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;
|
||||||
|
is_half_life = true;
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -255,9 +257,19 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
||||||
". Magic word (", ai_str_toprintable((const char *)&iMagicWord, sizeof(iMagicWord)), ") is not known");
|
". Magic word (", ai_str_toprintable((const char *)&iMagicWord, sizeof(iMagicWord)), ") is not known");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
if (is_half_life){
|
||||||
pScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f,
|
// Now rotate the whole scene 90 degrees around the z and x axes to convert to internal coordinate system
|
||||||
0.f, 0.f, 1.f, 0.f, 0.f, -1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f);
|
pScene->mRootNode->mTransformation = aiMatrix4x4(
|
||||||
|
0.f, -1.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 1.f, 0.f,
|
||||||
|
-1.f, 0.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 0.f, 1.f);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||||
|
pScene->mRootNode->mTransformation = aiMatrix4x4(1.f, 0.f, 0.f, 0.f,
|
||||||
|
0.f, 0.f, 1.f, 0.f, 0.f, -1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f);
|
||||||
|
}
|
||||||
|
|
||||||
DeleteBufferAndCleanup();
|
DeleteBufferAndCleanup();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ if os.name=='posix':
|
||||||
additional_dirs.append('./')
|
additional_dirs.append('./')
|
||||||
additional_dirs.append('/usr/lib/')
|
additional_dirs.append('/usr/lib/')
|
||||||
additional_dirs.append('/usr/lib/x86_64-linux-gnu/')
|
additional_dirs.append('/usr/lib/x86_64-linux-gnu/')
|
||||||
|
additional_dirs.append('/usr/lib/aarch64-linux-gnu/')
|
||||||
additional_dirs.append('/usr/local/lib/')
|
additional_dirs.append('/usr/local/lib/')
|
||||||
|
|
||||||
if 'LD_LIBRARY_PATH' in os.environ:
|
if 'LD_LIBRARY_PATH' in os.environ:
|
||||||
|
|
Loading…
Reference in New Issue