protected void createTerrain2DContinuous(DrawContext dc) { this.sglC = null; this.visibleSectorC = null; ((Globe2D)dc.getGlobe()).setOffset(0); if (dc.getGlobe().intersects(dc.getView().getFrustumInModelCoordinates())) { this.sglC = dc.getModel().getGlobe().tessellate(dc); this.visibleSectorC = this.sglC.getSector(); } this.sglR = null; this.visibleSectorR = null; ((Globe2D)dc.getGlobe()).setOffset(1); if (dc.getGlobe().intersects(dc.getView().getFrustumInModelCoordinates())) { this.sglR = dc.getModel().getGlobe().tessellate(dc); this.visibleSectorR = this.sglR.getSector(); } this.sglL = null; this.visibleSectorL = null; ((Globe2D)dc.getGlobe()).setOffset(-1); if (dc.getGlobe().intersects(dc.getView().getFrustumInModelCoordinates())) { this.sglL = dc.getModel().getGlobe().tessellate(dc); this.visibleSectorL = this.sglL.getSector(); } }
public static OrbitViewState getSurfaceIntersection(Globe globe, SectorGeometryList terrain, Position centerPosition, Angle heading, Angle pitch, double zoom) { if (globe != null) { var modelview = computeTransformMatrix(globe, centerPosition, heading, pitch, Angle.ZERO, zoom); if (modelview != null) { var modelviewInv = modelview.getInverse(); if (modelviewInv != null) { var eyePoint = Vec4.UNIT_W.transformBy4(modelviewInv); var centerPoint = globe.computePointFromPosition(centerPosition); var eyeToCenter = eyePoint.subtract3(centerPoint); var intersections = terrain.intersect(new Line(eyePoint, eyeToCenter.normalize3().multiply3(-1))); if (intersections != null && intersections.Length >= 0) { var newCenter = globe.computePositionFromPoint(intersections[0].getIntersectionPoint()); return(new OrbitViewState(newCenter, heading, pitch, zoom)); } } } } return(null); }
protected void createTerrain(DrawContext dc) { if (dc.getSurfaceGeometry() == null) { if (dc.getModel() != null && dc.getModel().getGlobe() != null) { SectorGeometryList sgl = dc.getModel().getGlobe().tessellate(dc); dc.setSurfaceGeometry(sgl); dc.setVisibleSector(sgl.getSector()); } if (dc.getSurfaceGeometry() == null) { Logging.logger().warning("generic.NoSurfaceGeometry"); dc.setPerFrameStatistic(PerformanceStatistic.TERRAIN_TILE_COUNT, "Terrain Tiles", 0); // keep going because some layers, etc. may have meaning w/o surface geometry } dc.setPerFrameStatistic(PerformanceStatistic.TERRAIN_TILE_COUNT, "Terrain Tiles", dc.getSurfaceGeometry().size()); } }
protected void drawMany(DrawContext dc, Iterable <Annotation> annotations, Layer layer) { if (dc == null) { String msg = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(msg); throw new ArgumentException(msg); } if (dc.getVisibleSector() == null) { return; } SectorGeometryList geos = dc.getSurfaceGeometry(); //noinspection RedundantIfStatement if (geos == null) { return; } if (annotations == null) { String msg = Logging.getMessage("nullValue.AnnotationIterator"); Logging.logger().severe(msg); throw new ArgumentException(msg); } if (dc.isContinuous2DGlobe() && this.currentFrameTime != dc.getFrameTimeStamp()) { // Keep track of which annotations are added to the ordered renderable list so that they are not added // to that list more than once per frame. this.currentPickAnnotations.clear(); this.currentDrawAnnotations.clear(); this.currentFrameTime = dc.getFrameTimeStamp(); } Iterator <Annotation> iterator = annotations.iterator(); if (!iterator.hasNext()) { return; } double altitude = dc.getView().getEyePosition().getElevation(); while (iterator.hasNext()) { Annotation annotation = iterator.next(); if (!isAnnotationValid(annotation, true)) { continue; } if (!annotation.getAttributes().isVisible()) { continue; } // Do not draw the pick pass if not at pick point range; if (dc.isPickingMode() && !this.isAtPickRange(dc, annotation)) { continue; } if (altitude < annotation.getMinActiveAltitude() || altitude > annotation.getMaxActiveAltitude()) { continue; } if (dc.isContinuous2DGlobe() && annotation is ScreenAnnotation) { if (dc.isPickingMode() && this.currentPickAnnotations.contains(annotation)) { continue; } if (currentDrawAnnotations.contains(annotation)) { continue; } } // TODO: cull annotations that are beyond the horizon double eyeDistance = 1; if (annotation is Locatable) { // Determine Cartesian position from the surface geometry if the annotation is near the surface, // otherwise draw it from the globe. Vec4 annotationPoint = getAnnotationDrawPoint(dc, annotation); if (annotationPoint == null) { continue; } eyeDistance = annotation.isAlwaysOnTop() ? 0 : dc.getView().getEyePoint().distanceTo3(annotationPoint); } if (annotation is ScreenAnnotation) { Rectangle screenBounds = annotation.getBounds(dc); if (screenBounds != null && !dc.getView().getViewport().intersects(screenBounds)) { return; } } // The annotations aren't drawn here, but added to the ordered queue to be drawn back-to-front. dc.addOrderedRenderable(new OrderedAnnotation(annotation, layer, eyeDistance)); if (dc.isContinuous2DGlobe() && annotation is ScreenAnnotation) { if (dc.isPickingMode()) { this.currentPickAnnotations.add(annotation); } else { this.currentDrawAnnotations.add(annotation); } } } }