27#ifndef EASY3D_TUTORIAL_CAMERA_INTERPOLATION_H
28#define EASY3D_TUTORIAL_CAMERA_INTERPOLATION_H
30#include <easy3d/viewer/viewer.h>
34 class KeyFrameInterpolator;
43 explicit TutorialCameraInterpolation(
const std::string& title);
44 ~TutorialCameraInterpolation()
override;
47 bool key_press_event(
int key,
int modifiers)
override;
48 void draw()
const override;
A keyframe interpolator for animation generation.
Definition key_frame_interpolator.h:104
The built-in Easy3D viewer.
Definition viewer.h:63
Definition collider.cpp:182
28#include <easy3d/renderer/camera.h>
29#include <easy3d/renderer/manipulated_camera_frame.h>
30#include <easy3d/renderer/key_frame_interpolator.h>
31#include <easy3d/core/model.h>
38TutorialCameraInterpolation::TutorialCameraInterpolation(
const std::string& title)
45 hint_ =
"Press 'k' to add key frames\n"
46 "Press 'space' to start/stop the animation\n"
47 "Press 'd' to delete the camera path";
51TutorialCameraInterpolation::~TutorialCameraInterpolation()
57bool TutorialCameraInterpolation::key_press_event(
int key,
int modifiers)
59 if (key == KEY_K && modifiers == 0) {
61 if (interpolator_->add_keyframe(*frame)) {
63 if (dist > camera_->sceneRadius())
64 camera_->setSceneRadius(dist);
65 std::cout <<
"Key frame added" << std::endl;
71 else if (key == KEY_SPACE && modifiers == 0) {
72 if (interpolator_->is_interpolation_started()) {
73 interpolator_->stop_interpolation();
74 std::cout <<
"Animation stopped" << std::endl;
77 interpolator_->start_interpolation();
78 if (interpolator_->is_interpolation_started())
79 std::cout <<
"Animation started" << std::endl;
83 else if (key == KEY_D && modifiers == 0) {
84 interpolator_->delete_path();
87 for (
auto m : models_)
90 std::cout <<
"path deleted"<< std::endl;
94 return Viewer::key_press_event(key, modifiers);
98void TutorialCameraInterpolation::draw()
const {
102 if (!interpolator_->is_interpolation_started()) {
103 interpolator_->draw_cameras(camera(), camera()->sceneRadius() * 0.05f);
104 interpolator_->draw_path(camera());
The Frame class represents a coordinate system, defined by a position and an orientation.
Definition frame.h:78
vec3 position() const
Returns the position of the Frame.
const Point & min_point() const
Return the coordinates of the min corner (const version).
Definition box.h:106
const Point & max_point() const
Return the coordinates of the max corner (const version).
Definition box.h:117
Box bounding_box(const Container &points)
Computes the bounding box of a set of points.
Definition types.h:179
T distance(const Vec< N, T > &v1, const Vec< N, T > &v2)
Computes the distance between two vectors/points.
Definition vec.h:295
int connect(SIGNAL *signal, FUNCTION const &slot)
Connects a function to the signal.
Definition signal.h:200