| 1129 | |
| 1130 | template<typename T> |
| 1131 | void ImportCurve(const ofbx::AnimationCurveNode* curveNode, LinearCurve<T>& curve, AnimInfo& info, void (*extractKeyframe)(const ofbx::Object*, ofbx::DVec3&, const Frame&, T&)) |
| 1132 | { |
| 1133 | if (curveNode == nullptr) |
| 1134 | return; |
| 1135 | const auto keyframes = curve.Resize(info.FramesCount); |
| 1136 | const auto bone = curveNode->getBone(); |
| 1137 | Frame localFrame; |
| 1138 | localFrame.Translation = bone->getLocalTranslation(); |
| 1139 | localFrame.Rotation = bone->getLocalRotation(); |
| 1140 | localFrame.Scaling = bone->getLocalScaling(); |
| 1141 | |
| 1142 | for (int32 i = 0; i < info.FramesCount; i++) |
| 1143 | { |
| 1144 | auto& key = keyframes[i]; |
| 1145 | const double alpha = (double)i / (info.FramesCount - 1); |
| 1146 | const double t = Math::Lerp(info.TimeStart, info.TimeEnd, alpha); |
| 1147 | key.Time = (float)i; |
| 1148 | ofbx::DVec3 trans = curveNode->getNodeLocalTransform(t); |
| 1149 | extractKeyframe(bone, trans, localFrame, key.Value); |
| 1150 | } |
| 1151 | } |
| 1152 | |
| 1153 | void ImportAnimation(int32 index, ModelData& data, OpenFbxImporterData& importerData) |
| 1154 | { |
no test coverage detected