Improve code / xml formatting, #54

This commit is contained in:
Emux
2016-07-12 19:25:33 +03:00
parent e793e8851b
commit 43ca550832
133 changed files with 2803 additions and 2791 deletions

View File

@@ -75,14 +75,14 @@ public class HairLineTest extends GdxMap {
//g.translate(10, 10);
//l1.addLine(g);
// int o = 0;
// for (int k = 0; k < g.index.length && g.index[k] >= 0; k++) {
// int o = 0;
// for (int k = 0; k < g.index.length && g.index[k] >= 0; k++) {
//
// for (int j = 0; j < g.index[k];)
// ll.addPoint(g.points[o + j++], g.points[o + j++]);
// for (int j = 0; j < g.index[k];)
// ll.addPoint(g.points[o + j++], g.points[o + j++]);
//
// o += g.index[k];
// }
// o += g.index[k];
// }
}
g = new GeometryBuffer(4, 2);
g.clear();

View File

@@ -63,11 +63,11 @@ public class PathLayerTest extends GdxMapApp {
for (double lon = -180; lon <= 180; lon += 2) {
//pts.add(new GeoPoint(lat, lon));
// double longitude = lon + (pos * 180);
// if (longitude < -180)
// longitude += 360;
// if (longitude > 180)
// longitude -= 360;
// double longitude = lon + (pos * 180);
// if (longitude < -180)
// longitude += 360;
// if (longitude > 180)
// longitude -= 360;
double longitude = lon;
double latitude = lat + (pos * 90);

View File

@@ -27,9 +27,9 @@ import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
public class TileRenderTest extends GdxMapApp {
static boolean loadOneTile = true;
// static int tileX = 34365 >> 2;
// static int tileY = 21333 >> 2;
// static byte tileZ = 14;
// static int tileX = 34365 >> 2;
// static int tileY = 21333 >> 2;
// static byte tileZ = 14;
static int tileX = 68747 >> 3;
static int tileY = 42648 >> 3;
@@ -62,7 +62,7 @@ public class TileRenderTest extends GdxMapApp {
tile.node.parent = tile.node;
tile.node.parent.parent = tile.node;
/* setup TileSet contatining one tile */
/* setup TileSet contatining one tile */
final TileSet tiles = new TileSet();
tiles.cnt = 1;
tiles.tiles[0] = tile;
@@ -74,7 +74,7 @@ public class TileRenderTest extends GdxMapApp {
tileManager = new TileManager(mMap, 100);
}
/* get the loader created by VectorTileLayer ... */
/* get the loader created by VectorTileLayer ... */
final TestTileLoader[] tileLoader = {null};
TestVectorTileLayer tileLayer = new TestVectorTileLayer(mMap, tileManager);
@@ -89,7 +89,7 @@ public class TileRenderTest extends GdxMapApp {
//tileLayer.setRenderTheme(theme);
//tileLayer.setRenderTheme(new DebugTheme());
/* need to create the labellayer here to get the tileloaded event */
/* need to create the labellayer here to get the tileloaded event */
LabelLayer labelLayer = new LabelLayer(mMap, tileLayer);
//mMap.layers().add(tileLayer);
@@ -169,7 +169,7 @@ public class TileRenderTest extends GdxMapApp {
@Override
public void onMapEvent(Event event, MapPosition mapPosition) {
/* ignore map events */
/* ignore map events */
if (event != Map.CLEAR_EVENT)
return;

View File

@@ -35,19 +35,19 @@ public class VectorLayerTest extends GdxMapApp {
VectorLayer vectorLayer = new VectorLayer(mMap);
// vectorLayer.add(new PointDrawable(0, 180, Style.builder()
// .setBuffer(10)
// .setFillColor(Color.RED)
// .setFillAlpha(0.5)
// .build()));
// vectorLayer.add(new PointDrawable(0, 180, Style.builder()
// .setBuffer(10)
// .setFillColor(Color.RED)
// .setFillAlpha(0.5)
// .build()));
//
// Geometry g = new GeomBuilder()
// .point(180, 0)
// .point()
// .buffer(6)
// .get();
// Geometry g = new GeomBuilder()
// .point(180, 0)
// .point()
// .buffer(6)
// .get();
//
// vectorLayer.add(new PolygonDrawable(g, defaultStyle()));
// vectorLayer.add(new PolygonDrawable(g, defaultStyle()));
//
Style.Builder sb = Style.builder()
@@ -55,18 +55,18 @@ public class VectorLayerTest extends GdxMapApp {
.fillColor(Color.RED)
.fillAlpha(0.2);
// int tileSize = 5;
// for (int x = -180; x < 200; x += tileSize) {
// for (int y = -90; y < 90; y += tileSize) {
// // Style style = sb.setFillAlpha(FastMath.clamp(FastMath.length(x, y) / 180, 0.2, 1))
// // .build();
// int tileSize = 5;
// for (int x = -180; x < 200; x += tileSize) {
// for (int y = -90; y < 90; y += tileSize) {
// // Style style = sb.setFillAlpha(FastMath.clamp(FastMath.length(x, y) / 180, 0.2, 1))
// // .build();
//
// vectorLayer.add(new RectangleDrawable(FastMath.clamp(y, -85, 85), x,
// FastMath.clamp(y + tileSize - 0.1, -85, 85),
// x + tileSize - 0.1, style));
// vectorLayer.add(new RectangleDrawable(FastMath.clamp(y, -85, 85), x,
// FastMath.clamp(y + tileSize - 0.1, -85, 85),
// x + tileSize - 0.1, style));
//
// }
// }
// }
// }
for (int i = 0; i < 1000; i++) {
Style style = sb.buffer(Math.random() * 1)

View File

@@ -21,24 +21,24 @@ public class GdxModelLayer extends Layer implements Map.UpdateListener {
public GdxModelLayer(Map map) {
super(map);
// tileLayer.addHook(new TileLoaderProcessHook() {
// tileLayer.addHook(new TileLoaderProcessHook() {
//
// @Override
// public boolean process(MapTile tile, ElementLayers layers, MapElement element) {
// @Override
// public boolean process(MapTile tile, ElementLayers layers, MapElement element) {
//
// if (!element.tags.contains(TREE_TAG))
// return false;
// if (!element.tags.contains(TREE_TAG))
// return false;
//
// Poi3DTileData td = get(tile);
// PointF p = element.getPoint(0);
// SymbolItem s = SymbolItem.pool.get();
// s.x = p.x;
// s.y = p.y;
// td.symbols.push(s);
// Poi3DTileData td = get(tile);
// PointF p = element.getPoint(0);
// SymbolItem s = SymbolItem.pool.get();
// s.x = p.x;
// s.y = p.y;
// td.symbols.push(s);
//
// return true;
// }
// });
// return true;
// }
// });
//mTileLayer = tileLayer;
mRenderer = g3d = new GdxRenderer3D(mMap);
@@ -57,11 +57,11 @@ public class GdxModelLayer extends Layer implements Map.UpdateListener {
loading = true;
}
// TileSet mTileSet = new TileSet();
// TileSet mPrevTiles = new TileSet();
// TileSet mTileSet = new TileSet();
// TileSet mPrevTiles = new TileSet();
//
// LinkedHashMap<Tile, Array<SharedModel>> mTileMap =
// new LinkedHashMap<Tile, Array<SharedModel>>();
// LinkedHashMap<Tile, Array<SharedModel>> mTileMap =
// new LinkedHashMap<Tile, Array<SharedModel>>();
boolean loading;
Model mModel;
@@ -92,14 +92,14 @@ public class GdxModelLayer extends Layer implements Map.UpdateListener {
@Override
public void onMapEvent(Event ev, MapPosition pos) {
// if (ev == Map.CLEAR_EVENT) {
// mTileSet = new TileSet();
// mPrevTiles = new TileSet();
// mTileMap = new LinkedHashMap<Tile, Array<SharedModel>>();
// synchronized (g3d) {
// g3d.instances.clear();
// }
// }
// if (ev == Map.CLEAR_EVENT) {
// mTileSet = new TileSet();
// mPrevTiles = new TileSet();
// mTileMap = new LinkedHashMap<Tile, Array<SharedModel>>();
// synchronized (g3d) {
// g3d.instances.clear();
// }
// }
//
if (loading && assets.update()) {
doneLoading();
@@ -122,116 +122,116 @@ public class GdxModelLayer extends Layer implements Map.UpdateListener {
g3d.cam.setMapPosition(x * scale - pos.x, y * scale - pos.y, scale / pos.scale);
//
// // log.debug("update");
// // log.debug("update");
//
// mTileLayer.tileRenderer().getVisibleTiles(mTileSet);
// mTileLayer.tileRenderer().getVisibleTiles(mTileSet);
//
// if (mTileSet.cnt == 0) {
// mTileSet.releaseTiles();
// return;
// }
// if (mTileSet.cnt == 0) {
// mTileSet.releaseTiles();
// return;
// }
//
// boolean changed = false;
// boolean changed = false;
//
// Array<SharedModel> added = new Array<SharedModel>();
// Array<SharedModel> removed = new Array<SharedModel>();
// Array<SharedModel> added = new Array<SharedModel>();
// Array<SharedModel> removed = new Array<SharedModel>();
// for (int i = 0; i < mTileSet.cnt; i++) {
// MapTile t = mTileSet.tiles[i];
// if (mPrevTiles.contains(t))
// continue;
// for (int i = 0; i < mTileSet.cnt; i++) {
// MapTile t = mTileSet.tiles[i];
// if (mPrevTiles.contains(t))
// continue;
//
// Array<SharedModel> instances = new Array<SharedModel>();
// Array<SharedModel> instances = new Array<SharedModel>();
//
// Poi3DTileData ld = (Poi3DTileData) t.getData(POI_DATA);
// if (ld == null)
// continue;
// Poi3DTileData ld = (Poi3DTileData) t.getData(POI_DATA);
// if (ld == null)
// continue;
//
// for (SymbolItem it : ld.symbols) {
// for (SymbolItem it : ld.symbols) {
//
// SharedModel inst = new SharedModel(mModel);
// inst.userData = it;
// // float r = 0.5f + 0.5f * (float) Math.random();
// // float g = 0.5f + 0.5f * (float) Math.random();
// // float b = 0.5f + 0.5f * (float) Math.random();
// SharedModel inst = new SharedModel(mModel);
// inst.userData = it;
// // float r = 0.5f + 0.5f * (float) Math.random();
// // float g = 0.5f + 0.5f * (float) Math.random();
// // float b = 0.5f + 0.5f * (float) Math.random();
//
// // inst.transform.setTranslation(new Vector3(it.x, it.y,
// // 10));
// // inst.materials.get(0).set(ColorAttribute.createDiffuse(r,
// // g, b, 0.8f));
// instances.add(inst);
// added.add(inst);
// }
// // inst.transform.setTranslation(new Vector3(it.x, it.y,
// // 10));
// // inst.materials.get(0).set(ColorAttribute.createDiffuse(r,
// // g, b, 0.8f));
// instances.add(inst);
// added.add(inst);
// }
//
// if (instances.size == 0)
// continue;
// if (instances.size == 0)
// continue;
//
// log.debug("add " + t + " " + instances.size);
// log.debug("add " + t + " " + instances.size);
//
// changed = true;
// changed = true;
//
// mTileMap.put(t, instances);
// }
// mTileMap.put(t, instances);
// }
//
// for (int i = 0; i < mPrevTiles.cnt; i++) {
// MapTile t = mPrevTiles.tiles[i];
// if (mTileSet.contains(t))
// continue;
// for (int i = 0; i < mPrevTiles.cnt; i++) {
// MapTile t = mPrevTiles.tiles[i];
// if (mTileSet.contains(t))
// continue;
//
// Array<SharedModel> instances = mTileMap.get(t);
// if (instances == null)
// continue;
// Array<SharedModel> instances = mTileMap.get(t);
// if (instances == null)
// continue;
//
// changed = true;
// changed = true;
//
// removed.addAll(instances);
// mTileMap.remove(t);
// log.debug("remove " + t);
// }
// removed.addAll(instances);
// mTileMap.remove(t);
// log.debug("remove " + t);
// }
//
// mPrevTiles.releaseTiles();
// mPrevTiles.releaseTiles();
//
// int zoom = mTileSet.tiles[0].zoomLevel;
// int zoom = mTileSet.tiles[0].zoomLevel;
//
// TileSet tmp = mPrevTiles;
// mPrevTiles = mTileSet;
// mTileSet = tmp;
// TileSet tmp = mPrevTiles;
// mPrevTiles = mTileSet;
// mTileSet = tmp;
//
// if (!changed)
// return;
// if (!changed)
// return;
//
// // scale aka tree height
// float scale = (float) (1f / (1 << (17 - zoom))) * 8;
// // scale aka tree height
// float scale = (float) (1f / (1 << (17 - zoom))) * 8;
//
// double tileX = (pos.x * (Tile.SIZE << zoom));
// double tileY = (pos.y * (Tile.SIZE << zoom));
// double tileX = (pos.x * (Tile.SIZE << zoom));
// double tileY = (pos.y * (Tile.SIZE << zoom));
//
// synchronized (g3d) {
// synchronized (g3d) {
//
// for (Entry<Tile, Array<SharedModel>> e : mTileMap.entrySet()) {
// Tile t = e.getKey();
// for (Entry<Tile, Array<SharedModel>> e : mTileMap.entrySet()) {
// Tile t = e.getKey();
//
// float dx = (float) (t.tileX * Tile.SIZE - tileX);
// float dy = (float) (t.tileY * Tile.SIZE - tileY);
// float dx = (float) (t.tileX * Tile.SIZE - tileX);
// float dy = (float) (t.tileY * Tile.SIZE - tileY);
//
// for (SharedModel inst : e.getValue()) {
// SymbolItem it = (SymbolItem) inst.userData;
// for (SharedModel inst : e.getValue()) {
// SymbolItem it = (SymbolItem) inst.userData;
//
// // variable height
// float s = scale + (it.x * it.y) % 3;
// float r = (it.x * it.y) % 360;
// // variable height
// float s = scale + (it.x * it.y) % 3;
// float r = (it.x * it.y) % 360;
//
// inst.transform.idt();
// inst.transform.scale(s, s, s);
// inst.transform.translate((dx + it.x) / s, (dy + it.y) / s, 0);
// inst.transform.rotate(0, 0, 1, r);
// inst.transform.idt();
// inst.transform.scale(s, s, s);
// inst.transform.translate((dx + it.x) / s, (dy + it.y) / s, 0);
// inst.transform.rotate(0, 0, 1, r);
//
// // inst.transform.setToTranslationAndScaling((dx +
// // it.x), (dy + it.y),
// // 0, s, s, s);
// // inst.transform.setToTranslationAndScaling((dx +
// // it.x), (dy + it.y),
// // 0, s, s, s);
//
// }
// }
// }
// }
}
}

View File

@@ -138,27 +138,27 @@ public class GdxModelRenderer extends LayerRenderer {
//renderContext.begin();
// if (shader == null) {
// r = instances.get(0).getRenderable(r);
// DefaultShader.Config c = new DefaultShader.Config();
// c.numBones = 0;
// c.numDirectionalLights = 1;
// r.environment = lights;
// if (shader == null) {
// r = instances.get(0).getRenderable(r);
// DefaultShader.Config c = new DefaultShader.Config();
// c.numBones = 0;
// c.numDirectionalLights = 1;
// r.environment = lights;
//
// shader = new DefaultShader(r, c);
// shader.init();
// }
// shader = new DefaultShader(r, c);
// shader.init();
// }
mBatch.begin(cam);
//shader.begin(cam, renderContext);
for (SharedModel instance : instances) {
instance.transform.getTranslation(tempVector);
//instance.getRenderables(renderables, pool);
// if (tempVector.x * tempVector.x + tempVector.y * tempVector.y > sqRadius)
// continue;
// tempVector.scl(0.8f, 0.8f, 1);
// if (!GeometryUtils.pointInPoly(tempVector.x, tempVector.y, mBox, 8, 0))
// continue;
// if (tempVector.x * tempVector.x + tempVector.y * tempVector.y > sqRadius)
// continue;
// tempVector.scl(0.8f, 0.8f, 1);
// if (!GeometryUtils.pointInPoly(tempVector.x, tempVector.y, mBox, 8, 0))
// continue;
mBatch.render(instance);

View File

@@ -317,12 +317,12 @@ public class SharedModel implements RenderableProvider {
if (nodePart.invBoneBindTransforms != null)
nodePartBones.put(copy, nodePart.invBoneBindTransforms);
// final int index = materials.indexOf(nodePart.material, false);
// if (index < 0)
// materials.add(copy.material = nodePart.material.copy());
// else
// copy.material = materials.get(index);
//
// final int index = materials.indexOf(nodePart.material, false);
// if (index < 0)
// materials.add(copy.material = nodePart.material.copy());
// else
// copy.material = materials.get(index);
//
copy.material = nodePart.material;
return copy;
@@ -502,29 +502,29 @@ public class SharedModel implements RenderableProvider {
return null;
}
// /** @param id The ID of the material to fetch.
// * @return The {@link Material} with the specified id, or null if not available. */
// public Material getMaterial(final String id) {
// return getMaterial(id, true);
// }
//
// /** @param id The ID of the material to fetch.
// * @param ignoreCase whether to use case sensitivity when comparing the material id.
// * @return The {@link Material} with the specified id, or null if not available. */
// public Material getMaterial(final String id, boolean ignoreCase) {
// final int n = materials.size;
// Material material;
// if (ignoreCase) {
// for (int i = 0; i < n; i++)
// if ((material = materials.get(i)).id.equalsIgnoreCase(id))
// return material;
// } else {
// for (int i = 0; i < n; i++)
// if ((material = materials.get(i)).id.equals(id))
// return material;
// }
// return null;
// }
// /** @param id The ID of the material to fetch.
// * @return The {@link Material} with the specified id, or null if not available. */
// public Material getMaterial(final String id) {
// return getMaterial(id, true);
// }
//
// /** @param id The ID of the material to fetch.
// * @param ignoreCase whether to use case sensitivity when comparing the material id.
// * @return The {@link Material} with the specified id, or null if not available. */
// public Material getMaterial(final String id, boolean ignoreCase) {
// final int n = materials.size;
// Material material;
// if (ignoreCase) {
// for (int i = 0; i < n; i++)
// if ((material = materials.get(i)).id.equalsIgnoreCase(id))
// return material;
// } else {
// for (int i = 0; i < n; i++)
// if ((material = materials.get(i)).id.equals(id))
// return material;
// }
// return null;
// }
/**
* @param id The ID of the node to fetch.

View File

@@ -107,7 +107,7 @@ public class CustomRenderer extends LayerRenderer {
GLState.enableVertexArrays(hVertexPosition, -1);
/* apply view and projection matrices */
/* apply view and projection matrices */
// set mvp (tmp) matrix relative to mMapPosition
// i.e. fixed on the map

View File

@@ -31,11 +31,11 @@ public class HexagonRenderTest extends GdxMap {
GdxMapApp.run(new HexagonRenderTest(), null, 400);
}
/* This is an example how to integrate custom OpenGL drawing routines as map
/* This is an example how to integrate custom OpenGL drawing routines as map
* overlay
*
* based on chapter 2 from:
* https://github.com/dalinaum/opengl-es-book-samples/tree/master/Android */
*
* based on chapter 2 from:
* https://github.com/dalinaum/opengl-es-book-samples/tree/master/Android */
static class HexagonRenderer extends BucketRenderer {
@@ -65,8 +65,8 @@ public class HexagonRenderTest extends GdxMap {
}
//if (mZoom != v.pos.zoomLevel) {
// mMapPosition.copy(v.pos);
// mZoom = v.pos.zoomLevel;
// mMapPosition.copy(v.pos);
// mZoom = v.pos.zoomLevel;
//}
}
@@ -105,7 +105,7 @@ public class HexagonRenderTest extends GdxMap {
GLState.enableVertexArrays(hVertexPosition, -1);
/* apply view and projection matrices */
/* apply view and projection matrices */
// set mvp (tmp) matrix relative to mMapPosition
// i.e. fixed on the map
setMatrix(v);
@@ -123,7 +123,7 @@ public class HexagonRenderTest extends GdxMap {
gl.uniform2f(hCenterPosition, xx * (mCellScale * 1.5f), yy * mCellScale);
//float alpha = 1 + (float) Math.log10(FastMath.clamp(
// (float) Math.sqrt(xx * xx + yy * yy) / offset_y, 0.0f, 1.0f)) * 2;
// (float) Math.sqrt(xx * xx + yy * yy) / offset_y, 0.0f, 1.0f)) * 2;
float alpha = (float) Math.sqrt(xx * xx + yy * yy) / offset_y;