/** * Prepares this placemark's icon or symbol for processing in a subsequent drawing pass. Implementations must be * careful not to leak resources from Placemark into the Drawable. * * @param rc the current render context * @param drawable the Drawable to be prepared */ protected void prepareDrawableIcon(RenderContext rc, DrawableScreenTexture drawable) { // Use the basic GLSL program to draw the placemark's icon. drawable.program = (BasicShaderProgram) rc.getShaderProgram(BasicShaderProgram.KEY); if (drawable.program == null) { drawable.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources)); } // Use the plaemark's unit square transform matrix. drawable.unitSquareTransform.set(unitSquareTransform); // Configure the drawable according to the placemark's active attributes. Use a color appropriate for the pick // mode. When picking use a unique color associated with the picked object ID. Use the texture associated with // the active attributes' image source and its associated tex coord transform. If the texture is not specified // or not available, draw a simple colored square. drawable.color.set(rc.pickMode ? this.pickColor : this.activeAttributes.imageColor); drawable.texture = this.activeTexture; drawable.enableDepthTest = this.activeAttributes.depthTest; }
/** * Prepares this placemark's leader for drawing in a subsequent drawing pass. Implementations must be careful not to * leak resources from Placemark into the Drawable. * * @param rc the current render context * @param drawable the Drawable to be prepared */ protected void prepareDrawableLeader(RenderContext rc, DrawableLines drawable) { // Use the basic GLSL program to draw the placemark's leader. drawable.program = (BasicShaderProgram) rc.getShaderProgram(BasicShaderProgram.KEY); if (drawable.program == null) { drawable.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources)); } // Compute the drawable's vertex points, in Cartesian coordinates relative to the placemark's ground point. drawable.vertexPoints[0] = 0; // groundPoint.x - groundPoint.x drawable.vertexPoints[1] = 0; // groundPoint.y - groundPoint.y drawable.vertexPoints[2] = 0; // groundPoint.z - groundPoint.z drawable.vertexPoints[3] = (float) (placePoint.x - groundPoint.x); drawable.vertexPoints[4] = (float) (placePoint.y - groundPoint.y); drawable.vertexPoints[5] = (float) (placePoint.z - groundPoint.z); // Compute the drawable's modelview-projection matrix, relative to the placemark's ground point. drawable.mvpMatrix.set(rc.modelviewProjection); drawable.mvpMatrix.multiplyByTranslation(groundPoint.x, groundPoint.y, groundPoint.z); // Configure the drawable according to the placemark's active leader attributes. Use a color appropriate for the // pick mode. When picking use a unique color associated with the picked object ID. drawable.color.set(rc.pickMode ? this.pickColor : this.activeAttributes.leaderAttributes.outlineColor); drawable.lineWidth = this.activeAttributes.leaderAttributes.outlineWidth; drawable.enableDepthTest = this.activeAttributes.leaderAttributes.depthTest; }
@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*/); } }
drawState.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources));
drawState.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources));
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)); } }
drawState.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources));
drawable.program = (BasicShaderProgram) rc.putShaderProgram(BasicShaderProgram.KEY, new BasicShaderProgram(rc.resources));