Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PoseT< PointT > Class Template Reference

A general pose, used to store the frames of the animation. More...

#include <ObjectTypes/Skeleton/PoseT.hh>

Public Member Functions

 PoseT (SkeletonT< Point > *_skeleton)
 Constructor. More...
 
 PoseT (const PoseT< PointT > &_other)
 Copy Constructor. More...
 
virtual ~PoseT ()
 Destructor.
 
Pose editing

These methods update the other coordinate systems, changing the local coordinates will also change the global and vice versa.

const MatrixlocalMatrix (unsigned int _joint) const
 Returns the local matrix for the given joint. More...
 
void setLocalMatrix (unsigned int _joint, const Matrix &_local, bool _keepLocalChildPositions=true)
 Sets the local coordinate system. More...
 
Vector localTranslation (unsigned int _joint)
 Returns the local translation vector. More...
 
void setLocalTranslation (unsigned int _joint, const Vector &_position, bool _keepLocalChildPositions=true)
 Sets the local translation vector. More...
 
Matrix localMatrixInv (unsigned int _joint) const
 Simply returns the inverse of the local matrix.
 
const MatrixglobalMatrix (unsigned int _joint) const
 Returns the global matrix for the given joint. More...
 
void setGlobalMatrix (unsigned int _joint, const Matrix &_global, bool _keepGlobalChildPositions=true)
 Sets the global coordinate system. More...
 
Vector globalTranslation (unsigned int _joint)
 Returns the global translation vector. More...
 
void setGlobalTranslation (unsigned int _joint, const Vector &_position, bool _keepGlobalChildPositions=true)
 Sets the global translation vector. More...
 
virtual Matrix globalMatrixInv (unsigned int _joint) const
 Simply returns the inverse of the global matrix. More...
 
Synchronization

Use these methods to keep the pose in sync with the number (and indices) of the joints.

virtual void insertJointAt (unsigned int _index)
 Called by the skeleton/animation as a new joint is inserted. More...
 
virtual void removeJointAt (unsigned int _index)
 Called by the skeleton/animation as a joint is removed. More...
 
Unified Matrices

Use these methods to gain access to the precalculations performed by this derivation.

const MatrixunifiedMatrix (unsigned int _joint)
 Returns the unified matrix. More...
 
const QuaternionunifiedRotation (unsigned int _joint)
 Returns a quaternion holding the rotational part of the unified matrix. More...
 
const DualQuaternionunifiedDualQuaternion (unsigned int _joint)
 Returns a dual quaternion holding the unified matrix represented as dual quaternion. More...
 

Protected Types

typedef PointT Point
 
typedef Point::value_type Scalar
 
typedef ACG::VectorT< Scalar, 3 > Vector
 
typedef ACG::Matrix4x4T< Scalar > Matrix
 
typedef ACG::QuaternionT< Scalar > Quaternion
 
typedef ACG::DualQuaternionT
< Scalar > 
DualQuaternion
 

Protected Member Functions

Coordinate system update methods

These methods propagate the change in one of the coordinate systems into the other. This will keep intact the children nodes' positions per default (by recursively updating all children.). This behavior can be influenced via the _keepChildPositions parameter.

void updateFromLocal (unsigned int _joint, bool _keepChildPositions=true)
 This method propagates the change in the local coordinate system to the global system and all children. More...
 
void updateFromGlobal (unsigned int _joint, bool _keepChildPositions=true)
 This method propagates the change in the global coordinate system to the local system and all children. More...
 

Protected Attributes

SkeletonT< PointT > * skeleton_
 a pointer to the skeleton
 
std::vector< Matrixlocal_
 the pose in local coordinates
 
std::vector< Matrixglobal_
 the pose in global coordinates
 
std::vector< Matrixunified_
 the global pose matrix left-multiplied to the inverse global reference matrix: $ M_{pose} \cdot M^{-1}_{reference} $
 
std::vector< DualQuaternionunifiedDualQuaternion_
 

Friends

template<typename >
class SkeletonT
 
template<typename >
class AnimationT
 
template<typename >
class FrameAnimationT
 

Detailed Description

template<typename PointT>
class PoseT< PointT >

A general pose, used to store the frames of the animation.

Definition at line 68 of file PoseT.hh.

Constructor & Destructor Documentation

template<typename PointT >
PoseT< PointT >::PoseT ( SkeletonT< Point > *  _skeleton)

Constructor.

Constructor for a new pose.

