3
0

Transform2DFunctor.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 <Atom/RPI.Reflect/Material/MaterialFunctor.h>
  10. #include <Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h>
  11. #include <Atom/RHI.Reflect/Limits.h>
  12. #include <Atom/Utils/MaterialUtils.h>
  13. namespace AZ
  14. {
  15. namespace Render
  16. {
  17. //! Materials can use this functor to map 2D scale, translate, and rotate properties into a float3x3 transform matrix.
  18. class Transform2DFunctor final
  19. : public RPI::MaterialFunctor
  20. {
  21. friend class Transform2DFunctorSourceData;
  22. public:
  23. AZ_CLASS_ALLOCATOR(Transform2DFunctor, SystemAllocator)
  24. AZ_RTTI(Transform2DFunctor, "{3E9C4357-6B2D-4A22-89DB-462441C9D8CD}", RPI::MaterialFunctor);
  25. static void Reflect(ReflectContext* context);
  26. using RPI::MaterialFunctor::Process;
  27. void Process(RPI::MaterialFunctorAPI::RuntimeContext& context) override;
  28. private:
  29. AZStd::vector<TransformType> m_transformOrder; //!< Controls the order in which Scale, Translate, Rotate are performed
  30. // Material property inputs...
  31. RPI::MaterialPropertyIndex m_center; //!< index of material property for the center of scaling and rotation
  32. RPI::MaterialPropertyIndex m_scale; //!< index of material property for scaling in both directions
  33. RPI::MaterialPropertyIndex m_scaleX; //!< index of material property for X scale
  34. RPI::MaterialPropertyIndex m_scaleY; //!< index of material property for Y scale
  35. RPI::MaterialPropertyIndex m_translateX; //!< index of material property for X translation
  36. RPI::MaterialPropertyIndex m_translateY; //!< index of material property for Y translation
  37. RPI::MaterialPropertyIndex m_rotateDegrees; //!< index of material property for rotating
  38. // Shader setting output...
  39. RHI::ShaderInputConstantIndex m_transformMatrix; //!< the index of a float3x3 shader input
  40. RHI::ShaderInputConstantIndex m_transformMatrixInverse; //!< the index of the inverse float3x3 shader input
  41. };
  42. } // namespace Render
  43. } // namespace AZ