Exemplo n.º 1
0
  /**
   * Get the current mouse position in world coordinates.
   *
   * @return
   */
  public double[] getPosition() {
    double[] p = new double[3];
    if (myMouse != null) {
      int x = myMouse.getX();
      int y = myMouse.getY();

      GLU glu = new GLU();
      /* note viewport[3] is height of window in pixels */
      y = myViewport[3] - y - 1;

      glu.gluUnProject(
          (double) x,
          (double) y,
          0.0, //
          myMVMatrix,
          0,
          myProjMatrix,
          0,
          myViewport,
          0,
          p,
          0);
    }

    return p;
  }