Blue Brain BioExplorer
Camera.cpp
Go to the documentation of this file.
1 /*
2  *
3  * The Blue Brain BioExplorer is a tool for scientists to extract and analyse
4  * scientific data from visualization
5  *
6  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
7  *
8  * Copyright 2020-2024 Blue BrainProject / EPFL
9  *
10  * This program is free software: you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License as published by the Free Software
12  * Foundation, either version 3 of the License, or (at your option) any later
13  * version.
14  *
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License along with
21  * this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
25 
26 namespace core
27 {
29 {
30  if (this == &rhs)
31  return *this;
32 
34 
35  setPosition(rhs.getPosition());
37 
38  _initialPosition = rhs._initialPosition;
39  _initialOrientation = rhs._initialOrientation;
40 
41  return *this;
42 }
43 
44 void Camera::set(const Vector3d& position, const Quaterniond& orientation, const Vector3d& target)
45 {
46  setPosition(position);
47  setOrientation(orientation);
48  setTarget(target);
49 }
50 
51 void Camera::setInitialState(const Vector3d& position, const Quaterniond& orientation, const Vector3d& target)
52 {
53  _initialPosition = position;
54  _initialTarget = target;
55  _initialOrientation = orientation;
56  _initialOrientation = glm::normalize(_initialOrientation);
57  set(position, orientation, target);
58 }
59 
61 {
62  set(_initialPosition, _initialOrientation, _initialTarget);
63 }
64 
65 std::ostream& operator<<(std::ostream& os, Camera& camera)
66 {
67  const auto& position = camera.getPosition();
68  const auto& orientation = camera.getOrientation();
69  return os << position << ", " << orientation;
70 }
71 } // namespace core
The Camera class is an abstract interface for a camera in a 3D graphics application....
Definition: Camera.h:41
PLATFORM_API void setInitialState(const Vector3d &position, const Quaterniond &orientation, const Vector3d &target=Vector3d(0.0, 0.0, 0.0))
Sets the initial state of the camera.
Definition: Camera.cpp:51
PLATFORM_API void reset()
Resets the camera to its initial values.
Definition: Camera.cpp:60
PLATFORM_API void setTarget(const Vector3d &target)
Sets the camera target.
Definition: Camera.h:101
PLATFORM_API void setPosition(const Vector3d &position)
Sets the camera position.
Definition: Camera.h:94
PLATFORM_API const Vector3d & getPosition() const
Gets the camera position.
Definition: Camera.h:108
PLATFORM_API Camera & operator=(const Camera &rhs)
Copy constructor.
Definition: Camera.cpp:28
PLATFORM_API void set(const Vector3d &position, const Quaterniond &orientation, const Vector3d &target=Vector3d(0.0, 0.0, 0.0))
Sets the position, orientation quaternion, and target of the camera.
Definition: Camera.cpp:44
PLATFORM_API const Quaterniond & getOrientation() const
Gets the camera orientation quaternion.
Definition: Camera.h:133
PLATFORM_API void setOrientation(Quaterniond orientation)
Sets the camera orientation quaternion.
Definition: Camera.h:122
void clonePropertiesFrom(const PropertyObject &obj)
glm::vec< 3, double > Vector3d
Definition: MathTypes.h:143
glm::tquat< double, glm::highp > Quaterniond
Double quaternion.
Definition: MathTypes.h:153
std::ostream & operator<<(std::ostream &os, const Box< T > &aabb)
Definition: MathTypes.h:110