Update to latest Melange SDK
parent
e7acd82b8c
commit
9c7de7b2a8
|
@ -229,31 +229,35 @@ SET ( ASSIMP_BUILD_NONFREE_C4D_IMPORTER OFF CACHE BOOL
|
||||||
|
|
||||||
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/_melange/includes")
|
SET(C4D_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/includes")
|
||||||
|
|
||||||
# pick the correct prebuilt library
|
# pick the correct prebuilt library
|
||||||
IF(MSVC11)
|
IF(MSVC14)
|
||||||
SET(C4D_LIB_POSTFIX "_2012md")
|
SET(C4D_LIB_POSTFIX "_2015")
|
||||||
|
ELSEIF(MSVC12)
|
||||||
|
SET(C4D_LIB_POSTFIX "_2013")
|
||||||
|
ELSEIF(MSVC11)
|
||||||
|
SET(C4D_LIB_POSTFIX "_2012")
|
||||||
ELSEIF(MSVC10)
|
ELSEIF(MSVC10)
|
||||||
SET(C4D_LIB_POSTFIX "_2010md")
|
SET(C4D_LIB_POSTFIX "_2010")
|
||||||
ELSEIF(MSVC90)
|
ELSEIF(MSVC90)
|
||||||
SET(C4D_LIB_POSTFIX "_2008md")
|
SET(C4D_LIB_POSTFIX "_2008")
|
||||||
ELSE()
|
ELSE()
|
||||||
MESSAGE( FATAL_ERROR
|
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()
|
ENDIF()
|
||||||
|
|
||||||
IF(CMAKE_CL_64)
|
SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/libraries/win")
|
||||||
SET(C4D_LIB_ARCH_POSTFIX "_x64")
|
|
||||||
ELSE()
|
|
||||||
SET(C4D_LIB_ARCH_POSTFIX "")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(C4D_LIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Melange/_melange/lib/WIN")
|
SET(C4D_DEBUG_LIBRARY
|
||||||
|
"${C4D_LIB_BASE_PATH}/melangelib${C4D_LIB_POSTFIX}/melangelib_debug.lib"
|
||||||
SET(C4D_DEBUG_LIBRARY "${C4D_LIB_BASE_PATH}/debug/_melange_lib${C4D_LIB_ARCH_POSTFIX}${C4D_LIB_POSTFIX}.lib")
|
"${C4D_LIB_BASE_PATH}/jpeglib${C4D_LIB_POSTFIX}/jpeglib_debug.lib"
|
||||||
SET(C4D_RELEASE_LIBRARY "${C4D_LIB_BASE_PATH}/release/_melange_lib${C4D_LIB_ARCH_POSTFIX}${C4D_LIB_POSTFIX}.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.)
|
# winsock and winmm are necessary dependencies of melange (this is undocumented, but true.)
|
||||||
SET(C4D_EXTRA_LIBRARIES WSock32.lib Winmm.lib)
|
SET(C4D_EXTRA_LIBRARIES WSock32.lib Winmm.lib)
|
||||||
|
|
|
@ -52,6 +52,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "C4DImporter.h"
|
#include "C4DImporter.h"
|
||||||
#include "TinyFormatter.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__)
|
#if defined(_M_X64) || defined(__amd64__)
|
||||||
# define __C4D_64BIT
|
# define __C4D_64BIT
|
||||||
|
@ -61,10 +65,10 @@ 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_;
|
using namespace melange;
|
||||||
|
|
||||||
// overload this function and fill in your own unique data
|
// overload this function and fill in your own unique data
|
||||||
void GetWriterInfo(LONG &id, String &appname)
|
void GetWriterInfo(int &id, String &appname)
|
||||||
{
|
{
|
||||||
id = 2424226;
|
id = 2424226;
|
||||||
appname = "Open Asset Import Library";
|
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)
|
// based on Melange sample code (C4DImportExport.cpp)
|
||||||
while(shader) {
|
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
|
// based on Melange sample code
|
||||||
while (mat)
|
while (mat)
|
||||||
|
@ -288,7 +292,7 @@ void C4DImporter::ReadMaterials(_melange_::BaseMaterial* mat)
|
||||||
mat->GetParameter(MATERIAL_COLOR_COLOR, data);
|
mat->GetParameter(MATERIAL_COLOR_COLOR, data);
|
||||||
Vector color = data.GetVector();
|
Vector color = data.GetVector();
|
||||||
mat->GetParameter(MATERIAL_COLOR_BRIGHTNESS, data);
|
mat->GetParameter(MATERIAL_COLOR_BRIGHTNESS, data);
|
||||||
const Real brightness = data.GetReal();
|
const Float brightness = data.GetFloat();
|
||||||
|
|
||||||
color *= brightness;
|
color *= brightness;
|
||||||
|
|
||||||
|
@ -507,11 +511,13 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object)
|
||||||
|
|
||||||
// copy normals
|
// copy normals
|
||||||
if (normals_src) {
|
if (normals_src) {
|
||||||
if(i >= normals_src->GetNormalCount()) {
|
if(i >= normals_src->GetDataCount()) {
|
||||||
LogError("unexpected number of normals, ignoring");
|
LogError("unexpected number of normals, ignoring");
|
||||||
}
|
}
|
||||||
else {
|
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->x = nor.a.x;
|
||||||
normals->y = nor.a.y;
|
normals->y = nor.a.y;
|
||||||
normals->z = nor.a.z;
|
normals->z = nor.a.z;
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct aiMaterial;
|
||||||
|
|
||||||
struct aiImporterDesc;
|
struct aiImporterDesc;
|
||||||
|
|
||||||
namespace _melange_ {
|
namespace melange {
|
||||||
class BaseObject; // c4d_file.h
|
class BaseObject; // c4d_file.h
|
||||||
class PolygonObject;
|
class PolygonObject;
|
||||||
class BaseMaterial;
|
class BaseMaterial;
|
||||||
|
@ -103,17 +103,17 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void ReadMaterials(_melange_::BaseMaterial* mat);
|
void ReadMaterials(melange::BaseMaterial* mat);
|
||||||
void RecurseHierarchy(_melange_::BaseObject* object, aiNode* parent);
|
void RecurseHierarchy(melange::BaseObject* object, aiNode* parent);
|
||||||
aiMesh* ReadMesh(_melange_::BaseObject* object);
|
aiMesh* ReadMesh(melange::BaseObject* object);
|
||||||
unsigned int ResolveMaterial(_melange_::PolygonObject* obj);
|
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<aiMesh*> meshes;
|
||||||
std::vector<aiMaterial*> materials;
|
std::vector<aiMaterial*> materials;
|
||||||
|
|
||||||
typedef std::map<_melange_::BaseMaterial*, unsigned int> MaterialMap;
|
typedef std::map<melange::BaseMaterial*, unsigned int> MaterialMap;
|
||||||
MaterialMap material_mapping;
|
MaterialMap material_mapping;
|
||||||
|
|
||||||
}; // !class C4DImporter
|
}; // !class C4DImporter
|
||||||
|
|
Loading…
Reference in New Issue