mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:10:04 +00:00
Rotate placefile icons
This commit is contained in:
parent
e66c202edf
commit
6c0b62709f
4 changed files with 29 additions and 3 deletions
|
|
@ -5,12 +5,13 @@
|
||||||
#define LONGITUDE_MAX 180.0f
|
#define LONGITUDE_MAX 180.0f
|
||||||
#define PI 3.1415926535897932384626433f
|
#define PI 3.1415926535897932384626433f
|
||||||
#define RAD2DEG 57.295779513082320876798156332941f
|
#define RAD2DEG 57.295779513082320876798156332941f
|
||||||
|
#define DEG2RAD 0.0174532925199432957692369055556f
|
||||||
|
|
||||||
layout (location = 0) in vec2 aLatLong;
|
layout (location = 0) in vec2 aLatLong;
|
||||||
layout (location = 1) in vec2 aXYOffset;
|
layout (location = 1) in vec2 aXYOffset;
|
||||||
layout (location = 2) in vec2 aTexCoord;
|
layout (location = 2) in vec2 aTexCoord;
|
||||||
layout (location = 3) in vec4 aModulate;
|
layout (location = 3) in vec4 aModulate;
|
||||||
layout (location = 4) in float aAngle;
|
layout (location = 4) in float aAngleDeg;
|
||||||
|
|
||||||
uniform mat4 uMVPMatrix;
|
uniform mat4 uMVPMatrix;
|
||||||
uniform mat4 uMapMatrix;
|
uniform mat4 uMapMatrix;
|
||||||
|
|
@ -36,7 +37,12 @@ void main()
|
||||||
|
|
||||||
vec2 p = latLngToScreenCoordinate(aLatLong) - uMapScreenCoord;
|
vec2 p = latLngToScreenCoordinate(aLatLong) - uMapScreenCoord;
|
||||||
|
|
||||||
|
// Rotate clockwise
|
||||||
|
float angle = aAngleDeg * DEG2RAD;
|
||||||
|
mat2 rotate = mat2(cos(angle), -sin(angle),
|
||||||
|
sin(angle), cos(angle));
|
||||||
|
|
||||||
// Transform the position to screen coordinates
|
// Transform the position to screen coordinates
|
||||||
gl_Position = uMapMatrix * vec4(p, 0.0f, 1.0f) +
|
gl_Position = uMapMatrix * vec4(p, 0.0f, 1.0f) +
|
||||||
uMVPMatrix * vec4(aXYOffset, 0.0f, 0.0f);
|
uMVPMatrix * vec4(rotate * aXYOffset, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,23 @@ void DrawItem::UseDefaultProjection(
|
||||||
uMVPMatrixLocation, 1, GL_FALSE, glm::value_ptr(projection));
|
uMVPMatrixLocation, 1, GL_FALSE, glm::value_ptr(projection));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawItem::UseRotationProjection(
|
||||||
|
const QMapLibreGL::CustomLayerRenderParameters& params,
|
||||||
|
GLint uMVPMatrixLocation)
|
||||||
|
{
|
||||||
|
glm::mat4 projection = glm::ortho(0.0f,
|
||||||
|
static_cast<float>(params.width),
|
||||||
|
0.0f,
|
||||||
|
static_cast<float>(params.height));
|
||||||
|
|
||||||
|
projection = glm::rotate(projection,
|
||||||
|
glm::radians<float>(params.bearing),
|
||||||
|
glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
|
p->gl_.glUniformMatrix4fv(
|
||||||
|
uMVPMatrixLocation, 1, GL_FALSE, glm::value_ptr(projection));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Refactor to utility class
|
// TODO: Refactor to utility class
|
||||||
static glm::vec2
|
static glm::vec2
|
||||||
LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate)
|
LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ protected:
|
||||||
void
|
void
|
||||||
UseDefaultProjection(const QMapLibreGL::CustomLayerRenderParameters& params,
|
UseDefaultProjection(const QMapLibreGL::CustomLayerRenderParameters& params,
|
||||||
GLint uMVPMatrixLocation);
|
GLint uMVPMatrixLocation);
|
||||||
|
void
|
||||||
|
UseRotationProjection(const QMapLibreGL::CustomLayerRenderParameters& params,
|
||||||
|
GLint uMVPMatrixLocation);
|
||||||
void UseMapProjection(const QMapLibreGL::CustomLayerRenderParameters& params,
|
void UseMapProjection(const QMapLibreGL::CustomLayerRenderParameters& params,
|
||||||
GLint uMVPMatrixLocation,
|
GLint uMVPMatrixLocation,
|
||||||
GLint uMapScreenCoordLocation);
|
GLint uMapScreenCoordLocation);
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ void PlacefileIcons::Render(
|
||||||
|
|
||||||
p->Update();
|
p->Update();
|
||||||
p->shaderProgram_->Use();
|
p->shaderProgram_->Use();
|
||||||
UseDefaultProjection(params, p->uMVPMatrixLocation_);
|
UseRotationProjection(params, p->uMVPMatrixLocation_);
|
||||||
UseMapProjection(
|
UseMapProjection(
|
||||||
params, p->uMapMatrixLocation_, p->uMapScreenCoordLocation_);
|
params, p->uMapMatrixLocation_, p->uMapScreenCoordLocation_);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue