diff options
author | Lauren Budorick <lauren@mapbox.com> | 2017-10-14 03:15:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-14 03:15:34 +0200 |
commit | e43e2aa3d700cb086e8de0e1c07a6623a192bfe0 (patch) | |
tree | 11949cef17e85e66f329444a88982196794db960 /src | |
parent | 98bb8613c341bc9e07692f6172c661e8f700272d (diff) | |
download | qtlocation-mapboxgl-e43e2aa3d700cb086e8de0e1c07a6623a192bfe0.tar.gz |
[core, node] Support axonometric rendering
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map.cpp | 29 | ||||
-rw-r--r-- | src/mbgl/map/transform.cpp | 26 | ||||
-rw-r--r-- | src/mbgl/map/transform.hpp | 8 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.cpp | 9 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.hpp | 3 |
5 files changed, 75 insertions, 0 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 6eb555ad1e..378bd40ab7 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -617,6 +617,35 @@ ViewportMode Map::getViewportMode() const { return impl->transform.getViewportMode(); } +#pragma mark - Projection mode + +void Map::setAxonometric(bool axonometric) { + impl->transform.setAxonometric(axonometric); + impl->onUpdate(); +} + +bool Map::getAxonometric() const { + return impl->transform.getAxonometric(); +} + +void Map::setXSkew(double xSkew) { + impl->transform.setXSkew(xSkew); + impl->onUpdate(); +} + +double Map::getXSkew() const { + return impl->transform.getXSkew(); +} + +void Map::setYSkew(double ySkew) { + impl->transform.setYSkew(ySkew); + impl->onUpdate(); +} + +double Map::getYSkew() const { + return impl->transform.getYSkew(); +} + #pragma mark - Projection ScreenCoordinate Map::pixelForLatLng(const LatLng& latLng) const { diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 2bb25af28f..105adf0400 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -527,6 +527,32 @@ ViewportMode Transform::getViewportMode() const { return state.getViewportMode(); } +#pragma mark - Projection mode + +void Transform::setAxonometric(bool axonometric) { + state.axonometric = axonometric; +} + +bool Transform::getAxonometric() const { + return state.axonometric; +} + +void Transform::setXSkew(double xSkew) { + state.xSkew = xSkew; +} + +double Transform::getXSkew() const { + return state.xSkew; +} + +void Transform::setYSkew(double ySkew) { + state.ySkew = ySkew; +} + +double Transform::getYSkew() const { + return state.ySkew; +} + #pragma mark - Transition void Transform::startTransition(const CameraOptions& camera, diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp index 749228bdf5..d429c57661 100644 --- a/src/mbgl/map/transform.hpp +++ b/src/mbgl/map/transform.hpp @@ -125,6 +125,14 @@ public: void setViewportMode(ViewportMode); ViewportMode getViewportMode() const; + // Projection mode + void setAxonometric(bool); + bool getAxonometric() const; + void setXSkew(double xSkew); + double getXSkew() const; + void setYSkew(double ySkew); + double getYSkew() const; + // Transitions bool inTransition() const; void updateTransitions(const TimePoint& now); diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index d1a320beae..d79a65c61e 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -66,6 +66,15 @@ void TransformState::getProjMatrix(mat4& projMatrix, uint16_t nearZ) const { matrix::translate(projMatrix, projMatrix, pixel_x() - size.width / 2.0f, pixel_y() - size.height / 2.0f, 0); + if (axonometric) { + // mat[11] controls perspective + projMatrix[11] = 0; + + // mat[8], mat[9] control x-skew, y-skew + projMatrix[8] = xSkew; + projMatrix[9] = ySkew; + } + matrix::scale(projMatrix, projMatrix, 1, 1, 1.0 / Projection::getMetersPerPixelAtLatitude(getLatLng(LatLng::Unwrapped).latitude(), getZoom())); } diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index 59522d89fd..0dd6d5a15e 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -134,6 +134,9 @@ private: // `fov = 2 * arctan((height / 2) / (height * 1.5))` double fov = 0.6435011087932844; double pitch = 0.0; + double xSkew = 0.0; + double ySkew = 1.0; + bool axonometric = false; // cache values for spherical mercator math double Bc = Projection::worldSize(scale) / util::DEGREES_MAX; |