float AnimationTrack::getLength() const { if( getNumKeyFrames() <= 0 ) return 0; return mKeyFrames[ getNumKeyFrames() - 1 ]->getTime(); }
void AnimationTrack::deleteKeyFrame( unsigned int index ) { assert( index < getNumKeyFrames() ); delete mKeyFrames[index]; mKeyFrames.erase( mKeyFrames.begin() + index ); _updateKeyFrameIndices(); }
void Spline::displayline() { glColor3f(0.7, 0.7, 0.0); glPointSize(8.0); glBegin(GL_POINTS); int length = getNumKeyFrames() + 1; for (int i = -1; i < length; ++i) { Vec3D vec = getKeyPoint(i); glVertex3f(vec.getX(), vec.getY(), vec.getZ()); } glEnd(); glColor3f(1.0, 1.0, 1.0); glBegin(GL_LINE_STRIP); length = getNumKeyFrames() - 1; for (float u = 0; u < length; u += 0.02) { Vec3D v = getPoint(u); //glColor3f(0.5 + sin(u * 2 * M_PI) / 2.0, 0.5 + cos(u * 2 * M_PI) / 2.0, 0); glVertex3f(v.getX(), v.getY(), v.getZ()); } glEnd(); }
/* * u >= 0 only */ Vec3D Spline::getPoint(float u) { double part; double frac = modf(u, &part); int v = ((int) part ) % (getNumKeyFrames() - 1); return catmull_rom(getKeyPoint(v-1), getKeyPoint(v), getKeyPoint(v+1), getKeyPoint(v+2), frac); }
float Spline::getULength() { return (getNumKeyFrames() - 1); }
KeyFrame* AnimationTrack::getKeyFrame( unsigned int index ) const { assert( index < getNumKeyFrames() ); return mKeyFrames[index]; }