|
@@ -2,7 +2,7 @@
|
|
|
Open Asset Import Library (assimp)
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
-Copyright (c) 2006-2020, assimp team
|
|
|
+Copyright (c) 2006-2021, assimp team
|
|
|
All rights reserved.
|
|
|
|
|
|
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
|
|
|
|
|
|
#include "C4DImporter.h"
|
|
|
-#include <assimp/TinyFormatter.h>
|
|
|
#include <memory>
|
|
|
#include <assimp/IOSystem.hpp>
|
|
|
#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 "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
|
|
|
void GetWriterInfo(int &id, String &appname) {
|
|
@@ -73,9 +84,6 @@ void GetWriterInfo(int &id, String &appname) {
|
|
|
appname = "Open Asset Import Library";
|
|
|
}
|
|
|
|
|
|
-using namespace Assimp;
|
|
|
-using namespace Assimp::Formatter;
|
|
|
-
|
|
|
namespace Assimp {
|
|
|
template<> const char* LogFunctions<C4DImporter>::Prefix() {
|
|
|
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 {
|
|
|
const std::string& extension = GetExtension(pFile);
|
|
@@ -125,11 +122,6 @@ const aiImporterDesc* C4DImporter::GetInfo () const {
|
|
|
return &desc;
|
|
|
}
|
|
|
|
|
|
-// ------------------------------------------------------------------------------------------------
|
|
|
-void C4DImporter::SetupProperties(const Importer* /*pImp*/) {
|
|
|
- // nothing to be done for the moment
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
// 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) {
|
|
|
- // based on Melange sample code (C4DImportExport.cpp)
|
|
|
+bool C4DImporter::ReadShader(aiMaterial* out, BaseShader* shader) {
|
|
|
+ // based on Cineware sample code (C4DImportExport.cpp)
|
|
|
while(shader) {
|
|
|
if(shader->GetType() == Xlayer) {
|
|
|
BaseContainer* container = shader->GetDataInstance();
|
|
@@ -242,9 +234,7 @@ bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader) {
|
|
|
lsl = lsl->GetNext();
|
|
|
}
|
|
|
} else if ( shader->GetType() == Xbitmap ) {
|
|
|
- aiString path;
|
|
|
- shader->GetFileName().GetString().GetCString(path.data, MAXLEN-1);
|
|
|
- path.length = ::strlen(path.data);
|
|
|
+ auto const path = aiStringFrom(shader->GetFileName().GetString());
|
|
|
out->AddProperty(&path, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
|
|
return true;
|
|
|
} else {
|
|
@@ -257,18 +247,15 @@ bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader) {
|
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
-void C4DImporter::ReadMaterials(melange::BaseMaterial* mat) {
|
|
|
- // based on Melange sample code
|
|
|
+void C4DImporter::ReadMaterials(BaseMaterial* mat) {
|
|
|
+ // based on Cineware sample code
|
|
|
while (mat) {
|
|
|
- const String& name = mat->GetName();
|
|
|
if (mat->GetType() == Mmaterial) {
|
|
|
aiMaterial* out = new aiMaterial();
|
|
|
material_mapping[mat] = static_cast<unsigned int>(materials.size());
|
|
|
materials.push_back(out);
|
|
|
|
|
|
- aiString ai_name;
|
|
|
- name.GetCString(ai_name.data, MAXLEN-1);
|
|
|
- ai_name.length = ::strlen(ai_name.data);
|
|
|
+ auto const ai_name = aiStringFrom(mat->GetName());
|
|
|
out->AddProperty(&ai_name, AI_MATKEY_NAME);
|
|
|
|
|
|
Material& m = dynamic_cast<Material&>(*mat);
|
|
@@ -305,19 +292,15 @@ void C4DImporter::RecurseHierarchy(BaseObject* object, aiNode* parent) {
|
|
|
ai_assert(parent != nullptr );
|
|
|
std::vector<aiNode*> nodes;
|
|
|
|
|
|
- // based on Melange sample code
|
|
|
+ // based on Cineware sample code
|
|
|
while (object) {
|
|
|
- const String& name = object->GetName();
|
|
|
const LONG type = object->GetType();
|
|
|
const Matrix& ml = object->GetMl();
|
|
|
|
|
|
- aiString string;
|
|
|
- name.GetCString(string.data, MAXLEN-1);
|
|
|
- string.length = ::strlen(string.data);
|
|
|
aiNode* const nd = new aiNode();
|
|
|
|
|
|
nd->mParent = parent;
|
|
|
- nd->mName = string;
|
|
|
+ nd->mName = aiStringFrom(object->GetName());
|
|
|
|
|
|
nd->mTransformation.a1 = ml.v1.x;
|
|
|
nd->mTransformation.b1 = ml.v1.y;
|
|
@@ -370,7 +353,7 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object) {
|
|
|
ai_assert(object != nullptr);
|
|
|
ai_assert( object->GetType() == Opolygon );
|
|
|
|
|
|
- // based on Melange sample code
|
|
|
+ // based on Cineware sample code
|
|
|
PolygonObject* const polyObject = dynamic_cast<PolygonObject*>(object);
|
|
|
ai_assert(polyObject != nullptr);
|
|
|
|
|
@@ -618,4 +601,3 @@ unsigned int C4DImporter::ResolveMaterial(PolygonObject* obj) {
|
|
|
}
|
|
|
|
|
|
#endif // ASSIMP_BUILD_NO_C4D_IMPORTER
|
|
|
-
|