3
0

AnimGraphFactory.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. #pragma once
  9. #include <AzCore/std/smart_ptr/unique_ptr.h>
  10. #include <EMotionFX/Source/AnimGraph.h>
  11. #include <EMotionFX/Source/AnimGraphStateMachine.h>
  12. #include <EMotionFX/Source/BlendTree.h>
  13. #include <EMotionFX/Source/BlendTreeParameterNode.h>
  14. namespace EMotionFX
  15. {
  16. class EmptyAnimGraph
  17. : public AnimGraph
  18. {
  19. public:
  20. AZ_RTTI(EmptyAnimGraph, "{B4BFE0F0-3A7D-4D90-A4C5-219F0A8E3997}", AnimGraph)
  21. EmptyAnimGraph();
  22. static void Reflect(AZ::ReflectContext* context);
  23. AnimGraphInstance* GetAnimGraphInstance(ActorInstance* actorInstance, MotionSet* motionSet);
  24. };
  25. ///////////////////////////////////////////////////////////////////////////
  26. class TwoMotionNodeAnimGraph
  27. : public EmptyAnimGraph
  28. {
  29. public:
  30. AZ_CLASS_ALLOCATOR(TwoMotionNodeAnimGraph, AnimGraphAllocator)
  31. AZ_RTTI(TwoMotionNodeAnimGraph, "{CBF4DE6B-BCDA-42A4-8AAC-1184019459CA}", EmptyAnimGraph)
  32. TwoMotionNodeAnimGraph();
  33. static void Reflect(AZ::ReflectContext* context);
  34. AnimGraphMotionNode* GetMotionNodeA();
  35. AnimGraphMotionNode* GetMotionNodeB();
  36. private:
  37. AnimGraphMotionNode* m_motionNodeA = nullptr;
  38. AnimGraphMotionNode* m_motionNodeB = nullptr;
  39. };
  40. ///////////////////////////////////////////////////////////////////////////
  41. class OneBlendTreeNodeAnimGraph
  42. : public EmptyAnimGraph
  43. {
  44. public:
  45. AZ_RTTI(OneBlendTreeNodeAnimGraph, "{C939CFD0-B50F-4694-8CDD-5E8C7A10CE58}", AnimGraph)
  46. AZ_CLASS_ALLOCATOR(OneBlendTreeNodeAnimGraph, AnimGraphAllocator)
  47. OneBlendTreeNodeAnimGraph();
  48. static void Reflect(AZ::ReflectContext* context);
  49. BlendTree* GetBlendTreeNode() const;
  50. private:
  51. BlendTree* m_blendTree = nullptr;
  52. };
  53. ///////////////////////////////////////////////////////////////////////////
  54. // This AnimGraph also contains a Final Node, which is required in order
  55. // for the blend tree to be valid
  56. class OneBlendTreeParameterNodeAnimGraph
  57. : public EmptyAnimGraph
  58. {
  59. public:
  60. AZ_CLASS_ALLOCATOR(OneBlendTreeParameterNodeAnimGraph, AnimGraphAllocator)
  61. OneBlendTreeParameterNodeAnimGraph();
  62. BlendTreeParameterNode* GetParameterNode() const;
  63. private:
  64. BlendTreeParameterNode* m_parameterNode = nullptr;
  65. BlendTreeFinalNode* m_finalNode = nullptr;
  66. };
  67. ///////////////////////////////////////////////////////////////////////////
  68. class AnimGraphFactory
  69. {
  70. public:
  71. template <class AnimGraphType, class... Args>
  72. static AZStd::unique_ptr<AnimGraphType> Create(Args&&... args)
  73. {
  74. AZStd::unique_ptr<AnimGraphType> animGraph = AZStd::make_unique<AnimGraphType>(AZStd::forward(args)...);
  75. return animGraph;
  76. }
  77. static void ReflectTestTypes(AZ::ReflectContext* context)
  78. {
  79. // Reflect all subclasses of animgraph in AnimGraphFactory
  80. EMotionFX::EmptyAnimGraph::Reflect(context);
  81. EMotionFX::TwoMotionNodeAnimGraph::Reflect(context);
  82. EMotionFX::OneBlendTreeNodeAnimGraph::Reflect(context);
  83. }
  84. };
  85. } // namespace EMotionFX