1 Reply Latest reply on Aug 9, 2011 2:29 AM by 880406

    Mouse coord to virtual world - Parallel projection


      I've been able to do it in Perspective projection the code above. Why does'n it work the same with Parallel projection? The point where new geometry is added doesn't correspond to the mouse point on screen...

      public Point3d getCanvasPtToVworldPt(int x, int y) {
      Point3d VworldPt = new Point3d();
      Point3d centerEyePt = new Point3d();
      // convert the canvas point to ImagePlate coords
      cv.getPixelLocationInImagePlate(x, y, VworldPt);
      // transform the point from an imageplate coordinate to a Vworld
      // coordinate
      Transform3D imagePlateToVworld = new Transform3D();


      double alpha = 0.0;
      if (VworldPt.z != centerEyePt.z) {
      alpha = centerEyePt.z / (VworldPt.z - centerEyePt.z);

      Point3d planePt = new Point3d(
      centerEyePt.x - alpha * (VworldPt.x - centerEyePt.x),
      centerEyePt.y - alpha * (VworldPt.y - centerEyePt.y),
      0.0); //centerEyePt.z - beta * (VworldPt.z - centerEyePt.z )

      return planePt;

        • 1. Re: Mouse coord to virtual world - Parallel projection

          I am unsure of what you mean by perspective and parallell projection. I am relatively new to Java3D and am unfamiliar with these terms.

          I think I am trying to solve a similar problem to you so maybe we can help each other as I suspect both our answers relate to [Transform3D|http://download.oracle.com/docs/cd/E17802_01/j2se/javase/technologies/desktop/java3d/forDevelopers/J3D_1_3_API/j3dapi/index.html].

          In my case, I am simply trying to move a point in the scene. I am able to get this to work when in top down view and the default zoom. However, when the scene is rotated or scaled the coordinates do not match up. Is this the same issue you are dealing with?

          The Transform3D has a 4x4 matrix that I believe stores the current views "translations, rotations, and scaling and shear effects". If we are able to understand this matrix then we should be able to perform some math to match up the coordinates.

          If this isn't the issue you are dealing with, I apologise for the response but things seem to move slowly on this forum.