Hi,
i'm not sure how to do the following in a correct manner:
I want to always let "look" a physics node in the direction of my mouse-pointer.
To archieve this, i have used the
[pre]display.getPickRay(mousePosition, true, mouseRay)[/pre]
method which seems to return the correct 3D-Coordinates.
In my MouseInputListener (onMove) i'm trying to always look at that position:
[pre]position = mouseRay.getOrigin();
position.z = 0.0f;
[…]
mShip.getLocalRotation().lookAt(position, new Vector3f(0, 1, 0));[/pre]
X is left, Y is up. I think that's the problem because lookAt seems to do the following:
lookAt is a convienence method for auto-setting the quaternion based on a direction and an up vector. It computes the rotation to transform the z-axis to point into 'direction' and the y-axis to 'up'.
What have i to do to make my ship correctly look at the ray's origin?
My vector-math is not (yet) so good to get it solved all by myself
Another problem could be the "flipping" along the axes of the coordinate system…
Thank you,
Maurice