private void makePartialCylinderTerrainConformant(
      DrawContext dc,
      int slices,
      int stacks,
      float[] verts,
      double[] altitudes,
      boolean[] terrainConformant,
      Vec4 referenceCenter) {
    Globe globe = dc.getGlobe();
    Matrix transform = this.computeTransform(dc.getGlobe(), dc.getVerticalExaggeration());

    for (int i = 0; i <= slices; i++) {
      int index = i * (stacks + 1);
      index = 3 * index;
      Vec4 vec = new Vec4(verts[index], verts[index + 1], verts[index + 2]);
      vec = vec.transformBy4(transform);
      Position p = globe.computePositionFromPoint(vec);

      for (int j = 0; j <= stacks; j++) {
        double elevation = altitudes[j];
        if (terrainConformant[j])
          elevation += this.computeElevationAt(dc, p.getLatitude(), p.getLongitude());
        vec = globe.computePointFromPosition(p.getLatitude(), p.getLongitude(), elevation);

        index = j + i * (stacks + 1);
        index = 3 * index;
        verts[index] = (float) (vec.x - referenceCenter.x);
        verts[index + 1] = (float) (vec.y - referenceCenter.y);
        verts[index + 2] = (float) (vec.z - referenceCenter.z);
      }
    }
  }
  private void makeRadialWallTerrainConformant(
      DrawContext dc,
      int pillars,
      int stacks,
      float[] verts,
      double[] altitudes,
      boolean[] terrainConformant,
      Vec4 referenceCenter) {
    Globe globe = dc.getGlobe();
    Matrix transform = this.computeTransform(dc.getGlobe(), dc.getVerticalExaggeration());

    for (int p = 0; p <= pillars; p++) {
      int index = p;
      index = 3 * index;
      Vec4 vec = new Vec4(verts[index], verts[index + 1], verts[index + 2]);
      vec = vec.transformBy4(transform);
      Position pos = globe.computePositionFromPoint(vec);

      for (int s = 0; s <= stacks; s++) {
        double elevation = altitudes[s];
        if (terrainConformant[s])
          elevation += this.computeElevationAt(dc, pos.getLatitude(), pos.getLongitude());
        vec = globe.computePointFromPosition(pos.getLatitude(), pos.getLongitude(), elevation);

        index = p + s * (pillars + 1);
        index = 3 * index;
        verts[index] = (float) (vec.x - referenceCenter.x);
        verts[index + 1] = (float) (vec.y - referenceCenter.y);
        verts[index + 2] = (float) (vec.z - referenceCenter.z);
      }
    }
  }
