cleanups
This commit is contained in:
parent
a61d2d4804
commit
05e6490d3a
@ -168,6 +168,8 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
||||
// TODO: building with non simple holes (Berlin):
|
||||
//if ((tile.zoomLevel != 17) || (tile.tileX == 70428 && tile.tileY == 43009)),
|
||||
//if ((tile.zoomLevel != 17) || (tile.tileX == 70463 && tile.tileY == 42990))
|
||||
// FIXME 180 degree angle in building
|
||||
//if ((tile.zoomLevel != 17) || (tile.tileX == 68728 && tile.tileY == 42634))
|
||||
|
||||
if (mMapDatabase.executeQuery(tile, this) != QueryResult.SUCCESS) {
|
||||
//Log.d(TAG, "Failed loading: " + tile);
|
||||
@ -198,9 +200,6 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
||||
mLayers = null;
|
||||
mLabels = null;
|
||||
|
||||
if (tile.layers.extrusionLayers != null)
|
||||
((ExtrusionLayer) tile.layers.extrusionLayers).ready = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,8 @@ import android.util.Log;
|
||||
|
||||
/**
|
||||
* @author Hannes Janetzek
|
||||
* FIXME check if polygon has self intersections or 0/180 degree
|
||||
* angles!!!
|
||||
*/
|
||||
public class ExtrusionLayer extends Layer {
|
||||
private final static String TAG = ExtrusionLayer.class.getName();
|
||||
@ -51,6 +53,9 @@ public class ExtrusionLayer extends Layer {
|
||||
private final static int IND_ROOF = 2;
|
||||
private final static int IND_OUTLINE = 3;
|
||||
|
||||
public boolean compiled = false;
|
||||
private int[] mVboIds;
|
||||
|
||||
public ExtrusionLayer(int level) {
|
||||
this.type = Layer.EXTRUSION;
|
||||
this.layer = level;
|
||||
@ -182,8 +187,7 @@ public class ExtrusionLayer extends Layer {
|
||||
}
|
||||
}
|
||||
|
||||
private static short getColor(float vx, float vy) {
|
||||
float a = (float) Math.sqrt(vx * vx + vy * vy);
|
||||
private static short getColor(float vx, float a) {
|
||||
float vlight = vx > 0 ? (vx / a) : -(vx / a);
|
||||
return (short) (220 + (35 * vlight));
|
||||
}
|
||||
@ -207,7 +211,8 @@ public class ExtrusionLayer extends Layer {
|
||||
// vector from previous point
|
||||
float ux, uy;
|
||||
|
||||
short color1 = getColor(vx, vy);
|
||||
float a = (float) Math.sqrt(vx * vx + vy * vy);
|
||||
short color1 = getColor(vx, a);
|
||||
short fcolor = color1;
|
||||
short color2 = 0;
|
||||
|
||||
@ -245,7 +250,7 @@ public class ExtrusionLayer extends Layer {
|
||||
vertices[v + 2] = 0;
|
||||
vertices[v + 6] = h;
|
||||
|
||||
// calculate direction to next point
|
||||
// get direction to next point
|
||||
if (i < len) {
|
||||
nx = points[pos + i + 0];
|
||||
ny = points[pos + i + 1];
|
||||
@ -259,11 +264,12 @@ public class ExtrusionLayer extends Layer {
|
||||
break;
|
||||
}
|
||||
|
||||
// vector to next point
|
||||
vx = nx - cx;
|
||||
vy = ny - cy;
|
||||
|
||||
color2 = getColor(vx, vy);
|
||||
// set lighting (by direction)
|
||||
a = (float) Math.sqrt(vx * vx + vy * vy);
|
||||
color2 = getColor(vx, a);
|
||||
|
||||
short c;
|
||||
if (even == 0)
|
||||
@ -271,7 +277,6 @@ public class ExtrusionLayer extends Layer {
|
||||
else
|
||||
c = (short) (color2 | color1 << 8);
|
||||
|
||||
// set lighting (direction)
|
||||
vertices[v + 3] = vertices[v + 7] = c;
|
||||
color1 = color2;
|
||||
|
||||
@ -395,12 +400,6 @@ public class ExtrusionLayer extends Layer {
|
||||
compiled = true;
|
||||
}
|
||||
|
||||
public boolean compiled = false;
|
||||
|
||||
int[] mVboIds;
|
||||
|
||||
public boolean ready;
|
||||
|
||||
@Override
|
||||
protected void clear() {
|
||||
if (compiled) {
|
||||
|
@ -19,6 +19,7 @@ import java.nio.ByteOrder;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.generator.JobTile;
|
||||
import org.oscim.renderer.GLRenderer;
|
||||
import org.oscim.renderer.GLState;
|
||||
import org.oscim.renderer.MapTile;
|
||||
@ -105,7 +106,7 @@ public class ExtrusionOverlay extends RenderOverlay {
|
||||
if (el == null)
|
||||
continue;
|
||||
|
||||
if (el.ready && !el.compiled) {
|
||||
if (!el.compiled) {
|
||||
el.compile(mShortBuffer);
|
||||
GlUtils.checkGlError("...");
|
||||
}
|
||||
@ -139,7 +140,8 @@ public class ExtrusionOverlay extends RenderOverlay {
|
||||
}
|
||||
|
||||
private static ExtrusionLayer getLayer(MapTile t) {
|
||||
if (t.layers != null && t.layers.extrusionLayers != null)
|
||||
if (t.layers != null && t.layers.extrusionLayers != null
|
||||
&& t.state == JobTile.STATE_READY)
|
||||
return (ExtrusionLayer) t.layers.extrusionLayers;
|
||||
return null;
|
||||
}
|
||||
@ -162,6 +164,8 @@ public class ExtrusionOverlay extends RenderOverlay {
|
||||
GLES20.glUniform1i(hExtrusionMode, 0);
|
||||
GLES20.glUniform4f(hExtrusionColor, 0.6f, 0.6f, 0.6f, 0.8f);
|
||||
|
||||
GLState.test(false, false);
|
||||
|
||||
for (int i = 0; i < mTileCnt; i++) {
|
||||
ExtrusionLayer el = (ExtrusionLayer) tiles[i].layers.extrusionLayers;
|
||||
|
||||
@ -182,7 +186,6 @@ public class ExtrusionOverlay extends RenderOverlay {
|
||||
(el.mIndiceCnt[0] + el.mIndiceCnt[1] + el.mIndiceCnt[2]),
|
||||
GLES20.GL_UNSIGNED_SHORT, 0);
|
||||
|
||||
GLES20.glUniform1i(hExtrusionMode, 0);
|
||||
GLES20.glUniform4f(hExtrusionColor, 1.0f, 0.5f, 0.5f, 0.9f);
|
||||
|
||||
GLES20.glDrawElements(GLES20.GL_LINES, el.mIndiceCnt[3],
|
||||
@ -317,7 +320,9 @@ public class ExtrusionOverlay extends RenderOverlay {
|
||||
float mColor[] = { 201 / 255f, 200 / 255f, 198 / 255f, 0.8f };
|
||||
float mColor2[] = { 201 / 255f, 200 / 255f, 199 / 255f, 0.8f };
|
||||
|
||||
float mRoofColor[] = { 0.895f, 0.89f, 0.88f, 0.9f };
|
||||
//float mRoofColor[] = { 0.895f, 0.89f, 0.88f, 0.9f };
|
||||
float _a = 0.8f;
|
||||
float mRoofColor[] = { 236 / 255f * _a, 235 / 255f * _a, 234 / 255f * _a, _a };
|
||||
|
||||
final static String extrusionVertexShader = ""
|
||||
+ "precision mediump float;"
|
||||
|
Loading…
x
Reference in New Issue
Block a user