Atoms Crowd  4.1.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  kBoundingBox,
37  kUserValue
38  };
39 
41  {
42  unsigned short thisIndex; // index of the chain in target
43  unsigned short otherIndex; // index of the chain in source
44  std::vector<unsigned short> thisMetadataIndices; // joint indices in target for metadata transference
45  std::vector<unsigned short> otherMetadataIndices; // joint indices in source for metadata transference
46  double factor; // scaling factor for diff chain lengths
47  AtomsCore::Vector3 offset; // offset in case of spines to respect bind pose
48  AtomsCore::Matrix startRefDiffMatrix; // matrix difference in bind-reference pose of start joint
49  AtomsCore::Quaternion startRefDiff; // difference in bind-reference pose of start joint
50  AtomsCore::Quaternion endRefDiff; // difference in bind-reference pose of end joint
51  std::vector<AtomsCore::Quaternion> refDiffList; // difference in bind-reference pose for each joint in chain order
52  };
53 
56 
58 
61  AgentType(unsigned int numJoints);
62 
64 
67  AgentType(const AtomsCore::Skeleton& skeleton);
68 
71 
73 
76  inline AtomsCore::Skeleton& skeleton();
77 
79 
82  inline const AtomsCore::Skeleton& skeleton() const;
83 
85 
88  void setSkeleton(const AtomsCore::Skeleton& skeleton);
89 
91 
94  inline AtomsCore::MapMetadata& metadata();
95 
97 
100  inline const AtomsCore::MapMetadata& metadata() const;
101 
103  inline const std::string& name() const;
104 
106  inline void setName(const std::string& name);
107 
109  bool addAgentTypeRetargeting(const std::string &agentType, const std::string& fileName, const unsigned int method = kPelvisToFeet, const double userFactor =1.0);
110 
112  std::vector<std::string> getRetargetingAgentTypes() const;
113 
115  AtomsPtr<const AtomsCore::MapMetadata> getRetargetingJointMap(const std::string &agentType) const;
116 
117  const unsigned int getRetargetingMethod(const std::string &agentType) const;
118 
119  const double getRetargetingUserFactor(const std::string &agentType) const;
120 
122  void removeAgentTypeRetargeting(const std::string &agentType);
123 
125  size_t memSize();
126 
128  void hash(AtomsCore::MurmurHash3& h) const;
129 
132 
134  inline double pelvisToFeet() const;
135 
137  inline const std::vector<AtomsCore::JointChain>& jointChains() const;
138 
140  inline const std::vector<AtomsCore::Matrix>& retargetJointRefWorldMatrix() const;
141 
143  inline const std::vector<AtomsCore::Quaternion>& retargetJointOffset() const;
144 
146  void initializeRetargeting(const std::string &other);
147 
149  inline const std::vector<RetargetJointChainData>& retargetData(const std::string &other) const;
150 
152  inline const bool hasRetargetData(const std::string &other) const;
153 
155  double getPelvisHeight() const;
156 
157  private:
158 
160  AtomsCore::Skeleton m_skeleton;
161 
163  AtomsCore::MapMetadata m_metadata;
164 
166  std::string m_name;
167 
169  std::vector<AtomsCore::JointChain> m_jointChains;
170 
172  std::map<std::string, std::vector<RetargetJointChainData>> m_retargetData;
173 
175  std::vector<AtomsCore::Matrix> m_retargetJointRefWorldMatrix;
176 
178  std::vector<AtomsCore::Quaternion> m_retargetJointOffset;
179 
181  double m_pelvisToFeet;
182  };
183 }
184 
185 namespace AtomsCore
186 {
187  ATOMS_EXPORT AtomsCore::Archive& operator<<(AtomsCore::Archive& os, const Atoms::AgentType& agentType);
188 
189  ATOMS_EXPORT AtomsCore::Archive& operator >> (AtomsCore::Archive& is, Atoms::AgentType& agentType);
190 }
191 #include "AgentType.impl.h"
Atoms::AgentType::getRetargetingAgentTypes
std::vector< std::string > getRetargetingAgentTypes() const
get config map number
Atoms::AgentType::memSize
size_t memSize()
Get memory size.
Atoms::AgentType::addAgentTypeRetargeting
bool addAgentTypeRetargeting(const std::string &agentType, const std::string &fileName, const unsigned int method=kPelvisToFeet, const double userFactor=1.0)
add agent type retargeting
AtomsCore::Quaternion
AtomsMath::Quaternion Quaternion
Quaternion class.
Definition: AtomsMath.h:67
Atoms::AgentType::initializeRetargeting
void initializeRetargeting(const std::string &other)
Fill retarget data relative to the given other agent type (other as source, this as target)
Atoms::AgentType::AgentType
AgentType(unsigned int numJoints)
Constructor.
AtomsCore::Archive
Archive class.
Definition: Serialiser.h:29
Atoms::AgentType
Agent type.
Definition: AgentType.h:30
Atoms::AgentType::~AgentType
~AgentType()
Destructor.
Atoms::AgentTypePtr
AtomsPtr< AgentType > AgentTypePtr
Agent type pointer.
Definition: AgentType.h:17
AtomsCore::Matrix
AtomsMath::Matrix Matrix
Matrix class.
Definition: AtomsMath.h:63
AtomsCore::Vector3
AtomsMath::Vector3 Vector3
Vector3 class.
Definition: AtomsMath.h:57
Atoms::AgentType::hash
void hash(AtomsCore::MurmurHash3 &h) const
Get hash.
Atoms::AgentType::AgentType
AgentType(const AtomsCore::Skeleton &skeleton)
Constructor.
Atoms
Atoms namespace.
Definition: Agent.h:28
AtomsCore
AtomsCore namespace.
Definition: AtomsMath.h:24
AtomsCore::MapMetadata
MapMetadata class.
Definition: MapMetadata.h:24
Atoms::AgentType::getPelvisHeight
double getPelvisHeight() const
Returns the distance from the first foot to the height.
AtomsCore::Skeleton
Skeleton class.
Definition: Skeleton.h:68
Atoms::AgentType::RetargetJointChainData
Definition: AgentType.h:41
Atoms::AgentType::loadCharacterization
void loadCharacterization()
Fill characterization joint chains.
Atoms::AgentType::setSkeleton
void setSkeleton(const AtomsCore::Skeleton &skeleton)
Sets the agent type skeleton.
Atoms::AgentTypeCPtr
AtomsPtr< const AgentType > AgentTypeCPtr
Agent type const pointer.
Definition: AgentType.h:21
Atoms::AgentType::AgentType
AgentType()
Constructor.
Atoms::AgentType::removeAgentTypeRetargeting
void removeAgentTypeRetargeting(const std::string &agentType)
remove config map
AtomsCore::MurmurHash3
Definition: Hash.h:23
Atoms::AgentType::getRetargetingJointMap
AtomsPtr< const AtomsCore::MapMetadata > getRetargetingJointMap(const std::string &agentType) const
get config map compatible agent type