Exemplo n.º 3
0
  /**
   * Draws text for subsequent Label ordered renderables in the ordered renderable list. This method
   * is called after the text renderer has been set up (after beginRendering has been called), so
   * this method can only draw text for subsequent labels that use the same font and rotation as
   * this label. This method differs from {@link #drawBatched(gov.nasa.worldwind.render.DrawContext)
   * drawBatched} in that this method reuses the active text renderer context to draw as many labels
   * as possible without switching text renderer state.
   *
   * @param dc the current draw context.
   * @param textRenderer Text renderer used to draw the label.
   */
  protected void drawBatchedText(DrawContext dc, TextRenderer textRenderer) {
    // Draw as many as we can in a batch to save ogl state switching.
    Object nextItem = dc.peekOrderedRenderables();

    if (!dc.isPickingMode()) {
      while (nextItem != null && nextItem instanceof TacticalGraphicLabel) {
        TacticalGraphicLabel nextLabel = (TacticalGraphicLabel) nextItem;
        if (!nextLabel.isEnableBatchRendering()) break;

        boolean sameFont = this.font.equals(nextLabel.getFont());
        boolean sameRotation =
            (this.rotation == null && nextLabel.rotation == null)
                || (this.rotation != null && this.rotation.equals(nextLabel.rotation));
        boolean drawInterior = nextLabel.isDrawInterior();

        // We've already set up the text renderer state, so we can can't change the font or text
        // rotation.
        // Also can't batch render if the next label needs an interior since that will require
        // tearing down the
        // text renderer context.
        if (!sameFont || !sameRotation || drawInterior) break;

        dc.pollOrderedRenderables(); // take it off the queue
        nextLabel.doDrawText(textRenderer);

        nextItem = dc.peekOrderedRenderables();
      }
    }
  }
  protected static boolean isTileVisible(
      DrawContext dc, Tile tile, double minDistanceSquared, double maxDistanceSquared) {
    if (!tile.getSector().intersects(dc.getVisibleSector())) return false;

    View view = dc.getView();
    Position eyePos = view.getEyePosition();
    if (eyePos == null) return false;

    Angle lat =
        clampAngle(
            eyePos.getLatitude(),
            tile.getSector().getMinLatitude(),
            tile.getSector().getMaxLatitude());
    Angle lon =
        clampAngle(
            eyePos.getLongitude(),
            tile.getSector().getMinLongitude(),
            tile.getSector().getMaxLongitude());
    Vec4 p = dc.getGlobe().computePointFromPosition(lat, lon, 0d);
    double distSquared = dc.getView().getEyePoint().distanceToSquared3(p);
    //noinspection RedundantIfStatement
    if (minDistanceSquared > distSquared || maxDistanceSquared < distSquared) return false;

    return true;
  }
  @Override
  protected void draw(DrawContext dc) {
    // Capture the capabilities actually in use.
    if (this.capabilities == null) {
      this.capabilities = dc.getGLContext().getGLDrawable().getChosenGLCapabilities();
      this.hardwareStereo = this.capabilities.getStereo();
      this.inStereo = this.isHardwareStereo() ? true : this.isInStereo();
    }

    // If stereo isn't to be applied, just draw and return.
    if (!isInStereo()) {
      super.draw(dc);
      return;
    }

    // Check if pitch is in correct range (50 - 90 degrees) for current stereo implementation to
    // work correctly (temporary hack)
    View dcView = dc.getView();
    Boolean pitchInRange =
        (dcView.getPitch().compareTo(Angle.fromDegrees(50)) > 0
            && dcView.getPitch().compareTo(Angle.POS90) < 0);

    if (AVKey.STEREO_MODE_DEVICE.equals(this.stereoMode) && this.isHardwareStereo() && pitchInRange)
      this.doDrawToStereoDevice(dc);
    else if (AVKey.STEREO_MODE_RED_BLUE.equals(this.stereoMode) && pitchInRange)
      this.doDrawStereoRedBlue(dc);
    else // AVKey.STEREO_MODE_NONE
    this.doDrawStereoNone(dc);
  }
  /**
   * Implement stereo using the stereo-enabled graphics device. The mode has an effect only if the
   * display device implements stereo.
   *
   * @param dc the current draw context.
   */
  protected void doDrawToStereoDevice(DrawContext dc) {
    GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
    View dcView = dc.getView();

    // Draw the left eye
    if (this.isSwapEyes()) gl.glDrawBuffer(GL2.GL_BACK_RIGHT);
    else gl.glDrawBuffer(GL2.GL_BACK_LEFT);

    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    super.draw(dc);

    // Move the view to the right eye
    Angle viewHeading = dcView.getHeading();
    dcView.setHeading(dcView.getHeading().subtract(this.getFocusAngle()));
    dcView.apply(dc);

    // Draw the right eye
    try {
      if (this.isSwapEyes()) gl.glDrawBuffer(GL2.GL_BACK_LEFT);
      else gl.glDrawBuffer(GL2.GL_BACK_RIGHT);

      gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
      super.draw(dc);
    } finally {
      // Restore the original view heading
      dcView.setHeading(viewHeading);
      dcView.apply(dc);
    }
  }