The pose will automatically be equipped with the right number of fields for the joints stored in the skeleton. Just fill them with data.

Parameters
_skeletonThe skeleton that owns this pose

Definition at line 65 of file PoseT.cc.

template<typename PointT>
PoseT< PointT >::PoseT ( const PoseT< PointT > &  _other)

Copy Constructor.

Copy constructor.

Creates an independent copy of the given pose.

Definition at line 82 of file PoseT.cc.

Member Function Documentation

template<typename PointT >
const PoseT< PointT >::Matrix & PoseT< PointT >::globalMatrix ( unsigned int  _joint) const
inline

Returns the global matrix for the given joint.

global matrix manipulation the global matrix represents a joints orientation/translation in global coordinates

The global Matrix defines the transformation from bone coordinates back into global world coordinates.

Parameters
_jointThe joints index, same as for SkeletonT<>::joint
Returns
The global matrix, relative to world coordinates

Definition at line 199 of file PoseT.cc.

template<typename PointT >
PoseT< PointT >::Matrix PoseT< PointT >::globalMatrixInv ( unsigned int  _joint) const
virtual

Simply returns the inverse of the global matrix.

The inverse of the global Matrix defines the transformation from global world coordinates in the currently active pose into bone coordinates.

Definition at line 273 of file PoseT.cc.

template<typename PointT >
PoseT< PointT >::Vector PoseT< PointT >::globalTranslation ( unsigned int  _joint)
inline

Returns the global translation vector.

Parameters
_jointThe joints index, same as for SkeletonT<>::joint
Returns
The global translation vector (the 4th column in the global matrix)

Definition at line 233 of file PoseT.cc.

template<typename PointT >
void PoseT< PointT >::insertJointAt ( unsigned int  _index)
virtual

Called by the skeleton/animation as a new joint is inserted.

To keep the vectors storing the matrices for the joints in sync with the joints a new entry has to be inserted in exactly the same place if a new joint is added to the skeleton. This is done here. Derived classes have to overwrite this method to keep their data members in sync as well. Always call the base class method first.

Parameters
_indexThe new joint is inserted at this position. Insert new joints at the end by passing SkeletonT<>::jointCount() as parameter.

Definition at line 287 of file PoseT.cc.

template<typename PointT >
const PoseT< PointT >::Matrix & PoseT< PointT >::localMatrix ( unsigned int  _joint) const
inline

Returns the local matrix for the given joint.

local matrix manipulation the local matrix represents a joints orientation/translation in the coordinate frame of the parent joint

Parameters
_jointThe joints index, same as for SkeletonT<>::joint
Returns
The local matrix, relative to the parents coordinate system

Definition at line 110 of file PoseT.cc.

template<typename PointT >
PoseT< PointT >::Vector PoseT< PointT >::localTranslation ( unsigned int  _joint)
inline

Returns the local translation vector.

The local translation vector describes the translation from the origin of the parent joint coordinate system to the origin of the local joint coordinate system in local coordinates.

Parameters
_jointThe joints index, same as for SkeletonT<>::joint
Returns
The local translation vector (the 4th column in the local matrix)

Definition at line 145 of file PoseT.cc.

template<typename PointT >
void PoseT< PointT >::removeJointAt ( unsigned int  _index)
virtual

Called by the skeleton/animation as a joint is removed.

To keep the vectors storing the matrices for the joints in sync with the joints exactly the same entry has to be removed as a joint is removed from the skeleton. This is done here. Derived classes have to overwrite this method to keep their data members in sync as well. Always call the base class method first.

Parameters
_indexThe new joint is inserted at this position. Insert new joints at the end by passing SkeletonT<>::jointCount() as parameter.

Definition at line 304 of file PoseT.cc.

template<typename PointT >
void PoseT< PointT >::setGlobalMatrix ( unsigned int  _joint,
const Matrix _global,
bool  _keepGlobalChildPositions = true 
)

Sets the global coordinate system.

The global Matrix defines the transformation from bone coordinates back into global world coordinates. The change will automatically be propagated to all children. Also the local matrices will be updated.

Parameters
_jointThe joints index, same as for SkeletonT<>::joint
_globalThe new global matrix
_keepGlobalChildPositionsDo the children stay at the same position or do they move with their parent joint

Definition at line 217 of file PoseT.cc.

template<typename PointT >
void PoseT< PointT >::setGlobalTranslation ( unsigned int  _joint,
const Vector _position,
bool  _keepGlobalChildPositions = true 
)

Sets the global translation vector.

