SkyBoxFogSettings.cpp 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/SkyBoxFogSettings.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. #include <AzCore/Serialization/EditContext.h>
  11. #include <AzCore/RTTI/BehaviorContext.h>
  12. #include <Atom/Feature/SkyBox/SkyBoxFogBus.h>
  13. namespace AZ
  14. {
  15. namespace Render
  16. {
  17. void SkyBoxFogSettings::Reflect(ReflectContext* context)
  18. {
  19. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  20. {
  21. serializeContext->Class<SkyBoxFogSettings>()
  22. ->Version(1)
  23. ->Field("Enable", &SkyBoxFogSettings::m_enable)
  24. ->Field("Color", &SkyBoxFogSettings::m_color)
  25. ->Field("TopHeight", &SkyBoxFogSettings::m_topHeight)
  26. ->Field("BottomHeight", &SkyBoxFogSettings::m_bottomHeight)
  27. ;
  28. if (auto editContext = serializeContext->GetEditContext())
  29. {
  30. editContext->Class<SkyBoxFogSettings>("SkyBoxFogSettings", "")
  31. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  32. ->DataElement(AZ::Edit::UIHandlers::Default, &SkyBoxFogSettings::m_enable, "Enable Fog", "Toggle fog on or off")
  33. ->DataElement(AZ::Edit::UIHandlers::Default, &SkyBoxFogSettings::m_color, "Fog Color", "Color of the fog")
  34. ->Attribute(AZ::Edit::Attributes::ReadOnly, &SkyBoxFogSettings::IsFogDisabled)
  35. ->DataElement(AZ::Edit::UIHandlers::Slider, &SkyBoxFogSettings::m_topHeight, "Fog Top Height", "Height of the fog upwards from the horizon")
  36. ->Attribute(AZ::Edit::Attributes::ReadOnly, &SkyBoxFogSettings::IsFogDisabled)
  37. ->Attribute(AZ::Edit::Attributes::Min, 0.0)
  38. ->Attribute(AZ::Edit::Attributes::Max, 0.5)
  39. ->Attribute(AZ::Edit::Attributes::Step, 0.01)
  40. ->DataElement(AZ::Edit::UIHandlers::Slider, &SkyBoxFogSettings::m_bottomHeight, "Fog Bottom Height", "Height of the fog downwards from the horizon")
  41. ->Attribute(AZ::Edit::Attributes::ReadOnly, &SkyBoxFogSettings::IsFogDisabled)
  42. ->Attribute(AZ::Edit::Attributes::Min, 0.0)
  43. ->Attribute(AZ::Edit::Attributes::Max, 0.3)
  44. ->Attribute(AZ::Edit::Attributes::Step, 0.01)
  45. ;
  46. }
  47. }
  48. if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
  49. {
  50. behaviorContext->EBus<SkyBoxFogRequestBus>("SkyBoxFogRequestBus")
  51. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
  52. ->Attribute(AZ::Script::Attributes::Category, "render")
  53. ->Attribute(AZ::Script::Attributes::Module, "render")
  54. ->Event("SetEnabled", &SkyBoxFogRequestBus::Events::SetEnabled)
  55. ->Event("IsEnabled", &SkyBoxFogRequestBus::Events::IsEnabled)
  56. ->Event("SetColor", &SkyBoxFogRequestBus::Events::SetColor)
  57. ->Event("GetColor", &SkyBoxFogRequestBus::Events::GetColor)
  58. ->Event("SetTopHeight", &SkyBoxFogRequestBus::Events::SetTopHeight)
  59. ->Event("GetTopHeight", &SkyBoxFogRequestBus::Events::GetTopHeight)
  60. ->Event("SetBottomHeight", &SkyBoxFogRequestBus::Events::SetBottomHeight)
  61. ->Event("GetBottomHeight", &SkyBoxFogRequestBus::Events::GetBottomHeight)
  62. ->VirtualProperty("Enable", "IsEnabled", "SetEnabled")
  63. ->VirtualProperty("Color", "GetColor", "SetColor")
  64. ->VirtualProperty("TopHeight", "GetTopHeight", "SetTopHeight")
  65. ->VirtualProperty("BottomHeight", "GetTopHeight", "SetBottomHeight")
  66. ;
  67. }
  68. }
  69. bool SkyBoxFogSettings::IsFogDisabled() const
  70. {
  71. return !m_enable;
  72. }
  73. }
  74. }