Exemplo n.º 7
0
 /** {@inheritDoc} */
 public void render(DrawContext dc) {
   TreeLayout layout = this.getLayout();
   if (layout != null) {
     if (!dc.isOrderedRenderingMode()) dc.addOrderedRenderable(this);
     else layout.render(dc);
   }
 }
Exemplo n.º 8
0
  public void pick(DrawContext dc, java.awt.Point point) {
    if (!this.enabled) return; // Don't check for arg errors if we're disabled

    if (null == dc) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalStateException(message);
    }

    if (null == dc.getGlobe()) {
      String message = Logging.getMessage("layers.AbstractLayer.NoGlobeSpecifiedInDrawingContext");
      Logging.logger().severe(message);
      throw new IllegalStateException(message);
    }

    if (null == dc.getView()) {
      String message = Logging.getMessage("layers.AbstractLayer.NoViewSpecifiedInDrawingContext");
      Logging.logger().severe(message);
      throw new IllegalStateException(message);
    }

    if (!this.isLayerActive(dc)) return;

    if (!this.isLayerInView(dc)) return;

    this.doPick(dc, point);
  }
  public void testMaliciousSetIcons() {
    // Create an Iterable with null elements.
    java.util.List<WWIcon> list = new java.util.ArrayList<WWIcon>();
    list.add(null);

    IconLayer layer =
        new IconLayer() {
          // Override to avoid View initialization issues.
          public boolean isLayerActive(DrawContext dc) {
            return true;
          }
        };
    layer.setIcons(list);

    DrawContext dc = new DrawContextImpl();
    dc.setModel(new BasicModel());
    dc.setView(new BasicOrbitView());

    try {
      // Test that the layer does not fail when the Iterable is used.
      layer.render(dc);
    } catch (NullPointerException e) {
      fail("Layer does not check for null elements in Iterable");
    }
  }
Exemplo n.º 10
0
  /**
   * Establish the OpenGL state needed to draw text.
   *
   * @param dc the current draw context.
   */
  protected void beginDrawing(DrawContext dc) {
    GL gl = dc.getGL();

    int attrMask =
        GL.GL_DEPTH_BUFFER_BIT // for depth test, depth mask and depth func
            | GL.GL_TRANSFORM_BIT // for modelview and perspective
            | GL.GL_VIEWPORT_BIT // for depth range
            | GL.GL_CURRENT_BIT // for current color
            | GL.GL_COLOR_BUFFER_BIT // for alpha test func and ref, and blend
            | GL.GL_DEPTH_BUFFER_BIT // for depth func
            | GL.GL_ENABLE_BIT; // for enable/disable changes

    this.BEogsh.pushAttrib(gl, attrMask);

    if (!dc.isPickingMode()) {
      gl.glEnable(GL.GL_BLEND);
      OGLUtil.applyBlending(gl, false);
    }

    // Do not depth buffer the label. (Labels beyond the horizon are culled above.)
    gl.glDisable(GL.GL_DEPTH_TEST);
    gl.glDepthMask(false);

    // The image is drawn using a parallel projection.
    this.BEogsh.pushProjectionIdentity(gl);
    gl.glOrtho(
        0d, dc.getView().getViewport().width, 0d, dc.getView().getViewport().height, -1d, 1d);

    this.BEogsh.pushModelviewIdentity(gl);
  }
