# Strange thing with getWorldCoordinates()

Hello!

Let’s explain my situation. I hava a scene rendered on a JMECanvas. What I’m trying to do with it is display it shown using an elevation view. Therefore what you “see” is the plane XZ. Over that plane I’d like to select a point of the scene (I only care about x and z coordinates) by clicking on it. For that purpose I collect the coordinates on the JMECanvas when a mouse click is performed (mouseEvent.getX(), mouseEvent.getY()) and then y use those arguments to invoke the camera’s getWorldCoordinates method. The problem is I only get the right coordinates when the camera is centered on the point I’m clicking. Here goes an example:

The plant shown in the figure is located at (50,0,40).

If I click on it when the camera is located at (0,h,0) -see figure - those are the coordinates I get:

WORLD COORD:com.jme.math.Vector3f [X=2.8803194, Y=290.90424, Z=0.8084578]

However, If I move the camera so it is just over the plant (next figure), the coordinates I get are much closer to the real coordinates:

WORLD COORD:com.jme.math.Vector3f [X=55.348408, Y=290.9001, Z=42.340603] (I only care about x,z and the plant is at 50,40)

Any ideas about how get this sorted out? Any help will be much appreciated

jtorrente84 said:

Hello!

Let's explain my situation. I hava a scene rendered on a JMECanvas. What I'm trying to do with it is display it shown using an elevation view. Therefore what you "see" is the plane XZ. Over that plane I'd like to select a point of the scene (I only care about x and z coordinates) by clicking on it. For that purpose I collect the coordinates on the JMECanvas when a mouse click is performed (mouseEvent.getX(), mouseEvent.getY()) and then y use those arguments to invoke the camera's getWorldCoordinates method. The problem is I only get the right coordinates when the camera is centered on the point I'm clicking. Here goes an example:

The plant shown in the figure is located at (50,0,40).

If I click on it when the camera is located at (0,h,0) -see figure - those are the coordinates I get:

WORLD COORD:com.jme.math.Vector3f [X=2.8803194, Y=290.90424, Z=0.8084578]

However, If I move the camera so it is just over the plant (next figure), the coordinates I get are much closer to the real coordinates:

WORLD COORD:com.jme.math.Vector3f [X=55.348408, Y=290.9001, Z=42.340603] (I only care about x,z and the plant is at 50,40)

Any ideas about how get this sorted out? Any help will be much appreciated

I just had a similar problem and got a good answer, check out the last page in the thread linked in my thread, it will tell you how to calculate the world coordinates:
http://www.jmonkeyengine.com/jmeforum/index.php?topic=7654.0

Apparently a lot of people are misinterpreting "getWorldCoordinates" and it is not entirely clear from the documentation what it returns.

I hope this helps.

Its good for you because you’ve done to collect the coordinates on the JMECanvas when a mouse click is performed.

________________

Artificial Trees