MeshExampleComponent.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 <CommonSampleComponentBase.h>
  14. #include <AzCore/Component/EntityBus.h>
  15. #include <AzCore/Component/TickBus.h>
  16. #include <Utils/Utils.h>
  17. #include <Utils/ImGuiSidebar.h>
  18. #include <Utils/ImGuiMaterialDetails.h>
  19. #include <Utils/ImGuiAssetBrowser.h>
  20. #include <Atom/Feature/SkyBox/SkyBoxFeatureProcessorInterface.h>
  21. namespace AtomSampleViewer
  22. {
  23. class MeshExampleComponent final
  24. : public CommonSampleComponentBase
  25. , public AZ::TickBus::Handler
  26. {
  27. public:
  28. AZ_COMPONENT(MeshExampleComponent, "{A2402165-5DF1-4981-BF7F-665209640BBD}", CommonSampleComponentBase);
  29. static void Reflect(AZ::ReflectContext* context);
  30. MeshExampleComponent();
  31. ~MeshExampleComponent() override = default;
  32. // AZ::Component
  33. void Activate() override;
  34. void Deactivate() override;
  35. private:
  36. // AZ::TickBus::Handler
  37. void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
  38. // AZ::EntityBus::MultiHandler
  39. void OnEntityDestruction(const AZ::EntityId& entityId) override;
  40. void ModelChange();
  41. void UseArcBallCameraController();
  42. void UseNoClipCameraController();
  43. void RemoveController();
  44. void SetArcBallControllerParams();
  45. void ResetCameraController();
  46. enum class CameraControllerType : int32_t
  47. {
  48. ArcBall = 0,
  49. NoClip,
  50. Count
  51. };
  52. static const uint32_t CameraControllerCount = static_cast<uint32_t>(CameraControllerType::Count);
  53. static const char* CameraControllerNameTable[CameraControllerCount];
  54. CameraControllerType m_currentCameraControllerType = CameraControllerType::ArcBall;
  55. // Not owned by this sample, we look this up
  56. AZ::Component* m_cameraControlComponent = nullptr;
  57. AZ::Render::MeshFeatureProcessorInterface::ModelChangedEvent::Handler m_changedHandler;
  58. static constexpr float ArcballRadiusMinModifier = 0.01f;
  59. static constexpr float ArcballRadiusMaxModifier = 4.0f;
  60. AZ::RPI::Cullable::LodOverride m_lodOverride = AZ::RPI::Cullable::NoLodOverride;
  61. bool m_enableMaterialOverride = true;
  62. // If false, only azmaterials generated from ".material" files will be listed.
  63. // Otherwise, all azmaterials, regardless of its source (e.g ".fbx"), will
  64. // be shown in the material list.
  65. bool m_showModelMaterials = false;
  66. bool m_cameraControllerDisabled = false;
  67. AZ::Data::Instance<AZ::RPI::Material> m_materialOverrideInstance; //< Holds a copy of the material instance being used when m_enableMaterialOverride is true.
  68. AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle;
  69. ImGuiSidebar m_imguiSidebar;
  70. ImGuiMaterialDetails m_imguiMaterialDetails;
  71. ImGuiAssetBrowser m_materialBrowser;
  72. ImGuiAssetBrowser m_modelBrowser;
  73. };
  74. } // namespace AtomSampleViewer