@Override public void tessellate(RenderContext rc) { this.currentTerrain.clear(); this.assembleTiles(rc); rc.terrain = this.currentTerrain; }
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; }
@Before public void setUp() { // Mock all the static methods in Logger PowerMockito.mockStatic(Logger.class); // Create the globe object used by the test this.globe = new Globe(WorldWind.WGS84_ELLIPSOID, new ProjectionWgs84()); // Create the terrain object used by the test this.terrain = new BasicTerrain(); // Add a terrain tile used to the mocked terrain LevelSet levelSet = new LevelSet(new Sector().setFullSphere(), 1.0, 1, 5, 5); // tiles with 5x5 vertices TerrainTile tile = new TerrainTile(new Sector(0, 0, 1, 1), levelSet.firstLevel(), 90, 180); ((BasicTerrain) this.terrain).addTile(tile); // Populate the terrain tile's geometry int tileWidth = tile.level.tileWidth; int tileHeight = tile.level.tileHeight; int rowStride = (tileWidth + 2) * 3; float[] points = new float[(tileWidth + 2) * (tileHeight + 2) * 3]; Vec3 tileOrigin = this.globe.geographicToCartesian(0.5, 0.5, 0.0, new Vec3()); this.globe.geographicToCartesianGrid(tile.sector, tileWidth, tileHeight, null, 1.0f, tileOrigin, points, rowStride + 3, rowStride); this.globe.geographicToCartesianBorder(tile.sector, tileWidth + 2, tileHeight + 2, 0.0f, tileOrigin, points); tile.setOrigin(tileOrigin); tile.setPoints(points); }
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()); }
protected void invalidateTiles() { this.topLevelTiles.clear(); this.currentTerrain.clear(); this.tileCache.clear(); this.levelSetVertexTexCoords = null; this.levelSetLineElements = null; this.levelSetTriStripElements = null; }