Atoms Crowd  4.1.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() : wasDown(false), initialized(false), detachingFromGround(false), frameSinceUp(10000u), lastValue(2.0){};
20 
21  bool wasDown;
22  bool initialized;
23  bool detachingFromGround;
24 
25  double lastValue;
26 
27  bool ik;
28  unsigned short frameSinceUp;
29  AtomsCore::Matrix tipMatrix;
30  AtomsCore::Vector3 poleVector;
31 
32  unsigned int numMidJoints;
33  std::vector<unsigned short> midJointIds;
34 
35  AtomsCore::Vector3 tipWorldZAxis, tipWorldPos;
36 
37  double ankleLength;
38  AtomsCore::Vector3 anklePlaneNormal;
39 
40  AtomsCore::Quaternion rootQ, ikQ, tipQ;
41  AtomsCore::Vector3 rootT, ikT, tipT;
42 
43  AtomsCore::Quaternion rootQdiff, ikQdiff, tipQdiff;
44  AtomsCore::Vector3 rootTdiff, ikTdiff, tipTdiff;
45 
46  std::vector<AtomsCore::Quaternion> midQs;
47  std::vector<AtomsCore::Vector3> midTs;
48  std::vector<AtomsCore::Quaternion> midQdiffs;
49  std::vector<AtomsCore::Vector3> midTdiffs;
50  };
51 
52  class ATOMS_EXPORT FootOperator : public Operator
53  {
54  public:
55 
56  NODE_STANDARD_MEMBERS
57 
58  FootOperator();
59 
60  virtual ~FootOperator();
61 
62  bool compute(const AtomsGraph::ComputeData* computeData);
63 
64  void reset();
65 
66  private:
67  AtomsGraph::PosePort* m_inPose;
68  AtomsGraph::DoublePort* m_FootThreshold;
69  AtomsGraph::DoublePort* m_softIkDistance;
70  AtomsGraph::BooleanPort* m_debug;
71 
72  //std::map<unsigned short, FootCache> m_feetCache;
73  std::vector<FootCache> m_feetCache;
74 
75  AtomsPtr<AtomsCore::MapMetadata> m_hfAnimatedMetaMap;
76 
77  bool m_first;
78 
79  public:
80 
81  static const std::string ikSolverKey;
82  static const std::string ikTolleranceKey;
83  static const std::string ikMaxIterationsKey;
84  };
85 }
AtomsCore::Quaternion
AtomsMath::Quaternion Quaternion
Quaternion class.
Definition: AtomsMath.h:67
Atoms::FootOperator::compute
bool compute(const AtomsGraph::ComputeData *computeData)
Compute function.
AtomsCore::Matrix
AtomsMath::Matrix Matrix
Matrix class.
Definition: AtomsMath.h:63
AtomsCore::Vector3
AtomsMath::Vector3 Vector3
Vector3 class.
Definition: AtomsMath.h:57
AtomsGraph::PortTemplate
Generic node port class.
Definition: PortTemplate.h:24
Atoms
Atoms namespace.
Definition: Agent.h:28
Atoms::Operator
Operator node.
Definition: Operator.h:26
Atoms::FootOperator::reset
void reset()
Operator reset function.
AtomsGraph::ComputeData
Definition: Node.h:21
Atoms::FootOperator
Definition: FootOperator.h:53
Atoms::FootCache
Definition: FootOperator.h:18