3
0

EditorHDRiSkyboxComponent.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #include <SkyBox/EditorHDRiSkyboxComponent.h>
  9. #include <AzCore/RTTI/BehaviorContext.h>
  10. namespace AZ
  11. {
  12. namespace Render
  13. {
  14. void EditorHDRiSkyboxComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. BaseClass::Reflect(context);
  17. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serializeContext->Class<EditorHDRiSkyboxComponent, BaseClass>()
  20. ->Version(2, ConvertToEditorRenderComponentAdapter<2>);
  21. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  22. {
  23. editContext->Class<EditorHDRiSkyboxComponent>(
  24. "HDRi Skybox", "SkyBox component render the background of your scene with cubemap")
  25. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  26. ->Attribute(AZ::Edit::Attributes::Category, "Graphics/Environment")
  27. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg")
  28. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Component_Placeholder.svg")
  29. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
  30. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  31. ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/atom/hdri-skybox/")
  32. ;
  33. editContext->Class<HDRiSkyboxComponentController>(
  34. "HDRiSkyboxComponentController", "")
  35. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  36. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  37. ->DataElement(AZ::Edit::UIHandlers::Default, &HDRiSkyboxComponentController::m_configuration, "Configuration", "")
  38. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  39. ;
  40. editContext->Class<HDRiSkyboxComponentConfig>(
  41. "HDRiSkyboxComponentConfig", "")
  42. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  43. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  44. ->DataElement(AZ::Edit::UIHandlers::Default, &HDRiSkyboxComponentConfig::m_cubemapAsset, "Cubemap Texture", "The texture used for cubemap rendering")
  45. ->DataElement(AZ::Edit::UIHandlers::Slider, &HDRiSkyboxComponentConfig::m_exposure, "Exposure", "Exposure in stops")
  46. ->Attribute(AZ::Edit::Attributes::SoftMin, -5.0f)
  47. ->Attribute(AZ::Edit::Attributes::SoftMax, 5.0f)
  48. ->Attribute(AZ::Edit::Attributes::Min, -20.0f)
  49. ->Attribute(AZ::Edit::Attributes::Max, 20.0f)
  50. ;
  51. }
  52. }
  53. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  54. {
  55. behaviorContext->Class<EditorHDRiSkyboxComponent>()->RequestBus("HDRiSkyboxRequestBus");
  56. behaviorContext->ConstantProperty("EditorHDRiSkyboxComponentTypeId", BehaviorConstant(Uuid(EditorHDRiSkyboxComponentTypeId)))
  57. ->Attribute(AZ::Script::Attributes::Module, "render")
  58. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  59. }
  60. }
  61. EditorHDRiSkyboxComponent::EditorHDRiSkyboxComponent(const HDRiSkyboxComponentConfig& config)
  62. : BaseClass(config)
  63. {
  64. }
  65. }
  66. }