DecalContainer.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. * its licensors.
  4. *
  5. * For complete copyright and license terms please see the LICENSE at the root of this
  6. * distribution (the "License"). All use of this software is governed by the License,
  7. * or, if provided, by the license below or the license accompanying this file. Do not
  8. * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. *
  11. */
  12. #pragma once
  13. #include <AzCore/std/containers/vector.h>
  14. #include <AzCore/Math/Quaternion.h>
  15. #include <Atom/Feature/Decals/DecalFeatureProcessorInterface.h>
  16. namespace AtomSampleViewer
  17. {
  18. //! Helper class used by the AtomSampleViewer examples.
  19. //! Stores a list of decals and will automatically release them upon destruction of the container.
  20. class DecalContainer
  21. {
  22. public:
  23. DecalContainer(AZ::Render::DecalFeatureProcessorInterface* fp);
  24. DecalContainer(const DecalContainer&) = delete;
  25. DecalContainer& operator=(const DecalContainer&) = delete;
  26. ~DecalContainer();
  27. void SetNumDecalsActive(int numDecals);
  28. int GetMaxDecals() const { return aznumeric_cast<int>(m_decals.size()); }
  29. int GetNumDecalsActive() const { return m_numDecalsActive; }
  30. private:
  31. void SetupDecals();
  32. void SetupNewDecal(const AZ::Vector3 position, const AZ::Vector3 halfSize, const char* const decalMaterialName);
  33. void AcquireDecal(int i);
  34. void ReleaseDecal(int i);
  35. struct Decal
  36. {
  37. AZ::Vector3 m_position;
  38. AZ::Vector3 m_halfSize;
  39. AZ::Quaternion m_quaternion;
  40. const char* m_materialName = nullptr;
  41. AZ::Render::DecalFeatureProcessorInterface::DecalHandle m_decalHandle;
  42. };
  43. AZStd::vector<Decal> m_decals;
  44. AZ::Render::DecalFeatureProcessorInterface* m_decalFeatureProcessor = nullptr;
  45. int m_numDecalsActive = 0;
  46. };
  47. } // namespace AtomSampleViewer