diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index e7cdcc864..af4b11cf7 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -62,7 +62,6 @@ namespace FBX { #define MAGIC_NODE_TAG "_$AssimpFbx$" -#define MAGIC_NULL_TAG "_$AssimpFbxNull$" #define CONVERT_FBX_TIME(time) static_cast(time) / 46186158000L @@ -95,7 +94,13 @@ public: TransformationComp_MAXIMUM }; + enum MetadataKeys + { + MetadataKeys_UserProperties = 0, + MetadataKeys_IsNull, + MetadataKeys_MAXIMUM + }; public: @@ -257,14 +262,6 @@ private: ConvertCameras(*model); } - // preserve the info that a node was marked as Null node - // in the original file. - if(model->IsNull()) { - const std::string& new_name = original_name + MAGIC_NULL_TAG; - RenameNode(original_name, new_name); - name_carrier->mName.Set( new_name.c_str() ); - } - nodes.push_back(nodes_chain.front()); nodes_chain.clear(); } @@ -764,20 +761,20 @@ private: { const PropertyTable& props = model.Props(); - // find user defined properties - const std::string& userProps = PropertyGet(props, "UDP3DSMAX", ""); - - //setup metadata //TODO: make metadata more friendly (eg. have Add()/Remove() functions to be easier to use) + //create metadata on node aiMetadata* data = new aiMetadata(); - data->mNumProperties = 1; + data->mNumProperties = MetadataKeys_MAXIMUM; data->mKeys = new aiString[data->mNumProperties](); data->mValues = new aiString[data->mNumProperties](); - - //add user properties - data->mKeys[0].Set("UserProperties"); - data->mValues[0].Set(userProps); - nd.mMetaData = data; + + // find user defined properties + data->mKeys[MetadataKeys_UserProperties].Set("UserProperties"); + data->mValues[MetadataKeys_UserProperties].Set(PropertyGet(props, "UDP3DSMAX", "")); + + // preserve the info that a node was marked as Null node in the original file. + data->mKeys[MetadataKeys_IsNull].Set("IsNull"); + data->mValues[MetadataKeys_IsNull].Set(model.IsNull() ? "true" : "false"); } // ------------------------------------------------------------------------------------------------ diff --git a/code/PlyParser.cpp b/code/PlyParser.cpp index 792392511..67f5b0bc8 100644 --- a/code/PlyParser.cpp +++ b/code/PlyParser.cpp @@ -427,7 +427,7 @@ bool PLY::DOM::SkipComments (const char* pCur, } // ------------------------------------------------------------------------------------------------ -bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut) +bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut,bool isBinary) { ai_assert(NULL != pCur && NULL != pCurOut); DefaultLogger::get()->debug("PLY::DOM::ParseHeader() begin"); @@ -458,7 +458,10 @@ bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut) SkipLine(&pCur); } } - SkipSpacesAndLineEnd(pCur,&pCur); + if(!isBinary) + { // it would occur an error, if binary data start with values as space or line end. + SkipSpacesAndLineEnd(pCur,&pCur); + } *pCurOut = pCur; DefaultLogger::get()->debug("PLY::DOM::ParseHeader() succeeded"); @@ -527,7 +530,7 @@ bool PLY::DOM::ParseInstanceBinary (const char* pCur,DOM* p_pcOut,bool p_bBE) DefaultLogger::get()->debug("PLY::DOM::ParseInstanceBinary() begin"); - if(!p_pcOut->ParseHeader(pCur,&pCur)) + if(!p_pcOut->ParseHeader(pCur,&pCur,true)) { DefaultLogger::get()->debug("PLY::DOM::ParseInstanceBinary() failure"); return false; @@ -550,7 +553,7 @@ bool PLY::DOM::ParseInstance (const char* pCur,DOM* p_pcOut) DefaultLogger::get()->debug("PLY::DOM::ParseInstance() begin"); - if(!p_pcOut->ParseHeader(pCur,&pCur)) + if(!p_pcOut->ParseHeader(pCur,&pCur,false)) { DefaultLogger::get()->debug("PLY::DOM::ParseInstance() failure"); return false; diff --git a/code/PlyParser.h b/code/PlyParser.h index d02e39d85..47ea1c265 100644 --- a/code/PlyParser.h +++ b/code/PlyParser.h @@ -434,7 +434,7 @@ private: // ------------------------------------------------------------------- //! Handle the file header and read all element descriptions - bool ParseHeader (const char* pCur,const char** pCurOut); + bool ParseHeader (const char* pCur,const char** pCurOut, bool p_bBE); // ------------------------------------------------------------------- //! Read in all element instance lists