Overte C++ Documentation
AnimPoleVectorConstraint.h
1 //
2 // AnimPoleVectorConstraint.h
3 //
4 // Created by Anthony J. Thibault on 5/25/18.
5 // Copyright (c) 2018 High Fidelity, Inc. All rights reserved.
6 //
7 // Distributed under the Apache License, Version 2.0.
8 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9 //
10 
11 #ifndef hifi_AnimPoleVectorConstraint_h
12 #define hifi_AnimPoleVectorConstraint_h
13 
14 #include "AnimNode.h"
15 #include "AnimChain.h"
16 
17 // Three bone IK chain
18 
19 class AnimPoleVectorConstraint : public AnimNode {
20 public:
21  friend class AnimTests;
22 
23  AnimPoleVectorConstraint(const QString& id, bool enabled, glm::vec3 referenceVector,
24  const QString& baseJointName, const QString& midJointName, const QString& tipJointName,
25  const QString& enabledVar, const QString& poleVectorVar);
26  virtual ~AnimPoleVectorConstraint() override;
27 
28  virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimVariantMap& triggersOut) override;
29 
30 protected:
31 
32  enum class InterpType {
33  None = 0,
34  SnapshotToUnderPoses,
35  SnapshotToSolve,
36  NumTypes
37  };
38 
39  // for AnimDebugDraw rendering
40  virtual const AnimPoseVec& getPosesInternal() const override;
41  virtual void setSkeletonInternal(AnimSkeleton::ConstPointer skeleton) override;
42 
43  void lookUpIndices();
44  void beginInterp(InterpType interpType, const AnimChain& chain);
45 
46  AnimPoseVec _poses;
47 
48  bool _enabled;
49  glm::vec3 _referenceVector;
50 
51  QString _baseJointName;
52  QString _midJointName;
53  QString _tipJointName;
54 
55  QString _enabledVar;
56  QString _poleVectorVar;
57 
58  int _baseParentJointIndex { -1 };
59  int _baseJointIndex { -1 };
60  int _midJointIndex { -1 };
61  int _tipJointIndex { -1 };
62 
63  InterpType _interpType { InterpType::None };
64  float _interpAlphaVel { 0.0f };
65  float _interpAlpha { 0.0f };
66 
67  AnimChain _snapshotChain;
68 
69  // no copies
70  AnimPoleVectorConstraint(const AnimPoleVectorConstraint&) = delete;
71  AnimPoleVectorConstraint& operator=(const AnimPoleVectorConstraint&) = delete;
72 };
73 
74 #endif // hifi_AnimPoleVectorConstraint_h