Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50 #ifndef POSET_HH
51 #define POSET_HH
52
53 #include "ACG/Math/Matrix4x4T.hh"
54 #include "ACG/Math/VectorT.hh"
55
56 #include "ACG/Math/QuaternionT.hh"
57 #include "ACG/Math/DualQuaternionT.hh"
58
59
60 template<typename PointT>
61 class SkeletonT;
62
67 template<typename PointT>
68 class PoseT
69 {
70 template<typename>
71 friend class SkeletonT;
72 template<typename>
73 friend class AnimationT;
74 template<typename>
75 friend class FrameAnimationT;
76
77 protected:
78 typedef PointT Point;
79 typedef typename Point::value_type Scalar;
80 typedef typename ACG::VectorT<Scalar, 3> Vector;
81 typedef typename ACG::Matrix4x4T<Scalar> Matrix;
82 typedef typename ACG::QuaternionT<Scalar> Quaternion;
83 typedef typename ACG::DualQuaternionT<Scalar> DualQuaternion;
84
85 public:
87 PoseT(SkeletonT<Point>* _skeleton);
89 PoseT(const PoseT<PointT>& _other);
91 virtual ~PoseT();
92
93 // =======================================================================================
98 // =======================================================================================
99
102 inline const Matrix& localMatrix(unsigned int _joint) const;
103 void setLocalMatrix(unsigned int _joint, const Matrix &_local, bool _keepLocalChildPositions=true);
104 inline Vector localTranslation(unsigned int _joint);
105 void setLocalTranslation(unsigned int _joint, const Vector &_position, bool _keepLocalChildPositions=true);
106
107 inline Matrix localMatrixInv(unsigned int _joint) const;
108
111 inline const Matrix& globalMatrix(unsigned int _joint) const;
112 void setGlobalMatrix(unsigned int _joint, const Matrix &_global, bool _keepGlobalChildPositions=true);
113 inline Vector globalTranslation(unsigned int _joint);
114 void setGlobalTranslation(unsigned int _joint, const Vector &_position, bool _keepGlobalChildPositions=true);
115
116 virtual Matrix globalMatrixInv(unsigned int _joint) const;
117
120 // =======================================================================================
125 // =======================================================================================
126
138 virtual void insertJointAt(unsigned int _index);
139
151 virtual void removeJointAt(unsigned int _index);
152
155 protected:
156 // =======================================================================================
162 // =======================================================================================
163
164 void updateFromLocal(unsigned int _joint, bool _keepChildPositions=true);
165 void updateFromGlobal(unsigned int _joint, bool _keepChildPositions=true);
166
169 public:
170
171 // =======================================================================================
176 // =======================================================================================
177
178 inline const Matrix& unifiedMatrix(unsigned int _joint);
179 inline const Quaternion& unifiedRotation(unsigned int _joint);
180 inline const DualQuaternion& unifiedDualQuaternion(unsigned int _joint);
181
184 protected:
185
187 SkeletonT<PointT>* skeleton_;
189 std::vector<Matrix> local_;
191 std::vector<Matrix> global_;
192
194 std::vector<Matrix> unified_;
195
198 std::vector<DualQuaternion> unifiedDualQuaternion_;
199 };
200
201 //=============================================================================
202 //=============================================================================
203 #if defined(INCLUDE_TEMPLATES) && !defined(POSET_C)
204 #define POSET_TEMPLATES
205 #include "PoseT.cc"
206 #endif
207 //=============================================================================
208 #endif
209 //=============================================================================
210
PoseT::globalMatrixInv
virtual Matrix globalMatrixInv(unsigned int _joint) const
Simply returns the inverse of the global matrix.
Definition: PoseT.cc:273
PoseT::setGlobalMatrix
void setGlobalMatrix(unsigned int _joint, const Matrix &_global, bool _keepGlobalChildPositions=true)
Sets the global coordinate system.
Definition: PoseT.cc:217
PoseT::skeleton_
SkeletonT< PointT > * skeleton_
a pointer to the skeleton
Definition: PoseT.hh:187
PoseT::setGlobalTranslation
void setGlobalTranslation(unsigned int _joint, const Vector &_position, bool _keepGlobalChildPositions=true)
Sets the global translation vector.
Definition: PoseT.cc:255
PoseT::removeJointAt
virtual void removeJointAt(unsigned int _index)
Called by the skeleton/animation as a joint is removed.
Definition: PoseT.cc:304
PoseT::PoseT
PoseT(SkeletonT< Point > *_skeleton)
Constructor.
Definition: PoseT.cc:65
PoseT::updateFromGlobal
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...
Definition: PoseT.cc:359
PoseT::localTranslation
Vector localTranslation(unsigned int _joint)
Returns the local translation vector.
Definition: PoseT.cc:145
PoseT::updateFromLocal
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...
Definition: PoseT.cc:321
PoseT::unifiedDualQuaternion_
std::vector< DualQuaternion > unifiedDualQuaternion_
Definition: PoseT.hh:198
PoseT
A general pose, used to store the frames of the animation.
Definition: PoseT.hh:68
PoseT::unified_
std::vector< Matrix > unified_
the global pose matrix left-multiplied to the inverse global reference matrix:
Definition: PoseT.hh:194
Vector
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
Definition: DataTypes.hh:187
PoseT::insertJointAt
virtual void insertJointAt(unsigned int _index)
Called by the skeleton/animation as a new joint is inserted.
Definition: PoseT.cc:287
ACG::DualQuaternionT
DualQuaternion class for representing rigid motions in 3d.
Definition: DualQuaternionT.hh:90
PoseT::~PoseT
virtual ~PoseT()
Destructor.
Definition: PoseT.cc:97
PoseT::localMatrix
const Matrix & localMatrix(unsigned int _joint) const
Returns the local matrix for the given joint.
Definition: PoseT.cc:110
PoseT::unifiedRotation
const Quaternion & unifiedRotation(unsigned int _joint)
Returns a quaternion holding the rotational part of the unified matrix.
Definition: PoseT.cc:421
PoseT::unifiedMatrix
const Matrix & unifiedMatrix(unsigned int _joint)
Returns the unified matrix.
Definition: PoseT.cc:403
OpenMesh::VectorT
Definition: Vector11T.hh:83
PoseT::setLocalTranslation
void setLocalTranslation(unsigned int _joint, const Vector &_position, bool _keepLocalChildPositions=true)
Sets the local translation vector.
Definition: PoseT.cc:167
SkeletonT
Definition: JointT.hh:56
PoseT::globalTranslation
Vector globalTranslation(unsigned int _joint)
Returns the global translation vector.
Definition: PoseT.cc:233
PoseT::localMatrixInv
Matrix localMatrixInv(unsigned int _joint) const
Simply returns the inverse of the local matrix.
Definition: PoseT.cc:182
PoseT::unifiedDualQuaternion
const DualQuaternion & unifiedDualQuaternion(unsigned int _joint)
Returns a dual quaternion holding the unified matrix represented as dual quaternion.
Definition: PoseT.cc:437
PoseT::global_
std::vector< Matrix > global_
the pose in global coordinates
Definition: PoseT.hh:191
PoseT::setLocalMatrix
void setLocalMatrix(unsigned int _joint, const Matrix &_local, bool _keepLocalChildPositions=true)
Sets the local coordinate system.
Definition: PoseT.cc:126
AnimationT
Stores a single animation.
Definition: AnimationT.hh:67
PoseT::globalMatrix
const Matrix & globalMatrix(unsigned int _joint) const
Returns the global matrix for the given joint.
Definition: PoseT.cc:199
ACG::Matrix4x4T
Definition: Matrix4x4T.hh:98
PoseT::local_
std::vector< Matrix > local_
the pose in local coordinates
Definition: PoseT.hh:189
FrameAnimationT
Definition: FrameAnimationT.hh:56
ACG::QuaternionT
Definition: QuaternionT.hh:81