Atoms Crowd  7.0.0
AgentType.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 <Atoms/Globals.h>
11 #include <AtomsCore/Skeleton.h>
12 #include <AtomsCore/JointChain.h>
13 #include <AtomsCore/Metadata/MapMetadata.h>
14 
15 namespace Atoms
16 {
17  class AgentType;
18 
19  typedef AtomsPtr<AgentType> AgentTypePtr;
20 
21  typedef AtomsPtr<const AgentType> AgentTypeCPtr;
22 
24 
29  class ATOMS_EXPORT AgentType
30  {
31  public:
32 
33  enum RetargetMethodType
34  {
35  kPelvisToFeet = 0,
36  kFootRootToFootIK,
37  kBoundingBox,
38  kUserValue
39  };
40 
41  enum FacingDirection
42  {
43  kX = 0,
44  kY,
45  kZ,
46  kNegativeX,
47  kNegativeY,
48  kNegativeZ
49  };
50 
52  {
53  unsigned short thisIndex; // index of the chain in target
54  unsigned short otherIndex; // index of the chain in source
55  std::vector<unsigned short> thisMetadataIndices; // joint indices in target for metadata transference
56  std::vector<unsigned short> otherMetadataIndices; // joint indices in source for metadata transference
57  double factor; // scaling factor for diff chain lengths
58  AtomsCore::Vector3 offset; // offset in case of spines to respect bind pose
59  AtomsCore::Matrix startRefDiffMatrix; // matrix difference in bind-reference pose of start joint
60  AtomsCore::Quaternion startRefDiff; // difference in bind-reference pose of start joint
61  AtomsCore::Quaternion endRefDiff; // difference in bind-reference pose of end joint
62  std::vector<AtomsCore::Quaternion> refDiffList; // difference in bind-reference pose for each joint in chain order
63  };
64 
67 
69 
72  AgentType(unsigned int numJoints);
73 
75 
78  AgentType(const AtomsCore::Skeleton& skeleton);
79 
82 
84 
87  inline AtomsCore::Skeleton& skeleton();
88 
90 
93  inline const AtomsCore::Skeleton& skeleton() const;
94 
96 
99  void setSkeleton(const AtomsCore::Skeleton& skeleton);
100 
102 
105  inline AtomsCore::MapMetadata& metadata();
106 
108 
111  inline const AtomsCore::MapMetadata& metadata() const;
112 
114  inline const std::string& name() const;
115 
117  inline void setName(const std::string& name);
118 
120  void setRetargetingFactorMethod(const RetargetMethodType method = kPelvisToFeet, const double userFactor =1.0);
121 
123  const RetargetMethodType getRetargetingFactorMethod() const;
124 
126  const double getRetargetingUserFactor() const;
127 
129  const double evaluateRetargetingFactor(const RetargetMethodType method = kPelvisToFeet, const double userFactor = 1.0) const;
130 
132  const double getRetargetingFactor() const;
133 
135  size_t memSize();
136 
138  void hash(AtomsCore::MurmurHash3& h) const;
139 
142 
144  inline const std::vector<AtomsCore::JointChain>& jointChains() const;
145 
147  inline const std::vector<AtomsCore::Matrix>& retargetJointRefWorldMatrix() const;
148 
150  inline const std::vector<AtomsCore::Quaternion>& retargetJointOffset() const;
151 
153  void initializeRetargeting(const std::string &other);
154 
156  inline const std::vector<RetargetJointChainData>& retargetData(const std::string &other) const;
157 
159  inline const bool hasRetargetData(const std::string &other) const;
160 
162  double getPelvisHeight() const;
163 
165  inline double collisionRadius() const;
166 
168  inline void setCollisionRadius(double value);
169 
171 
175  void setVirtualRoot(const bool value, const AtomsCore::Vector3& position);
176 
178  inline bool hasVirtualRoot() const;
179 
181  inline const AtomsCore::Vector3& virtualRootPosition() const;
182 
184  inline FacingDirection getFacingDirection() const;
185 
187  inline void setFacingDirection(FacingDirection direction);
188 
189  private:
190 
192  AtomsCore::Skeleton m_skeleton;
193 
195  AtomsCore::MapMetadata m_metadata;
196 
198  std::string m_name;
199 
201  FacingDirection m_facingDirection;
202 
204  std::vector<AtomsCore::JointChain> m_jointChains;
205 
207  std::map<std::string, std::vector<RetargetJointChainData>> m_retargetData;
208 
210  std::vector<AtomsCore::Matrix> m_retargetJointRefWorldMatrix;
211 
213  std::vector<AtomsCore::Quaternion> m_retargetJointOffset;
214 
216  AtomsCore::Vector3 m_virtualRootPosition;
217 
219  double m_radius;
220 
221  //| Retargeting factor
222  double m_retargetingFactor;
223 
225  double m_retargetingUserFactor;
226 
228  RetargetMethodType m_retargetingMethod;
229 
231  bool m_hasVirtualRoot;
232  };
233 }
234 
235 namespace AtomsCore
236 {
237  ATOMS_EXPORT AtomsCore::Archive& operator<<(AtomsCore::Archive& os, const Atoms::AgentType& agentType);
238 
239  ATOMS_EXPORT AtomsCore::Archive& operator >> (AtomsCore::Archive& is, Atoms::AgentType& agentType);
240 }
241 #include "AgentType.impl.h"
Agent type.
Definition: AgentType.h:30
void setRetargetingFactorMethod(const RetargetMethodType method=kPelvisToFeet, const double userFactor=1.0)
set agent type retargeting method
size_t memSize()
Get memory size.
double getPelvisHeight() const
Returns the distance from the first foot to the height.
void setSkeleton(const AtomsCore::Skeleton &skeleton)
Sets the agent type skeleton.
const double getRetargetingFactor() const
gets the retargeting factor
void setVirtualRoot(const bool value, const AtomsCore::Vector3 &position)
Add virtual root.
void initializeRetargeting(const std::string &other)
Fill retarget data relative to the given other agent type (other as source, this as target)
const RetargetMethodType getRetargetingFactorMethod() const
get the retargeting factor method
AgentType(const AtomsCore::Skeleton &skeleton)
Constructor.
const double getRetargetingUserFactor() const
get the retargeting factor provided by the user
~AgentType()
Destructor.
AgentType(unsigned int numJoints)
Constructor.
void hash(AtomsCore::MurmurHash3 &h) const
Get hash.
AgentType()
Constructor.
void loadCharacterization()
Fill characterization joint chains.
const double evaluateRetargetingFactor(const RetargetMethodType method=kPelvisToFeet, const double userFactor=1.0) const
evaluates the retargeting factor
Archive class.
Definition: Serialiser.h:29
MapMetadata class.
Definition: MapMetadata.h:24
Definition: Hash.h:23
Skeleton class.
Definition: Skeleton.h:68
AtomsCore namespace.
Definition: Agent.h:344
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
AtomsPtr< AgentType > AgentTypePtr
Agent type pointer.
Definition: AgentType.h:17
AtomsPtr< const AgentType > AgentTypeCPtr
Agent type const pointer.
Definition: AgentType.h:21