Add SetCurrentPose to Animated Model

This commit is contained in:
Wojtek Figat
2021-05-13 13:09:06 +02:00
parent 9a3884636b
commit e00e9d1552
2 changed files with 23 additions and 1 deletions

View File

@@ -132,6 +132,21 @@ void AnimatedModel::GetCurrentPose(Array<Matrix>& nodesTransformation, bool worl
}
}
void AnimatedModel::SetCurrentPose(const Array<Matrix>& nodesTransformation, bool worldSpace)
{
if (GraphInstance.NodesPose.Count() == 0)
return;
CHECK(nodesTransformation.Count() == GraphInstance.NodesPose.Count());
GraphInstance.NodesPose = nodesTransformation;
if (worldSpace)
{
Matrix invWorld;
Matrix::Invert(_world, invWorld);
for (auto& m : GraphInstance.NodesPose)
m = invWorld * m;
}
}
void AnimatedModel::GetNodeTransformation(int32 nodeIndex, Matrix& nodeTransformation, bool worldSpace) const
{
if (nodeIndex >= 0 && nodeIndex < GraphInstance.NodesPose.Count())