Atoms Crowd  7.0.0
JointChain.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2020 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/Joint.h>
13 #include <AtomsCore/Poser.h>
14 #include <string>
15 #include <vector>
16 
17 namespace AtomsCore
18 {
19  class JointChain;
20 
22 
23  typedef const JointChain * JointChainCPtr;
24 
25  typedef std::vector<JointChainPtr> JointChainPtrArray;
26 
28  /*
29  */
30  class ATOMSCORE_EXPORT JointChain
31  {
32 
33  public:
34 
35  struct BindData
36  {
37  AtomsCore::Matrix matrix;
40  };
41 
43  JointChain(unsigned short numberOfJoints);
44 
46  JointChain(const JointChain& rhs);
47 
50 
53 
55 
58  inline const std::string& name() const;
59 
61 
64  inline void setName(const std::string& name);
65 
67 
70  inline const std::string& fullName() const;
71 
73 
76  inline void setFullName(const std::string& fullName);
77 
79 
82  inline unsigned short id() const;
83 
85 
88  inline void setId(unsigned short id);
89 
91 
95  Joint& joint(unsigned short i);
96 
98 
102  const Joint& joint(unsigned short i) const;
103 
105 
108  inline unsigned short jointId(unsigned short i) const;
109 
111 
113  inline const std::vector<unsigned short>& ikJointIds() const;
114 
116 
118  inline const std::vector<unsigned short>& skeletalJointIds() const;
119 
121 
124  inline const BindData& bindData(unsigned short i) const;
125 
127 
131  inline void setJoint(const Joint& joint, unsigned short i);
132 
134 
138  inline void setJointId(unsigned short id, unsigned short i);
139 
141 
144  inline void setIkJointIds(std::vector<unsigned short> ikIds);
145 
147 
150  inline unsigned short numJoints() const;
151 
153 
156  inline unsigned short numIkJoints() const;
157 
159 
162  inline unsigned short numSkeletalJointIds() const;
163 
165 
168  inline const std::vector<unsigned short>& jointIds() const;
169 
171 
174  inline const JointChain* parent() const;
175 
177 
179  inline void setParent(JointChain &parent);
180 
182 
185  inline const JointPtr start() const;
186 
188 
190  void setStart();
191 
193 
196  inline const JointPtr end() const;
197 
199 
201  void setEnd();
202 
204 
206  inline bool isConnectedToParent() const;
207 
209 
212  inline void setIsConnectedToParent(bool isConnected);
213 
215 
217  inline bool isRoot() const;
218 
220 
223  inline void setIsRoot(bool isRoot);
224 
226 
228  inline bool isSpine() const;
229 
231 
234  inline void setIsSpine(bool isSpine);
235 
237 
239  inline bool isLimb() const;
240 
242 
245  inline void setIsLimb(bool isLimb);
246 
248 
250  inline bool isEffector() const;
251 
253 
256  inline void setIsEffector(bool isEffector);
257 
259 
261  inline bool isCenter() const;
262 
264 
267  inline void setIsCenter(bool isCenter);
268 
270 
272  inline bool forceUseFabrik() const;
273 
275 
278  inline void setForceUseFabrik(bool useFabrik);
279 
281 
283  inline bool forceOrientEnd() const;
284 
286 
289  inline void setForceOrientEnd(bool orientEnd);
290 
292 
294  inline bool hasFootTip() const;
295 
297 
300  inline void setHasFootIk(bool hasFootIk);
301 
303 
305  inline bool hasFootIk() const;
306 
308 
311  inline void setHasFootTip(bool hasFoot);
312 
314 
316  inline bool hasPelvis() const;
317 
319 
322  inline void setHasPelvis(bool hasPelvis);
323 
325 
327  inline bool hasPoleVector() const;
328 
330 
333  inline void setHasPoleVector(bool hasPoleVector);
334 
336 
338  inline AtomsCore::Vector3 poleVector() const;
339 
341 
344  inline void setPoleVector(AtomsCore::Vector3 poleVector);
345 
347 
349  inline unsigned short footTip() const;
350 
352 
355  inline void setFootTip(unsigned short footTip);
356 
358 
360  inline unsigned short footIk() const;
361 
363 
366  inline void setFootIk(unsigned short footIk);
367 
369 
371  inline unsigned short pelvisId() const;
372 
374 
377  inline void setPelvisId(unsigned short pelvisId);
378 
380 
382  void computeWorldBindData(const AtomsCore::Skeleton &skeleton, const AtomsCore::Poser &poser);
383 
385 
387  inline double length() const;
388 
390 
392  inline void setLength(double len);
393 
395 
398 
400 
402  inline AtomsCore::Vector3 start2endBindVector() const;
403 
405 
407  inline double start2endBindDistance() const;
408 
410 
413  const AtomsCore::Poser &poser,
414  const unsigned int jointId,
415  AtomsCore::Matrix &matrix,
416  AtomsCore::Vector3 &scale,
417  AtomsCore::Vector3 &shear,
418  AtomsCore::Euler &euler,
419  AtomsCore::Vector3 &pos) const;
420 
422 
425 
427  inline void setParentSpine(unsigned short spineJointId, const AtomsCore::Vector3& planeNormal, double baseSize);
428 
430  inline const AtomsCore::Vector3& spinePlaneNormal() const;
431 
433  inline const unsigned int spineJointId() const;
434 
436  inline const double spineBaseSize() const;
437 
438  private:
439 
441  JointPtr m_joints;
442 
444  std::string m_name;
445 
447  std::string m_fullName;
448 
450  unsigned short m_id;
451 
453  unsigned short m_numJoints;
454 
456  double m_length;
457 
459  std::vector<unsigned short> m_jointIds;
460 
462  std::vector<unsigned short> m_ikJointIds;
463 
465  std::vector<unsigned short> m_skeletalJointIds;
466 
468  std::vector<BindData> m_jointBindData;
469 
471  JointPtr m_start;
472 
474  JointPtr m_end;
475 
477  JointChain* m_parent;
478 
480  unsigned short m_footTip;
481 
483  unsigned short m_footIk;
484 
486  unsigned short m_pelvisId;
487 
489  AtomsCore::Vector3 m_start2endBindVector;
490 
492  AtomsCore::Vector3 m_poleVector;
493 
495  AtomsCore::Vector3 m_spinePlaneNormal;
496 
498  unsigned short m_spineId;
499 
501  double m_spineBaseSize;
502 
504  double m_start2endBindDistance;
505 
507  bool m_isConnectedToParent;
508 
510  bool m_isRoot;
511 
513  bool m_isSpine;
514 
516  bool m_isLimb;
517 
519  bool m_isEffector;
520 
522  bool m_isCenter;
523 
525  bool m_forceUseFabrik;
526 
528  bool m_forceOrientEnd;
529 
531  bool m_hasFootTip;
532 
534  bool m_hasFootIk;
535 
537  bool m_hasPelvis;
538 
540  bool m_hasPoleVector;
541  };
542 }
543 
545 ATOMSCORE_EXPORT std::ostream& operator<<(std::ostream& os, const AtomsCore::JointChain& jointChain);
546 
547 #include "JointChain.impl.h"
JointChain class.
Definition: JointChain.h:31
~JointChain()
Destructor.
void computeSkeletalJointIds(const AtomsCore::Skeleton &skeleton)
Sets the skeletal joint ids vector navigating on the skeleton.
const Joint & joint(unsigned short i) const
Gets a joint.
Joint & joint(unsigned short i)
Gets a joint.
JointChain(const JointChain &rhs)
Copy constructor.
void setStart()
Refresh pointer to the start joint.
void computeLength()
Computes the length of the chain.
JointChain & operator=(const JointChain &ptr)
Assign operator.
void getWorldBindData(const AtomsCore::Poser &poser, const unsigned int jointId, AtomsCore::Matrix &matrix, AtomsCore::Vector3 &scale, AtomsCore::Vector3 &shear, AtomsCore::Euler &euler, AtomsCore::Vector3 &pos) const
Extracts the world bind data of the given joint.
JointChain(unsigned short numberOfJoints)
Constructor.
void computeWorldBindData(const AtomsCore::Skeleton &skeleton, const AtomsCore::Poser &poser)
Computes the world bind data of every joint in chain.
void setEnd()
Refresh pointer to the end joint.
Joint class.
Definition: Joint.h:30
Poser class.
Definition: Poser.h:24
Skeleton class.
Definition: Skeleton.h:68
AtomsCore namespace.
Definition: Agent.h:344
std::vector< JointChainPtr > JointChainPtrArray
Vector fo jointChain pointers.
Definition: JointChain.h:25
AtomsMath::Quaternion Quaternion
Quaternion class.
Definition: AtomsMath.h:67
AtomsMath::Vector3 Vector3
Vector3 class.
Definition: AtomsMath.h:57
const JointChain * JointChainCPtr
JointChain const pointer.
Definition: JointChain.h:23
AtomsMath::Matrix Matrix
Matrix class.
Definition: AtomsMath.h:63
AtomsMath::Euler Euler
Euler class.
Definition: AtomsMath.h:69
JointChain * JointChainPtr
JointChain pointer.
Definition: JointChain.h:19
Definition: JointChain.h:36