50 #define INTERPOLATIONANIMATIONT_C
52 #include "AnimationT.hh"
67 template<
class Po
intT>
70 skeleton_(_other.skeleton_),
71 matrixManipulator_(_other.matrixManipulator_),
85 template<
class Po
intT>
88 matrixManipulator_(_matrixManipulator),
96 template<
class Po
intT>
104 template<
class Po
intT>
111 template<
class Po
intT>
114 return pose(_iFrame, skeleton_->referencePose());
119 template<
class Po
intT>
124 if (interpolatedPoses_.find(_iFrame) != interpolatedPoses_.end()) {
126 return (interpolatedPoses_[_iFrame]);
130 interpolatedPoses_.insert( std::make_pair(0,
new Pose(*_reference)) );
132 return pose(_iFrame, _reference);
136 unsigned long min = 0;
139 for (i=0; i<interpolators_.size(); ++i) {
140 min = (i==0 ? 0.0 : calcAbsoluteMaxForInterpolator(i-1) + 1);
141 const unsigned long max = calcAbsoluteMaxForInterpolator(i);
142 if (_iFrame >= min && _iFrame <= max) {
143 interpolator = interpolators_[i];
148 if (interpolator == NULL) {
156 Pose *generatedPose =
new Pose(*_reference);
158 for (uint i=0; i<influencedJoints_.size(); ++i) {
162 TargetType precalcVal = precalculations_[interpolator][_iFrame - min];
164 matrixManipulator_->doManipulation(transformation, precalcVal);
165 generatedPose->
setGlobalMatrix(influencedJoints_[i], transformation,
false);
170 interpolatedPoses_.insert(std::pair<unsigned long, Pose*>(_iFrame, generatedPose));
171 return (interpolatedPoses_.find(_iFrame)->second);
180 template<
class Po
intT>
188 template<
class Po
intT>
197 template<
class Po
intT>
213 template<
class Po
intT>
221 template<
class Po
intT>
223 if (_interpolator == NULL)
226 interpolators_.push_back(_interpolator);
229 std::vector < TargetType > valueVector;
233 for (i=_interpolator->getMinInput()*FPS;i<=(_interpolator->getMaxInput()) * FPS;++i) {
234 TargetType precalcValue;
235 double input = ((double)i) / ((double)FPS);
236 precalcValue = _interpolator->getValue(input);
237 valueVector.push_back(precalcValue);
244 precalculations_.insert( std::pair<
Interpolator*, std::vector < TargetType > >(_interpolator, valueVector) );
246 frames_ = std::max<long unsigned int>(frames_, i+1);
251 template<
class Po
intT>
255 if ( _index < interpolators_.size() )
256 return interpolators_[ _index ];
263 template<
class Po
intT>
266 return interpolators_.size();
274 template<
class Po
intT>
276 assert (_index < interpolators_.size());
279 return precalculations_[interpolators_[_index]].size() - 1;
281 return precalculations_[interpolators_[_index]].size() + calcAbsoluteMaxForInterpolator(_index - 1);
287 template<
class Po
intT>
289 if (interpolators_.size() == 0)
292 _result = interpolators_[0]->getMinInput();
294 for (uint i=0;i<interpolators_.size();++i) {
295 if (interpolators_[i]->getMinInput() < _result)
296 _result = interpolators_[i]->getMinInput();
304 template<
class Po
intT>
306 if (interpolators_.size() == 0)
309 _result = interpolators_[0]->getMaxInput();
311 for (uint i=0;i<interpolators_.size();++i) {
312 if (interpolators_[i]->getMaxInput() > _result)
313 _result = interpolators_[i]->getMaxInput();
321 template<
class Po
intT>
323 for (uint i=0; i<influencedJoints_.size(); ++i)
324 if ( influencedJoints_[i] == _joint )
332 template<
class Po
intT>
334 return influencedJoints_;
virtual Pose * pose(unsigned int _iFrame)
Returns a pointer to the pose calculated for the given frame.
unsigned int frameCount()
Returns the number of frames stored in this pose.
void setGlobalMatrix(unsigned int _joint, const Matrix &_global, bool _keepGlobalChildPositions=true)
Sets the global coordinate system.
unsigned int calcAbsoluteMaxForInterpolator(uint _index)
Calculates the last frame that interpolator _index is responsible for.
Knows how to apply the values generated by an interpolator to a matrix. When playing back an Interpol...
Pose * pose(const AnimationHandle &_hAni)
Returns a pointer to the pose with the given animation handle.
A general pose, used to store the frames of the animation.
Interpolator * interpolator(unsigned int _index)
Get the i-th interpolator.
4x4 matrix implementing OpenGL commands.
InterpolationAnimationT(const InterpolationAnimationT< PointT > &_other)
Copy constructor.
Stores a single animation.
const Matrix & globalMatrix(unsigned int _joint) const
Returns the global matrix for the given joint.
void addInterpolator(InterpolationT< double > *_interpolator)
Add an 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.
unsigned int interpolatorCount()
Get the number of interpolators.
virtual void removeJointAt(unsigned int _index)
Called by the skeleton as a joint is deleted.