Update to latest Melange SDK

pull/931/head
cmdrf 2016-07-01 14:50:46 +02:00
parent e7acd82b8c
commit 9c7de7b2a8
3 changed files with 39 additions and 29 deletions

View File

@ -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)

View File

@ -52,6 +52,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "C4DImporter.h"
#include "TinyFormatter.h"
#include <memory>
#include <assimp/IOSystem.hpp>
#include <assimp/scene.h>
#include <assimp/ai_assert.h>
#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;

View File

@ -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<aiMesh*> meshes;
std::vector<aiMaterial*> materials;
typedef std::map<_melange_::BaseMaterial*, unsigned int> MaterialMap;
typedef std::map<melange::BaseMaterial*, unsigned int> MaterialMap;
MaterialMap material_mapping;
}; // !class C4DImporter