What's the different between local coordinate and world coordinate?

Hi all,

I’m confused about local coordinate system and world coordinate system. What’s the different between both?

And in what use cases i should use the local coordinate system, in what use cases i should use the world coordinate system?


Let’s say you are driving in your car, where is the passenger seat? Chances are, you did not give me a latitude and a longitude but told me that it’s just to your right (or left depending on country). That’s a local coordinate.

If you’d given me the latitude and the longitude of the seat then that would be a world coordinate… and is dependent on the location and orientation of the car… in world coordinates.

Thanks pspeed!

But i still don’t how to use them in Jme3…

For example:

[java]Vector3f origin = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.0f);[/java]

What’s the relationship between cam and the mouse cursor in the world coordinate?

That is something else entirely.

That is taking a 2D coordinate on the screen, projecting it relative to the camera’s current world position and giving you the position in world space. You can use it as the origin of a vector that can be used for picking whatever the mouse has clicked on… but you need the other end of the vector to get a direction, ie: passing 1 instead of 0.

Back to the conceptual picture, sort of…

If you could click your mouse on the windshield of the car then inputManager.getCursorPosition() is the x,y position on the windshield. cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.0f); is the “latitude, longitude, and elevation” of that point on the windshield based on the current position and orientation of the car.

cam.getWorldCoordinates(inputManager.getCursorPosition(), 1) is the point 1 meter outside the windshield in the same direction as the first point. Your eyeball, to the point at z=0, to the point at z=1 all form a straight line.

Back to reality, if you have:


Vector3f near = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.0f);

Vector3f far = cam.getWorldCoordinates(inputManager.getCursorPosition(), 1.0f);




Ray ray = new Ray( near, far.subtract(near).normalizeLocal() );


Could be used for picking.

Local coordinates are the coordinates of a spatial relative to its parent, World coordinates are its coordinates in world world space.

You sets the local coordinates, and the world coordinates are updated if needed according to the parents world coordinates.

let’s say you have a node in 0,0,0 in world space, its local coordinates are 0,0,0 too. you attach a spatial to this node and set its local coordinates to 1,1,1. the World coordinates of the spatial will be 1,1,1 too.

Now, if you set the local coordinates of the parent node to 1,1,1, its world coord will be 1,1,1. But, for the Spatial child, its world coordinates will be 2,2,2, and local coord still 1,1,1.

Thanks nehon!

I began to understand a lot now.