@Override protected void doRender(RenderContext rc) { // Compute this sightline's center point in Cartesian coordinates. if (!this.determineCenterPoint(rc)) { return; } // Don't render anything if the sightline's coverage area is not visible. if (!this.isVisible(rc)) { return; } // Select the currently active attributes. this.determineActiveAttributes(rc); // Configure the pick color when rendering in pick mode. if (rc.pickMode) { this.pickedObjectId = rc.nextPickedObjectId(); this.pickColor = PickedObject.identifierToUniqueColor(this.pickedObjectId, this.pickColor); } // Enqueue drawables for processing on the OpenGL thread. this.makeDrawable(rc); // Enqueue a picked object that associates the sightline's drawables with its picked object ID. if (rc.pickMode) { rc.offerPickedObject(PickedObject.fromRenderable(this.pickedObjectId, this, rc.currentLayer)); } }
@Override protected void doRender(RenderContext rc) { // Don't render anything if the shape is not visible. if (!this.intersectsFrustum(rc)) { return; } // Select the currently active attributes. Don't render anything if the attributes are unspecified. this.determineActiveAttributes(rc); if (this.activeAttributes == null) { return; } // Keep track of the drawable count to determine whether or not this shape has enqueued drawables. int drawableCount = rc.drawableCount(); if (rc.pickMode) { this.pickedObjectId = rc.nextPickedObjectId(); this.pickColor = PickedObject.identifierToUniqueColor(this.pickedObjectId, this.pickColor); } // Enqueue drawables for processing on the OpenGL thread. this.makeDrawable(rc); // Enqueue a picked object that associates the shape's drawables with its picked object ID. if (rc.pickMode && rc.drawableCount() != drawableCount) { rc.offerPickedObject(PickedObject.fromRenderable(this.pickedObjectId, this, rc.currentLayer)); } }
renderData.pickedObjectId = rc.nextPickedObjectId(); renderData.pickColor = PickedObject.identifierToUniqueColor(renderData.pickedObjectId, renderData.pickColor);
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)); } }
@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)); } }
this.pickedObjectId = rc.nextPickedObjectId(); this.pickColor = PickedObject.identifierToUniqueColor(this.pickedObjectId, this.pickColor);