Overte C++ Documentation
IKTarget.h
1 //
2 // IKTarget.h
3 //
4 // Copyright 2015 High Fidelity, Inc.
5 //
6 // Distributed under the Apache License, Version 2.0.
7 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
8 //
9 
10 #ifndef hifi_IKTarget_h
11 #define hifi_IKTarget_h
12 
13 #include "AnimSkeleton.h"
14 
15 const float HACK_HMD_TARGET_WEIGHT = 8.0f;
16 
17 class IKTarget {
18 public:
19  /*@jsdoc
20  * <p>An IK target type.</p>
21  * <table>
22  * <thead>
23  * <tr><th>Value</th><th>Name</th><th>Description</th>
24  * </thead>
25  * <tbody>
26  * <tr><td><code>0</code></td><td>RotationAndPosition</td><td>Attempt to reach the rotation and position end
27  * effector.</td></tr>
28  * <tr><td><code>1</code></td><td>RotationOnly</td><td>Attempt to reach the end effector rotation only.</td></tr>
29  * <tr><td><code>2</code></td><td>HmdHead</td><td>
30  * <p>A special mode of IK that would attempt to prevent unnecessary bending of the spine.</p>
31  * <p class="important">Deprecated: This target type is deprecated and will be removed.</p></td></tr>
32  * <tr><td><code>3</code></td><td>HipsRelativeRotationAndPosition</td><td>Attempt to reach a rotation and position end
33  * effector that is not in absolute rig coordinates but is offset by the avatar hips translation.</td></tr>
34  * <tr><td><code>4</code></td><td>Spline</td><td>Use a cubic Hermite spline to model the human spine. This prevents
35  * kinks in the spine and allows for a small amount of stretch and squash.</td></tr>
36  * <tr><td><code>5</code></td><td>Unknown</td><td>IK is disabled.</td></tr>
37  * </tbody>
38  * </table>
39  * @typedef {number} MyAvatar.IKTargetType
40  */
41  enum class Type {
42  RotationAndPosition,
43  RotationOnly,
44  HmdHead,
45  HipsRelativeRotationAndPosition,
46  Spline,
47  Unknown
48  };
49 
50  IKTarget() {}
51 
52  const glm::vec3& getTranslation() const { return _pose.trans(); }
53  const glm::quat& getRotation() const { return _pose.rot(); }
54  const AnimPose& getPose() const { return _pose; }
55  glm::vec3 getPoleVector() const { return _poleVector; }
56  glm::vec3 getPoleReferenceVector() const { return _poleReferenceVector; }
57  bool getPoleVectorEnabled() const { return _poleVectorEnabled; }
58  int getIndex() const { return _index; }
59  Type getType() const { return _type; }
60  int getNumFlexCoefficients() const { return (int)_numFlexCoefficients; }
61  float getFlexCoefficient(size_t chainDepth) const;
62 
63  void setPose(const glm::quat& rotation, const glm::vec3& translation);
64  void setPoleVector(const glm::vec3& poleVector) { _poleVector = poleVector; }
65  void setPoleReferenceVector(const glm::vec3& poleReferenceVector) { _poleReferenceVector = poleReferenceVector; }
66  void setPoleVectorEnabled(bool poleVectorEnabled) { _poleVectorEnabled = poleVectorEnabled; }
67  void setIndex(int index) { _index = index; }
68  void setType(int);
69  void setFlexCoefficients(size_t numFlexCoefficientsIn, const float* flexCoefficientsIn);
70 
71  void setWeight(float weight) { _weight = weight; }
72  float getWeight() const { return _weight; }
73 
74  enum FlexCoefficients { MAX_FLEX_COEFFICIENTS = 10 };
75 
76 private:
77  AnimPose _pose;
78  glm::vec3 _poleVector;
79  glm::vec3 _poleReferenceVector;
80  bool _poleVectorEnabled { false };
81  int _index { -1 };
82  Type _type { Type::Unknown };
83  float _weight { 0.0f };
84  float _flexCoefficients[MAX_FLEX_COEFFICIENTS];
85  size_t _numFlexCoefficients;
86 };
87 
88 #endif // hifi_IKTarget_h
@ Unknown
Socket type unknown or not set.