44 #define INTERPOLATIONANIMATIONT_C 46 #include "AnimationT.hh" 61 template<
class Po
intT>
64 skeleton_(_other.skeleton_),
65 matrixManipulator_(_other.matrixManipulator_),
79 template<
class Po
intT>
82 matrixManipulator_(_matrixManipulator),
90 template<
class Po
intT>
98 template<
class Po
intT>
105 template<
class Po
intT>
113 template<
class Po
intT>
118 if (interpolatedPoses_.find(_iFrame) != interpolatedPoses_.end()) {
120 return (interpolatedPoses_[_iFrame]);
124 interpolatedPoses_.insert( std::make_pair(0,
new Pose(*_reference)) );
126 return pose(_iFrame, _reference);
130 unsigned long min = 0;
133 for (i=0; i<interpolators_.size(); ++i) {
136 if (_iFrame >= min && _iFrame <= max) {
137 interpolator = interpolators_[i];
142 if (interpolator == NULL) {
150 Pose *generatedPose =
new Pose(*_reference);
152 for (uint i=0; i<influencedJoints_.size(); ++i) {
156 TargetType precalcVal = precalculations_[
interpolator][_iFrame - min];
159 generatedPose->
setGlobalMatrix(influencedJoints_[i], transformation,
false);
164 interpolatedPoses_.insert(std::pair<unsigned long, Pose*>(_iFrame, generatedPose));
165 return (interpolatedPoses_.find(_iFrame)->second);
174 template<
class Po
intT>
182 template<
class Po
intT>
191 template<
class Po
intT>
207 template<
class Po
intT>
215 template<
class Po
intT>
217 if (_interpolator == NULL)
220 interpolators_.push_back(_interpolator);
223 std::vector < TargetType > valueVector;
227 for (i=_interpolator->getMinInput()*FPS;i<=(_interpolator->getMaxInput()) * FPS;++i) {
228 TargetType precalcValue;
229 double input = ((double)i) / ((double)FPS);
230 precalcValue = _interpolator->getValue(input);
231 valueVector.push_back(precalcValue);
238 precalculations_.insert( std::pair<
Interpolator*, std::vector < TargetType > >(_interpolator, valueVector) );
240 frames_ = std::max<long unsigned int>(frames_, i+1);
245 template<
class Po
intT>
249 if ( _index < interpolators_.size() )
250 return interpolators_[ _index ];
257 template<
class Po
intT>
260 return interpolators_.size();
268 template<
class Po
intT>
270 assert (_index < interpolators_.size());
273 return precalculations_[interpolators_[_index]].size() - 1;
281 template<
class Po
intT>
283 if (interpolators_.size() == 0)
286 _result = interpolators_[0]->getMinInput();
288 for (uint i=0;i<interpolators_.size();++i) {
289 if (interpolators_[i]->getMinInput() < _result)
290 _result = interpolators_[i]->getMinInput();
298 template<
class Po
intT>
300 if (interpolators_.size() == 0)
303 _result = interpolators_[0]->getMaxInput();
305 for (uint i=0;i<interpolators_.size();++i) {
306 if (interpolators_[i]->getMaxInput() > _result)
307 _result = interpolators_[i]->getMaxInput();
315 template<
class Po
intT>
317 for (uint i=0; i<influencedJoints_.size(); ++i)
318 if ( influencedJoints_[i] == _joint )
326 template<
class Po
intT>
328 return influencedJoints_;
unsigned int frameCount()
Returns the number of frames stored in this pose.
unsigned int interpolatorCount()
Get the number of interpolators.
const Matrix & globalMatrix(unsigned int _joint) const
Returns the global matrix for the given joint.
void addInterpolator(InterpolationT< double > *_interpolator)
Add an interpolator.
virtual Pose * pose(unsigned int _iFrame)
Returns a pointer to the pose calculated for the given frame.
void setGlobalMatrix(unsigned int _joint, const Matrix &_global, bool _keepGlobalChildPositions=true)
Sets the global coordinate system.
A general pose, used to store the frames of the animation.
virtual void removeJointAt(unsigned int _index)
Called by the skeleton as a joint is deleted.
unsigned int calcAbsoluteMaxForInterpolator(uint _index)
Calculates the last frame that interpolator _index is responsible for.
Pose * referencePose()
Returns a pointer to the reference pose.
4x4 matrix implementing OpenGL commands.
Knows how to apply the values generated by an interpolator to a matrix. When playing back an Interpol...
Interpolator * interpolator(unsigned int _index)
Get the i-th interpolator.
virtual void updateFromGlobal(unsigned int _index)
Updates the local matrix using the global matrix.
virtual void insertJointAt(unsigned int _index)
Called by the skeleton as a new joint is inserted.
Stores a single animation.
InterpolationAnimationT(const InterpolationAnimationT< PointT > &_other)
Copy constructor.
virtual void doManipulation(GLMatrixT &_matrix, std::vector< Scalar > _value)=0