64 template<
typename Po
intT>
67 assert(_skeleton != 0);
81 template<
typename Po
intT>
96 template<
typename Po
intT>
109 template<
typename Po
intT>
112 return local_[_joint];
125 template<
typename Po
intT>
128 local_[_joint] = _local;
130 updateFromLocal(_joint, _keepLocalChildPositions);
144 template<
typename Po
intT>
148 Matrix &mat = local_[_joint];
149 for(
int i = 0; i < 3; ++i)
166 template<
typename Po
intT>
169 Matrix &mat = local_[_joint];
170 for(
int i = 0; i < 3; ++i)
171 mat(i, 3) = _position[i];
173 updateFromLocal(_joint, _keepLocalChildPositions);
181 template<
typename Po
intT>
184 Matrix ret = local_[_joint];
198 template<
typename Po
intT>
201 return global_[_joint];
216 template<
typename Po
intT>
219 global_[_joint] = _global;
221 updateFromGlobal(_joint, _keepGlobalChildPositions);
232 template<
typename Po
intT>
236 Matrix &mat = global_[_joint];
237 for(
int i = 0; i < 3; ++i)
254 template<
typename Po
intT>
257 Matrix &mat = global_[_joint];
258 for(
int i = 0; i < 3; ++i)
259 mat(i, 3) = _position[i];
261 updateFromGlobal(_joint, _keepGlobalChildPositions);
272 template<
typename Po
intT>
275 if (_joint >= global_.size()) {
276 std::cerr <<
"Illegal joint number: " << _joint << std::endl;
279 Matrix ret = global_[_joint];
286 template<
typename Po
intT>
295 local_.insert(local_.begin() + _index, id);
296 global_.insert(global_.begin() + _index, id);
297 unified_.insert(unified_.begin() + _index, id);
298 unifiedDualQuaternion_.insert(unifiedDualQuaternion_.begin() + _index, idDQ);
303 template<
typename Po
intT>
306 local_.erase(local_.begin() + _index);
307 global_.erase(global_.begin() + _index);
308 unified_.erase(unified_.begin() + _index);
309 unifiedDualQuaternion_.erase(unifiedDualQuaternion_.begin() + _index);
320 template<
typename Po
intT>
324 if(skeleton_->parent(_joint) == -1)
325 global_[_joint] = local_[_joint];
327 global_[_joint] = globalMatrix(skeleton_->parent(_joint)) * localMatrix(_joint);
330 Matrix matRefGlobalInv = skeleton_->referencePose()->globalMatrix(_joint);
333 unified_[_joint] = globalMatrix(_joint) * matRefGlobalInv;
334 unifiedDualQuaternion_[_joint] =
DualQuaternion(unified_[_joint]);
337 if (_keepChildPositions) {
339 for(
unsigned int i = 0; i < skeleton_->childCount(_joint); ++i) {
340 updateFromLocal(skeleton_->child(_joint, i));
343 updateFromGlobal(_joint,
true);
358 template<
typename Po
intT>
362 if(skeleton_->parent(_joint) == -1)
363 local_[_joint] = global_[_joint];
365 local_[_joint] = globalMatrixInv(skeleton_->parent(_joint)) * globalMatrix(_joint);
368 Matrix matRefGlobalInv = skeleton_->referencePose()->globalMatrix(_joint);
371 unified_[_joint] = globalMatrix(_joint) * matRefGlobalInv;
372 unifiedDualQuaternion_[_joint] =
DualQuaternion(unified_[_joint]);
375 if (_keepChildPositions) {
376 for(
unsigned int i = 0; i < skeleton_->childCount(_joint); ++i) {
377 updateFromGlobal(skeleton_->child(_joint, i));
380 updateFromLocal(_joint,
true);
402 template<
typename Po
intT>
405 return unified_[_joint];
420 template<
typename Po
intT>
423 return unifiedDualQuaternion_[_joint].real();
436 template<
typename Po
intT>
439 return unifiedDualQuaternion_[_joint];
virtual Matrix globalMatrixInv(unsigned int _joint) const
Simply returns the inverse of the global matrix.
void setGlobalMatrix(unsigned int _joint, const Matrix &_global, bool _keepGlobalChildPositions=true)
Sets the global coordinate system.
SkeletonT< PointT > * skeleton_
a pointer to the skeleton
void setGlobalTranslation(unsigned int _joint, const Vector &_position, bool _keepGlobalChildPositions=true)
Sets the global translation vector.
virtual void removeJointAt(unsigned int _index)
Called by the skeleton/animation as a joint is removed.
PoseT(SkeletonT< Point > *_skeleton)
Constructor.
void updateFromGlobal(unsigned int _joint, bool _keepChildPositions=true)
This method propagates the change in the global coordinate system to the local system and all childre...
Vector localTranslation(unsigned int _joint)
Returns the local translation vector.
void updateFromLocal(unsigned int _joint, bool _keepChildPositions=true)
This method propagates the change in the local coordinate system to the global system and all childre...
std::vector< DualQuaternion > unifiedDualQuaternion_
A general pose, used to store the frames of the animation.
std::vector< Matrix > unified_
the global pose matrix left-multiplied to the inverse global reference matrix:
virtual void insertJointAt(unsigned int _index)
Called by the skeleton/animation as a new joint is inserted.
DualQuaternion class for representing rigid motions in 3d.
virtual ~PoseT()
Destructor.
const Matrix & localMatrix(unsigned int _joint) const
Returns the local matrix for the given joint.
const Quaternion & unifiedRotation(unsigned int _joint)
Returns a quaternion holding the rotational part of the unified matrix.
const Matrix & unifiedMatrix(unsigned int _joint)
Returns the unified matrix.
void setLocalTranslation(unsigned int _joint, const Vector &_position, bool _keepLocalChildPositions=true)
Sets the local translation vector.
Vector globalTranslation(unsigned int _joint)
Returns the global translation vector.
Matrix localMatrixInv(unsigned int _joint) const
Simply returns the inverse of the local matrix.
const DualQuaternion & unifiedDualQuaternion(unsigned int _joint)
Returns a dual quaternion holding the unified matrix represented as dual quaternion.
std::vector< Matrix > global_
the pose in global coordinates
void identity()
setup an identity matrix
void setLocalMatrix(unsigned int _joint, const Matrix &_local, bool _keepLocalChildPositions=true)
Sets the local coordinate system.
static DualQuaternion identity()
identity dual quaternion [ R(1, 0, 0, 0), D(0,0,0,0) ]
const Matrix & globalMatrix(unsigned int _joint) const
Returns the global matrix for the given joint.
bool invert()
matrix inversion (returns true on success)
std::vector< Matrix > local_
the pose in local coordinates