From 57b4b2829e8033d6cf3f7bd48c1fe511e00b830c Mon Sep 17 00:00:00 2001 From: Mikko Pulkki Date: Mon, 27 Apr 2020 13:26:49 +0300 Subject: Refactor TransformState to use internal 3d camera --- src/mbgl/util/camera.hpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/mbgl/util/camera.hpp (limited to 'src/mbgl/util/camera.hpp') 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 +#include +#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 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 -- cgit v1.2.1