Exemplo n.º 1
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;
  }
Exemplo n.º 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;
  }