keyFrameInterpolator.cpp
36 : frame_(NULL), period_(40), interpolationTime_(0.0), interpolationSpeed_(1.0), interpolationStarted_(false),
37 closedPath_(false), loopInterpolation_(false), pathIsValid_(false), valuesAreValid_(true), currentFrameValid_(false)
369 // cout << kf_[0]->time() << " , " << kf_[1]->time() << " , " << kf_[2]->time() << " , " << kf_[3]->time() << endl;
374 fr.setOrientation(Quaternion::squad(kf_[1]->orientation(), kf_[1]->tgQ(), kf_[2]->tgQ(), kf_[2]->orientation(), alpha));
552 // currentFrame_[1]->peekNext()->time() << " , " << currentFrame_[2]->peekNext()->time() << " , " << currentFrame_[3]->peekNext()->time() << endl;
557 Vec delta = currentFrame_[2]->peekNext()->position() - currentFrame_[1]->peekNext()->position();
558 v1 = 3.0 * delta - 2.0 * currentFrame_[1]->peekNext()->tgP() - currentFrame_[2]->peekNext()->tgP();
593 // Vec pos = alpha*(currentFrame_[2]->peekNext()->position()) + (1.0-alpha)*(currentFrame_[1]->peekNext()->position());
594 Vec pos = currentFrame_[1]->peekNext()->position() + alpha * (currentFrame_[1]->peekNext()->tgP() + alpha * (v1+alpha*v2));
595 Quaternion q = Quaternion::squad(currentFrame_[1]->peekNext()->orientation(), currentFrame_[1]->peekNext()->tgQ(),
702 void KeyFrameInterpolator::KeyFrame::computeTangent(const KeyFrame* const prev, const KeyFrame* const next)
void endReached()
This signal is emitted when the interpolation reaches the first (when interpolationSpeed() is negativ...
void setInterpolationTime(float time)
Sets the interpolationTime().
Definition: keyFrameInterpolator.h:247
void setInterpolationPeriod(int period)
Sets the interpolationPeriod().
Definition: keyFrameInterpolator.h:251
float keyFrameTime(int index) const
Returns the time corresponding to the index keyFrame.
Definition: keyFrameInterpolator.cpp:468
Definition: camera.h:29
virtual void initFromDOMElement(const QDomElement &element)
Restores the Frame state from a QDomElement created by domElement().
Definition: frame.cpp:1011
KeyFrameInterpolator(Frame *fr=NULL)
Creates a KeyFrameInterpolator, with frame as associated frame().
Definition: keyFrameInterpolator.cpp:35
float interpolationSpeed() const
Returns the current interpolation speed.
Definition: keyFrameInterpolator.h:213
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
Returns an XML QDomElement that represents the Frame.
Definition: frame.cpp:994
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
Returns an XML QDomElement that represents the KeyFrameInterpolator.
Definition: keyFrameInterpolator.cpp:617
void interpolated()
This signal is emitted whenever the frame() state is interpolated.
static double dot(const Quaternion &a, const Quaternion &b)
Returns the "dot" product of a and b: a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3].
Definition: quaternion.h:270
void stopInterpolation()
Stops an interpolation started with startInterpolation().
Definition: keyFrameInterpolator.cpp:145
void setFrame(Frame *const frame)
Sets the frame() associated to the KeyFrameInterpolator.
Definition: keyFrameInterpolator.cpp:55
float lastTime() const
Returns the time corresponding to the last keyFrame, expressed in seconds.
Definition: keyFrameInterpolator.cpp:496
void startInterpolation(int period=-1)
Starts the interpolation process.
Definition: keyFrameInterpolator.cpp:126
virtual void drawPath(int mask=1, int nbFrames=6, float scale=1.0f)
Draws the path used to interpolate the frame().
Definition: keyFrameInterpolator.cpp:337
const GLdouble * matrix() const
Returns the 4x4 OpenGL transformation matrix represented by the Frame.
Definition: frame.cpp:123
void setPositionAndOrientationWithConstraint(Vec &position, Quaternion &orientation)
Same as setPositionAndOrientation() but position and orientation are modified to satisfy the constrai...
Definition: frame.cpp:641
static Quaternion squadTangent(const Quaternion &before, const Quaternion ¢er, const Quaternion &after)
Returns a tangent Quaternion for center, defined by before and after Quaternions. ...
Definition: quaternion.cpp:513
int interpolationPeriod() const
Returns the current interpolation period, expressed in milliseconds.
Definition: keyFrameInterpolator.h:222
static Quaternion squad(const Quaternion &a, const Quaternion &tgA, const Quaternion &tgB, const Quaternion &b, float t)
Returns the slerp interpolation of the two Quaternions a and b, at time t, using tangents tgA and tgB...
Definition: quaternion.cpp:467
void resetInterpolation()
Stops the interpolation and resets interpolationTime() to the firstTime().
Definition: keyFrameInterpolator.cpp:156
void addKeyFrame(const Frame &frame)
Appends a new keyFrame to the path.
Definition: keyFrameInterpolator.cpp:236
float duration() const
Returns the duration of the KeyFrameInterpolator path, expressed in seconds.
Definition: keyFrameInterpolator.cpp:477
Frame * frame() const
Returns the associated Frame and that is interpolated by the KeyFrameInterpolator.
Definition: keyFrameInterpolator.h:180
Quaternion orientation() const
Returns the orientation of the Frame, defined in the world coordinate system.
Definition: frame.cpp:546
float interpolationTime() const
Returns the current interpolation time (in seconds) along the KeyFrameInterpolator path...
Definition: keyFrameInterpolator.h:205
float firstTime() const
Returns the time corresponding to the first keyFrame, expressed in seconds.
Definition: keyFrameInterpolator.cpp:485
void setInterpolationSpeed(float speed)
Sets the interpolationSpeed().
Definition: keyFrameInterpolator.h:249
virtual void initFromDOMElement(const QDomElement &element)
Restores the KeyFrameInterpolator state from a QDomElement created by domElement().
Definition: keyFrameInterpolator.cpp:647
The Quaternion class represents 3D rotations and orientations.
Definition: quaternion.h:66
void setPosition(const Vec &position)
Sets the position() of the Frame, defined in the world coordinate system.
Definition: frame.cpp:443
Frame keyFrame(int index) const
Returns the Frame associated with the keyFrame at index index.
Definition: keyFrameInterpolator.cpp:459
void setClosedPath(bool closed=true)
Sets the closedPath() value.
Definition: keyFrameInterpolator.h:256
bool loopInterpolation() const
Returns true when the interpolation is played in an infinite loop.
Definition: keyFrameInterpolator.h:232
bool closedPath() const
Whether or not (default) the path defined by the keyFrames is a closed loop.
Definition: keyFrameInterpolator.h:239
The Frame class represents a coordinate system, defined by a position and an orientation.
Definition: frame.h:121
void setLoopInterpolation(bool loop=true)
Sets the loopInterpolation() value.
Definition: keyFrameInterpolator.h:253
void setOrientation(const Quaternion &orientation)
Sets the orientation() of the Frame, defined in the world coordinate system.
Definition: frame.cpp:505
Vec position() const
Returns the position of the Frame, defined in the world coordinate system.
Definition: frame.cpp:537
static void drawAxis(float length=1.0f)
Draws an XYZ axis, with a given size (default is 1.0).
Definition: qglviewer.cpp:3253
virtual void interpolateAtTime(float time)
Interpolate frame() at time time (expressed in seconds).
Definition: keyFrameInterpolator.cpp:570