/******************************************************************************************************************* * * ******************************************************************************************************************/ @Override protected double[] computeFrustumLimits (final @Nonnull DrawContext dc) { final double r = dc.getGlobe().getEquatorialRadius(); final Vec4 center = dc.getGlobe().getCenter(); final double distanceFromOrigin = dc.getView().getEyePoint().distanceTo3(center); final double near = 1000; // ditanceFromOrigine - r * 2; final double far = distanceFromOrigin; return new double[]{ near, far }; }
/******************************************************************************************************************* * * ******************************************************************************************************************/ private void drawBoundingVolumes(DrawContext dc, ArrayList<MercatorTextureTile> tiles) { float[] previousColor = new float[4]; dc.getGL().glGetFloatv(GL.GL_CURRENT_COLOR, previousColor, 0); dc.getGL().glColor3d(0, 1, 0); for (MercatorTextureTile tile : tiles) { ((Cylinder) tile.getExtent(dc)).render(dc); } Cylinder c = dc.getGlobe().computeBoundingCylinder(dc.getVerticalExaggeration(), this.levels.getSector()); dc.getGL().glColor3d(1, 1, 0); c.render(dc); dc.getGL().glColor4fv(previousColor, 0); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Override protected final void doRender(DrawContext dc) { if (this.forceLevelZeroLoads && !this.levelZeroLoaded) { this.loadAllTopLevelTextures(dc); } if (dc.getSurfaceGeometry() == null || dc.getSurfaceGeometry().size() < 1) { return; } dc.getGeographicSurfaceTileRenderer().setShowImageTileOutlines(this.showImageTileOutlines); draw(dc); }
@Override public Extent getExtent( DrawContext dc ) { if ( dc == null ) { String msg = Logging.getMessage( "nullValue.DrawContextIsNull" ); Logging.logger( ).severe( msg ); throw new IllegalArgumentException( msg ); } return Sector.computeBoundingCylinder( dc.getGlobe( ), dc.getVerticalExaggeration( ), this.getSector( ) ); } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ private Vec4 computeReferencePoint(DrawContext dc) { if (dc.getViewportCenterPosition() != null) { return dc.getGlobe().computePointFromPosition(dc.getViewportCenterPosition()); } java.awt.geom.Rectangle2D viewport = dc.getView().getViewport(); int x = (int) viewport.getWidth() / 2; for (int y = (int) (0.5 * viewport.getHeight()); y >= 0; y--) { Position pos = dc.getView().computePositionFromScreenPoint(x, y); if (pos == null) { continue; } return dc.getGlobe().computePointFromPosition(pos.getLatitude(), pos.getLongitude(), 0d); } return null; }
java.awt.Rectangle viewport = dc.getView().getViewport(); dc.getGL().glDisable(GL.GL_DEPTH_TEST); dc.getGL().glDisable(GL.GL_BLEND); dc.getGL().glDisable(GL.GL_TEXTURE_2D); Vec4 pt = dc.getGlobe().computePointFromPosition( ll.getLatitude(), ll.getLongitude(), dc.getGlobe().getElevation(ll.getLatitude(), ll.getLongitude())); pt = dc.getView().project(pt); this.textRenderer.draw(tileLabel, (int) pt.x, (int) pt.y);
final GL gl = dc.getGL(); gl.glPushAttrib(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_POLYGON_BIT | GL.GL_TEXTURE_BIT | GL.GL_ENABLE_BIT gl.glLoadIdentity(); double limits[] = computeFrustumLimits(dc); dc.getGLU().gluPerspective(dc.getView().getFieldOfView().degrees, dc.getView().getViewport().getWidth() / dc.getView().getViewport().getHeight(), limits[0], limits[1]); gl.glCallList(glListId);
/******************************************************************************************************************* * * ******************************************************************************************************************/ private boolean isTileVisible(DrawContext dc, MercatorTextureTile tile) { // if (!(tile.getExtent(dc).intersects(dc.getView().getFrustumInModelCoordinates()) // && (dc.getVisibleSector() == null || dc.getVisibleSector().intersects(tile.getSector())))) // return false; // // Position eyePos = dc.getView().getEyePosition(); // LatLon centroid = tile.getSector().getCentroid(); // Angle d = LatLon.greatCircleDistance(eyePos.getLatLon(), centroid); // if ((!tile.getLevelName().equals("0")) && d.compareTo(tile.getSector().getDeltaLat().multiply(2.5)) == 1) // return false; // // return true; // return tile.getExtent(dc).intersects( dc.getView().getFrustumInModelCoordinates()) && (dc.getVisibleSector() == null || dc.getVisibleSector().intersects(tile.getSector())); }
public void render(final DrawContext dc) { //System.out.println("render"); final double x = dc.getView().getViewport().getWidth() - 75.0; final double y = 320.0; setScreenLocation(new Point((int) x, (int) y)); super.render(dc); }
Arrays.sort(sortedTiles, levelComparer); GL gl = dc.getGL(); gl.glCullFace(GL.GL_BACK); dc.setPerFrameStatistic(PerformanceStatistic.IMAGE_TILE_COUNT, this.tileCountName, this.currentTiles.size()); dc.getGeographicSurfaceTileRenderer().renderTiles(dc, this.currentTiles);
/******************************************************************************************************************* * * ******************************************************************************************************************/ private boolean atMaxLevel(DrawContext dc) { Position vpc = dc.getViewportCenterPosition(); if (dc.getView() == null || this.getLevels() == null || vpc == null) { return false; } if (!this.getLevels().getSector().contains(vpc.getLatitude(), vpc.getLongitude())) { return true; } Level nextToLast = this.getLevels().getNextToLastLevel(); if (nextToLast == null) { return true; } Sector centerSector = nextToLast.computeSectorForPosition(vpc.getLatitude(), vpc.getLongitude()); return this.needToSplit(dc, centerSector); }
@Override public void render( DrawContext dc ) { GL2 gl = dc.getGL( ).getGL2( ); gl.glPushAttrib( GL2.GL_POLYGON_BIT ); gl.glPolygonMode( GL2.GL_FRONT, GL2.GL_FILL ); gl.glEnable( GL2.GL_CULL_FACE ); gl.glCullFace( GL2.GL_BACK ); SurfaceTileRenderer r = renderer != null ? renderer : dc.getGeographicSurfaceTileRenderer( ); if ( opacity != 1.0f ) { gl.glEnable( GL2.GL_BLEND ); gl.glBlendFunc( GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA ); gl.glColor4f( 1.0f, 1.0f, 1.0f, opacity ); } else { gl.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); } try { r.renderTiles( dc, this.thisList ); } finally { gl.glPopAttrib( ); } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ private void makeGList (final @Nonnull DrawContext dc) { GL gl = dc.getGL(); glListId = gl.glGenLists(1); // FIXME: what about garbaging the old one? gl.glNewList(glListId, GL.GL_COMPILE); createGList(dc, gl); gl.glEndList(); } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Override protected void requestTexture (final @Nonnull DrawContext dc, final @Nonnull MercatorTextureTile tile) { logger.finer("requestTexture(%s, %s)", dc, tile); final Vec4 centroid = tile.getCentroidPoint(dc.getGlobe()); if (this.getReferencePoint() != null) { tile.setPriority(centroid.distanceTo3(this.getReferencePoint())); } final RequestTask task = new RequestTask(tile, this); this.getRequestQ().add(task); }
@Override public void preRender( DrawContext dc ) { if ( tile == null ) { if ( context == null ) { GLContext oldcontext = dc.getGLContext( ); context = dc.getGLDrawable( ).createContext( oldcontext ); } this.offscreenCanvas.initialize( context ); } drawOffscreen( dc ); if ( tile == null ) { int textureHandle = offscreenCanvas.getFrameBuffer( ).getTextureId( ); tile = newTextureSurfaceTile( textureHandle, corners ); } }
protected void drawOffscreen( DrawContext dc ) { drawOffscreen( dc.getGLContext( ) ); }
private double computeSegmentLength(Path path, DrawContext dc, Position posA, Position posB) { final LatLon llA = new LatLon(posA.getLatitude(), posA.getLongitude()); final LatLon llB = new LatLon(posB.getLatitude(), posB.getLongitude()); Angle ang; String pathType = path.getPathType(); if (Objects.equals(pathType, AVKey.LINEAR)) { ang = LatLon.linearDistance(llA, llB); } else if (Objects.equals(pathType, AVKey.RHUMB_LINE) || Objects.equals(pathType, AVKey.LOXODROME)) { ang = LatLon.rhumbDistance(llA, llB); } else { // Great circle ang = LatLon.greatCircleDistance(llA, llB); } if (path.getAltitudeMode() == WorldWind.CLAMP_TO_GROUND) { return ang.radians * (dc.getGlobe().getRadius()); } final double height = 0.5 * (posA.getElevation() + posB.getElevation()); return ang.radians * (dc.getGlobe().getRadius() + height * dc.getVerticalExaggeration()); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Override public boolean isLayerInView(DrawContext dc) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); logger.severe(message); throw new IllegalStateException(message); } if (dc.getView() == null) { String message = Logging.getMessage("layers.AbstractLayer.NoViewSpecifiedInDrawingContext"); logger.severe(message); throw new IllegalStateException(message); } return !(dc.getVisibleSector() != null && !this.levels.getSector().intersects(dc.getVisibleSector())); }
double currAlt = dc.getView().getCurrentEyePosition().getAltitude();