Open3D (C++ API)  0.15.1
ViewControlWithCustomAnimation.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// The MIT License (MIT)
5//
6// Copyright (c) 2018-2021 www.open3d.org
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to deal
10// in the Software without restriction, including without limitation the rights
11// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12// copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25// ----------------------------------------------------------------------------
26
27#pragma once
28
32
33namespace open3d {
34namespace visualization {
35
37public:
42 };
43
44public:
46
47 void Reset() override;
48 void ChangeFieldOfView(double step) override;
49 void Scale(double scale) override;
50 void Rotate(double x, double y, double xo, double yo) override;
51 void Translate(double x, double y, double xo, double yo) override;
52
54 void AddKeyFrame();
55 void UpdateKeyFrame();
56 void DeleteKeyFrame();
57 void AddSpinKeyFrames(int num_of_key_frames = 20);
59 size_t NumOfKeyFrames() const {
60 return view_trajectory_.view_status_.size();
61 }
62 size_t NumOfFrames() const { return view_trajectory_.NumOfFrames(); }
64 if (animation_mode_ == AnimationMode::FreeMode) {
66 }
67 }
68 void ChangeTrajectoryInterval(int change) {
69 if (animation_mode_ == AnimationMode::FreeMode) {
71 }
72 }
74 std::string GetStatusString() const;
75 void Step(double change);
76 void GoToFirst();
77 void GoToLast();
78 bool CaptureTrajectory(const std::string &filename = "");
79 bool LoadTrajectoryFromJsonFile(const std::string &filename);
81 const camera::PinholeCameraTrajectory &camera_trajectory);
82 bool IsPreviewing() {
83 return animation_mode_ == AnimationMode::PreviewMode;
84 }
85 bool IsPlaying() { return animation_mode_ == AnimationMode::PlayMode; }
86 bool IsPlayingEnd(size_t num) {
87 return (IsPlaying() && num >= view_trajectory_.NumOfFrames());
88 }
90
91protected:
92 size_t CurrentFrame() const { return (size_t)round(current_frame_); }
93 size_t CurrentKeyframe() const { return (size_t)round(current_keyframe_); }
94 double RegularizeFrameIndex(double current_frame,
95 size_t num_of_frames,
96 bool is_loop);
98
99protected:
100 AnimationMode animation_mode_ = AnimationMode::FreeMode;
102 double current_frame_ = 0.0;
103 double current_keyframe_ = 0.0;
104};
105
106} // namespace visualization
107} // namespace open3d
Definition: PinholeCameraTrajectory.h:40
View controller for visualizer.
Definition: ViewControl.h:41
Definition: ViewControlWithCustomAnimation.h:36
bool IsPlayingEnd(size_t num)
Definition: ViewControlWithCustomAnimation.h:86
bool IsPlaying()
Definition: ViewControlWithCustomAnimation.h:85
void Scale(double scale) override
Definition: ViewControlWithCustomAnimation.cpp:64
void GoToLast()
Definition: ViewControlWithCustomAnimation.cpp:222
void Step(double change)
Definition: ViewControlWithCustomAnimation.cpp:192
ViewTrajectory view_trajectory_
Definition: ViewControlWithCustomAnimation.h:101
bool IsValidPinholeCameraTrajectory() const
Definition: ViewControlWithCustomAnimation.cpp:289
size_t CurrentFrame() const
Definition: ViewControlWithCustomAnimation.h:92
size_t NumOfKeyFrames() const
Definition: ViewControlWithCustomAnimation.h:59
size_t CurrentKeyframe() const
Definition: ViewControlWithCustomAnimation.h:93
double RegularizeFrameIndex(double current_frame, size_t num_of_frames, bool is_loop)
Definition: ViewControlWithCustomAnimation.cpp:305
double current_keyframe_
Definition: ViewControlWithCustomAnimation.h:103
bool CaptureTrajectory(const std::string &filename="")
Definition: ViewControlWithCustomAnimation.cpp:234
bool LoadTrajectoryFromJsonFile(const std::string &filename)
Definition: ViewControlWithCustomAnimation.cpp:249
void SetAnimationMode(AnimationMode mode)
Definition: ViewControlWithCustomAnimation.cpp:88
void GoToFirst()
Definition: ViewControlWithCustomAnimation.cpp:210
double current_frame_
Definition: ViewControlWithCustomAnimation.h:102
virtual ~ViewControlWithCustomAnimation()
Definition: ViewControlWithCustomAnimation.h:45
void AddSpinKeyFrames(int num_of_key_frames=20)
Definition: ViewControlWithCustomAnimation.cpp:144
void Reset() override
Definition: ViewControlWithCustomAnimation.cpp:36
void UpdateKeyFrame()
Definition: ViewControlWithCustomAnimation.cpp:123
AnimationMode animation_mode_
Definition: ViewControlWithCustomAnimation.h:100
void ChangeTrajectoryInterval(int change)
Definition: ViewControlWithCustomAnimation.h:68
void ChangeFieldOfView(double step) override
Definition: ViewControlWithCustomAnimation.cpp:42
std::string GetStatusString() const
Definition: ViewControlWithCustomAnimation.cpp:155
void ToggleTrajectoryLoop()
Definition: ViewControlWithCustomAnimation.h:63
void DeleteKeyFrame()
Definition: ViewControlWithCustomAnimation.cpp:131
size_t NumOfFrames() const
Definition: ViewControlWithCustomAnimation.h:62
AnimationMode
Definition: ViewControlWithCustomAnimation.h:38
@ PlayMode
Definition: ViewControlWithCustomAnimation.h:41
@ PreviewMode
Definition: ViewControlWithCustomAnimation.h:40
@ FreeMode
Definition: ViewControlWithCustomAnimation.h:39
bool LoadTrajectoryFromCameraTrajectory(const camera::PinholeCameraTrajectory &camera_trajectory)
Definition: ViewControlWithCustomAnimation.cpp:261
void AddKeyFrame()
Definition: ViewControlWithCustomAnimation.cpp:106
bool IsPreviewing()
Definition: ViewControlWithCustomAnimation.h:82
void ClearAllKeyFrames()
Definition: ViewControlWithCustomAnimation.h:58
void SetViewControlFromTrajectory()
Definition: ViewControlWithCustomAnimation.cpp:329
void Rotate(double x, double y, double xo, double yo) override
Function to process rotation.
Definition: ViewControlWithCustomAnimation.cpp:70
void Translate(double x, double y, double xo, double yo) override
Function to process translation.
Definition: ViewControlWithCustomAnimation.cpp:79
int GetTrajectoryInterval() const
Definition: ViewControlWithCustomAnimation.h:73
Definition: ViewTrajectory.h:39
bool is_loop_
Definition: ViewTrajectory.h:90
int interval_
Definition: ViewTrajectory.h:91
void ChangeInterval(int change)
Definition: ViewTrajectory.h:61
std::vector< ViewParameters > view_status_
Definition: ViewTrajectory.h:89
size_t NumOfFrames() const
Definition: ViewTrajectory.h:68
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle image_handle timestamp_usec white_balance image_handle k4a_device_configuration_t config device_handle char size_t serial_number_size bool int32_t int32_t int32_t int32_t k4a_color_control_mode_t default_mode mode
Definition: K4aPlugin.cpp:697
Definition: PinholeCameraIntrinsic.cpp:35