From 5bf974ae3b86bac89ca250b79a456d90ea1eb50d Mon Sep 17 00:00:00 2001 From: aoowweenn Date: Wed, 22 Mar 2017 17:06:55 +0800 Subject: [PATCH] keep writing dae skinning --- code/ColladaExporter.cpp | 19 +++++++++++++++++++ code/ColladaExporter.h | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 8c5b03e77..278ded66a 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -860,6 +860,15 @@ void WriteController( size_t pIndex) PopTag(); mOutput << startstr << "" << endstr; + std::vector bind_poses; + bind_poses.reserve(mesh->mNumBones * 16); + for( size_t i = 0; i< mesh->mNumBones; ++i) + for( size_t j = 0; j < 4; ++j) + bind_poses.insert(bind_poses.end(), mesh->mBones[i]->mOffsetMatrix[0], mesh->mBones[i]->mOffsetMatrix[0] + 4); + + WriteFloatArray( idstr + "-skin-bind_poses", FloatType_Mat4x4, (const ai_real*) bind_poses.data(), bind_poses.size()); + + PopTag(); mOutput << startstr << "" << endstr; @@ -1031,6 +1040,8 @@ void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataTy case FloatType_TexCoord2: floatsPerElement = 2; break; case FloatType_TexCoord3: floatsPerElement = 3; break; case FloatType_Color: floatsPerElement = 3; break; + case FloatType_Mat4x4: floatsPerElement = 16; break; + case FloatType_Weight: floatsPerElement = 1; break; default: return; } @@ -1099,6 +1110,14 @@ void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataTy mOutput << startstr << "" << endstr; mOutput << startstr << "" << endstr; break; + + case FloatType_Mat4x4: + mOutput << startstr << "" << endstr; + break; + + case FloatType_Weight: + mOutput << startstr << "" << endstr; + break; } PopTag(); diff --git a/code/ColladaExporter.h b/code/ColladaExporter.h index 9521e61ad..695b00bfd 100644 --- a/code/ColladaExporter.h +++ b/code/ColladaExporter.h @@ -113,7 +113,7 @@ protected: /// Writes the given mesh void WriteGeometry( size_t pIndex); - enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color }; + enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color, FloatType_Mat4x4, FloatType_Weight }; /// Writes a float array of the given type void WriteFloatArray( const std::string& pIdString, FloatDataType pType, const ai_real* pData, size_t pElementCount);