summaryrefslogtreecommitdiff
path: root/src/mbgl/util/camera.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/util/camera.hpp')
-rw-r--r--src/mbgl/util/camera.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/mbgl/util/camera.hpp b/src/mbgl/util/camera.hpp
new file mode 100644
index 0000000000..030d7cfaac
--- /dev/null
+++ b/src/mbgl/util/camera.hpp
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <mbgl/util/optional.hpp>
+#include <mbgl/util/size.hpp>
+#include "quaternion.hpp"
+
+namespace mbgl {
+
+class LatLng;
+
+namespace util {
+
+class Camera {
+public:
+ Camera();
+
+ vec3 getPosition() const;
+ mat4 getCameraToWorld(double scale, bool flippedY) const;
+ mat4 getWorldToCamera(double scale, bool flippedY) const;
+ mat4 getCameraToClipPerspective(double fovy, double aspectRatio, double nearZ, double farZ) const;
+
+ vec3 forward() const;
+ vec3 right() const;
+ vec3 up() const;
+
+ const Quaternion& getOrientation() const { return orientation; }
+ void getOrientation(double& pitch, double& bearing) const;
+ void setOrientation(double pitch, double bearing);
+ void setOrientation(const Quaternion& orientation_);
+ void setPosition(const vec3& position);
+
+ // Computes orientation using forward and up vectors of the provided coordinate frame.
+ // Only bearing and pitch components will be used. Does not return a value if input is invalid
+ static optional<Quaternion> orientationFromFrame(const vec3& forward, const vec3& up);
+
+private:
+ Quaternion orientation;
+ mat4 transform; // Position (mercator) and orientation of the camera
+};
+
+} // namespace util
+} // namespace mbgl \ No newline at end of file