Atoms Crowd  7.0.0
Pose.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 <AtomsCore/Globals.h>
11 #include <AtomsCore/AtomsMath.h>
12 #include <AtomsCore/JointPose.h>
13 #include <AtomsCore/Metadata/MapMetadata.h>
14 #include <AtomsCore/Serialiser.h>
15 #include <string>
16 #include <vector>
17 #include <map>
18 
19 namespace AtomsCore
20 {
21  class Pose;
22 
23  typedef Pose* PosePtr;
24 
25  typedef const Pose * PoseCPtr;
26 
28 
31  class ATOMSCORE_EXPORT Pose
32  {
33  public:
34 
36  typedef std::map<unsigned short, MapMetadata> JointMetadataMap;
37 
39  Pose();
40 
42 
45  Pose(const Skeleton* skeleton, bool inParentSpace = false);
46 
48  Pose(const Pose& rhs);
49 
51  ~Pose();
52 
54  Pose& operator=(const Pose& rhs);
55 
57 
61  void setNumberJoints(unsigned short n);
62 
64 
67  inline unsigned short numJoints() const;
68 
70 
73  inline JointPose& jointPose(unsigned short index);
74 
76 
79  inline const JointPose& jointPose(unsigned short index) const;
80 
82 
86  inline void setJointPose(unsigned short index, const JointPose& jointPose);
87 
89  inline void clearAllPose();
90 
92 
95  inline void setDirection(const AtomsCore::Vector3& direction);
96 
98 
101  inline const AtomsCore::Vector3& getDirection() const;
102 
104 
108  bool jointHasMetadata(unsigned short index) const;
109 
111 
114  inline JointMetadataMap& jointsMetadata();
115 
117 
120  inline const JointMetadataMap& jointsMetadata() const;
121 
123 
127  inline MapMetadata& jointMetadata(unsigned short index);
128 
130 
134  const MapMetadata& jointMetadata(unsigned short index) const;
135 
137 
141  inline void setJointMetadata(unsigned short index, const MapMetadata& data);
142 
144 
149  inline void addJointMetadata(unsigned short index, const std::string& key, Metadata *data);
150 
152 
157  inline void addJointMetadata(unsigned short index, const std::string& key, const AtomsPtr<Metadata> data);
158 
160 
163  void clearJointMetadata(unsigned short index);
164 
166 
169  inline MapMetadata& poseMetadata();
170 
172 
175  inline const MapMetadata& poseMetadata() const;
176 
178 
182  inline void addPoseMetadata(const std::string& key, Metadata *data);
183 
185  inline void clearPoseMetadata();
186 
188  inline void clearJointsMetadata();
189 
191  size_t memSize() const;
192 
194  std::vector<unsigned short> jointMetadataIds() const;
195 
197 
199  size_t hash(short roundBits = 10) const;
200 
201  void resetActiveJoints();
202 
203  void setActiveJoints(const std::vector<short>& flags);
204 
205  void setActiveJoint(size_t index, bool value);
206 
207  bool isJointActive(size_t index) const;
208 
210  inline void setInParentSpace(bool flag);
211 
213  inline bool inParentSpace() const;
214 
216  void convertToParentSpace(const Skeleton* skeleton);
217 
219  void convertToLocalSpace(const Skeleton* skeleton);
220 
221  private:
222 
224  std::vector<JointPose> m_jointPose;
225 
227  MapMetadata m_poseMetadata;
228 
230  JointMetadataMap m_jointMetadata;
231 
233  AtomsCore::Vector3 m_direction;
234 
236  std::vector<short> m_activeJoints;
237 
239  bool m_inParentSpace;
240  };
241 }
242 
243 namespace AtomsCore
244 {
246  ATOMSCORE_EXPORT AtomsCore::Archive& operator<<(AtomsCore::Archive& os, const AtomsCore::Pose& pose);
247 
249  ATOMSCORE_EXPORT AtomsCore::Archive& operator >> (AtomsCore::Archive& is, AtomsCore::Pose& pose);
250 }
251 #include "Pose.impl.h"
Archive class.
Definition: Serialiser.h:29
Joint pose.
Definition: JointPose.h:20
MapMetadata class.
Definition: MapMetadata.h:24
Base Metadata class.
Definition: Metadata.h:24
Pose class.
Definition: Pose.h:32
Pose()
Constructor.
std::vector< unsigned short > jointMetadataIds() const
Gets the ids of the joints that have some metadatas.
Pose(const Pose &rhs)
Copy constructor.
bool jointHasMetadata(unsigned short index) const
Checks if a joint has some metadata.
~Pose()
Destructor.
size_t hash(short roundBits=10) const
Return the hash of this pose.
Pose(const Skeleton *skeleton, bool inParentSpace=false)
Constructor.
void setNumberJoints(unsigned short n)
Sets the number of joints.
const MapMetadata & jointMetadata(unsigned short index) const
Gets the joint metadata.
void convertToLocalSpace(const Skeleton *skeleton)
Converts this pose to local space.
size_t memSize() const
Gets the memory size.
Pose & operator=(const Pose &rhs)
Assign operator.
void convertToParentSpace(const Skeleton *skeleton)
Converts this pose to parent space.
void clearJointMetadata(unsigned short index)
Clears joint metadata.
std::map< unsigned short, MapMetadata > JointMetadataMap
Joint metadata map.
Definition: Pose.h:36
Skeleton class.
Definition: Skeleton.h:68
AtomsCore namespace.
Definition: Agent.h:344
Pose * PosePtr
Fwd declaration.
Definition: Pose.h:21
const Pose * PoseCPtr
Pose const pointer.
Definition: Pose.h:25
AtomsMath::Vector3 Vector3
Vector3 class.
Definition: AtomsMath.h:57