diff --git a/CMakeLists.txt b/CMakeLists.txt index b3b41a180..8951532d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,31 +237,33 @@ 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") - ELSEIF(MSVC90) - SET(C4D_LIB_POSTFIX "_2008md") + SET(C4D_LIB_POSTFIX "_2010") ELSE() MESSAGE( FATAL_ERROR - "C4D is currently only supported with MSVC 9, 10, 11" + "C4D is currently only supported with MSVC 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_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/C4DImporter.cpp b/code/C4DImporter.cpp index 11e3d0c54..252766ca6 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..3ba2a17c6 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 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)