23 #ifndef QGLVIEWER_KEY_FRAME_INTERPOLATOR_H
24 #define QGLVIEWER_KEY_FRAME_INTERPOLATOR_H
26 #if QT_VERSION > 0x040000
34 #include "quaternion.h"
167 void addKeyFrame(
const Frame& frame);
168 void addKeyFrame(
const Frame& frame,
float time);
170 void addKeyFrame(
const Frame*
const frame);
171 void addKeyFrame(
const Frame*
const frame,
float time);
188 void setFrame(
Frame*
const frame);
194 Frame keyFrame(
int index)
const;
195 float keyFrameTime(
int index)
const;
198 float duration()
const;
199 float firstTime()
const;
200 float lastTime()
const;
273 void startInterpolation(
int period = -1);
274 void stopInterpolation();
275 void resetInterpolation();
277 void toggleInterpolation() {
if (interpolationIsStarted()) stopInterpolation();
else startInterpolation(); };
278 virtual void interpolateAtTime(
float time);
284 virtual void drawPath(
int mask=1,
int nbFrames=6,
float scale=1.0f);
290 virtual QDomElement domElement(
const QString& name, QDomDocument& document)
const;
291 virtual void initFromDOMElement(
const QDomElement& element);
295 virtual void update();
296 virtual void invalidateValues() { valuesAreValid_ =
false; pathIsValid_ =
false; splineCacheIsValid_ =
false; };
304 void updateCurrentKeyFrameForTime(
float time);
305 void updateModifiedFrameValues();
306 void updateSplineCache();
313 KeyFrame(
const Frame& fr,
float t);
314 KeyFrame(
const Frame* fr,
float t);
316 Vec position()
const {
return p_; }
317 Quaternion orientation()
const {
return q_; }
318 Vec tgP()
const {
return tgP_; }
319 Quaternion tgQ()
const {
return tgQ_; }
320 float time()
const {
return time_; }
321 const Frame* frame()
const {
return frame_; }
322 void updateValuesFromPointer();
323 void flipOrientationIfNeeded(
const Quaternion& prev);
324 void computeTangent(
const KeyFrame*
const prev,
const KeyFrame*
const next);
329 const Frame*
const frame_;
334 #if QT_VERSION >= 0x040000
335 mutable QList<KeyFrame*> keyFrame_;
336 QMutableListIterator<KeyFrame*>* currentFrame_[4];
339 mutable QPtrList<KeyFrame> keyFrame_;
341 QPtrListIterator<KeyFrame>* currentFrame_[4];
342 # if QT_VERSION >= 0x030000
344 QValueVector<Frame> path_;
346 QVector<Frame> path_;
356 float interpolationTime_;
357 float interpolationSpeed_;
358 bool interpolationStarted_;
362 bool loopInterpolation_;
366 bool valuesAreValid_;
367 bool currentFrameValid_;
368 bool splineCacheIsValid_;
374 #endif // QGLVIEWER_KEY_FRAME_INTERPOLATOR_H