JDK-8091210 : 3D to 2D coordinates conversion API is needed
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: fx2.0
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2011-07-18
  • Updated: 2019-01-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Relates :  
Relates :  
Description
To support successful position of 3D objects within 2D scene and to support successful mix of 2D and 3D components within a single scene, coordinates conversion API is needed.

It seems that the minimal necessary amount of methods are these two:
- PerspectiveCamera.localToScene(Node node, Point2D point) converting 2D point (z = 0) in given node local coordinates into into 2D point on projection plane (z = 0)
- PerspectiveCamera.SceneToLocal(Node node, Point2D point) converting 2D point on projection plane into 2D point on the z = 0 plane of the given node local coordinates.

Comments
CameraHelper.pickProjectPlane(camera, moux, mouy) is almost exactly the method requested. It returns a Point3D at camera-World space, On the projection plane. This is not a public api however. Rather than create a lot of complicated error prone math, Why not just expose this publicly? I do not see how there could be a simpler implementation. Nor do I see how this could have a negative effect on the System, provided no access is given to the CameraAccessor (if that's an issue) In fact the only 3 methods in the class are: CameraHelper.pickNodeXYPlane(camera, node, moux, mouy);// Point2D CameraHelper.pickProjectPlane(camera, moux, mouy);// Point3D CameraHelper.project(camera, Point3D.ZERO); // Point2D These are easier to use and more relevant than many of the provided methods. And If I am not mistaken these methods are the basis for much of the PickRay (also private, should be public) as it is anyways.
25-02-2015

This is not a duplicate. Current conversion methods convert 3D to 3D. For example, with localToScene conversion of a point on a 3D object I'm getting coordinates where Z is not zero so these coordinates are useless in 2D world. This particular issue is about projection and un-projection coordinates conversion.
23-09-2013

This seems like a duplicate of RT-17966 which was addressed as part of the 3D work.
06-08-2013

Recently I tried to implement following use-case: a rectangular parent and a small circle in it; the circle can be dragged by mouse. Now I used perspective camera and rotated the parent in 3D. Then I wanted to drag the circle so that it stays in the plane of the parent AND keeps its position under cursor. I was not able to do this, because there is no way to find out the mouse location in the parent's coordinate system. Looks like the request I was about to file would be a duplicate of this one. Regardless of where the API will exist, I believe we need to use it in mouse event delivery. Right now the correct node is picked on mouse location (using pick ray), but the event.getX() and event.getY() return complete nonsense because they don't consider the camera, so they return coordinates from a world totally different from the one displayed to user (for instance when mouse hovers over the circle, the circle is picked, but the reported coordinates are way outside the circle). When the necessary API is there I can do the work of using it for mouse events. Please let me know if I should file a separate dependent issue for it.
18-10-2012

Maybe the description is confusing but the requested API requires the information that is exclusively on camera. With parallel camera any 3d point (x, y, z) has its projection point (x, y) with the same x and y coordinates. For Perspective Camera you have to calculate it based on the distance from the camera. So do you agree this API make sense on Camera?
19-07-2011

The proposed API doesn't make sense on Camera, since neither Local coordinates nor Scene coordinates are affected in any way by the camera. We will likely need new methods to convert scene coordinates to window (or device) coordinates that will need to take the camera into account. We will also need methods that accept and return 3D coordinates. This is targeted for Lombard.
19-07-2011