Location renderer custom color, closes #361
This commit is contained in:
parent
644c83ed69
commit
d409aa5b96
@ -6,7 +6,7 @@
|
|||||||
- Marker clustering [#312](https://github.com/mapsforge/vtm/issues/312)
|
- Marker clustering [#312](https://github.com/mapsforge/vtm/issues/312)
|
||||||
- Osmagray theme [#300](https://github.com/mapsforge/vtm/issues/300)
|
- Osmagray theme [#300](https://github.com/mapsforge/vtm/issues/300)
|
||||||
- Symbol rotation [#294](https://github.com/mapsforge/vtm/issues/294)
|
- Symbol rotation [#294](https://github.com/mapsforge/vtm/issues/294)
|
||||||
- Location custom shaders & improvements [#317](https://github.com/mapsforge/vtm/issues/317) [#321](https://github.com/mapsforge/vtm/issues/321)
|
- Location renderer improvements [#317](https://github.com/mapsforge/vtm/issues/317) [#321](https://github.com/mapsforge/vtm/issues/321) [#361](https://github.com/mapsforge/vtm/issues/361)
|
||||||
- POT textures [#334](https://github.com/mapsforge/vtm/issues/334)
|
- POT textures [#334](https://github.com/mapsforge/vtm/issues/334)
|
||||||
- OkHttp external cache [#135](https://github.com/mapsforge/vtm/issues/135)
|
- OkHttp external cache [#135](https://github.com/mapsforge/vtm/issues/135)
|
||||||
- Texture atlas improvements [#301](https://github.com/mapsforge/vtm/pull/301) [#304](https://github.com/mapsforge/vtm/pull/304)
|
- Texture atlas improvements [#301](https://github.com/mapsforge/vtm/pull/301) [#304](https://github.com/mapsforge/vtm/pull/304)
|
||||||
|
|||||||
@ -21,10 +21,11 @@ uniform float u_scale;
|
|||||||
uniform float u_phase;
|
uniform float u_phase;
|
||||||
uniform vec2 u_dir;
|
uniform vec2 u_dir;
|
||||||
uniform int u_mode;
|
uniform int u_mode;
|
||||||
|
uniform vec4 u_color;
|
||||||
void main() {
|
void main() {
|
||||||
float len = 1.0 - length(v_tex);
|
float len = 1.0 - length(v_tex);
|
||||||
if (u_mode == -1) {
|
if (u_mode == -1) {
|
||||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len;
|
gl_FragColor = u_color * len;
|
||||||
} else {
|
} else {
|
||||||
// outer ring
|
// outer ring
|
||||||
float a = smoothstep(0.0, 2.0 / u_scale, len);
|
float a = smoothstep(0.0, 2.0 / u_scale, len);
|
||||||
@ -40,6 +41,6 @@ void main() {
|
|||||||
// - multiply by viewshed
|
// - multiply by viewshed
|
||||||
// - add center point
|
// - add center point
|
||||||
a = d * (a - (b + c)) + c;
|
a = d * (a - (b + c)) + c;
|
||||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * a;
|
gl_FragColor = u_color * a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,10 +21,11 @@ uniform float u_scale;
|
|||||||
uniform float u_phase;
|
uniform float u_phase;
|
||||||
uniform vec2 u_dir;
|
uniform vec2 u_dir;
|
||||||
uniform int u_mode;
|
uniform int u_mode;
|
||||||
|
uniform vec4 u_color;
|
||||||
void main() {
|
void main() {
|
||||||
float len = 1.0 - length(v_tex);
|
float len = 1.0 - length(v_tex);
|
||||||
if (u_mode == -1) {
|
if (u_mode == -1) {
|
||||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len;
|
gl_FragColor = u_color * len;
|
||||||
} else {
|
} else {
|
||||||
// outer ring
|
// outer ring
|
||||||
float a = smoothstep(0.0, 2.0 / u_scale, len);
|
float a = smoothstep(0.0, 2.0 / u_scale, len);
|
||||||
@ -40,6 +41,6 @@ void main() {
|
|||||||
// - multiply by viewshed
|
// - multiply by viewshed
|
||||||
// - add center point
|
// - add center point
|
||||||
a = d * (a - (b + c)) + c;
|
a = d * (a - (b + c)) + c;
|
||||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * a;
|
gl_FragColor = u_color * a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,10 +21,11 @@ uniform float u_scale;
|
|||||||
uniform float u_phase;
|
uniform float u_phase;
|
||||||
uniform vec2 u_dir;
|
uniform vec2 u_dir;
|
||||||
uniform int u_mode;
|
uniform int u_mode;
|
||||||
|
uniform vec4 u_color;
|
||||||
void main() {
|
void main() {
|
||||||
float len = 1.0 - length(v_tex);
|
float len = 1.0 - length(v_tex);
|
||||||
if (u_mode == -1) {
|
if (u_mode == -1) {
|
||||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len;
|
gl_FragColor = u_color * len;
|
||||||
} else {
|
} else {
|
||||||
// outer ring
|
// outer ring
|
||||||
float a = smoothstep(0.0, 2.0 / u_scale, len);
|
float a = smoothstep(0.0, 2.0 / u_scale, len);
|
||||||
@ -40,6 +41,6 @@ void main() {
|
|||||||
// - multiply by viewshed
|
// - multiply by viewshed
|
||||||
// - add center point
|
// - add center point
|
||||||
a = max(d, (a - (b + c)) + c) + (u_mode == 2 ? c : 0);
|
a = max(d, (a - (b + c)) + c) + (u_mode == 2 ? c : 0);
|
||||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * a;
|
gl_FragColor = u_color * a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
package org.oscim.renderer;
|
package org.oscim.renderer;
|
||||||
|
|
||||||
import org.oscim.backend.GL;
|
import org.oscim.backend.GL;
|
||||||
|
import org.oscim.backend.canvas.Color;
|
||||||
import org.oscim.core.Box;
|
import org.oscim.core.Box;
|
||||||
import org.oscim.core.Point;
|
import org.oscim.core.Point;
|
||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
@ -35,6 +36,7 @@ public class LocationRenderer extends LayerRenderer {
|
|||||||
private static final long INTERVAL = 2000;
|
private static final long INTERVAL = 2000;
|
||||||
|
|
||||||
private static final float CIRCLE_SIZE = 60;
|
private static final float CIRCLE_SIZE = 60;
|
||||||
|
private static final int COLOR = 0xff3333cc;
|
||||||
private static final int SHOW_ACCURACY_ZOOM = 16;
|
private static final int SHOW_ACCURACY_ZOOM = 16;
|
||||||
|
|
||||||
private final Map mMap;
|
private final Map mMap;
|
||||||
@ -47,6 +49,7 @@ public class LocationRenderer extends LayerRenderer {
|
|||||||
private int hScale;
|
private int hScale;
|
||||||
private int hPhase;
|
private int hPhase;
|
||||||
private int hDirection;
|
private int hDirection;
|
||||||
|
private int uColor;
|
||||||
private int uMode;
|
private int uMode;
|
||||||
|
|
||||||
private final Point mIndicatorPosition = new Point();
|
private final Point mIndicatorPosition = new Point();
|
||||||
@ -62,6 +65,7 @@ public class LocationRenderer extends LayerRenderer {
|
|||||||
private long mAnimStart;
|
private long mAnimStart;
|
||||||
|
|
||||||
private Callback mCallback;
|
private Callback mCallback;
|
||||||
|
private final float[] mColors = new float[4];
|
||||||
private final Point mLocation = new Point(Double.NaN, Double.NaN);
|
private final Point mLocation = new Point(Double.NaN, Double.NaN);
|
||||||
private double mRadius;
|
private double mRadius;
|
||||||
private int mShowAccuracyZoom = SHOW_ACCURACY_ZOOM;
|
private int mShowAccuracyZoom = SHOW_ACCURACY_ZOOM;
|
||||||
@ -69,12 +73,26 @@ public class LocationRenderer extends LayerRenderer {
|
|||||||
public LocationRenderer(Map map, Layer layer) {
|
public LocationRenderer(Map map, Layer layer) {
|
||||||
mMap = map;
|
mMap = map;
|
||||||
mLayer = layer;
|
mLayer = layer;
|
||||||
|
|
||||||
|
float a = Color.aToFloat(COLOR);
|
||||||
|
mColors[0] = a * Color.rToFloat(COLOR);
|
||||||
|
mColors[1] = a * Color.gToFloat(COLOR);
|
||||||
|
mColors[2] = a * Color.bToFloat(COLOR);
|
||||||
|
mColors[3] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCallback(Callback callback) {
|
public void setCallback(Callback callback) {
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setColor(int color) {
|
||||||
|
float a = Color.aToFloat(color);
|
||||||
|
mColors[0] = a * Color.rToFloat(color);
|
||||||
|
mColors[1] = a * Color.gToFloat(color);
|
||||||
|
mColors[2] = a * Color.bToFloat(color);
|
||||||
|
mColors[3] = a;
|
||||||
|
}
|
||||||
|
|
||||||
public void setLocation(double x, double y, double radius) {
|
public void setLocation(double x, double y, double radius) {
|
||||||
mLocation.x = x;
|
mLocation.x = x;
|
||||||
mLocation.y = y;
|
mLocation.y = y;
|
||||||
@ -242,6 +260,8 @@ public class LocationRenderer extends LayerRenderer {
|
|||||||
} else
|
} else
|
||||||
gl.uniform1i(uMode, -1); // Outside screen
|
gl.uniform1i(uMode, -1); // Outside screen
|
||||||
|
|
||||||
|
GLUtils.glUniform4fv(uColor, 1, mColors);
|
||||||
|
|
||||||
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
|
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +276,7 @@ public class LocationRenderer extends LayerRenderer {
|
|||||||
hPhase = gl.getUniformLocation(program, "u_phase");
|
hPhase = gl.getUniformLocation(program, "u_phase");
|
||||||
hScale = gl.getUniformLocation(program, "u_scale");
|
hScale = gl.getUniformLocation(program, "u_scale");
|
||||||
hDirection = gl.getUniformLocation(program, "u_dir");
|
hDirection = gl.getUniformLocation(program, "u_dir");
|
||||||
|
uColor = gl.getUniformLocation(program, "u_color");
|
||||||
uMode = gl.getUniformLocation(program, "u_mode");
|
uMode = gl.getUniformLocation(program, "u_mode");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user