コード例 #1
0
  /**
   * Using this slot's camera, construct a pick ray for the specified screen coordinates.
   *
   * @param screenLocation screen coordinates (in pixels, measured from the lower left, not null,
   *     unaffected)
   * @return new instance
   */
  @Override
  public Ray pickRay(Vector2f screenLocation) {
    Validate.nonNull(screenLocation, "screen location");

    Vector3f startLocation = cam.getWorldCoordinates(screenLocation, 0f);
    Vector3f farPoint = cam.getWorldCoordinates(screenLocation, 1f);
    Vector3f direction = farPoint.subtract(startLocation).normalizeLocal();
    Ray result = new Ray(startLocation, direction);

    return result;
  }
コード例 #2
0
  /**
   * Test whether the specified screen coordinates are inside this slot.
   *
   * @param screenLocation screen coordinates (in pixels, measured from the lower left, not null,
   *     unaffected)
   * @return true if location is in this slot, otherwise false
   */
  @Override
  public boolean isInside(Vector2f screenLocation) {
    Validate.nonNull(screenLocation, "screen location");

    if (insetSlotState.isInside(screenLocation)) {
      return false;
    }
    /*
     * Scale coordinates to fractions of the viewport dimensions.
     */
    float xFraction = screenLocation.x / cam.getWidth();
    float yFraction = screenLocation.y / cam.getHeight();
    if (xFraction > 0f && xFraction < 1f && yFraction > 0f && yFraction < 1f) {
      return true;
    }
    return false;
  }
コード例 #3
0
 /**
  * Alter this slot's background color.
  *
  * @param newColor new color (not null)
  */
 @Override
 public void setBackgroundColor(ColorRGBA newColor) {
   Validate.nonNull(newColor, "color");
   viewPort.setBackgroundColor(newColor);
 }