Transform.h 720 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include "irrMath.h"
  3. #include <matrix4.h>
  4. #include <vector3d.h>
  5. #include <quaternion.h>
  6. namespace core
  7. {
  8. struct Transform {
  9. vector3df translation;
  10. quaternion rotation;
  11. vector3df scale{1};
  12. Transform interpolate(Transform to, f32 time) const
  13. {
  14. core::quaternion interpolated_rotation;
  15. interpolated_rotation.slerp(rotation, to.rotation, time);
  16. return {
  17. to.translation.getInterpolated(translation, time),
  18. interpolated_rotation,
  19. to.scale.getInterpolated(scale, time),
  20. };
  21. }
  22. matrix4 buildMatrix() const
  23. {
  24. matrix4 T;
  25. T.setTranslation(translation);
  26. matrix4 R;
  27. rotation.getMatrix_transposed(R);
  28. matrix4 S;
  29. S.setScale(scale);
  30. return T * R * S;
  31. }
  32. };
  33. } // end namespace core