Exemplo n.º 11
0
  protected void initializeTexture(DrawContext dc) {
    Texture iconTexture = dc.getTextureCache().getTexture(this.getIconFilePath());
    if (iconTexture != null) return;

    try {
      InputStream iconStream = this.getClass().getResourceAsStream("/" + this.getIconFilePath());
      if (iconStream == null) {
        File iconFile = new File(this.iconFilePath);
        if (iconFile.exists()) {
          iconStream = new FileInputStream(iconFile);
        }
      }

      iconTexture = TextureIO.newTexture(iconStream, false, null);
      iconTexture.bind();
      this.iconWidth = iconTexture.getWidth();
      this.iconHeight = iconTexture.getHeight();
      dc.getTextureCache().put(this.getIconFilePath(), iconTexture);
    } catch (IOException e) {
      String msg = Logging.getMessage("layers.IOExceptionDuringInitialization");
      Logging.logger().severe(msg);
      throw new WWRuntimeException(msg, e);
    }

    GL gl = dc.getGL();
    gl.glTexParameteri(
        GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); // _MIPMAP_LINEAR);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
    // Enable texture anisotropy, improves "tilted" world map quality.
    int[] maxAnisotropy = new int[1];
    gl.glGetIntegerv(GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy, 0);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy[0]);
  }
  private void makePartialDiskTerrainConformant(
      DrawContext dc,
      int numCoords,
      float[] verts,
      double altitude,
      boolean terrainConformant,
      Vec4 referenceCenter) {
    Globe globe = dc.getGlobe();
    Matrix transform = this.computeTransform(dc.getGlobe(), dc.getVerticalExaggeration());

    for (int i = 0; i < numCoords; i += 3) {
      Vec4 vec = new Vec4(verts[i], verts[i + 1], verts[i + 2]);
      vec = vec.transformBy4(transform);
      Position p = globe.computePositionFromPoint(vec);

      double elevation = altitude;
      if (terrainConformant)
        elevation += this.computeElevationAt(dc, p.getLatitude(), p.getLongitude());

      vec = globe.computePointFromPosition(p.getLatitude(), p.getLongitude(), elevation);
      verts[i] = (float) (vec.x - referenceCenter.x);
      verts[i + 1] = (float) (vec.y - referenceCenter.y);
      verts[i + 2] = (float) (vec.z - referenceCenter.z);
    }
  }
Exemplo n.º 13
0
  /**
   * Draw labels for picking.
   *
   * @param dc Current draw context.
   * @param pickSupport the PickSupport instance to be used.
   */
  protected void doPick(DrawContext dc, PickSupport pickSupport) {
    GL gl = dc.getGL();

    Angle heading = this.rotation;

    double headingDegrees;
    if (heading != null) headingDegrees = heading.degrees;
    else headingDegrees = 0;

    int x = this.screenPoint.x;
    int y = this.screenPoint.y;

    boolean matrixPushed = false;
    try {
      if (headingDegrees != 0) {
        gl.glPushMatrix();
        matrixPushed = true;

        gl.glTranslated(x, y, 0);
        gl.glRotated(headingDegrees, 0, 0, 1);
        gl.glTranslated(-x, -y, 0);
      }

      for (int i = 0; i < this.lines.length; i++) {
        Rectangle2D bounds = this.lineBounds[i];
        double width = bounds.getWidth();
        double height = bounds.getHeight();

        x = this.screenPoint.x;
        if (this.textAlign.equals(AVKey.CENTER)) x = x - (int) (width / 2.0);
        else if (this.textAlign.equals(AVKey.RIGHT)) x = x - (int) width;
        y -= this.lineHeight;

        Color color = dc.getUniquePickColor();
        int colorCode = color.getRGB();
        PickedObject po = new PickedObject(colorCode, this.getPickedObject(), this.position, false);
        pickSupport.addPickableObject(po);

        // Draw line rectangle
        gl.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());

        try {
          gl.glBegin(GL.GL_POLYGON);
          gl.glVertex3d(x, y, 0);
          gl.glVertex3d(x + width - 1, y, 0);
          gl.glVertex3d(x + width - 1, y + height - 1, 0);
          gl.glVertex3d(x, y + height - 1, 0);
          gl.glVertex3d(x, y, 0);
        } finally {
          gl.glEnd();
        }

        y -= this.lineSpacing;
      }
    } finally {
      if (matrixPushed) {
        gl.glPopMatrix();
      }
    }
  }
  /**
   * Select the visible grid elements
   *
   * @param dc the current <code>DrawContext</code>.
   */
  protected void selectRenderables(DrawContext dc) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }
    Sector vs = dc.getVisibleSector();
    OrbitView view = (OrbitView) dc.getView();
    // Compute labels offset from view center
    Position centerPos = view.getCenterPosition();
    Double pixelSizeDegrees =
        Angle.fromRadians(
                view.computePixelSizeAtDistance(view.getZoom())
                    / dc.getGlobe().getEquatorialRadius())
            .degrees;
    Double labelOffsetDegrees = pixelSizeDegrees * view.getViewport().getWidth() / 4;
    Position labelPos =
        Position.fromDegrees(
            centerPos.getLatitude().degrees - labelOffsetDegrees,
            centerPos.getLongitude().degrees - labelOffsetDegrees,
            0);
    Double labelLatDegrees = labelPos.getLatitude().normalizedLatitude().degrees;
    labelLatDegrees = Math.min(Math.max(labelLatDegrees, -76), 78);
    labelPos =
        new Position(
            Angle.fromDegrees(labelLatDegrees), labelPos.getLongitude().normalizedLongitude(), 0);

    if (vs != null) {
      for (GridElement ge : this.gridElements) {
        if (ge.isInView(dc)) {
          if (ge.renderable instanceof GeographicText) {
            GeographicText gt = (GeographicText) ge.renderable;
            if (labelPos.getLatitude().degrees < 72
                || "*32*34*36*".indexOf("*" + gt.getText() + "*") == -1) {
              // Adjust label position according to eye position
              Position pos = gt.getPosition();
              if (ge.type.equals(GridElement.TYPE_LATITUDE_LABEL))
                pos =
                    Position.fromDegrees(
                        pos.getLatitude().degrees,
                        labelPos.getLongitude().degrees,
                        pos.getElevation());
              else if (ge.type.equals(GridElement.TYPE_LONGITUDE_LABEL))
                pos =
                    Position.fromDegrees(
                        labelPos.getLatitude().degrees,
                        pos.getLongitude().degrees,
                        pos.getElevation());

              gt.setPosition(pos);
            }
          }

          this.graticuleSupport.addRenderable(ge.renderable, GRATICULE_UTM);
        }
      }
      // System.out.println("Total elements: " + count + " visible sector: " + vs);
    }
  }
  @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);
  }
