diff --git a/Source/Engine/Level/Actors/AnimatedModel.cpp b/Source/Engine/Level/Actors/AnimatedModel.cpp index dc9f2fdf1..73e72ea38 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.cpp +++ b/Source/Engine/Level/Actors/AnimatedModel.cpp @@ -132,6 +132,21 @@ void AnimatedModel::GetCurrentPose(Array& nodesTransformation, bool worl } } +void AnimatedModel::SetCurrentPose(const Array& 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()) diff --git a/Source/Engine/Level/Actors/AnimatedModel.h b/Source/Engine/Level/Actors/AnimatedModel.h index 9e9957fd4..6317e280c 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.h +++ b/Source/Engine/Level/Actors/AnimatedModel.h @@ -187,12 +187,19 @@ public: API_FUNCTION() void PreInitSkinningData(); /// - /// Gets the per-node final transformations. + /// Gets the per-node final transformations (skeleton pose). /// /// The output per-node final transformation matrices. /// True if convert matrices into world-space, otherwise returned values will be in local-space of the actor. API_FUNCTION() void GetCurrentPose(API_PARAM(Out) Array& nodesTransformation, bool worldSpace = false) const; + /// + /// Sets the per-node final transformations (skeleton pose). + /// + /// The per-node final transformation matrices. + /// True if convert matrices from world-space, otherwise values are in local-space of the actor. + API_FUNCTION() void SetCurrentPose(const Array& nodesTransformation, bool worldSpace = false); + /// /// Gets the node final transformation. ///