Transform.h 759 B

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