Exemplo n.º 16
0
 /**
  * Draw this label during ordered rendering.
  *
  * @param dc Current draw context.
  * @param pickSupport Support object used during picking.
  */
 protected void doDrawOrderedRenderable(DrawContext dc, PickSupport pickSupport) {
   TextRenderer textRenderer =
       OGLTextRenderer.getOrCreateTextRenderer(dc.getTextRendererCache(), font);
   if (dc.isPickingMode()) {
     this.doPick(dc, pickSupport);
   } else {
     this.drawText(dc, textRenderer);
   }
 }
Exemplo n.º 17
0
  protected static boolean isServiceVisible(DrawContext dc, PlaceNameService placeNameService) {
    //noinspection SimplifiableIfStatement
    if (!placeNameService.isEnabled()) return false;

    return (dc.getVisibleSector() != null)
        && placeNameService.getMaskingSector().intersects(dc.getVisibleSector());
    //
    //        return
    // placeNameService.getExtent(dc).intersects(dc.getView().getFrustumInModelCoordinates());
  }
    @SuppressWarnings({"RedundantIfStatement"})
    public boolean isInView(DrawContext dc) {
      if (!viewFrustum.intersects(this.getExtent(dc.getGlobe(), dc.getVerticalExaggeration())))
        return false;

      // Check apparent size
      if (getSizeInPixels(dc) <= MIN_CELL_SIZE_PIXELS) return false;

      return true;
    }
Exemplo n.º 19
0
  protected static boolean isNameVisible(
      DrawContext dc, PlaceNameService service, Position namePosition) {
    double elevation = dc.getVerticalExaggeration() * namePosition.getElevation();
    Vec4 namePoint =
        dc.getGlobe()
            .computePointFromPosition(
                namePosition.getLatitude(), namePosition.getLongitude(), elevation);
    Vec4 eyeVec = dc.getView().getEyePoint();

    double dist = eyeVec.distanceTo3(namePoint);
    return dist >= service.getMinDisplayDistance() && dist <= service.getMaxDisplayDistance();
  }
Exemplo n.º 20
0
  protected void draw(DrawContext dc, java.awt.Point pickPoint) {
    if (this.markers == null) return;

    if (dc.getVisibleSector() == null) return;

    SectorGeometryList geos = dc.getSurfaceGeometry();
    if (geos == null) return;

    // Adds markers to the draw context's ordered renderable queue. During picking, this gets the
    // pick point and the
    // current layer from the draw context.
    this.getMarkerRenderer().render(dc, this.markers);
  }
Exemplo n.º 21
0
  @Override
  protected void doRender(DrawContext dc) {
    if (this.frameTimestamp != dc.getFrameTimeStamp()) {
      this.assembleControlPoints(dc);
      this.frameTimestamp = dc.getFrameTimeStamp();
    }

    this.markerRenderer.render(dc, this.controlPoints);

    if (this.annotation != null && isShowAnnotation()) {
      this.annotation.render(dc);
    }
  }
Exemplo n.º 22
0
  /**
   * Draws the graphic as an ordered renderable.
   *
   * @param dc the current draw context.
   */
  protected void makeOrderedRenderable(DrawContext dc) {
    if (this.lines == null || this.position == null) return;

    this.computeGeometryIfNeeded(dc);

    // Don't draw if beyond the horizon.
    double horizon = dc.getView().getHorizonDistance();
    if (this.eyeDistance > horizon) return;

    if (this.intersectsFrustum(dc)) dc.addOrderedRenderable(this);

    if (dc.isPickingMode()) this.pickLayer = dc.getCurrentLayer();
  }
Exemplo n.º 23
0
  public void beginPicking(DrawContext dc) {
    javax.media.opengl.GL gl = dc.getGL();

    gl.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_CURRENT_BIT);

    gl.glDisable(GL.GL_DITHER);
    gl.glDisable(GL.GL_LIGHTING);
    gl.glDisable(GL.GL_FOG);
    gl.glDisable(GL.GL_BLEND);
    gl.glDisable(GL.GL_TEXTURE_2D);

    if (dc.isDeepPickingEnabled()) gl.glDisable(GL.GL_DEPTH_TEST);
  }
  @Override
  protected void setupShader(DrawContext dc) {
    if (shaderProgram == -1) {
      initShader(dc);
    }

    GL gl = dc.getGL().getGL2();
    gl.glUseProgram(shaderProgram);

    // double minElevation = ((ElevationTesselator)
    // dc.getGlobe().getTessellator()).getMinElevation();
    // double maxElevation = ((ElevationTesselator)
    // dc.getGlobe().getTessellator()).getMaxElevation();
    double minElevation = clamp(shaderMinElevation, minElevationClamp, maxElevationClamp);
    double maxElevation = clamp(shaderMaxElevation, minElevationClamp, maxElevationClamp);
    gl.glUniform1f(minElevationUniform, (float) minElevation);
    gl.glUniform1f(maxElevationUniform, (float) maxElevation);
    gl.glUniform1f(exaggerationUniform, (float) exaggeration);
    gl.glUniform1f(bakedExaggerationUniform, (float) bakedExaggeration);
    gl.glUniform1f(opacityUniform, (float) getOpacity());

    Matrix modelViewInv = dc.getView().getModelviewMatrix().getInverse();
    float[] modelViewInvArray =
        new float[] {
          (float) modelViewInv.m11,
          (float) modelViewInv.m21,
          (float) modelViewInv.m31,
          (float) modelViewInv.m41,
          (float) modelViewInv.m12,
          (float) modelViewInv.m22,
          (float) modelViewInv.m32,
          (float) modelViewInv.m42,
          (float) modelViewInv.m13,
          (float) modelViewInv.m23,
          (float) modelViewInv.m33,
          (float) modelViewInv.m43,
          (float) modelViewInv.m14,
          (float) modelViewInv.m24,
          (float) modelViewInv.m34,
          (float) modelViewInv.m44
        };
    gl.glUniformMatrix4fv(oldModelViewInverseUniform, 1, false, modelViewInvArray, 0);

    Vec4 eye = dc.getView().getEyePoint();
    gl.glUniform3f(eyePositionUniform, (float) eye.x, (float) eye.y, (float) eye.z);
    gl.glUniform3f(
        sunPositionUniform,
        (float) sunPositionNormalized.x,
        (float) sunPositionNormalized.y,
        (float) sunPositionNormalized.z);
  }
