@Override public void tessellate(RenderContext rc) { this.currentTerrain.clear(); this.assembleTiles(rc); rc.terrain = this.currentTerrain; }
@Override public void setEnabled(boolean enabled) { this.enabled = enabled; this.updateTimestamp(); }
public short readTexel(int row, int column, int i, int j) { short[] array = this.getTileArray(row, column); int pos = i + j * this.tileMatrix.tileWidth; return array[pos]; } }
protected void addTileOrDescendants(RenderContext rc, TerrainTile tile) { if (!tile.intersectsSector(this.levelSet.sector) || !tile.intersectsFrustum(rc, rc.frustum)) { return; // ignore the tile and its descendants if it's not needed or not visible } if (tile.level.isLastLevel() || !tile.mustSubdivide(rc, this.detailControl)) { this.addTile(rc, tile); return; // use the tile if it does not need to be subdivided } for (Tile child : tile.subdivideToCache(this, this.tileCache, 4)) { // each tile has a cached size of 1 this.addTileOrDescendants(rc, (TerrainTile) child); // recursively process the tile's children } }
protected void addTile(RenderContext rc, TerrainTile tile) { // Prepare the terrain tile and add it. this.prepareTile(rc, tile); this.currentTerrain.addTile(tile); // Prepare a drawable for the terrain tile for processing on the OpenGL thread. Pool<BasicDrawableTerrain> pool = rc.getDrawablePool(BasicDrawableTerrain.class); BasicDrawableTerrain drawable = BasicDrawableTerrain.obtain(pool); this.prepareDrawableTerrain(rc, tile, drawable); rc.offerDrawableTerrain(drawable, tile.getDistanceToCamera()); }
public double radiusOfPrimeVeritcal(double geographicLat) { double a = globe.getEquatorialRadius(); double e2 = globe.getEccentricitySquared(); double sinSquared = Math.pow(Math.sin(Math.toRadians(geographicLat)), 2); return a / Math.sqrt(1 - e2 * sinSquared); }
protected void assembleTiles(RenderContext rc) { // Assemble the terrain buffers and OpenGL buffer objects associated with the level set. this.assembleLevelSetBuffers(rc); this.currentTerrain.setTriStripElements(this.levelSetTriStripElements); // Assemble the tessellator's top level terrain tiles, which we keep permanent references to. if (this.topLevelTiles.isEmpty()) { this.createTopLevelTiles(); } // Subdivide the top level tiles until the desired resolution is achieved in each part of the scene. for (int idx = 0, len = this.topLevelTiles.size(); idx < len; idx++) { this.addTileOrDescendants(rc, (TerrainTile) this.topLevelTiles.get(idx)); } // Release references to render resources acquired while assembling tiles. this.levelSetVertexTexCoordBuffer = null; this.levelSetElementBuffer = null; }
protected short[] fetchTileArray(TileMatrix tileMatrix, int row, int column) { long key = tileKey(tileMatrix, row, column); ImageSource tileSource = this.coverageSource.get(key); if (tileSource == null) { tileSource = this.tileFactory.createTileSource(tileMatrix, row, column); this.coverageSource.put(key, tileSource, 1); } short[] tileArray = this.coverageCache.get(tileSource); if (tileArray == null && this.isEnableRetrieval()) { this.coverageRetriever.retrieve(tileSource, null, this); } return tileArray; }
@Before public void setUp() throws Exception { // To accommodate WorldWind exception handling, we must mock all // the static methods in Logger to avoid calls to android.util.log PowerMockito.mockStatic(Logger.class); // Create the globe object used by the test globe = new Globe(WorldWind.WGS84_ELLIPSOID, new ProjectionWgs84()); }
protected void determineLightDirection(RenderContext rc) { // TODO Make light/sun direction an optional property of the WorldWindow and attach it to the RenderContext each frame // TODO RenderContext property defaults to the eye lat/lon like we have below if (this.lightLocation != null) { rc.globe.geographicToCartesianNormal(this.lightLocation.latitude, this.lightLocation.longitude, this.activeLightDirection); } else { rc.globe.geographicToCartesianNormal(rc.camera.latitude, rc.camera.longitude, this.activeLightDirection); } }
@Override public Tile createTile(Sector sector, Level level, int row, int column) { return new TerrainTile(sector, level, row, column); }
public void setTileFactory(TileFactory tileFactory) { this.tileFactory = tileFactory; this.invalidateTiles(); }
public long getTimestamp() { long maxTimestamp = 0; for (int idx = 0, len = this.coverages.size(); idx < len; idx++) { ElevationCoverage coverage = this.coverages.get(idx); long timestamp = coverage.getTimestamp(); if (maxTimestamp < timestamp) { maxTimestamp = timestamp; } } return maxTimestamp; }
public short[] getTileArray(int row, int column) { if (this.texelRow != row || this.texelCol != column) { long key = tileKey(this.tileMatrix, row, column); this.texelRow = row; this.texelCol = column; this.texelArray = this.arrays.get(key); } return this.texelArray; }
protected void invalidateTiles() { this.coverageSource.clear(); this.coverageCache.clear(); this.updateTimestamp(); }
protected Matrix4 cameraToViewingMatrix(Globe globe, Camera camera, Matrix4 result) { // TODO interpret altitude mode other than absolute // Transform by the local cartesian transform at the camera's position. globe.geographicToCartesianTransform(camera.latitude, camera.longitude, camera.altitude, result); // Transform by the heading, tilt and roll. result.multiplyByRotation(0, 0, 1, -camera.heading); // rotate clockwise about the Z axis result.multiplyByRotation(1, 0, 0, camera.tilt); // rotate counter-clockwise about the X axis result.multiplyByRotation(0, 0, 1, camera.roll); // rotate counter-clockwise about the Z axis (again) // Make the transform a viewing matrix. result.invertOrthonormal(); return result; }
@Before public void setUp() { // Mock all the static methods in Logger PowerMockito.mockStatic(Logger.class); // Create the globe object used by the test globe = new Globe(WorldWind.WGS84_ELLIPSOID, new ProjectionWgs84()); }
public AbstractElevationCoverage() { this.updateTimestamp(); }
@Before public void setUp() throws Exception { // To accommodate WorldWind exception handling, we must mock all // the static methods in Logger to avoid calls to android.util.log PowerMockito.mockStatic(Logger.class); // Create the globe object used by the test globe = new Globe(WorldWind.WGS84_ELLIPSOID, new ProjectionWgs84()); }
@Before public void setUp() throws Exception { // To accommodate WorldWind exception handling, we must mock all // the static methods in Logger to avoid calls to android.util.log PowerMockito.mockStatic(Logger.class); // Create a globe with a WGS84 definition. this.globe = new Globe(WorldWind.WGS84_ELLIPSOID, new ProjectionWgs84()); }