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())

View File

@@ -187,12 +187,19 @@ public:
API_FUNCTION() void PreInitSkinningData();
/// <summary>
/// Gets the per-node final transformations.
/// Gets the per-node final transformations (skeleton pose).
/// </summary>
/// <param name="nodesTransformation">The output per-node final transformation matrices.</param>
/// <param name="worldSpace">True if convert matrices into world-space, otherwise returned values will be in local-space of the actor.</param>
API_FUNCTION() void GetCurrentPose(API_PARAM(Out) Array<Matrix>& nodesTransformation, bool worldSpace = false) const;
/// <summary>
/// Sets the per-node final transformations (skeleton pose).
/// </summary>
/// <param name="nodesTransformation">The per-node final transformation matrices.</param>
/// <param name="worldSpace">True if convert matrices from world-space, otherwise values are in local-space of the actor.</param>
API_FUNCTION() void SetCurrentPose(const Array<Matrix>& nodesTransformation, bool worldSpace = false);
/// <summary>
/// Gets the node final transformation.
/// </summary>