28#include <easy3d/util/resource.h>
29#include <easy3d/util/initializer.h>
38int main(
int argc,
char** argv) {
42 const std::string& file_name = resource::directory() +
"/data/sphere.obj";
44 CameraInterpolation viewer(EXAMPLE_TITLE);
45 if (!viewer.add_model(file_name,
true)) {
46 LOG(ERROR) <<
"failed to load model. Please make sure the file exists and format is correct.";
Definition: collider.cpp:182
void initialize(bool use_log_file, bool use_setting_file, const std::string &resource_dir)
Initialization of Easy3D.
Definition: initializer.cpp:35
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>
37CameraInterpolation::CameraInterpolation(
const std::string& title)
45 "------------ Camera Interpolation usage ---------- \n"
46 "Press 'K' to add key frames\n"
47 "Press 'Space' to start/stop the animation\n"
48 "Press 'D' to delete the camera path\n"
49 "-------------------------------------------------- \n";
53CameraInterpolation::~CameraInterpolation()
59bool CameraInterpolation::key_press_event(
int key,
int modifiers)
61 if (key == KEY_K && modifiers == 0) {
63 if (interpolator_->add_keyframe(*frame)) {
65 if (dist > camera_->sceneRadius())
66 camera_->setSceneRadius(dist);
67 std::cout <<
"Key frame added" << std::endl;
73 else if (key == KEY_SPACE && modifiers == 0) {
74 if (interpolator_->is_interpolation_started()) {
75 interpolator_->stop_interpolation();
76 std::cout <<
"Animation stopped" << std::endl;
79 interpolator_->start_interpolation();
80 if (interpolator_->is_interpolation_started())
81 std::cout <<
"Animation started" << std::endl;
85 else if (key == KEY_D && modifiers == 0) {
86 interpolator_->delete_path();
89 for (
auto m : models_)
90 box.
grow(m->bounding_box());
92 std::cout <<
"path deleted"<< std::endl;
96 return Viewer::key_press_event(key, modifiers);
100void CameraInterpolation::draw()
const {
104 if (!interpolator_->is_interpolation_started()) {
105 interpolator_->draw_cameras(camera(), camera()->sceneRadius() * 0.05f);
106 interpolator_->draw_path(camera());
The Frame class represents a coordinate system, defined by a position and an orientation.
Definition: frame.h:152
vec3 position() const
Definition: frame.cpp:410
const Point & min_point() const
Definition: box.h:93
const Point & max_point() const
Definition: box.h:98
void grow(const Point &p)
Definition: box.h:216
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:202