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()); }
@Override protected void doRender(RenderContext rc) { if (rc.terrain.getSector().isEmpty()) { return; // no terrain to render } // Use WorldWind's basic GLSL program. BasicShaderProgram program = (BasicShaderProgram) rc.getShaderProgram(BasicShaderProgram.KEY); if (program == null) { program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources)); } Pool<DrawableTessellation> pool = rc.getDrawablePool(DrawableTessellation.class); Drawable drawable = DrawableTessellation.obtain(pool).set(program, this.color); rc.offerSurfaceDrawable(drawable, 1.0 /*z-order after surface textures*/); } }
protected void addTile(RenderContext rc, ImageTile tile) { ImageSource imageSource = tile.getImageSource(); if (imageSource == null) { return; // no image source indicates an empty level or an image missing from the tiled data store } Texture texture = rc.getTexture(imageSource); // try to get the texture from the cache if (texture == null) { texture = rc.retrieveTexture(imageSource, this.imageOptions); // puts retrieved textures in the cache } if (texture != null) { // use the tile's own texture Pool<DrawableSurfaceTexture> pool = rc.getDrawablePool(DrawableSurfaceTexture.class); Drawable drawable = DrawableSurfaceTexture.obtain(pool).set(this.activeProgram, tile.sector, texture, texture.getTexCoordTransform()); rc.offerSurfaceDrawable(drawable, 0 /*z-order*/); } else if (this.ancestorTile != null) { // use the ancestor tile's texture, transformed to fill the tile sector this.ancestorTexCoordMatrix.set(this.ancestorTexture.getTexCoordTransform()); this.ancestorTexCoordMatrix.multiplyByTileTransform(tile.sector, this.ancestorTile.sector); Pool<DrawableSurfaceTexture> pool = rc.getDrawablePool(DrawableSurfaceTexture.class); Drawable drawable = DrawableSurfaceTexture.obtain(pool).set(this.activeProgram, tile.sector, this.ancestorTexture, this.ancestorTexCoordMatrix); rc.offerSurfaceDrawable(drawable, 0 /*z-order*/); } }
DrawShapeState drawState; if (this.isSurfaceShape) { Pool<DrawableSurfaceShape> pool = rc.getDrawablePool(DrawableSurfaceShape.class); drawable = DrawableSurfaceShape.obtain(pool); drawState = ((DrawableSurfaceShape) drawable).drawState; this.cameraDistance = this.cameraDistanceGeographic(rc, this.boundingSector); } else { Pool<DrawableShape> pool = rc.getDrawablePool(DrawableShape.class); drawable = DrawableShape.obtain(pool); drawState = ((DrawableShape) drawable).drawState;
DrawShapeState drawState; if (this.isSurfaceShape) { Pool<DrawableSurfaceShape> pool = rc.getDrawablePool(DrawableSurfaceShape.class); drawable = DrawableSurfaceShape.obtain(pool); drawState = ((DrawableSurfaceShape) drawable).drawState; ((DrawableSurfaceShape) drawable).sector.set(this.boundingSector); } else { Pool<DrawableShape> pool = rc.getDrawablePool(DrawableShape.class); drawable = DrawableShape.obtain(pool); drawState = ((DrawableShape) drawable).drawState;
protected void makeDrawable(RenderContext rc) { // Obtain a pooled drawable and configure it to draw the sightline's coverage. Pool<DrawableSightline> pool = rc.getDrawablePool(DrawableSightline.class); DrawableSightline drawable = DrawableSightline.obtain(pool); // Compute the transform from sightline local coordinates to world coordinates. drawable.centerTransform = rc.globe.cartesianToLocalTransform(this.centerPoint.x, this.centerPoint.y, this.centerPoint.z, drawable.centerTransform); drawable.range = (float) WWMath.clamp(this.range, 0, Float.MAX_VALUE); // Configure the drawable colors according to the current attributes. When picking use a unique color associated // with the picked object ID. Null attributes indicate that nothing is drawn. if (this.activeAttributes != null) { drawable.visibleColor.set(rc.pickMode ? this.pickColor : this.activeAttributes.interiorColor); } if (this.occludeAttributes != null) { drawable.occludedColor.set(rc.pickMode ? this.pickColor : this.occludeAttributes.interiorColor); } // Use the sightline GLSL program to draw the coverage. drawable.program = (SightlineProgram) rc.getShaderProgram(SightlineProgram.KEY); if (drawable.program == null) { drawable.program = (SightlineProgram) rc.putShaderProgram(SightlineProgram.KEY, new SightlineProgram(rc.resources)); } // Enqueue a drawable for processing on the OpenGL thread. rc.offerSurfaceDrawable(drawable, 0 /*z-order*/); } }
protected void renderGround(RenderContext rc) { if (rc.terrain.getSector().isEmpty()) { return; // no terrain surface to render on } Pool<DrawableGroundAtmosphere> pool = rc.getDrawablePool(DrawableGroundAtmosphere.class); DrawableGroundAtmosphere drawable = DrawableGroundAtmosphere.obtain(pool); drawable.program = (GroundProgram) rc.getShaderProgram(GroundProgram.KEY); if (drawable.program == null) { drawable.program = (GroundProgram) rc.putShaderProgram(GroundProgram.KEY, new GroundProgram(rc.resources)); } drawable.lightDirection.set(this.activeLightDirection); drawable.globeRadius = rc.globe.getEquatorialRadius(); // Use this layer's night image when the light location is different than the eye location. if (this.nightImageSource != null && this.lightLocation != null) { drawable.nightTexture = rc.getTexture(this.nightImageSource); if (drawable.nightTexture == null) { drawable.nightTexture = rc.retrieveTexture(this.nightImageSource, this.nightImageOptions); } } else { drawable.nightTexture = null; } rc.offerSurfaceDrawable(drawable, Double.POSITIVE_INFINITY /*z-order after all other surface drawables*/); }
double cameraDistance; if (this.isSurfaceShape) { Pool<DrawableSurfaceShape> pool = rc.getDrawablePool(DrawableSurfaceShape.class); drawable = DrawableSurfaceShape.obtain(pool); drawState = ((DrawableSurfaceShape) drawable).drawState; ((DrawableSurfaceShape) drawable).sector.set(this.boundingSector); } else { Pool<DrawableShape> pool = rc.getDrawablePool(DrawableShape.class); drawable = DrawableShape.obtain(pool); drawState = ((DrawableShape) drawable).drawState;
protected void renderTerrainPickedObject(RenderContext rc) { if (rc.terrain.getSector().isEmpty()) { return; // no terrain to pick } // Acquire a unique picked object ID for terrain. int pickedObjectId = rc.nextPickedObjectId(); // Enqueue a drawable for processing on the OpenGL thread that displays terrain in the unique pick color. Pool<DrawableSurfaceColor> pool = rc.getDrawablePool(DrawableSurfaceColor.class); DrawableSurfaceColor drawable = DrawableSurfaceColor.obtain(pool); drawable.color = PickedObject.identifierToUniqueColor(pickedObjectId, drawable.color); drawable.program = (BasicShaderProgram) rc.getShaderProgram(BasicShaderProgram.KEY); if (drawable.program == null) { drawable.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources)); } rc.offerSurfaceDrawable(drawable, Double.NEGATIVE_INFINITY /*z-order before all other surface drawables*/); // If the pick ray intersects the terrain, enqueue a picked object that associates the terrain drawable with its // picked object ID and the intersection position. if (rc.pickRay != null && rc.terrain.intersect(rc.pickRay, this.pickPoint)) { rc.globe.cartesianToGeographic(this.pickPoint.x, this.pickPoint.y, this.pickPoint.z, this.pickPos); this.pickPos.altitude = 0; // report the actual altitude, which may not lie on the terrain's surface rc.offerPickedObject(PickedObject.fromTerrain(pickedObjectId, this.pickPos)); } }
protected void renderSky(RenderContext rc) { Pool<DrawableSkyAtmosphere> pool = rc.getDrawablePool(DrawableSkyAtmosphere.class); DrawableSkyAtmosphere drawable = DrawableSkyAtmosphere.obtain(pool); int size = 128; drawable.program = (SkyProgram) rc.getShaderProgram(SkyProgram.KEY); if (drawable.program == null) { drawable.program = (SkyProgram) rc.putShaderProgram(SkyProgram.KEY, new SkyProgram(rc.resources)); } drawable.vertexPoints = rc.getBufferObject(VERTEX_POINTS_KEY); if (drawable.vertexPoints == null) { drawable.vertexPoints = rc.putBufferObject(VERTEX_POINTS_KEY, this.assembleVertexPoints(rc, size, size, (float) drawable.program.getAltitude())); } drawable.triStripElements = rc.getBufferObject(TRI_STRIP_ELEMENTS_KEY); if (drawable.triStripElements == null) { drawable.triStripElements = rc.putBufferObject(TRI_STRIP_ELEMENTS_KEY, this.assembleTriStripElements(size, size)); } drawable.lightDirection.set(this.activeLightDirection); drawable.globeRadius = rc.globe.getEquatorialRadius(); rc.offerSurfaceDrawable(drawable, Double.POSITIVE_INFINITY /*z-order after all other surface drawables*/); }
@Override protected void doRender(RenderContext rc) { if (this.sector.isEmpty()) { return; // nothing to render } if (!rc.terrain.getSector().intersects(this.sector)) { return; // no terrain surface to render on } Texture texture = rc.getTexture(this.imageSource); // try to get the texture from the cache if (texture == null) { texture = rc.retrieveTexture(this.imageSource, this.imageOptions); // puts retrieved textures in the cache } if (texture == null) { return; // no texture to draw } // Enqueue a drawable surface texture for processing on the OpenGL thread. SurfaceTextureProgram program = this.getShaderProgram(rc); Pool<DrawableSurfaceTexture> pool = rc.getDrawablePool(DrawableSurfaceTexture.class); DrawableSurfaceTexture drawable = DrawableSurfaceTexture.obtain(pool).set(program, this.sector, texture, texture.getTexCoordTransform()); rc.offerSurfaceDrawable(drawable, 0 /*z-order*/); // Enqueue a picked object that associates the drawable surface texture with this surface image. if (rc.pickMode) { int pickedObjectId = rc.nextPickedObjectId(); PickedObject.identifierToUniqueColor(pickedObjectId, drawable.color); rc.offerPickedObject(PickedObject.fromRenderable(pickedObjectId, this, rc.currentLayer)); } }
Pool<DrawableLines> pool = rc.getDrawablePool(DrawableLines.class); DrawableLines drawable = DrawableLines.obtain(pool); this.prepareDrawableLeader(rc, drawable); Pool<DrawableScreenTexture> pool = rc.getDrawablePool(DrawableScreenTexture.class); DrawableScreenTexture drawable = DrawableScreenTexture.obtain(pool); this.prepareDrawableIcon(rc, drawable);
Pool<DrawableScreenTexture> pool = rc.getDrawablePool(DrawableScreenTexture.class); DrawableScreenTexture drawable = DrawableScreenTexture.obtain(pool);