keep writing dae skinning

pull/1212/head
aoowweenn 2017-03-22 17:06:55 +08:00
parent e5a3038abd
commit 5bf974ae3b
2 changed files with 20 additions and 1 deletions

View File

@ -860,6 +860,15 @@ void WriteController( size_t pIndex)
PopTag(); PopTag();
mOutput << startstr << "</technique_common>" << endstr; mOutput << startstr << "</technique_common>" << endstr;
std::vector<ai_real> 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(); PopTag();
mOutput << startstr << "</skin>" << endstr; mOutput << startstr << "</skin>" << endstr;
@ -1031,6 +1040,8 @@ void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataTy
case FloatType_TexCoord2: floatsPerElement = 2; break; case FloatType_TexCoord2: floatsPerElement = 2; break;
case FloatType_TexCoord3: floatsPerElement = 3; break; case FloatType_TexCoord3: floatsPerElement = 3; break;
case FloatType_Color: floatsPerElement = 3; break; case FloatType_Color: floatsPerElement = 3; break;
case FloatType_Mat4x4: floatsPerElement = 16; break;
case FloatType_Weight: floatsPerElement = 1; break;
default: default:
return; return;
} }
@ -1099,6 +1110,14 @@ void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataTy
mOutput << startstr << "<param name=\"G\" type=\"float\" />" << endstr; mOutput << startstr << "<param name=\"G\" type=\"float\" />" << endstr;
mOutput << startstr << "<param name=\"B\" type=\"float\" />" << endstr; mOutput << startstr << "<param name=\"B\" type=\"float\" />" << endstr;
break; break;
case FloatType_Mat4x4:
mOutput << startstr << "<param name=\"TRANSFORM\" type=\"float4x4\" />" << endstr;
break;
case FloatType_Weight:
mOutput << startstr << "<param name=\"WEIGHT\" type=\"float\" />" << endstr;
break;
} }
PopTag(); PopTag();

View File

@ -113,7 +113,7 @@ protected:
/// Writes the given mesh /// Writes the given mesh
void WriteGeometry( size_t pIndex); 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 /// Writes a float array of the given type
void WriteFloatArray( const std::string& pIdString, FloatDataType pType, const ai_real* pData, size_t pElementCount); void WriteFloatArray( const std::string& pIdString, FloatDataType pType, const ai_real* pData, size_t pElementCount);