58template<
typename Po
intT>
61 assert(_skeleton != 0);
75template<
typename Po
intT>
90template<
typename Po
intT>
103template<
typename Po
intT>
106 return local_[_joint];
119template<
typename Po
intT>
122 local_[_joint] = _local;
124 updateFromLocal(_joint, _keepLocalChildPositions);
138template<
typename Po
intT>
142 Matrix &mat = local_[_joint];
143 for(
int i = 0; i < 3; ++i)
160template<
typename Po
intT>
163 Matrix &mat = local_[_joint];
164 for(
int i = 0; i < 3; ++i)
165 mat(i, 3) = _position[i];
167 updateFromLocal(_joint, _keepLocalChildPositions);
175template<
typename Po
intT>
178 Matrix ret = local_[_joint];
192template<
typename Po
intT>
195 return global_[_joint];
210template<
typename Po
intT>
213 global_[_joint] = _global;
215 updateFromGlobal(_joint, _keepGlobalChildPositions);
226template<
typename Po
intT>
230 Matrix &mat = global_[_joint];
231 for(
int i = 0; i < 3; ++i)
248template<
typename Po
intT>
251 Matrix &mat = global_[_joint];
252 for(
int i = 0; i < 3; ++i)
253 mat(i, 3) = _position[i];
255 updateFromGlobal(_joint, _keepGlobalChildPositions);
266template<
typename Po
intT>
269 if (_joint >= global_.size()) {
270 std::cerr <<
"Illegal joint number: " << _joint << std::endl;
273 Matrix ret = global_[_joint];
280template<
typename Po
intT>
289 local_.insert(local_.begin() + _index,
id);
290 global_.insert(global_.begin() + _index,
id);
291 unified_.insert(unified_.begin() + _index,
id);
292 unifiedDualQuaternion_.insert(unifiedDualQuaternion_.begin() + _index, idDQ);
297template<
typename Po
intT>
300 local_.erase(local_.begin() + _index);
301 global_.erase(global_.begin() + _index);
302 unified_.erase(unified_.begin() + _index);
303 unifiedDualQuaternion_.erase(unifiedDualQuaternion_.begin() + _index);
314template<
typename Po
intT>
318 if(skeleton_->parent(_joint) == -1)
319 global_[_joint] = local_[_joint];
321 global_[_joint] = globalMatrix(skeleton_->parent(_joint)) * localMatrix(_joint);
324 Matrix matRefGlobalInv = skeleton_->referencePose()->globalMatrix(_joint);
327 unified_[_joint] = globalMatrix(_joint) * matRefGlobalInv;
328 unifiedDualQuaternion_[_joint] =
DualQuaternion(unified_[_joint]);
331 if (_keepChildPositions) {
333 for(
size_t i = 0; i < skeleton_->childCount(_joint); ++i) {
334 updateFromLocal(skeleton_->child(_joint, i));
337 updateFromGlobal(_joint,
true);
352template<
typename Po
intT>
356 if(skeleton_->parent(_joint) == -1)
357 local_[_joint] = global_[_joint];
359 local_[_joint] = globalMatrixInv(skeleton_->parent(_joint)) * globalMatrix(_joint);
362 Matrix matRefGlobalInv = skeleton_->referencePose()->globalMatrix(_joint);
365 unified_[_joint] = globalMatrix(_joint) * matRefGlobalInv;
366 unifiedDualQuaternion_[_joint] =
DualQuaternion(unified_[_joint]);
369 if (_keepChildPositions) {
370 for(
size_t i = 0; i < skeleton_->childCount(_joint); ++i) {
371 updateFromGlobal(skeleton_->child(_joint, i));
374 updateFromLocal(_joint,
true);
396template<
typename Po
intT>
399 return unified_[_joint];
414template<
typename Po
intT>
417 return unifiedDualQuaternion_[_joint].real();
430template<
typename Po
intT>
433 return unifiedDualQuaternion_[_joint];
DualQuaternion class for representing rigid motions in 3d.
static DualQuaternion identity()
identity dual quaternion [ R(1, 0, 0, 0), D(0,0,0,0) ]
void identity()
setup an identity matrix
bool invert()
matrix inversion (returns true on success)
A general pose, used to store the frames of the animation.
void setLocalMatrix(unsigned int _joint, const Matrix &_local, bool _keepLocalChildPositions=true)
Sets the local coordinate system.
std::vector< Matrix > global_
the pose in global coordinates
Matrix localMatrixInv(unsigned int _joint) const
Simply returns the inverse of the local matrix.
SkeletonT< PointT > * skeleton_
a pointer to the skeleton
const Matrix & unifiedMatrix(size_t _joint)
Returns the unified matrix.
const Matrix & localMatrix(unsigned int _joint) const
Returns the local matrix for the given joint.
void setGlobalTranslation(unsigned int _joint, const Vector &_position, bool _keepGlobalChildPositions=true)
Sets the global translation vector.
PoseT(SkeletonT< Point > *_skeleton)
Constructor.
void updateFromGlobal(size_t _joint, bool _keepChildPositions=true)
This method propagates the change in the global coordinate system to the local system and all childre...
void updateFromLocal(size_t _joint, bool _keepChildPositions=true)
This method propagates the change in the local coordinate system to the global system and all childre...
virtual ~PoseT()
Destructor.
void setLocalTranslation(unsigned int _joint, const Vector &_position, bool _keepLocalChildPositions=true)
Sets the local translation vector.
virtual void removeJointAt(size_t _index)
Called by the skeleton/animation as a joint is removed.
const Matrix & globalMatrix(unsigned int _joint) const
Returns the global matrix for the given joint.
std::vector< DualQuaternion > unifiedDualQuaternion_
std::vector< Matrix > local_
the pose in local coordinates
const Quaternion & unifiedRotation(size_t _joint)
Returns a quaternion holding the rotational part of the unified matrix.
Vector localTranslation(unsigned int _joint)
Returns the local translation vector.
void setGlobalMatrix(unsigned int _joint, const Matrix &_global, bool _keepGlobalChildPositions=true)
Sets the global coordinate system.
Vector globalTranslation(unsigned int _joint)
Returns the global translation vector.
virtual void insertJointAt(size_t _index)
Called by the skeleton/animation as a new joint is inserted.
const DualQuaternion & unifiedDualQuaternion(size_t _joint)
Returns a dual quaternion holding the unified matrix represented as dual quaternion.
std::vector< Matrix > unified_
the global pose matrix left-multiplied to the inverse global reference matrix:
virtual Matrix globalMatrixInv(unsigned int _joint) const
Simply returns the inverse of the global matrix.