Blue Brain BioExplorer
Camera.h
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 
24 #pragma once
25 
29 
31 
32 namespace core
33 {
40 class Camera : public PropertyObject
41 {
42 public:
46  PLATFORM_API Camera() = default;
47 
51  PLATFORM_API virtual ~Camera() = default;
52 
57  PLATFORM_API virtual void commit(){};
58 
62  PLATFORM_API Camera& operator=(const Camera& rhs);
63 
71  PLATFORM_API void set(const Vector3d& position, const Quaterniond& orientation,
72  const Vector3d& target = Vector3d(0.0, 0.0, 0.0));
73 
81  PLATFORM_API void setInitialState(const Vector3d& position, const Quaterniond& orientation,
82  const Vector3d& target = Vector3d(0.0, 0.0, 0.0));
83 
87  PLATFORM_API void reset();
88 
94  PLATFORM_API void setPosition(const Vector3d& position) { _updateValue(_position, position); }
95 
101  PLATFORM_API void setTarget(const Vector3d& target) { _updateValue(_target, target); }
102 
108  PLATFORM_API const Vector3d& getPosition() const { return _position; }
109 
115  PLATFORM_API const Vector3d& getTarget() const { return _target; }
116 
123  {
124  orientation = glm::normalize(orientation);
125  _updateValue(_orientation, orientation);
126  }
127 
133  PLATFORM_API const Quaterniond& getOrientation() const { return _orientation; }
134 
140  PLATFORM_API void setBufferTarget(const std::string& target) { _updateValue(_bufferTarget, target, false); }
141 
147  PLATFORM_API const std::string& getBufferTarget() const { return _bufferTarget; }
148 
154  PLATFORM_API void setEngine(Engine* engine) { _engine = engine; }
155 
156 protected:
157  Engine* _engine{nullptr};
158 
159 private:
160  Vector3d _target;
161  Vector3d _position;
162  Quaterniond _orientation;
163 
164  Vector3d _initialTarget;
165  Vector3d _initialPosition;
166  Quaterniond _initialOrientation;
167 
168  std::string _bufferTarget;
169 
170  SERIALIZATION_FRIEND(Camera);
171 };
172 
180 std::ostream& operator<<(std::ostream& os, Camera& camera);
181 } // namespace core
#define PLATFORM_API
Definition: Api.h:37
#define SERIALIZATION_ACCESS(type)
Definition: Macros.h:25
void _updateValue(T &member, const T &newValue, const bool triggerCallback=true)
Definition: BaseObject.h:87
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
virtual PLATFORM_API ~Camera()=default
Default destructor.
PLATFORM_API void setPosition(const Vector3d &position)
Sets the camera position.
Definition: Camera.h:94
Engine * _engine
Definition: Camera.h:157
PLATFORM_API const Vector3d & getTarget() const
Gets the camera target.
Definition: Camera.h:115
PLATFORM_API Camera()=default
Default constructor.
PLATFORM_API void setBufferTarget(const std::string &target)
Sets the name of the current rendered frame buffer.
Definition: Camera.h:140
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 void setEngine(Engine *engine)
Set the Engine object.
Definition: Camera.h:154
PLATFORM_API const std::string & getBufferTarget() const
Gets the name of the current rendered frame buffer.
Definition: Camera.h:147
virtual PLATFORM_API void commit()
Commits any changes made to the camera object so that attributes become available to the rendering en...
Definition: Camera.h:57
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
Provides an abstract implementation of a ray-tracing engine.
Definition: Engine.h:59
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