diff options
author | Mikko Pulkki <mikko.pulkki@mapbox.com> | 2020-04-27 13:26:49 +0300 |
---|---|---|
committer | Mikko Pulkki <55925868+mpulkki-mapbox@users.noreply.github.com> | 2020-05-02 17:07:02 +0300 |
commit | 57b4b2829e8033d6cf3f7bd48c1fe511e00b830c (patch) | |
tree | 0a7956b22946f4855547fc9016c35434aee96659 /src/mbgl/util/camera.hpp | |
parent | 9d391d7edd0e5c2bb5c7162deebfd22337588fec (diff) | |
download | qtlocation-mapboxgl-57b4b2829e8033d6cf3f7bd48c1fe511e00b830c.tar.gz |
Refactor TransformState to use internal 3d camera
Diffstat (limited to 'src/mbgl/util/camera.hpp')
-rw-r--r-- | src/mbgl/util/camera.hpp | 42 |
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 |