37#ifndef EASY3D_RENDERER_KEY_FRAME_INTERPOLATOR_H
38#define EASY3D_RENDERER_KEY_FRAME_INTERPOLATOR_H
40#include <easy3d/core/types.h>
41#include "easy3d/util/signal.h"
42#include <easy3d/util/timer.h>
43#include <easy3d/renderer/frame.h>
398 void draw_path(
const Camera* camera,
float thickness = 2.0f,
const vec4& color =
vec4(1.0f, 1.0f, 0.5f, 1.0f));
429 Keyframe(
const Frame& fr,
float t);
430 const vec3& position()
const {
return p_; }
431 const quat& orientation()
const {
return q_; }
432 float time()
const {
return time_; }
433 void set_time(
float t) { time_ = t; }
434 void set_position(
const vec3& p) { p_ = p; }
435 void set_orientation(
const quat& q) { q_ = q; }
436 void flip_if_needed(
const quat& prev);
448 std::vector<Keyframe> keyframes_;
449 std::vector<Frame> interpolated_path_;
454 Method interpolation_method_;
455 float interpolation_speed_;
456 bool interpolation_started_;
457 int last_stopped_index_;
462 LinesDrawable* path_drawable_;
463 TrianglesDrawable* cameras_drawable_;
A perspective or orthographic camera.
Definition camera.h:113
The Frame class represents a coordinate system, defined by a position and an orientation.
Definition frame.h:78
A keyframe interpolator for animation generation.
Definition key_frame_interpolator.h:104
float interpolation_speed() const
Returns the current interpolation speed.
Definition key_frame_interpolator.h:295
const quat & keyframe_orientation(std::size_t index) const
Returns the orientation of the index-th keyframe.
Definition key_frame_interpolator.cpp:171
virtual ~KeyFrameInterpolator()
Definition key_frame_interpolator.cpp:69
void delete_last_keyframe()
Removes the lastly added keyframe from the path.
Definition key_frame_interpolator.cpp:111
Method
Definition key_frame_interpolator.h:278
@ INTERPOLATION
Interpolate between keyframes.
Definition key_frame_interpolator.h:280
@ FITTING
Fit a curve to the keyframes.
Definition key_frame_interpolator.h:279
float duration() const
Returns the duration of the KeyFrameInterpolator path, expressed in seconds.
Definition key_frame_interpolator.cpp:176
Signal interpolation_stopped
Emitted when the interpolation is stopped.
Definition key_frame_interpolator.h:467
bool read_keyframes(const std::string &file_name)
Reads the camera path from a file.
Definition key_frame_interpolator.cpp:358
std::size_t number_of_keyframes() const
Returns the number of keyframes used by the interpolation.
Definition key_frame_interpolator.h:209
void set_keyframe_orientation(std::size_t index, const quat &q)
Sets the orientation of the index-th keyframe.
Definition key_frame_interpolator.cpp:133
const std::vector< Frame > & interpolate()
Computes and returns all the interpolated frames.
Definition key_frame_interpolator.cpp:385
void draw_path(const Camera *camera, float thickness=2.0f, const vec4 &color=vec4(1.0f, 1.0f, 0.5f, 1.0f))
Draws the interpolated camera path.
Definition key_frame_interpolator.cpp:300
void set_keyframe_time(std::size_t index, float t)
Sets the time corresponding to the index-th keyframe.
Definition key_frame_interpolator.cpp:119
void set_interpolation_method(Method m)
Sets the interpolation_method().
Definition key_frame_interpolator.cpp:195
int interpolation_period() const
Returns the current interpolation period, expressed in milliseconds.
Definition key_frame_interpolator.h:305
KeyFrameInterpolator(Frame *frame=nullptr)
Creates a KeyFrameInterpolator, with frame as associated frame().
Definition key_frame_interpolator.cpp:55
void start_interpolation()
Starts the interpolation process.
Definition key_frame_interpolator.cpp:213
void set_keyframe_position(std::size_t index, const vec3 &pos)
Sets the position of the index-th keyframe.
Definition key_frame_interpolator.cpp:126
void set_frame(Frame *const frame)
Sets the frame() associated to the KeyFrameInterpolator.
Definition key_frame_interpolator.h:198
void set_interpolation_speed(float speed)
Sets the interpolation_speed().
Definition key_frame_interpolator.cpp:201
int frame_rate() const
Returns the desired frame rate. Default value is 30.
Definition key_frame_interpolator.h:312
Frame keyframe(std::size_t index) const
Returns the Frame associated with the keyframe at index.
Definition key_frame_interpolator.cpp:155
const vec3 & keyframe_position(std::size_t index) const
Returns the position of the index-th keyframe.
Definition key_frame_interpolator.cpp:166
float last_time() const
Returns the time corresponding to the last keyframe, expressed in seconds.
Definition key_frame_interpolator.cpp:188
void toggle_interpolation()
Calls start_interpolation() or stop_interpolation(), depending on is_interpolation_started().
Definition key_frame_interpolator.h:364
void set_frame_rate(int fps)
Sets the desired frame rate.
Definition key_frame_interpolator.cpp:207
void stop_interpolation()
Stops an interpolation started with start_interpolation().
Definition key_frame_interpolator.cpp:245
bool save_keyframes(const std::string &file_name) const
Saves the camera path to a file.
Definition key_frame_interpolator.cpp:338
Signal frame_interpolated
Emitted when a frame is interpolated.
Definition key_frame_interpolator.h:466
bool is_interpolation_started() const
Returns whether the interpolation is being performed.
Definition key_frame_interpolator.h:342
void draw_cameras(const Camera *camera, float camera_width, const vec4 &color=vec4(0.5f, 0.8f, 0.5f, 1.0f))
Draws the virtual 3D cameras for the keyframes.
Definition key_frame_interpolator.cpp:251
Frame * frame() const
Returns the associated Frame and that is interpolated by the KeyFrameInterpolator.
Definition key_frame_interpolator.h:191
void delete_path()
Removes all keyframes from the path.
Definition key_frame_interpolator.cpp:140
float first_time() const
Returns the time corresponding to the first keyframe, expressed in seconds.
Definition key_frame_interpolator.cpp:181
Method interpolation_method() const
Returns the interpolation method.
Definition key_frame_interpolator.h:287
float keyframe_time(std::size_t index) const
Returns the time corresponding to the index-th keyframe.
Definition key_frame_interpolator.cpp:161
bool add_keyframe(const Frame &frame)
Appends a new keyframe to the path.
Definition key_frame_interpolator.cpp:74
The drawable for rendering a set of line segments, e.g., edges of a mesh, vector fields.
Definition drawable_lines.h:40
A light-weight implementation of the simple signal-slot mechanism.
Definition signal.h:54
The drawable for rendering a set of triangles, e.g., the surface of a triangular mesh.
Definition drawable_triangles.h:46
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
Quat< float > quat
A quaternion of float type.
Definition types.h:85
Vec< 4, float > vec4
A 4D point/vector of float type.
Definition types.h:46