From 9c7de7b2a845cf5e061a934d353dc4d631fd46b2 Mon Sep 17 00:00:00 2001 From: cmdrf Date: Fri, 1 Jul 2016 14:50:46 +0200 Subject: [PATCH 1/4] Update to latest Melange SDK --- CMakeLists.txt | 34 +++++++++++++++++++--------------- code/C4DImporter.cpp | 20 +++++++++++++------- code/C4DImporter.h | 14 +++++++------- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fbc43b72..d1cd2b320 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,31 +229,35 @@ SET ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER OFF CACHE BOOL IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER) IF ( MSVC ) - SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/_melange/includes") + SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/includes") # pick the correct prebuilt library - IF(MSVC11) - SET(C4D_LIB_POSTFIX "_2012md") + IF(MSVC14) + SET(C4D_LIB_POSTFIX "_2015") + ELSEIF(MSVC12) + SET(C4D_LIB_POSTFIX "_2013") + ELSEIF(MSVC11) + SET(C4D_LIB_POSTFIX "_2012") ELSEIF(MSVC10) - SET(C4D_LIB_POSTFIX "_2010md") + SET(C4D_LIB_POSTFIX "_2010") ELSEIF(MSVC90) - SET(C4D_LIB_POSTFIX "_2008md") + SET(C4D_LIB_POSTFIX "_2008") ELSE() MESSAGE( FATAL_ERROR - "C4D is currently only supported with MSVC 9, 10, 11" + "C4D is currently only supported with MSVC 9, 10, 11, 12, 14" ) ENDIF() - IF(CMAKE_CL_64) - SET(C4D_LIB_ARCH_POSTFIX "_x64") - ELSE() - SET(C4D_LIB_ARCH_POSTFIX "") - ENDIF() + SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/libraries/win") - SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/_melange/lib/WIN") - - SET(C4D_DEBUG_LIBRARY "${C4D_LIB_BASE_PATH}/debug/_melange_lib${C4D_LIB_ARCH_POSTFIX}${C4D_LIB_POSTFIX}.lib") - SET(C4D_RELEASE_LIBRARY "${C4D_LIB_BASE_PATH}/release/_melange_lib${C4D_LIB_ARCH_POSTFIX}${C4D_LIB_POSTFIX}.lib") + SET(C4D_DEBUG_LIBRARY + "${C4D_LIB_BASE_PATH}/melangelib${C4D_LIB_POSTFIX}/melangelib_debug.lib" + "${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_debug.lib" + ) + SET(C4D_RELEASE_LIBRARY + "${C4D_LIB_BASE_PATH}/melangelib${C4D_LIB_POSTFIX}/melangelib_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.) SET(C4D_EXTRA_LIBRARIES WSock32.lib Winmm.lib) diff --git a/code/C4DImporter.cpp b/code/C4DImporter.cpp index 11e3d0c54..5695ca7fd 100644 --- a/code/C4DImporter.cpp +++ b/code/C4DImporter.cpp @@ -52,6 +52,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "C4DImporter.h" #include "TinyFormatter.h" +#include +#include +#include +#include #if defined(_M_X64) || defined(__amd64__) # define __C4D_64BIT @@ -61,10 +65,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "c4d_file.h" #include "default_alien_overloads.h" -using namespace _melange_; +using namespace melange; // overload this function and fill in your own unique data -void GetWriterInfo(LONG &id, String &appname) +void GetWriterInfo(int &id, String &appname) { id = 2424226; appname = "Open Asset Import Library"; @@ -197,7 +201,7 @@ void C4DImporter::InternReadFile( const std::string& pFile, // ------------------------------------------------------------------------------------------------ -bool C4DImporter::ReadShader(aiMaterial* out, _melange_::BaseShader* shader) +bool C4DImporter::ReadShader(aiMaterial* out, melange::BaseShader* shader) { // based on Melange sample code (C4DImportExport.cpp) while(shader) { @@ -263,7 +267,7 @@ bool C4DImporter::ReadShader(aiMaterial* out, _melange_::BaseShader* shader) // ------------------------------------------------------------------------------------------------ -void C4DImporter::ReadMaterials(_melange_::BaseMaterial* mat) +void C4DImporter::ReadMaterials(melange::BaseMaterial* mat) { // based on Melange sample code while (mat) @@ -288,7 +292,7 @@ void C4DImporter::ReadMaterials(_melange_::BaseMaterial* mat) mat->GetParameter(MATERIAL_COLOR_COLOR, data); Vector color = data.GetVector(); mat->GetParameter(MATERIAL_COLOR_BRIGHTNESS, data); - const Real brightness = data.GetReal(); + const Float brightness = data.GetFloat(); color *= brightness; @@ -507,11 +511,13 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object) // copy normals if (normals_src) { - if(i >= normals_src->GetNormalCount()) { + if(i >= normals_src->GetDataCount()) { LogError("unexpected number of normals, ignoring"); } else { - const NormalStruct& nor = normals_src->GetNormals(i); + ConstNormalHandle normal_handle = normals_src->GetDataAddressR(); + NormalStruct nor; + NormalTag::Get(normal_handle, i, nor); normals->x = nor.a.x; normals->y = nor.a.y; normals->z = nor.a.z; diff --git a/code/C4DImporter.h b/code/C4DImporter.h index 5ecf4fdc8..28abde51e 100644 --- a/code/C4DImporter.h +++ b/code/C4DImporter.h @@ -54,7 +54,7 @@ struct aiMaterial; struct aiImporterDesc; -namespace _melange_ { +namespace melange { class BaseObject; // c4d_file.h class PolygonObject; class BaseMaterial; @@ -103,17 +103,17 @@ protected: private: - void ReadMaterials(_melange_::BaseMaterial* mat); - void RecurseHierarchy(_melange_::BaseObject* object, aiNode* parent); - aiMesh* ReadMesh(_melange_::BaseObject* object); - unsigned int ResolveMaterial(_melange_::PolygonObject* obj); + void ReadMaterials(melange::BaseMaterial* mat); + void RecurseHierarchy(melange::BaseObject* object, aiNode* parent); + aiMesh* ReadMesh(melange::BaseObject* object); + unsigned int ResolveMaterial(melange::PolygonObject* obj); - bool ReadShader(aiMaterial* out, _melange_::BaseShader* shader); + bool ReadShader(aiMaterial* out, melange::BaseShader* shader); std::vector meshes; std::vector materials; - typedef std::map<_melange_::BaseMaterial*, unsigned int> MaterialMap; + typedef std::map MaterialMap; MaterialMap material_mapping; }; // !class C4DImporter From 616aa022a78a1fac47bda130fe6c125482fd0558 Mon Sep 17 00:00:00 2001 From: Fabian Herb Date: Fri, 1 Jul 2016 16:57:45 +0200 Subject: [PATCH 2/4] CMake: whitespace consistency, variable naming --- CMakeLists.txt | 36 +++++++++++++++++------------------- code/CMakeLists.txt | 4 ++-- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1cd2b320..751c7036d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,32 +232,30 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER) SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/includes") # pick the correct prebuilt library - IF(MSVC14) - SET(C4D_LIB_POSTFIX "_2015") - ELSEIF(MSVC12) - SET(C4D_LIB_POSTFIX "_2013") - ELSEIF(MSVC11) - SET(C4D_LIB_POSTFIX "_2012") + IF(MSVC14) + SET(C4D_LIB_POSTFIX "_2015") + ELSEIF(MSVC12) + SET(C4D_LIB_POSTFIX "_2013") + ELSEIF(MSVC11) + SET(C4D_LIB_POSTFIX "_2012") ELSEIF(MSVC10) - SET(C4D_LIB_POSTFIX "_2010") - ELSEIF(MSVC90) - SET(C4D_LIB_POSTFIX "_2008") + SET(C4D_LIB_POSTFIX "_2010") ELSE() MESSAGE( FATAL_ERROR - "C4D is currently only supported with MSVC 9, 10, 11, 12, 14" + "C4D is currently only supported with MSVC 10, 11, 12, 14" ) ENDIF() - SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/libraries/win") + SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/libraries/win") - SET(C4D_DEBUG_LIBRARY - "${C4D_LIB_BASE_PATH}/melangelib${C4D_LIB_POSTFIX}/melangelib_debug.lib" - "${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_debug.lib" - ) - SET(C4D_RELEASE_LIBRARY - "${C4D_LIB_BASE_PATH}/melangelib${C4D_LIB_POSTFIX}/melangelib_release.lib" - "${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_release.lib" - ) + SET(C4D_DEBUG_LIBRARIES + "${C4D_LIB_BASE_PATH}/melangelib${C4D_LIB_POSTFIX}/melangelib_debug.lib" + "${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_debug.lib" + ) + SET(C4D_RELEASE_LIBRARIES + "${C4D_LIB_BASE_PATH}/melangelib${C4D_LIB_POSTFIX}/melangelib_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.) SET(C4D_EXTRA_LIBRARIES WSock32.lib Winmm.lib) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 2d39a00c2..35ecf5020 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -775,8 +775,8 @@ if(ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM) endif(ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM) IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER) - TARGET_LINK_LIBRARIES(assimp optimized ${C4D_RELEASE_LIBRARY}) - TARGET_LINK_LIBRARIES(assimp debug ${C4D_DEBUG_LIBRARY}) + TARGET_LINK_LIBRARIES(assimp optimized ${C4D_RELEASE_LIBRARIES}) + TARGET_LINK_LIBRARIES(assimp debug ${C4D_DEBUG_LIBRARIES}) TARGET_LINK_LIBRARIES(assimp ${C4D_EXTRA_LIBRARIES}) ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER) From 3c7dd2b302c10ab621c36d6d4e2b5a33c9d2c4e0 Mon Sep 17 00:00:00 2001 From: Fabian Herb Date: Fri, 1 Jul 2016 17:02:54 +0200 Subject: [PATCH 3/4] More whitespace consistency --- code/C4DImporter.cpp | 10 +++++----- code/C4DImporter.h | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/code/C4DImporter.cpp b/code/C4DImporter.cpp index 5695ca7fd..449f8d255 100644 --- a/code/C4DImporter.cpp +++ b/code/C4DImporter.cpp @@ -292,7 +292,7 @@ void C4DImporter::ReadMaterials(melange::BaseMaterial* mat) mat->GetParameter(MATERIAL_COLOR_COLOR, data); Vector color = data.GetVector(); mat->GetParameter(MATERIAL_COLOR_BRIGHTNESS, data); - const Float brightness = data.GetFloat(); + const Float brightness = data.GetFloat(); color *= brightness; @@ -511,13 +511,13 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object) // copy normals if (normals_src) { - if(i >= normals_src->GetDataCount()) { + if(i >= normals_src->GetDataCount()) { LogError("unexpected number of normals, ignoring"); } else { - ConstNormalHandle normal_handle = normals_src->GetDataAddressR(); - NormalStruct nor; - NormalTag::Get(normal_handle, i, nor); + ConstNormalHandle normal_handle = normals_src->GetDataAddressR(); + NormalStruct nor; + NormalTag::Get(normal_handle, i, nor); normals->x = nor.a.x; normals->y = nor.a.y; normals->z = nor.a.z; diff --git a/code/C4DImporter.h b/code/C4DImporter.h index 28abde51e..3ba2a17c6 100644 --- a/code/C4DImporter.h +++ b/code/C4DImporter.h @@ -103,17 +103,17 @@ protected: private: - void ReadMaterials(melange::BaseMaterial* mat); - void RecurseHierarchy(melange::BaseObject* object, aiNode* parent); - aiMesh* ReadMesh(melange::BaseObject* object); - unsigned int ResolveMaterial(melange::PolygonObject* obj); + void ReadMaterials(melange::BaseMaterial* mat); + void RecurseHierarchy(melange::BaseObject* object, aiNode* parent); + aiMesh* ReadMesh(melange::BaseObject* object); + unsigned int ResolveMaterial(melange::PolygonObject* obj); - bool ReadShader(aiMaterial* out, melange::BaseShader* shader); + bool ReadShader(aiMaterial* out, melange::BaseShader* shader); std::vector meshes; std::vector materials; - typedef std::map MaterialMap; + typedef std::map MaterialMap; MaterialMap material_mapping; }; // !class C4DImporter From 7b08233ef257c86778b47edf1a21144958c466fc Mon Sep 17 00:00:00 2001 From: Fabian Herb Date: Fri, 1 Jul 2016 17:08:28 +0200 Subject: [PATCH 4/4] Fix identation --- code/C4DImporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/C4DImporter.cpp b/code/C4DImporter.cpp index 449f8d255..252766ca6 100644 --- a/code/C4DImporter.cpp +++ b/code/C4DImporter.cpp @@ -511,7 +511,7 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object) // copy normals if (normals_src) { - if(i >= normals_src->GetDataCount()) { + if(i >= normals_src->GetDataCount()) { LogError("unexpected number of normals, ignoring"); } else {