Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #ifndef MYEFXNODE_H
- #define MYEFXNODE_H
- #include <AzCore/Math/Vector2.h>
- #include <AzCore/Math/Quaternion.h>
- #include <EMotionFX/Source/EMotionFXConfig.h>
- #include <EMotionFX/Source/AnimGraphNode.h>
- #include <EMotionFX/Source/ConstraintTransformRotationAngles.h>
- #include <EMotionFX/Source/Parameter/FloatSliderParameter.h>
- namespace EMotionFX
- {
- class MyEFXNode
- : public AnimGraphNode
- {
- public:
- AZ_RTTI(MyEFXNode, "{2FF35F31-D1BA-4045-A3DB-3EF86D94A018}", AnimGraphNode);
- AZ_CLASS_ALLOCATOR_DECL
- enum
- {
- INPUTPORT_POSE = 0,
- INPUTPORT_GOALPOS = 1,
- INPUTPORT_WEIGHT = 2,
- INPUTPORT_DEBUGVEC = 3,
- OUTPUTPORT_POSE = 0
- };
- enum
- {
- PORTID_INPUT_POSE = 0,
- PORTID_INPUT_GOALPOS = 1,
- PORTID_INPUT_WEIGHT = 2,
- PORTID_INPUT_DEBUGVEC = 3,
- PORTID_OUTPUT_POSE = 0
- };
- enum TwistAxis : AZ::u8
- {
- TWISTAXIS_X = 0,
- TWISTAXIS_Y = 1,
- TWISTAXIS_Z = 2
- };
- class UniqueData
- : public AnimGraphNodeData
- {
- EMFX_ANIMGRAPHOBJECTDATA_IMPLEMENT_LOADSAVE
- public:
- AZ_CLASS_ALLOCATOR_DECL
- UniqueData(AnimGraphNode* node, AnimGraphInstance* animGraphInstance)
- : AnimGraphNodeData(node, animGraphInstance) {
- mNodeIndex = MCORE_INVALIDINDEX32; mMustUpdate = true; mIsValid = false; mFirstUpdate = true; mTimeDelta = 0.0f;
- }
- ~UniqueData() {}
- public:
- MCore::Quaternion mRotationQuat;
- float mTimeDelta;
- uint32 mNodeIndex;
- uint32 mStartNodeIndex;
- uint32 mEndNodeIndex;
- bool mMustUpdate;
- bool mIsValid;
- bool mFirstUpdate;
- };
- MyEFXNode();
- ~MyEFXNode();
- void Reinit() override;
- bool InitAfterLoading(AnimGraph* animGraph) override;
- void OnUpdateUniqueData(AnimGraphInstance* animGraphInstance) override;
- bool GetSupportsVisualization() const override { return true; }
- bool GetHasOutputPose() const override { return true; }
- bool GetSupportsDisable() const override { return true; }
- AZ::Color GetVisualColor() const override { return AZ::Color(1.0f, 0.0f, 0.0f, 1.0f); }
- AnimGraphPose* GetMainOutputPose(AnimGraphInstance* animGraphInstance) const override { return GetOutputPose(animGraphInstance, OUTPUTPORT_POSE)->GetValue(); }
- const char* GetPaletteName() const override;
- AnimGraphObject::ECategory GetPaletteCategory() const override;
- void SetTargetNodeName(const AZStd::string& targetNodeName);
- void SetStartNodeName(const AZStd::string& startNodeName);
- void SetEndNodeName(const AZStd::string& endNodeName);
- void SetConstraintRotation(const AZ::Quaternion& constraintRotation);
- void SetPostRotation(const AZ::Quaternion& postRotation);
- void SetLimitMin(const AZ::Vector2& limitMin);
- void SetLimitMax(const AZ::Vector2& limitMax);
- void SetFollowSpeed(float followSpeed);
- void SetTwistAxis(ConstraintTransformRotationAngles::EAxis twistAxis);
- void SetLimitsEnabled(bool limitsEnabled);
- void SetSmoothingEnabled(bool smoothingEnabled);
- static void Reflect(AZ::ReflectContext* context);
- private:
- void UpdateUniqueData(AnimGraphInstance* animGraphInstance, UniqueData* uniqueData);
- void Output(AnimGraphInstance* animGraphInstance) override;
- void Update(AnimGraphInstance* animGraphInstance, float timePassedInSeconds) override;
- AZ::Crc32 GetLimitWidgetsVisibility() const;
- AZ::Crc32 GetFollowSpeedVisibility() const;
- AZStd::string m_targetNodeName;
- AZStd::string m_startNodeName;
- AZStd::string m_endNodeName;
- AZ::Quaternion m_constraintRotation;
- AZ::Quaternion m_postRotation;
- AZ::Vector2 m_limitMin;
- AZ::Vector2 m_limitMax;
- float m_followSpeed;
- ConstraintTransformRotationAngles::EAxis m_twistAxis;
- bool m_limitsEnabled;
- bool m_smoothing;
- AZ::Vector3 m_worldPos;
- EMotionFX::FloatSliderParameter fParam;
- };
- }; // namespace EMotionFX
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement