/**
   * 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);
  }
Exemple #2
0
  /**
   * Constructs a new PickPointFrustum from another Frustum and screen rectangle
   *
   * @param frustum frustum to create the PickPointFrustum from
   * @param rect screen rectangle to store with this frustum
   */
  public PickPointFrustum(Frustum frustum, android.graphics.Rect rect) {
    super(
        frustum.getLeft(),
        frustum.getRight(),
        frustum.getBottom(),
        frustum.getTop(),
        frustum.getNear(),
        frustum.getFar());

    if (rect == null) {
      String message = Logging.getMessage("nullValue.RectangleIsNull");
      Logging.verbose(message);
      throw new IllegalArgumentException(message);
    }

    this.screenRect = rect;
  }
Exemple #3
0
  /** {@inheritDoc} */
  public boolean intersects(Frustum frustum) {
    if (frustum == null) {
      String msg = Logging.getMessage("nullValue.FrustumIsNull");
      Logging.error(msg);
      throw new IllegalArgumentException(msg);
    }

    // FYI: this code is identical to that in Cylinder.intersects.

    double intersectionPoint;

    this.tmp1.set(this.bottomCenter);
    this.tmp2.set(this.topCenter);

    double effectiveRadius = this.getEffectiveRadius(frustum.getNear());
    intersectionPoint = this.intersectsAt(frustum.getNear(), effectiveRadius, this.tmp1, this.tmp2);
    if (intersectionPoint < 0) return false;

    // Near and far have the same effective radius.
    effectiveRadius = this.getEffectiveRadius(frustum.getFar());
    intersectionPoint = this.intersectsAt(frustum.getFar(), effectiveRadius, this.tmp1, this.tmp2);
    if (intersectionPoint < 0) return false;

    effectiveRadius = this.getEffectiveRadius(frustum.getLeft());
    intersectionPoint = this.intersectsAt(frustum.getLeft(), effectiveRadius, this.tmp1, this.tmp2);
    if (intersectionPoint < 0) return false;

    effectiveRadius = this.getEffectiveRadius(frustum.getRight());
    intersectionPoint =
        this.intersectsAt(frustum.getRight(), effectiveRadius, this.tmp1, this.tmp2);
    if (intersectionPoint < 0) return false;

    effectiveRadius = this.getEffectiveRadius(frustum.getTop());
    intersectionPoint = this.intersectsAt(frustum.getTop(), effectiveRadius, this.tmp1, this.tmp2);
    if (intersectionPoint < 0) return false;

    effectiveRadius = this.getEffectiveRadius(frustum.getBottom());
    intersectionPoint =
        this.intersectsAt(frustum.getBottom(), effectiveRadius, this.tmp1, this.tmp2);
    return intersectionPoint >= 0;
  }