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; }
@Override public void tessellate(RenderContext rc) { this.currentTerrain.clear(); this.assembleTiles(rc); rc.terrain = this.currentTerrain; }
public void setLevelSet(LevelSet levelSet) { if (levelSet == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "BasicTessellator", "setLevelSet", "missingLevelSet")); } this.levelSet = levelSet; this.invalidateTiles(); }
this.assembleVertexTexCoords(numLat, numLon, this.levelSetVertexTexCoords); this.levelSetLineElements = this.assembleLineElements(numLat, numLon); this.levelSetTriStripElements = this.assembleTriStripElements(numLat, numLon);
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 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 } }