Easy3D 2.5.3
manipulated_camera_frame.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
39#ifndef EASY3D_RENDERER_MANIPULATED_CAMERA_FRAME_H
40#define EASY3D_RENDERER_MANIPULATED_CAMERA_FRAME_H
41
42#include <easy3d/renderer/manipulated_frame.h>
43
44
45namespace easy3d {
46
47
69 public:
71
73 ~ManipulatedCameraFrame() override = default;
74
76
78
81 public:
92 vec3 pivotPoint() const { return pivotPoint_; }
93
95 void setPivotPoint(const vec3 &point) { pivotPoint_ = point; }
97
100 public:
112 bool zoomsOnPivotPoint() const { return zoomsOnPivotPoint_; }
113
115 void setZoomsOnPivotPoint(bool enabled) { zoomsOnPivotPoint_ = enabled; }
117
120 public:
121 void action_rotate(int mouse_x, int mouse_y, int mouse_dx, int mouse_dy, Camera* camera, ScreenAxis axis) override;
122 void action_translate(int mouse_x, int mouse_y, int mouse_dx, int mouse_dy, Camera* camera, ScreenAxis axis) override;
123 void action_zoom(int dy_wheel, Camera* camera) override;
124
125 virtual void action_turn(float angle_radian, Camera* camera); // The rotation around camera Y
127
128 //---------------------------------------------------------------
129 // more movement of the camera
130 //---------------------------------------------------------------
131
132// if (key == GLFW_KEY_UP && modifiers == 0) { // move camera forward
133// float step = 0.02f * camera_->sceneRadius();
134// camera_->frame()->translate(camera_->frame()->inverseTransformOf(vec3(0.0, 0.0, -step)));
135// }
136// else if (key == GLFW_KEY_DOWN && modifiers == 0) {// move camera backward
137// float step = 0.02f * camera_->sceneRadius();
138// camera_->frame()->translate(camera_->frame()->inverseTransformOf(vec3(0.0, 0.0, step)));
139// }
140// else if (key == GLFW_KEY_LEFT && modifiers == GLFW_MOD_CONTROL) { // move camera left
141// float step = 0.02f * camera_->sceneRadius();
142// camera_->frame()->translate(camera_->frame()->inverseTransformOf(vec3(-step, 0.0, 0.0)));
143// }
144// else if (key == GLFW_KEY_RIGHT && modifiers == GLFW_MOD_CONTROL) { // move camera right
145// float step = 0.02f * camera_->sceneRadius();
146// camera_->frame()->translate(camera_->frame()->inverseTransformOf(vec3(step, 0.0, 0.0)));
147// }
148// else if (key == GLFW_KEY_UP && modifiers == GLFW_MOD_CONTROL) { // move camera up
149// float step = 0.02f * camera_->sceneRadius();
150// camera_->frame()->translate(camera_->frame()->inverseTransformOf(vec3(0.0, step, 0.0)));
151// }
152// else if (key == GLFW_KEY_DOWN && modifiers == GLFW_MOD_CONTROL) { // move camera down
153// float step = 0.02f * camera_->sceneRadius();
154// camera_->frame()->translate(camera_->frame()->inverseTransformOf(vec3(0.0, -step, 0.0)));
155// }
156//
157//---------------------------------------------------------------------------
158//
159// // zoom to pixel
160// const double coef = 0.1;
161// // Small hack: attach a temporary frame to take advantage of lookAt without modifying frame
162// static ManipulatedCameraFrame* tempFrame = new ManipulatedCameraFrame;
163// tempFrame->setPosition(coef*camera()->frame()->position() + (1.0-coef)*p);
164// tempFrame->setOrientation(camera()->frame()->orientation());
165// camera()->setFrame(tempFrame);
166// camera()->lookAt(p);
167//
168// // zoom to fit screen
169// static ManipulatedCameraFrame* tempFrame = new ManipulatedCameraFrame;
170// tempFrame->setPosition(camera()->frame()->position());
171// tempFrame->setOrientation(camera()->frame()->orientation());
172// camera()->setFrame(tempFrame);
173// camera()->showEntireScene();
174
175 private:
176
177 bool zoomsOnPivotPoint_;
178
179 vec3 pivotPoint_;
180
181 private:
182 friend class Camera;
183
184 friend class Viewer;
185 };
186
187
188}
189
190#endif // EASY3D_RENDERER_MANIPULATED_CAMERA_FRAME_H
A perspective or orthographic camera.
Definition: camera.h:116
A manipulated frame with camera specific mouse bindings.
Definition: manipulated_camera_frame.h:68
void setPivotPoint(const vec3 &point)
Definition: manipulated_camera_frame.h:95
void action_rotate(int mouse_x, int mouse_y, int mouse_dx, int mouse_dy, Camera *camera, ScreenAxis axis) override
Definition: manipulated_camera_frame.cpp:71
vec3 pivotPoint() const
Definition: manipulated_camera_frame.h:92
ManipulatedCameraFrame & operator=(const ManipulatedCameraFrame &mcf)
Definition: manipulated_camera_frame.cpp:53
~ManipulatedCameraFrame() override=default
bool zoomsOnPivotPoint() const
Definition: manipulated_camera_frame.h:112
void setZoomsOnPivotPoint(bool enabled)
Definition: manipulated_camera_frame.h:115
A Frame that can be rotated and translated using the mouse.
Definition: manipulated_frame.h:110
The built-in Easy3D viewer.
Definition: viewer.h:61
Definition: collider.cpp:182