Exemplo n.º 25
0
  /**
   * Determine if this label intersects the view or pick frustum.
   *
   * @param dc Current draw context.
   * @return True if this label intersects the active frustum (view or pick). Otherwise false.
   */
  protected boolean intersectsFrustum(DrawContext dc) {
    View view = dc.getView();
    Frustum frustum = view.getFrustumInModelCoordinates();

    // Test the label's model coordinate point against the near and far clipping planes.
    if (this.placePoint != null
        && (frustum.getNear().distanceTo(this.placePoint) < 0
            || frustum.getFar().distanceTo(this.placePoint) < 0)) {
      return false;
    }

    if (dc.isPickingMode()) return dc.getPickFrustums().intersectsAny(this.screenExtent);
    else return view.getViewport().intersects(this.screenExtent);
  }
  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(), this.getLevels().getTileOrigin());
    return this.needToSplit(dc, centerSector);
  }
Exemplo n.º 27
0
  /**
   * Compute the lat/lon position of the view center
   *
   * @param dc the current DrawContext
   * @param view the current View
   * @return the ground position of the view center or null
   */
  protected Position computeGroundPosition(DrawContext dc, View view) {
    if (view == null) return null;

    Position groundPos =
        view.computePositionFromScreenPoint(
            view.getViewport().getWidth() / 2, view.getViewport().getHeight() / 2);
    if (groundPos == null) return null;

    double elevation =
        dc.getGlobe().getElevation(groundPos.getLatitude(), groundPos.getLongitude());
    return new Position(
        groundPos.getLatitude(),
        groundPos.getLongitude(),
        elevation * dc.getVerticalExaggeration());
  }
 public double getSizeInPixels(DrawContext dc) {
   View view = dc.getView();
   Vec4 centerPoint =
       getSurfacePoint(dc, this.centroid.getLatitude(), this.centroid.getLongitude());
   Double distance = view.getEyePoint().distanceTo3(centerPoint);
   return this.size / view.computePixelSizeAtDistance(distance);
 }
 public void computeZone(DrawContext dc) {
   try {
     Position centerPos = ((OrbitView) dc.getView()).getCenterPosition();
     if (centerPos != null) {
       if (centerPos.latitude.degrees <= UTM_MAX_LATITUDE
           && centerPos.latitude.degrees >= UTM_MIN_LATITUDE) {
         UTMCoord UTM =
             UTMCoord.fromLatLon(
                 centerPos.getLatitude(), centerPos.getLongitude(), dc.getGlobe());
         this.zone = UTM.getZone();
       } else this.zone = 0;
     }
   } catch (Exception ex) {
     this.zone = 0;
   }
 }
  public boolean isLayerInView(DrawContext dc) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalStateException(message);
    }

    if (dc.getView() == null) {
      String message = Logging.getMessage("layers.AbstractLayer.NoViewSpecifiedInDrawingContext");
      Logging.logger().severe(message);
      throw new IllegalStateException(message);
    }

    return !(dc.getVisibleSector() != null
        && !this.levels.getSector().intersects(dc.getVisibleSector()));
  }