add beginnings of OverlayModel, rendering only a box atm
- modified gl projection so that map layer is always between near- and far-plane
This commit is contained in:
@@ -77,6 +77,8 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
||||
|
||||
private static float[] mMVPMatrix = new float[16];
|
||||
private static float[] mProjMatrix = new float[16];
|
||||
// 'flat' projection used for clipping by depth buffer
|
||||
private static float[] mfProjMatrix = new float[16];
|
||||
private static float[] mTmpMatrix = new float[16];
|
||||
private static float[] mTileCoords = new float[8];
|
||||
private static float[] mDebugCoords = new float[8];
|
||||
@@ -351,7 +353,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
||||
Matrix.multiplyMM(matrix, 0, mapPosition.viewMatrix, 0, matrix, 0);
|
||||
|
||||
if (project)
|
||||
Matrix.multiplyMM(matrix, 0, mProjMatrix, 0, matrix, 0);
|
||||
Matrix.multiplyMM(matrix, 0, mfProjMatrix, 0, matrix, 0);
|
||||
}
|
||||
|
||||
private static float scaleDiv(MapTile t) {
|
||||
@@ -577,6 +579,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
||||
mMapViewPosition.getMapPosition(mapPosition, mDebugCoords);
|
||||
Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0,
|
||||
mapPosition.viewMatrix, 0);
|
||||
|
||||
PolygonRenderer.debugDraw(mMVPMatrix, mDebugCoords, 1);
|
||||
}
|
||||
|
||||
@@ -644,14 +647,14 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
||||
}
|
||||
}
|
||||
|
||||
if (tile.layers.textureLayers != null) {
|
||||
setMatrix(mvp, tile, div, false);
|
||||
|
||||
for (Layer l = tile.layers.textureLayers; l != null;) {
|
||||
l = TextureRenderer.draw(l, 1, mProjMatrix, mvp,
|
||||
tile.layers.texOffset);
|
||||
}
|
||||
}
|
||||
// if (tile.layers.textureLayers != null) {
|
||||
// setMatrix(mvp, tile, div, false);
|
||||
//
|
||||
// for (Layer l = tile.layers.textureLayers; l != null;) {
|
||||
// l = TextureRenderer.draw(l, 1, mProjMatrix, mvp,
|
||||
// tile.layers.texOffset);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private static boolean drawProxyChild(MapTile tile) {
|
||||
@@ -730,7 +733,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
||||
MapViewPosition.VIEW_FAR);
|
||||
|
||||
Matrix.setIdentityM(mTmpMatrix, 0);
|
||||
Matrix.translateM(mTmpMatrix, 0, 0, 0, -MapViewPosition.VIEW_DISTANCE);
|
||||
Matrix.translateM(mTmpMatrix, 0, 0, 0, -MapViewPosition.VIEW_DISTANCE * 2);
|
||||
Matrix.multiplyMM(mProjMatrix, 0, mProjMatrix, 0, mTmpMatrix, 0);
|
||||
|
||||
if (debugView) {
|
||||
@@ -741,9 +744,10 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
||||
Matrix.multiplyMM(mProjMatrix, 0, mMVPMatrix, 0, mProjMatrix, 0);
|
||||
}
|
||||
|
||||
System.arraycopy(mProjMatrix, 0, mfProjMatrix, 0, 16);
|
||||
// set to zero: we modify the z value with polygon-offset for clipping
|
||||
mProjMatrix[10] = 0;
|
||||
mProjMatrix[14] = 0;
|
||||
mfProjMatrix[10] = 0;
|
||||
mfProjMatrix[14] = 0;
|
||||
|
||||
GLES20.glViewport(0, 0, width, height);
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ public class OverlayText extends RenderOverlay {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float setMatrix(MapPosition curPos, float[] matrix) {
|
||||
protected void setMatrix(MapPosition curPos, float[] matrix) {
|
||||
// TODO if oPos == curPos this could be simplified
|
||||
|
||||
MapPosition oPos = mMapPosition;
|
||||
@@ -301,7 +301,5 @@ public class OverlayText extends RenderOverlay {
|
||||
matrix[5] = scale;
|
||||
|
||||
Matrix.multiplyMM(matrix, 0, curPos.viewMatrix, 0, matrix, 0);
|
||||
|
||||
return div;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,8 @@ public abstract class RenderOverlay {
|
||||
* current projection matrix
|
||||
*/
|
||||
public synchronized void render(MapPosition pos, float[] mv, float[] proj) {
|
||||
float div = setMatrix(pos, mv);
|
||||
setMatrix(pos, mv);
|
||||
float div = FastMath.pow(mMapPosition.zoomLevel - pos.zoomLevel);
|
||||
|
||||
Matrix.multiplyMM(mvp, 0, proj, 0, mv, 0);
|
||||
|
||||
@@ -121,8 +122,12 @@ public abstract class RenderOverlay {
|
||||
}
|
||||
}
|
||||
|
||||
// set matrix to scale relative to zoomlevel
|
||||
protected float setMatrix(MapPosition curPos, float[] matrix) {
|
||||
/**
|
||||
* Utility: set matrix to scale relative to zoomlevel
|
||||
* @param curPos ...
|
||||
* @param matrix ...
|
||||
*/
|
||||
protected void setMatrix(MapPosition curPos, float[] matrix) {
|
||||
// TODO if oPos == curPos this could be simplified
|
||||
|
||||
MapPosition oPos = mMapPosition;
|
||||
@@ -155,7 +160,5 @@ public abstract class RenderOverlay {
|
||||
matrix[5] = scale;
|
||||
|
||||
Matrix.multiplyMM(matrix, 0, curPos.viewMatrix, 0, matrix, 0);
|
||||
|
||||
return div;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user