Esempio n. 1
0
  protected void unproject(float x, float y, float[] coords, int position) {
    mv[0] = x;
    mv[1] = y;
    mv[2] = -1;
    mUnprojMatrix.prj(mv);
    double nx = mv[0];
    double ny = mv[1];
    double nz = mv[2];

    mv[0] = x;
    mv[1] = y;
    mv[2] = 1;
    mUnprojMatrix.prj(mv);
    double fx = mv[0];
    double fy = mv[1];
    double fz = mv[2];

    double dx = fx - nx;
    double dy = fy - ny;
    double dz = fz - nz;

    double dist = -nz / dz;

    coords[position + 0] = (float) (nx + dist * dx);
    coords[position + 1] = (float) (ny + dist * dy);
  }
Esempio n. 2
0
  /**
   * Get the screen pixel for map coordinates
   *
   * @param out Point projected to screen coordinate
   */
  public void toScreenPoint(double x, double y, Point out) {

    double cs = mPos.scale * Tile.SIZE;
    double cx = mPos.x * cs;
    double cy = mPos.y * cs;

    mv[0] = (float) (x * cs - cx);
    mv[1] = (float) (y * cs - cy);

    mv[2] = 0;
    mv[3] = 1;

    mViewProjMatrix.prj(mv);

    out.x = (mv[0] * (mWidth / 2));
    out.y = -(mv[1] * (mHeight / 2));
  }