MCPcopy Create free account
hub / github.com/assimp/assimp / WriteAnimationLibrary

Method WriteAnimationLibrary

code/AssetLib/Collada/ColladaExporter.cpp:1340–1501  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1338}
1339// ------------------------------------------------------------------------------------------------
1340void ColladaExporter::WriteAnimationLibrary(size_t pIndex) {
1341 const aiAnimation *anim = mScene->mAnimations[pIndex];
1342 if (anim == nullptr) {
1343 return;
1344 }
1345
1346 if (anim->mNumChannels == 0 && anim->mNumMeshChannels == 0 && anim->mNumMorphMeshChannels == 0) {
1347 return;
1348 }
1349
1350 const std::string animationNameEscaped = GetObjectName(AiObjectType::Animation, pIndex);
1351 const std::string idstrEscaped = GetObjectUniqueId(AiObjectType::Animation, pIndex);
1352
1353 mOutput << startstr << "<animation id=\"" + idstrEscaped + "\" name=\"" + animationNameEscaped + "\">" << endstr;
1354 PushTag();
1355
1356 std::string cur_node_idstr;
1357 for (size_t a = 0; a < anim->mNumChannels; ++a) {
1358 const aiNodeAnim *nodeAnim = anim->mChannels[a];
1359 if (nodeAnim == nullptr) {
1360 continue;
1361 }
1362
1363 // sanity checks
1364 if (nodeAnim->mNumPositionKeys != nodeAnim->mNumScalingKeys || nodeAnim->mNumPositionKeys != nodeAnim->mNumRotationKeys) {
1365 continue;
1366 }
1367
1368 {
1369 cur_node_idstr.clear();
1370 cur_node_idstr += nodeAnim->mNodeName.data;
1371 cur_node_idstr += std::string("_matrix-input");
1372
1373 std::vector<ai_real> frames;
1374 for (size_t i = 0; i < nodeAnim->mNumPositionKeys; ++i) {
1375 frames.push_back(static_cast<ai_real>(nodeAnim->mPositionKeys[i].mTime));
1376 }
1377
1378 WriteFloatArray(cur_node_idstr, FloatType_Time, (const ai_real *)frames.data(), frames.size());
1379 frames.clear();
1380 }
1381
1382 {
1383 cur_node_idstr.clear();
1384
1385 cur_node_idstr += nodeAnim->mNodeName.data;
1386 cur_node_idstr += std::string("_matrix-output");
1387
1388 std::vector<ai_real> keyframes;
1389 keyframes.reserve(nodeAnim->mNumPositionKeys * 16);
1390 for (size_t i = 0; i < nodeAnim->mNumPositionKeys; ++i) {
1391 aiVector3D Scaling = nodeAnim->mScalingKeys[i].mValue;
1392 aiMatrix4x4 ScalingM; // identity
1393 ScalingM[0][0] = Scaling.x;
1394 ScalingM[1][1] = Scaling.y;
1395 ScalingM[2][2] = Scaling.z;
1396
1397 aiQuaternion RotationQ = nodeAnim->mRotationKeys[i].mValue;

Callers

nothing calls this directly

Calls 10

aiMatrix4x4Class · 0.85
XMLIDEncodeFunction · 0.85
GetMatrixMethod · 0.80
emplace_backMethod · 0.80
clearMethod · 0.45
push_backMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
reserveMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected