コード例 #1
0
ファイル: Viewport.java プロジェクト: hjanetzek/vtm
  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);
  }
コード例 #2
0
ファイル: Viewport.java プロジェクト: hjanetzek/vtm
  protected boolean copy(Viewport viewport) {
    mHeight = viewport.mHeight;
    mWidth = viewport.mWidth;
    mProjMatrix.copy(viewport.mProjMatrix);
    mProjMatrixUnscaled.copy(viewport.mProjMatrixUnscaled);
    mProjMatrixInverse.copy(viewport.mProjMatrixInverse);

    mUnprojMatrix.copy(viewport.mUnprojMatrix);
    mRotationMatrix.copy(viewport.mRotationMatrix);
    mViewMatrix.copy(viewport.mViewMatrix);
    mViewProjMatrix.copy(viewport.mViewProjMatrix);
    return viewport.getMapPosition(mPos);
  }
コード例 #3
0
ファイル: Viewport.java プロジェクト: hjanetzek/vtm
  /**
   * 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));
  }