EditorHDRiSkyboxComponent.cpp 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_CE("Game"))
  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. ->Attribute(AZ::Edit::Attributes::ShowProductAssetFileName, false)
  46. ->Attribute(AZ::Edit::Attributes::HideProductFilesInAssetPicker, true)
  47. ->Attribute(AZ::Edit::Attributes::AssetPickerTitle, "Cubemap Asset")
  48. ->DataElement(AZ::Edit::UIHandlers::Slider, &HDRiSkyboxComponentConfig::m_exposure, "Exposure", "Exposure in stops")
  49. ->Attribute(AZ::Edit::Attributes::SoftMin, -5.0f)
  50. ->Attribute(AZ::Edit::Attributes::SoftMax, 5.0f)
  51. ->Attribute(AZ::Edit::Attributes::Min, -20.0f)
  52. ->Attribute(AZ::Edit::Attributes::Max, 20.0f)
  53. ;
  54. }
  55. }
  56. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  57. {
  58. behaviorContext->Class<EditorHDRiSkyboxComponent>()->RequestBus("HDRiSkyboxRequestBus");
  59. behaviorContext->ConstantProperty("EditorHDRiSkyboxComponentTypeId", BehaviorConstant(Uuid(EditorHDRiSkyboxComponentTypeId)))
  60. ->Attribute(AZ::Script::Attributes::Module, "render")
  61. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  62. }
  63. }
  64. EditorHDRiSkyboxComponent::EditorHDRiSkyboxComponent(const HDRiSkyboxComponentConfig& config)
  65. : BaseClass(config)
  66. {
  67. }
  68. }
  69. }