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

Method CreateAnimation

code/AssetLib/Collada/ColladaLoader.cpp:1100–1473  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Constructs the animation for the given source anim

Source from the content-addressed store, hash-verified

1098// ------------------------------------------------------------------------------------------------
1099// Constructs the animation for the given source anim
1100void ColladaLoader::CreateAnimation(aiScene *pScene, const ColladaParser &pParser, const Animation *pSrcAnim, const std::string &pName) {
1101 // collect a list of animatable nodes
1102 std::vector<const aiNode *> nodes;
1103 CollectNodes(pScene->mRootNode, nodes);
1104
1105 std::vector<aiNodeAnim *> anims;
1106 std::vector<aiMeshMorphAnim *> morphAnims;
1107
1108 for (auto node : nodes) {
1109 // find all the collada anim channels which refer to the current node
1110 std::vector<ChannelEntry> entries;
1111 std::string nodeName = node->mName.data;
1112
1113 // find the collada node corresponding to the aiNode
1114 const Node *srcNode = FindNode(pParser.mRootNode, nodeName);
1115 if (!srcNode) {
1116 continue;
1117 }
1118
1119 // now check all channels if they affect the current node
1120 std::string targetID, subElement;
1121 for (auto cit = pSrcAnim->mChannels.begin();
1122 cit != pSrcAnim->mChannels.end(); ++cit) {
1123 const AnimationChannel &srcChannel = *cit;
1124 ChannelEntry entry;
1125
1126 // we expect the animation target to be of type "nodeName/transformID.subElement". Ignore all others
1127 // find the slash that separates the node name - there should be only one
1128 std::string::size_type slashPos = srcChannel.mTarget.find('/');
1129 if (slashPos == std::string::npos) {
1130 std::string::size_type targetPos = srcChannel.mTarget.find(srcNode->mID);
1131 if (targetPos == std::string::npos) {
1132 continue;
1133 }
1134
1135 // not node transform, but something else. store as unknown animation channel for now
1136 entry.mChannel = &(*cit);
1137 entry.mTargetId = srcChannel.mTarget.substr(targetPos + pSrcAnim->mName.length(),
1138 srcChannel.mTarget.length() - targetPos - pSrcAnim->mName.length());
1139 if (entry.mTargetId.front() == '-') {
1140 entry.mTargetId = entry.mTargetId.substr(1);
1141 }
1142 entries.push_back(entry);
1143 continue;
1144 }
1145 if (srcChannel.mTarget.find('/', slashPos + 1) != std::string::npos) {
1146 continue;
1147 }
1148
1149 targetID.clear();
1150 targetID = srcChannel.mTarget.substr(0, slashPos);
1151 if (targetID != srcNode->mID) {
1152 continue;
1153 }
1154
1155 // find the dot that separates the transformID - there should be only one or zero
1156 std::string::size_type dotPos = srcChannel.mTarget.find('.');
1157 if (dotPos != std::string::npos) {

Callers

nothing calls this directly

Calls 15

DeadlyImportErrorFunction · 0.85
ReadFloatFunction · 0.85
insertMorphTimeValueFunction · 0.85
getWeightAtKeyFunction · 0.85
FindNodeFunction · 0.50
minFunction · 0.50
maxFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
frontMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected