Atoms Crowd  4.1.0
AtomsCore::Skeleton Class Reference

Skeleton class. More...

#include <Skeleton.h>

Public Types

typedef std::map< unsigned short, MapMetadataJointMetadataMap
 Joint metadata map.
 
typedef std::vector< FootStructFeetVector
 Vector of pair foot-foot root.
 

Public Member Functions

 Skeleton (unsigned short numberOfJoints=1)
 Constructor. More...
 
 Skeleton (const Skeleton &rhs)
 Copy constructor.
 
 ~Skeleton ()
 Destructor.
 
Skeletonoperator= (const Skeleton &rhs)
 Assign operator.
 
unsigned short numJoints () const
 Gets the number of joints. More...
 
void setNumJoints (unsigned int numJoints)
 Sets the number of joints. More...
 
Jointoperator[] (unsigned short index)
 Gets the joint. More...
 
const Jointoperator[] (unsigned short index) const
 Gets the joint. More...
 
Jointjoint (unsigned short index)
 Gets the joint. More...
 
const Jointjoint (unsigned short index) const
 Gets the joint. More...
 
JointCPtr root () const
 Gets the root joint. More...
 
JointPtr root ()
 Gets the root joint. More...
 
void setRoot (unsigned short id)
 Sets the root joint. More...
 
unsigned short numFeet () const
 Gets the number of feet. More...
 
void clearFeet ()
 Clears all the feet.
 
void addFoot (unsigned short footIK, unsigned short footRoot, unsigned short footTip)
 Adds a foot. More...
 
JointPtr footIK (unsigned short id)
 Gets the foot IK. More...
 
JointCPtr footIK (unsigned short id) const
 Gets the foot IK. More...
 
bool isFootIK (unsigned short id) const
 Check if a joint is a foot ik. More...
 
JointPtr footRoot (unsigned short id)
 Get foot root. More...
 
JointCPtr footRoot (unsigned short id) const
 Get foot root. More...
 
bool isFootRoot (unsigned short id) const
 Check if a joint is a foot root. More...
 
JointPtr footTip (unsigned short id)
 Get foot tip. More...
 
JointCPtr footTip (unsigned short id) const
 Get foot tip. More...
 
bool isFootTip (unsigned short id) const
 Check if a joint is a foot tip. More...
 
bool footHasPoleVector (unsigned short id) const
 Returns true if the foot at the given id has a pole vector.
 
AtomsCore::Vector3 footPoleVector (unsigned short id) const
 Returns the foot pole vector.
 
void setFootPoleVector (unsigned short id, const AtomsCore::Vector3 &value)
 Set the foto pole vector.
 
unsigned short footPelvis (unsigned short id) const
 Get foot pelvis. More...
 
const std::vector< unsigned short > & midJoints (unsigned short id) const
 Get leg mid joints. More...
 
const std::vector< unsigned short > & legJoints (unsigned short id) const
 Get leg joints. More...
 
unsigned short numPelvises () const
 Gets the number of pelvises. More...
 
void clearPelvises ()
 Clears all pelvises.
 
void addPelvis (unsigned short pelvisJoint)
 Adds a pelvis. More...
 
JointPtr pelvis (unsigned short id)
 Gets a pelvis. More...
 
JointCPtr pelvis (unsigned short id) const
 Get pelvis. More...
 
bool isPelvis (unsigned short id) const
 Check if a joint is a pelvis. More...
 
unsigned int numPelvisChains (unsigned int id) const
 Get number of pelvis chains. More...
 
PelvisChainpelvisChain (unsigned int id, unsigned int chain)
 Get a palvis chain. More...
 
const PelvisChainpelvisChain (unsigned int id, unsigned int chain) const
 Get a palvis chain. More...
 
const std::vector< unsigned short > & detachedJoints () const
 Get joints without a parent. More...
 
void buildIkData ()
 Build Ik data. More...
 
void buildJointNameMap ()
 Build Joint name -> id map.
 
void buildDetachedJointsList ()
 Build detached joints list.
 
int jointId (const std::string &name) const
 Gets the joint id. More...
 
void clear ()
 Clears all joints and metadatas.
 
size_t memSize () const
 Get the memory size.
 
std::vector< unsigned short > jointMetadataIds () const
 Gets the ids of the joints having some metadatas.
 
bool jointHasMetadata (unsigned short index)
 Check if a joint has some metadata. More...
 
bool jointHasMetadata (unsigned short index) const
 Check if a joint has some metadata. More...
 
MapMetadatajointMetadata (unsigned short index)
 Gets joint metadata. More...
 
const MapMetadatajointMetadata (unsigned short index) const
 Gets joint metadata. More...
 
void setJointMetadata (unsigned short index, const MapMetadata &data)
 Adds joint metadata. More...
 
void addJointMetadata (unsigned short index, const std::string &key, Metadata *data)
 Adds joint metadata. More...
 
void addJointMetadata (unsigned short index, const std::string &key, const AtomsPtr< Metadata > data)
 Adds joint metadata. More...
 
void clearJointMetadata (unsigned short index)
 Clears joint metadata. More...
 
void clearJointsMetadata ()
 Clears all joint metadata.
 
void hash (MurmurHash3 &hash) const
 Hash.
 
std::vector< SkeletonLod > & lods ()
 Get sim lod info.
 
const std::vector< SkeletonLod > & lods () const
 Get sim lod info.
 
void sanitizeJointNames ()
 Sanitize joint names.
 

Detailed Description

Skeleton class.

The skeleton class stores an array of joints. This array is initialized by the constructor. It's not possible to add other joints after the constructor. This class contains an array of joint ids that represent the skeleton pelvises. A pelvis is defined as a joint connecting two opposite legs. For example in a human there is just one pelvis, while in an horse there are 2 pelvises joint, one for the back legs and one for the front legs. The concept of multiple pelvises is used by the motion blending engine in order to bend the spine when a character with multiple pelvises turns. This class contains also a list of feet joints. For every foot, a foot root (usually corresponding to the hip joint), ik and tip must be defined. The three joints are used by the motion engine to compute the leg IKs during the simulation.

Constructor & Destructor Documentation

◆ Skeleton()

AtomsCore::Skeleton::Skeleton ( unsigned short  numberOfJoints = 1)

Constructor.

Initializes the skeleton with a fixed number of joints.

Parameters
numberOfJointsNumber of joints

Member Function Documentation

◆ addFoot()

void AtomsCore::Skeleton::addFoot ( unsigned short  footIK,
unsigned short  footRoot,
unsigned short  footTip 
)
inline

Adds a foot.

Adds a foot. In addition to the foot root joint, Atoms also need the joint index where the ik system will be attached and the foot tip.

Parameters
footIKFoot IK joint
footRootFoot root joint
footTipFoot tip joint

◆ addJointMetadata() [1/2]

void AtomsCore::Skeleton::addJointMetadata ( unsigned short  index,
const std::string &  key,
const AtomsPtr< Metadata data 
)
inline

Adds joint metadata.

Parameters
indexJoint index
keymetadata map key
datametadata

◆ addJointMetadata() [2/2]

void AtomsCore::Skeleton::addJointMetadata ( unsigned short  index,
const std::string &  key,
Metadata data 
)
inline

Adds joint metadata.

Parameters
indexJoint index
keymetadata map key
datametadata

◆ addPelvis()

void AtomsCore::Skeleton::addPelvis ( unsigned short  pelvisJoint)
inline

Adds a pelvis.

Parameters
pelvisJointPelvis joint

◆ buildIkData()

void AtomsCore::Skeleton::buildIkData ( )

Build Ik data.

It parse all the feet and fill the metadata with the parent pelvis and the midjoint list

◆ clearJointMetadata()

void AtomsCore::Skeleton::clearJointMetadata ( unsigned short  index)

Clears joint metadata.

Parameters
indexJoint index

◆ detachedJoints()

const std::vector< unsigned short > & AtomsCore::Skeleton::detachedJoints ( ) const
inline

Get joints without a parent.

Returns
Indices of the joints without a parent

◆ footIK() [1/2]

JointPtr AtomsCore::Skeleton::footIK ( unsigned short  id)
inline

Gets the foot IK.

Get the foot ik joint at the given index.

Parameters
idFoot id

◆ footIK() [2/2]

JointCPtr AtomsCore::Skeleton::footIK ( unsigned short  id) const
inline

Gets the foot IK.

Get the foot ik joint at the given index.

Parameters
idFoot id
Returns
Foot IK joint

◆ footPelvis()

unsigned short AtomsCore::Skeleton::footPelvis ( unsigned short  id) const
inline

Get foot pelvis.

Return the pelvis for the given foot.

Parameters
idFoot id
Returns
Pelvis index inside the pelvises array

◆ footRoot() [1/2]

JointPtr AtomsCore::Skeleton::footRoot ( unsigned short  id)
inline

Get foot root.

Get the foot root joint at the given index.

Parameters
idFoot id
Returns
Foot root joint of the n'th foot

◆ footRoot() [2/2]

JointCPtr AtomsCore::Skeleton::footRoot ( unsigned short  id) const
inline

Get foot root.

Get the foot root joint at the given index.

Parameters
idFoot id
Returns
Foot root joint of the n'th foot

◆ footTip() [1/2]

JointPtr AtomsCore::Skeleton::footTip ( unsigned short  id)
inline

Get foot tip.

Get the foot tip joint at the given index. The foot tip represents the joint which remains attach on the ground upon contact.

Parameters
idFoot id
Returns
Foot tip joint of the n'th foot

◆ footTip() [2/2]

JointCPtr AtomsCore::Skeleton::footTip ( unsigned short  id) const
inline

Get foot tip.

Get the foot tip joint at the given index. The foot tip represents the joint which remains attach on the ground upon contact.

Parameters
idFoot id
Returns
Foot tip joint of the n'th foot

◆ isFootIK()

bool AtomsCore::Skeleton::isFootIK ( unsigned short  id) const

Check if a joint is a foot ik.

Returns
true if the joint with the given id is a foot ik

◆ isFootRoot()

bool AtomsCore::Skeleton::isFootRoot ( unsigned short  id) const

Check if a joint is a foot root.

Returns
true if the joint with the given id is a foot root

◆ isFootTip()

bool AtomsCore::Skeleton::isFootTip ( unsigned short  id) const

Check if a joint is a foot tip.

Returns
true if the joint with the given id is a foot tip

◆ isPelvis()

bool AtomsCore::Skeleton::isPelvis ( unsigned short  id) const

Check if a joint is a pelvis.

Returns
true if the joint with the given id is a pelvis

◆ joint() [1/2]

Joint& AtomsCore::Skeleton::joint ( unsigned short  index)

Gets the joint.

The function automatically checks whether the given index is within the valid bounds, throwing an out_of_range exception if it is not.

Parameters
indexIndex of the joint
Returns
Joint

◆ joint() [2/2]

const Joint& AtomsCore::Skeleton::joint ( unsigned short  index) const

Gets the joint.

The function automatically checks whether the given index is within the valid bounds, throwing an out_of_range exception if it is not.

Parameters
indexIndex of the joint
Returns
Joint

◆ jointHasMetadata() [1/2]

bool AtomsCore::Skeleton::jointHasMetadata ( unsigned short  index)

Check if a joint has some metadata.

Parameters
indexJoint index
Returns
Return true if joint has some metadata

◆ jointHasMetadata() [2/2]

bool AtomsCore::Skeleton::jointHasMetadata ( unsigned short  index) const

Check if a joint has some metadata.

Parameters
indexJoint index
Returns
Return true if joint has some metadata

◆ jointId()

int AtomsCore::Skeleton::jointId ( const std::string &  name) const
inline

Gets the joint id.

Parameters
nameJoint name
Returns
Joint id

◆ jointMetadata() [1/2]

MapMetadata & AtomsCore::Skeleton::jointMetadata ( unsigned short  index)
inline

Gets joint metadata.

Parameters
indexJoint index
Returns
Joint metadata map

◆ jointMetadata() [2/2]

const MapMetadata& AtomsCore::Skeleton::jointMetadata ( unsigned short  index) const

Gets joint metadata.

Parameters
indexJoint index
Returns
Joint metadata map

◆ legJoints()

const std::vector< unsigned short > & AtomsCore::Skeleton::legJoints ( unsigned short  id) const
inline

Get leg joints.

Return the leg joints

Parameters
idFoot tip id
Returns
A list of joint indices.

◆ midJoints()

const std::vector< unsigned short > & AtomsCore::Skeleton::midJoints ( unsigned short  id) const
inline

Get leg mid joints.

Return the leg mid joints. The mid joints are the joints betweek the foot root and ik joints.

Parameters
idFoot tip id
Returns
A list of joint indices.

◆ numFeet()

unsigned short AtomsCore::Skeleton::numFeet ( ) const
inline

Gets the number of feet.

Returns
Number of feet

◆ numJoints()

unsigned short AtomsCore::Skeleton::numJoints ( ) const
inline

Gets the number of joints.

Returns
Number of joints

◆ numPelvisChains()

unsigned int AtomsCore::Skeleton::numPelvisChains ( unsigned int  id) const
inline

Get number of pelvis chains.

Get the number of pelvis chains connected to a pelvis

Parameters
idIndex of the pelvis
Returns
Number of pelvis chains

◆ numPelvises()

unsigned short AtomsCore::Skeleton::numPelvises ( ) const
inline

Gets the number of pelvises.

Returns
Number of pelvises

◆ operator[]() [1/2]

Joint & AtomsCore::Skeleton::operator[] ( unsigned short  index)
inline

Gets the joint.

Parameters
indexIndex of the joint
Returns
Joint

◆ operator[]() [2/2]

const Joint & AtomsCore::Skeleton::operator[] ( unsigned short  index) const
inline

Gets the joint.

Parameters
indexIndex of the joint
Returns
Joint

◆ pelvis() [1/2]

JointPtr AtomsCore::Skeleton::pelvis ( unsigned short  id)
inline

Gets a pelvis.

Returns
Index of the pelvis

◆ pelvis() [2/2]

JointCPtr AtomsCore::Skeleton::pelvis ( unsigned short  id) const
inline

Get pelvis.

Returns
Index of the pelvis

◆ pelvisChain() [1/2]

PelvisChain* AtomsCore::Skeleton::pelvisChain ( unsigned int  id,
unsigned int  chain 
)

Get a palvis chain.

A pelvis chain in a list of joint between two pelvises

Parameters
idIndex of the pelvis
idIndex of the chain
Returns
Pelvis chain

◆ pelvisChain() [2/2]

const PelvisChain* AtomsCore::Skeleton::pelvisChain ( unsigned int  id,
unsigned int  chain 
) const

Get a palvis chain.

A pelvis chain in a list of joint between two pelvises

Parameters
idIndex of the pelvis
idIndex of the chain
Returns
Pelvis chain

◆ root() [1/2]

JointPtr AtomsCore::Skeleton::root ( )
inline

Gets the root joint.

By default it's the joint at 0 index, otherwise is the joint set by the setRootJoint member function

Returns
Root joint

◆ root() [2/2]

JointCPtr AtomsCore::Skeleton::root ( ) const
inline

Gets the root joint.

By default it's the joint at 0 index, otherwise is the joint set by the setRootJoint member function

Returns
Root joint

◆ setJointMetadata()

void AtomsCore::Skeleton::setJointMetadata ( unsigned short  index,
const MapMetadata data 
)
inline

Adds joint metadata.

Parameters
indexJoint index
dataJoint metadata map

◆ setNumJoints()

void AtomsCore::Skeleton::setNumJoints ( unsigned int  numJoints)

Sets the number of joints.

Parameters
numJointsNumber of joints

◆ setRoot()

void AtomsCore::Skeleton::setRoot ( unsigned short  id)
inline

Sets the root joint.

Parameters
idRoot joint

The documentation for this class was generated from the following files: