ShadowsSetupNode.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. // Description : CryMovie animation node for shadow settings
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. #include "ShadowsSetupNode.h"
  11. #include "Maestro/Types/AnimNodeType.h"
  12. #include "Maestro/Types/AnimValueType.h"
  13. #include "Maestro/Types/AnimParamType.h"
  14. //////////////////////////////////////////////////////////////////////////
  15. namespace ShadowSetupNode
  16. {
  17. bool s_shadowSetupParamsInit = false;
  18. AZStd::vector<CAnimNode::SParamInfo> s_shadowSetupParams;
  19. void AddSupportedParam(const char* sName, AnimParamType paramId, AnimValueType valueType)
  20. {
  21. CAnimNode::SParamInfo param;
  22. param.name = sName;
  23. param.paramType = paramId;
  24. param.valueType = valueType;
  25. s_shadowSetupParams.push_back(param);
  26. }
  27. };
  28. //-----------------------------------------------------------------------------
  29. CShadowsSetupNode::CShadowsSetupNode()
  30. : CShadowsSetupNode(0)
  31. {
  32. }
  33. //-----------------------------------------------------------------------------
  34. CShadowsSetupNode::CShadowsSetupNode(const int id)
  35. : CAnimNode(id, AnimNodeType::ShadowSetup)
  36. {
  37. CShadowsSetupNode::Initialize();
  38. }
  39. //-----------------------------------------------------------------------------
  40. void CShadowsSetupNode::Initialize()
  41. {
  42. if (!ShadowSetupNode::s_shadowSetupParamsInit)
  43. {
  44. ShadowSetupNode::s_shadowSetupParamsInit = true;
  45. ShadowSetupNode::s_shadowSetupParams.reserve(1);
  46. ShadowSetupNode::AddSupportedParam("GSMCache", AnimParamType::GSMCache, AnimValueType::Bool);
  47. }
  48. }
  49. //-----------------------------------------------------------------------------
  50. void CShadowsSetupNode::Animate(SAnimContext& ac)
  51. {
  52. IAnimTrack* pGsmCache = GetTrackForParameter(AnimParamType::GSMCache);
  53. if (pGsmCache && (pGsmCache->GetFlags() & IAnimTrack::eAnimTrackFlags_Disabled) == 0)
  54. {
  55. bool val(false);
  56. pGsmCache->GetValue(ac.time, val);
  57. }
  58. }
  59. //-----------------------------------------------------------------------------
  60. void CShadowsSetupNode::CreateDefaultTracks()
  61. {
  62. CreateTrack(AnimParamType::GSMCache);
  63. }
  64. //-----------------------------------------------------------------------------
  65. void CShadowsSetupNode::OnReset()
  66. {
  67. }
  68. //-----------------------------------------------------------------------------
  69. unsigned int CShadowsSetupNode::GetParamCount() const
  70. {
  71. return static_cast<int>(ShadowSetupNode::s_shadowSetupParams.size());
  72. }
  73. //-----------------------------------------------------------------------------
  74. CAnimParamType CShadowsSetupNode::GetParamType(unsigned int nIndex) const
  75. {
  76. if (nIndex < ShadowSetupNode::s_shadowSetupParams.size())
  77. {
  78. return ShadowSetupNode::s_shadowSetupParams[nIndex].paramType;
  79. }
  80. return AnimParamType::Invalid;
  81. }
  82. //-----------------------------------------------------------------------------
  83. bool CShadowsSetupNode::GetParamInfoFromType(const CAnimParamType& paramId, SParamInfo& info) const
  84. {
  85. for (size_t i = 0; i < ShadowSetupNode::s_shadowSetupParams.size(); ++i)
  86. {
  87. if (ShadowSetupNode::s_shadowSetupParams[i].paramType == paramId)
  88. {
  89. info = ShadowSetupNode::s_shadowSetupParams[i];
  90. return true;
  91. }
  92. }
  93. return false;
  94. }
  95. //////////////////////////////////////////////////////////////////////////
  96. void CShadowsSetupNode::Reflect(AZ::ReflectContext* context)
  97. {
  98. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  99. {
  100. serializeContext->Class<CShadowsSetupNode, CAnimNode>()
  101. ->Version(1);
  102. }
  103. }