CoordinateSystemConverter.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Math/Transform.h>
  10. #include <AzCore/Math/Vector3.h>
  11. #include <AzCore/Math/Quaternion.h>
  12. #include <AzCore/RTTI/RTTI.h>
  13. #include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
  14. namespace AZ::SceneAPI
  15. {
  16. class SCENE_CORE_API CoordinateSystemConverter
  17. {
  18. public:
  19. CoordinateSystemConverter();
  20. static const CoordinateSystemConverter CreateFromBasisVectors(const AZ::Vector3 sourceBasisVectors[3], const AZ::Vector3 targetBasisVectors[3], const AZ::u32 targetBasisIndices[3]);
  21. static const CoordinateSystemConverter CreateFromTransforms(const AZ::Transform& sourceTransform, const AZ::Transform& targetTransform, const AZ::u32 targetBasisIndices[3]);
  22. // Inline get data.
  23. bool IsConversionNeeded() const { return m_needsConversion; }
  24. bool IsSourceRightHanded() const { return m_sourceRightHanded; }
  25. bool IsTargetRightHanded() const { return m_targetRightHanded; }
  26. const AZ::Transform GetSourceTransform() const { return m_sourceTransform; }
  27. const AZ::Transform GetTargetTransform() const { return m_targetTransform; }
  28. const AZ::Transform GetConversionTransform() const { return m_conversionTransform; }
  29. const AZ::Transform GetInverseConversionTransform() const { return m_conversionTransformInversed; }
  30. // Conversion methods.
  31. AZ::Quaternion ConvertQuaternion(const AZ::Quaternion& input) const;
  32. AZ::Vector3 ConvertVector3(const AZ::Vector3& input) const;
  33. AZ::Vector3 ConvertScale(const AZ::Vector3& input) const;
  34. AZ::Transform ConvertTransform(const AZ::Transform& input) const;
  35. AZ::Matrix3x4 ConvertMatrix3x4(const AZ::Matrix3x4 & input) const;
  36. // Inverse conversion methods.
  37. AZ::Quaternion InverseConvertQuaternion(const AZ::Quaternion& input) const;
  38. AZ::Vector3 InverseConvertVector3(const AZ::Vector3& input) const;
  39. AZ::Vector3 InverseConvertScale(const AZ::Vector3& input) const;
  40. AZ::Transform InverseConvertTransform(const AZ::Transform& input) const;
  41. // Helper methods.
  42. bool CheckIfIsRightHanded(const AZ::Transform& transform) const;
  43. private:
  44. AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option")
  45. AZ::Transform m_sourceTransform;
  46. AZ::Transform m_targetTransform;
  47. AZ::Transform m_conversionTransform;
  48. AZ::Transform m_conversionTransformInversed;
  49. AZ_POP_DISABLE_WARNING
  50. AZ::u32 m_targetBasisIndices[3];
  51. bool m_needsConversion;
  52. bool m_sourceRightHanded;
  53. bool m_targetRightHanded;
  54. CoordinateSystemConverter(const AZ::Vector3 sourceBasisVectors[3], const AZ::Vector3 targetBasisVectors[3], const AZ::u32 targetBasisIndices[3]);
  55. };
  56. } // namespace AZ::SceneAPI