Public Slots | |
virtual void | update () |
Public Methods | |
KeyFrameInterpolator (qglviewer::Frame *fr=NULL) | |
virtual | ~KeyFrameInterpolator () |
virtual QDomElement | domElement (const QString &name, QDomDocument &doc) const |
virtual void | initFromDOMElement (const QDomElement &de) |
virtual void | drawPath (const int mask=1, int nbFrames=6, const float scale=1.0) |
Key Frames | |
void | setFrame (qglviewer::Frame *fr) |
qglviewer::Frame * | frame () const |
void | addKeyFrame (const qglviewer::Frame &fr) |
void | addKeyFrame (const qglviewer::Frame &fr, const float time) |
void | addKeyFrame (const qglviewer::Frame *fr) |
void | addKeyFrame (const qglviewer::Frame *fr, const float time) |
void | deletePath () |
int | numberOfKeyFrames () const |
qglviewer::Vec | keyFramePosition (const int i) const |
qglviewer::Quaternion | keyFrameOrientation (const int i) const |
float | keyFrameTime (const int i) const |
Interpolation parameters | |
float | interpolationTime () const |
void | setInterpolationTime (const float time) |
float | interpolationSpeed () const |
void | setInterpolationSpeed (const float speed) |
int | interpolationPeriod () const |
void | setInterpolationPeriod (const int msecs) |
bool | loopInterpolation () const |
void | setLoopInterpolation (const bool loop=true) |
bool | closedPath () const |
void | setClosedPath (const bool closed=true) |
Interpolation | |
virtual void | interpolateAtTime (const float time) |
void | startInterpolation (const int msecs=-1) |
void | stopInterpolation () |
void | resetInterpolation () |
bool | interpolationIsStarted () const |
void | toggleInterpolation () |
KeyFrameInterpolator implements a classical interpolation of key Frames, using a smooth Catmull-Rom based interpolation.
Use addKeyFrame() to define the keyframes and then call startInterpolation(). The Frame associated with the interpolator (using the constructor or with setFrame()) will then be updated over time.
The interpolation can loop (setLoopInterpolation()) and the keyFrame path can be closed (setClosedPath()). The current interpolation time (interpolationTime()) and speed (interpolationSpeed()) can also be tuned.
The keyFrames are defined by a Frame and a time, expressed in seconds. The time has to be monotonously increasing over keyFrames.
See the keyFrames example for an illustration of the class.
|
Creates a KeyFrameInterpolator, which will drive the Use addKeyFrame() to define the key frames. Default interpolationTime() is 0.0, and interpolationSpeed() is 1.0. |
|
Virtual destructor. Empty. |
|
Same as the reference version of addKeyFrame(), but with a pointer to a frame. |
|
Same as the reference version of addKeyFrame(), but with a pointer to a frame. |
|
Defines a new keyFrame, and the associated time (in seconds) that will be used to rythm the interpolation. The keyFrameTime() have to be monotonously increasing over keyFrames. |
|
Defines a new keyFrame. Same as addKeyFrame() with a keyFrameTime() specification, except that the time is automatically set as previous keyFrameTime() + 1 second. |
|
Whether or not (default) the path defined by the keyFrames is a closed loop. When
Use setLoopInterpolation() to create a continuous animation over the entire path. |
|
Remove all keyFrames from the path. The numberOfKeyFrames() is set to 0. |
|
Creates an XML QDomElement that represents the KeyFrameInterpolator. Use initFromDOMElement() to restore the KeyFrameInterpolator state from the resulting domElement. See also Camera::domElement(), Frame::domElement()... If you want to save the KeyFrameInterpolator in a file, use QDomDocument doc("myKFI"); doc.appendChild(domElement("KFI", doc)); ofstream file("myKFI.xml"); file << doc.toString(); Use the following code to retrieve the KeyFrameInterpolator from the saved file: // Load DOM from file QDomDocument doc; QFile f("myKFI.xml"); f.open(IO_ReadOnly); doc.setContent(&f); f.close(); // Parse the DOM tree QDomElement main=doc.documentElement(); myKFI.initFromDOMElement(main);
|
|
Draws the path that will be used to interpolate the frame().
/code drawPath(); // Simply draws the interpolation path drawPath(3); // Draws path and cameras drawPath(7); // Draws path, cameras and axis drawPath(5); // Draws path and axis /endcode
When camera or axis is drawn,
|
|
The frame that is associated and modified by the KeyFrameInterpolator. Set using setFrame() or with the KeyFrameInterpolator() constructor. |
|
Restore the KeyFrameInterpolator state from a QDomElement created by domElement(). See also Camera::initFromDOMElement(), Frame::initFromDOMElement().
|
|
Interpolate frame() for time If you simply want to change interpolationTime() but not the frame(), use setInterpolationTime() instead. All the currently created QGLViewers have their display updated (see QGLViewer::updateGLForAllViewers()). |
|
Returns |
|
Returns the current interpolation period, expressed in milliseconds. This period will be added to the interpolationTime() at each update(), when interpolationIsStarted() is |
|
Returns the current interpolation speed. Default value is 1.0, which means that the times associated with the keyFrames (see keyFrameTime() and addKeyFrame()), expressed in seconds, will be respected during the interpolation (see startInterpolation()), provided that your display is fast enough. A negative value will result in a reverse interpolation of the keyFrames. |
|
Current interpolation time, updated when interpolationIsStarted() is true. Can be set directly with setInterpolationTime() or interpolateAtTime(). |
|
Returns the keyFrame orientation of keyFrame number |
|
Returns the keyFrame position of keyFrame number |
|
Returns the time associated with the keyframe number |
|
Whether or not (default) the interpolation will be played in (infinite) loop when startInterpolation() is called (until stopInterpolation() is called). When Use setClosedPath() to create a closed path with the keyFrames. |
|
Number of keyFrames used in the interpolation. Use addKeyFrame() to add new keyFrames. |
|
interpolationTime() is reset to the keyFrameTime() associated with the first keyFrame and interpolation is stopped() (not much than setInterpolationTime() and stopInterpolation()). |
|
Set the closedPath() value. |
|
Set the frame that will be associated with the KeyFrameInterpolator. Current frame is in frame(). |
|
Set the interpolationPeriod(). |
|
Set the interpolation speed. Negative values are possible. See interpolationSpeed(). |
|
Set the current interpolation time. See also interpolationTime().
|
|
Set the loopInterpolation() value. |
|
Starts the interpolation process. A timer will be started with a period defined by If interpolationTime() is greater than the last keyFrameTime(), it is reset to the first keyFrameTime() and interpolation starts from there (natural behavior).
If You may also be interested in QGLViewer::animate() and QGLViewer::startAnimation().
|
|
Stops an interpolation started with startInterpolation(). |
|
Calls startInterpolation() or stopInterpolation(), depending on interpolationIsStarted(). |
|
Interpolates frame() for the next interpolationTime() (defined by interpolationPeriod()). This internal function is called by a timer when startInterpolation() is called. It is publically provided for your debugging purpose only. stopInterpolation() is called when interpolationTime() reaches the first or last keyFrameTime(), unless loopInterpolation() is |