Developer Documentation
PoseT.hh
1/*===========================================================================*\
2* *
3* OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39* *
40\*===========================================================================*/
41
42#pragma once
43
44#include "ACG/Math/Matrix4x4T.hh"
45
46#include "ACG/Math/QuaternionT.hh"
47#include "ACG/Math/DualQuaternionT.hh"
48
49
50template<typename PointT>
51class SkeletonT;
52
57template<typename PointT>
58class PoseT
59{
60 template<typename>
61 friend class SkeletonT;
62 template<typename>
63 friend class AnimationT;
64 template<typename>
65 friend class FrameAnimationT;
66
67protected:
68 typedef PointT Point;
69 typedef typename Point::value_type Scalar;
70 typedef typename ACG::VectorT<Scalar, 3> Vector;
71 typedef typename ACG::Matrix4x4T<Scalar> Matrix;
72 typedef typename ACG::QuaternionT<Scalar> Quaternion;
74
75public:
77 explicit PoseT(SkeletonT<Point>* _skeleton);
78
80 explicit PoseT(const PoseT<PointT>& _other);
81
82
84 PoseT& operator= ( const PoseT & ) = default;
85
87 virtual ~PoseT();
88
89 // =======================================================================================
94 // =======================================================================================
95
98 inline const Matrix& localMatrix(unsigned int _joint) const;
99 void setLocalMatrix(unsigned int _joint, const Matrix &_local, bool _keepLocalChildPositions=true);
100 inline Vector localTranslation(unsigned int _joint);
101 void setLocalTranslation(unsigned int _joint, const Vector &_position, bool _keepLocalChildPositions=true);
102
103 inline Matrix localMatrixInv(unsigned int _joint) const;
104
107 inline const Matrix& globalMatrix(unsigned int _joint) const;
108 void setGlobalMatrix(unsigned int _joint, const Matrix &_global, bool _keepGlobalChildPositions=true);
109 inline Vector globalTranslation(unsigned int _joint);
110 void setGlobalTranslation(unsigned int _joint, const Vector &_position, bool _keepGlobalChildPositions=true);
111
112 virtual Matrix globalMatrixInv(unsigned int _joint) const;
113
116 // =======================================================================================
121 // =======================================================================================
122
134 virtual void insertJointAt(size_t _index);
135
147 virtual void removeJointAt(size_t _index);
148
151protected:
152 // =======================================================================================
158 // =======================================================================================
159
160 void updateFromLocal(size_t _joint, bool _keepChildPositions=true);
161 void updateFromGlobal(size_t _joint, bool _keepChildPositions=true);
162
165public:
166
167 // =======================================================================================
172 // =======================================================================================
173
174 inline const Matrix& unifiedMatrix(size_t _joint);
175 inline const Quaternion& unifiedRotation(size_t _joint);
176 inline const DualQuaternion& unifiedDualQuaternion(size_t _joint);
177
180protected:
181
185 std::vector<Matrix> local_;
187 std::vector<Matrix> global_;
188
190 std::vector<Matrix> unified_;
191
194 std::vector<DualQuaternion> unifiedDualQuaternion_;
195};
196
197//=============================================================================
198//=============================================================================
199#if defined(INCLUDE_TEMPLATES) && !defined(POSET_C)
200#define POSET_TEMPLATES
201#include "PoseT_impl.hh"
202#endif
203
204
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
Definition: DataTypes.hh:176
DualQuaternion class for representing rigid motions in 3d.
Stores a single animation.
Definition: AnimationT.hh:59
A general pose, used to store the frames of the animation.
Definition: PoseT.hh:59
void setLocalMatrix(unsigned int _joint, const Matrix &_local, bool _keepLocalChildPositions=true)
Sets the local coordinate system.
Definition: PoseT_impl.hh:120
std::vector< Matrix > global_
the pose in global coordinates
Definition: PoseT.hh:187
Matrix localMatrixInv(unsigned int _joint) const
Simply returns the inverse of the local matrix.
Definition: PoseT_impl.hh:176
SkeletonT< PointT > * skeleton_
a pointer to the skeleton
Definition: PoseT.hh:183
const Matrix & unifiedMatrix(size_t _joint)
Returns the unified matrix.
Definition: PoseT_impl.hh:397
const Matrix & localMatrix(unsigned int _joint) const
Returns the local matrix for the given joint.
Definition: PoseT_impl.hh:104
void setGlobalTranslation(unsigned int _joint, const Vector &_position, bool _keepGlobalChildPositions=true)
Sets the global translation vector.
Definition: PoseT_impl.hh:249
PoseT(SkeletonT< Point > *_skeleton)
Constructor.
Definition: PoseT_impl.hh:59
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...
Definition: PoseT_impl.hh:353
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...
Definition: PoseT_impl.hh:315
virtual ~PoseT()
Destructor.
Definition: PoseT_impl.hh:91
void setLocalTranslation(unsigned int _joint, const Vector &_position, bool _keepLocalChildPositions=true)
Sets the local translation vector.
Definition: PoseT_impl.hh:161
virtual void removeJointAt(size_t _index)
Called by the skeleton/animation as a joint is removed.
Definition: PoseT_impl.hh:298
const Matrix & globalMatrix(unsigned int _joint) const
Returns the global matrix for the given joint.
Definition: PoseT_impl.hh:193
std::vector< DualQuaternion > unifiedDualQuaternion_
Definition: PoseT.hh:194
std::vector< Matrix > local_
the pose in local coordinates
Definition: PoseT.hh:185
const Quaternion & unifiedRotation(size_t _joint)
Returns a quaternion holding the rotational part of the unified matrix.
Definition: PoseT_impl.hh:415
Vector localTranslation(unsigned int _joint)
Returns the local translation vector.
Definition: PoseT_impl.hh:139
void setGlobalMatrix(unsigned int _joint, const Matrix &_global, bool _keepGlobalChildPositions=true)
Sets the global coordinate system.
Definition: PoseT_impl.hh:211
Vector globalTranslation(unsigned int _joint)
Returns the global translation vector.
Definition: PoseT_impl.hh:227
PoseT & operator=(const PoseT &)=default
Use the default = operator.
virtual void insertJointAt(size_t _index)
Called by the skeleton/animation as a new joint is inserted.
Definition: PoseT_impl.hh:281
const DualQuaternion & unifiedDualQuaternion(size_t _joint)
Returns a dual quaternion holding the unified matrix represented as dual quaternion.
Definition: PoseT_impl.hh:431
std::vector< Matrix > unified_
the global pose matrix left-multiplied to the inverse global reference matrix:
Definition: PoseT.hh:190
virtual Matrix globalMatrixInv(unsigned int _joint) const
Simply returns the inverse of the global matrix.
Definition: PoseT_impl.hh:267