The matrix is otherwise not modified. The change is automatically propagated to all children. Also the local coordinate frames will be updated.

Parameters
_jointThe joints index, same as for SkeletonT<>::joint
_positionThe new global translation vector
_keepGlobalChildPositionsDo the children stay at the same position or do they move with their parent joint

Definition at line 255 of file PoseT.cc.

template<typename PointT >
void PoseT< PointT >::setLocalMatrix ( unsigned int  _joint,
const Matrix _local,
bool  _keepLocalChildPositions = true 
)

Sets the local coordinate system.

The change will automatically be propagated to all children. Also the global matrices will be updated.

Parameters
_jointThe joints index, same as for SkeletonT<>::joint
_localThe new local matrix
_keepLocalChildPositionsIf true, the positions of the children will be kept

Definition at line 126 of file PoseT.cc.

template<typename PointT >
void PoseT< PointT >::setLocalTranslation ( unsigned int  _joint,
const Vector _position,
bool  _keepLocalChildPositions = true 
)

Sets the local translation vector.

The matrix is otherwise not modified. The change is automatically propagated to all children. Also the global coordinate frames will be updated.

Parameters
_jointThe joints index, same as for SkeletonT<>::joint
_positionThe new local translation vector
_keepLocalChildPositionsIf true, the positions of the children will be kept

Definition at line 167 of file PoseT.cc.

template<typename PointT >
const PoseT< PointT >::DualQuaternion & PoseT< PointT >::unifiedDualQuaternion ( unsigned int  _joint)
inline

Returns a dual quaternion holding the unified matrix represented as dual quaternion.

This is used by the Dual Quaternion blend skinning.

Parameters
_jointThe joints index, same as for SkeletonT<>::joint
Returns
The rotational part of the unified matrix

Definition at line 437 of file PoseT.cc.

template<typename PointT >
const PoseT< PointT >::Matrix & PoseT< PointT >::unifiedMatrix ( unsigned int  _joint)
inline

Returns the unified matrix.

The unified matrix stores

\[ M_{unified} = M_{pose} \cdot M^{-1}_{reference} \]

speeding up the calculation of the vertices in the current pose

\[ v_{pose} = M_{pose} \cdot M^{-1}_{reference} \cdot v_{reference} \]

The matrix

\[ M^{-1}_{reference} \]

transforms a point of the skin in global coordinates when the skeleton is in the reference pose to local bone coordinates. The Matrix

\[ M_{pose} \]

takes a point in bone coordinates and transforms it back into global coordinates. As the matrix is given by a skeleton in a different pose, the points in local coordinates will therefore follow the skeleton.

\[ v_{pose} = M_{unified} \cdot v_{reference} \]

Parameters
_jointThe joints index, same as for SkeletonT<>::joint

Definition at line 403 of file PoseT.cc.

template<typename PointT >
const PoseT< PointT >::Quaternion & PoseT< PointT >::unifiedRotation ( unsigned int  _joint)
inline

Returns a quaternion holding the rotational part of the unified matrix.

This is used by the spherical blend skinning.

The rotational part of the unified matrix is stored in the real part of the dual quaternion

Parameters
_jointThe joints index, same as for SkeletonT<>::joint
Returns
The rotational part of the unified matrix

Definition at line 421 of file PoseT.cc.

template<typename PointT >
void PoseT< PointT >::updateFromGlobal ( unsigned int  _joint,
bool  _keepChildPositions = true 
)
protected

This method propagates the change in the global coordinate system to the local system and all children.

Do not overwrite this method, instead overwrite BasePose::UpdateFromGlobalCallback. Otherwise the recursion will become a problem.

Parameters
_jointThe updated joints index
_keepChildPositionsDo the children stay at the same global position or do they move with their parent joint

Definition at line 359 of file PoseT.cc.

template<typename PointT >
void PoseT< PointT >::updateFromLocal ( unsigned int  _joint,
bool  _keepChildPositions = true 
)
protected

This method propagates the change in the local coordinate system to the global system and all children.

Parameters
_jointThe updated joints index
_keepChildPositionsDo the children stay at the same position or do they move with their parent joint

Definition at line 321 of file PoseT.cc.

Member Data Documentation

template<typename PointT>
std::vector<DualQuaternion> PoseT< PointT >::unifiedDualQuaternion_
protected

JointT::PoseT::unified in DualQuaternion representation note: the real part of the dual quaternion is the rotation part of the transformation as quaternion

Definition at line 198 of file PoseT.hh.


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