Advertisement
Guest User

Untitled

a guest
Dec 26th, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.15 KB | None | 0 0
  1. #pragma once
  2. #ifndef MYEFXNODE_H
  3. #define MYEFXNODE_H
  4.  
  5. #include <AzCore/Math/Vector2.h>
  6. #include <AzCore/Math/Quaternion.h>
  7. #include <EMotionFX/Source/EMotionFXConfig.h>
  8. #include <EMotionFX/Source/AnimGraphNode.h>
  9. #include <EMotionFX/Source/ConstraintTransformRotationAngles.h>
  10. #include <EMotionFX/Source/Parameter/FloatSliderParameter.h>
  11.  
  12. namespace EMotionFX
  13. {
  14.     class MyEFXNode
  15.         : public AnimGraphNode
  16.     {
  17.     public:
  18.         AZ_RTTI(MyEFXNode, "{2FF35F31-D1BA-4045-A3DB-3EF86D94A018}", AnimGraphNode);
  19.         AZ_CLASS_ALLOCATOR_DECL
  20.  
  21.         enum
  22.         {
  23.             INPUTPORT_POSE = 0,
  24.             INPUTPORT_GOALPOS = 1,
  25.             INPUTPORT_WEIGHT = 2,
  26.             INPUTPORT_DEBUGVEC = 3,
  27.  
  28.             OUTPUTPORT_POSE = 0
  29.         };
  30.  
  31.         enum
  32.         {
  33.             PORTID_INPUT_POSE = 0,
  34.             PORTID_INPUT_GOALPOS = 1,
  35.             PORTID_INPUT_WEIGHT = 2,
  36.             PORTID_INPUT_DEBUGVEC = 3,
  37.  
  38.             PORTID_OUTPUT_POSE = 0
  39.         };
  40.  
  41.         enum TwistAxis : AZ::u8
  42.         {
  43.             TWISTAXIS_X = 0,
  44.             TWISTAXIS_Y = 1,
  45.             TWISTAXIS_Z = 2
  46.         };
  47.  
  48.         class UniqueData
  49.             : public AnimGraphNodeData
  50.         {
  51.             EMFX_ANIMGRAPHOBJECTDATA_IMPLEMENT_LOADSAVE
  52.         public:
  53.             AZ_CLASS_ALLOCATOR_DECL
  54.  
  55.                 UniqueData(AnimGraphNode* node, AnimGraphInstance* animGraphInstance)
  56.                 : AnimGraphNodeData(node, animGraphInstance) {
  57.                 mNodeIndex = MCORE_INVALIDINDEX32; mMustUpdate = true; mIsValid = false; mFirstUpdate = true; mTimeDelta = 0.0f;
  58.             }
  59.             ~UniqueData() {}
  60.  
  61.         public:
  62.             MCore::Quaternion mRotationQuat;
  63.             float       mTimeDelta;
  64.             uint32      mNodeIndex;
  65.             uint32      mStartNodeIndex;
  66.             uint32      mEndNodeIndex;
  67.             bool        mMustUpdate;
  68.             bool        mIsValid;
  69.             bool        mFirstUpdate;
  70.         };
  71.  
  72.         MyEFXNode();
  73.         ~MyEFXNode();
  74.  
  75.         void Reinit() override;
  76.         bool InitAfterLoading(AnimGraph* animGraph) override;
  77.  
  78.         void OnUpdateUniqueData(AnimGraphInstance* animGraphInstance) override;
  79.         bool GetSupportsVisualization() const override { return true; }
  80.         bool GetHasOutputPose() const override { return true; }
  81.         bool GetSupportsDisable() const override { return true; }
  82.         AZ::Color GetVisualColor() const override { return AZ::Color(1.0f, 0.0f, 0.0f, 1.0f); }
  83.         AnimGraphPose* GetMainOutputPose(AnimGraphInstance* animGraphInstance) const override { return GetOutputPose(animGraphInstance, OUTPUTPORT_POSE)->GetValue(); }
  84.  
  85.         const char* GetPaletteName() const override;
  86.         AnimGraphObject::ECategory GetPaletteCategory() const override;
  87.  
  88.         void SetTargetNodeName(const AZStd::string& targetNodeName);
  89.         void SetStartNodeName(const AZStd::string& startNodeName);
  90.         void SetEndNodeName(const AZStd::string& endNodeName);
  91.         void SetConstraintRotation(const AZ::Quaternion& constraintRotation);
  92.         void SetPostRotation(const AZ::Quaternion& postRotation);
  93.         void SetLimitMin(const AZ::Vector2& limitMin);
  94.         void SetLimitMax(const AZ::Vector2& limitMax);
  95.         void SetFollowSpeed(float followSpeed);
  96.         void SetTwistAxis(ConstraintTransformRotationAngles::EAxis twistAxis);
  97.         void SetLimitsEnabled(bool limitsEnabled);
  98.         void SetSmoothingEnabled(bool smoothingEnabled);
  99.  
  100.         static void Reflect(AZ::ReflectContext* context);
  101.  
  102.     private:
  103.         void UpdateUniqueData(AnimGraphInstance* animGraphInstance, UniqueData* uniqueData);
  104.         void Output(AnimGraphInstance* animGraphInstance) override;
  105.         void Update(AnimGraphInstance* animGraphInstance, float timePassedInSeconds) override;
  106.  
  107.         AZ::Crc32 GetLimitWidgetsVisibility() const;
  108.         AZ::Crc32 GetFollowSpeedVisibility() const;
  109.  
  110.         AZStd::string                               m_targetNodeName;
  111.         AZStd::string                               m_startNodeName;
  112.         AZStd::string                               m_endNodeName;
  113.         AZ::Quaternion                              m_constraintRotation;
  114.         AZ::Quaternion                              m_postRotation;
  115.         AZ::Vector2                                 m_limitMin;
  116.         AZ::Vector2                                 m_limitMax;
  117.         float                                       m_followSpeed;
  118.         ConstraintTransformRotationAngles::EAxis    m_twistAxis;
  119.         bool                                        m_limitsEnabled;
  120.         bool                                        m_smoothing;
  121.  
  122.         AZ::Vector3                                 m_worldPos;
  123.  
  124.         EMotionFX::FloatSliderParameter fParam;
  125.     };
  126. }; // namespace EMotionFX
  127.  
  128. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement