BoneTransform.cpp 826 B

12345678910111213141516171819202122232425
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #include "BoneTransform.h"
  9. Matrix4 BoneTransform::ToMatrix() const
  10. {
  11. Matrix4 rot = Matrix4::CreateFromQuaternion(mRotation);
  12. Matrix4 trans = Matrix4::CreateTranslation(mTranslation);
  13. return rot * trans;
  14. }
  15. BoneTransform BoneTransform::Interpolate(const BoneTransform& a, const BoneTransform& b, float f)
  16. {
  17. BoneTransform retVal;
  18. retVal.mRotation = Quaternion::Slerp(a.mRotation, b.mRotation, f);
  19. retVal.mTranslation = Vector3::Lerp(a.mTranslation, b.mTranslation, f);
  20. return retVal;
  21. }