Atoms Crowd  7.0.0
FootOperator.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <AtomsGraph/Ports.h>
11 
12 #include <Atoms/Globals.h>
13 #include <Atoms/Graph/Operator.h>
14 
15 namespace Atoms
16 {
17  struct FootCache
18  {
19  FootCache() :
20  wasDown(false),
21  initialized(false),
22  detachingFromGround(false),
23  legStretched(false),
24  lastValue(2.0),
25  bindLegLength(0),
26  ik(false),
27  frameSinceUp(10000u),
28  numBlendFramesAfterFootUp(1),
29  numMidJoints(0),
30  ankleLength(0)
31  {};
32 
33  bool wasDown;
34  bool initialized;
35  bool detachingFromGround;
36  bool legStretched;
37 
38  double lastValue;
39  double bindLegLength;
40 
41  bool ik;
42  unsigned short frameSinceUp;
43  int numBlendFramesAfterFootUp;
44  AtomsCore::Matrix tipMatrix;
45  AtomsCore::Vector3 poleVector;
46 
47  unsigned int numMidJoints;
48  std::vector<unsigned short> midJointIds;
49 
50  AtomsCore::Vector3 tipWorldZAxis, tipWorldPos;
51 
52  double ankleLength;
53  AtomsCore::Vector3 anklePlaneNormal;
54 
55  AtomsCore::Quaternion rootQ, ikQ, tipQ;
56  AtomsCore::Vector3 rootT, ikT, tipT;
57 
58  AtomsCore::Quaternion rootQdiff, ikQdiff, tipQdiff;
59  AtomsCore::Vector3 rootTdiff, ikTdiff, tipTdiff;
60 
61  std::vector<AtomsCore::Quaternion> midQs;
62  std::vector<AtomsCore::Vector3> midTs;
63  std::vector<AtomsCore::Quaternion> midQdiffs;
64  std::vector<AtomsCore::Vector3> midTdiffs;
65  };
66 
67  class ATOMS_EXPORT FootOperator : public Operator
68  {
69  public:
70 
71  NODE_STANDARD_MEMBERS
72 
73  FootOperator();
74 
75  virtual ~FootOperator();
76 
77  bool compute(const AtomsGraph::ComputeData* computeData);
78 
79  void reset();
80 
81  inline std::vector<FootCache>& feetCache() {
82  return m_feetCache;
83  }
84 
85  private:
86  AtomsGraph::PosePort* m_inPose;
87  AtomsGraph::DoublePort* m_FootThreshold;
88  AtomsGraph::DoublePort* m_softIkDistance;
89  AtomsGraph::BooleanPort* m_debug;
90  AtomsGraph::BooleanPort* m_disableFootLockOnLegStretch;
91  AtomsGraph::DoublePort* m_legStretchMaxRatio;
92 
93  //std::map<unsigned short, FootCache> m_feetCache;
94  std::vector<FootCache> m_feetCache;
95 
96  AtomsPtr<AtomsCore::MapMetadata> m_hfAnimatedMetaMap;
97 
98  bool m_first;
99 
100  public:
101 
102  static const std::string ikSolverKey;
103  static const std::string ikTolleranceKey;
104  static const std::string ikMaxIterationsKey;
105  };
106 }
Definition: FootOperator.h:68
bool compute(const AtomsGraph::ComputeData *computeData)
Compute function.
void reset()
Operator reset function.
Operator node.
Definition: Operator.h:26
Definition: Node.h:21
Generic node port class.
Definition: PortTemplate.h:24
AtomsMath::Quaternion Quaternion
Quaternion class.
Definition: AtomsMath.h:67
AtomsMath::Vector3 Vector3
Vector3 class.
Definition: AtomsMath.h:57
AtomsMath::Matrix Matrix
Matrix class.
Definition: AtomsMath.h:63
Atoms namespace.
Definition: Agent.h:29
Definition: FootOperator.h:18