Search code examples
javarotationcursorjmonkeyengine

JME3 geom rotation using mouse


So i've got this geom at the center of my window in a top-down view, if i place my cursor to the right of said geom, i want said geom to rotate to face the cursor, the geom pretty much always faces the cursor. I would like to know how to do this in the JMonkeyEngine SDK 3.0.

For a good visual example, refer to the game Noct, a top-down game.


Solution

  • Never mind,

    • find the cursor position making the center of the window being the origin of the coordinates
    • find the angle between the center and the cursor position
    • setLocalRotation(new Quaternion().fromAngleAxis(angle, Vector3f.UNIT_Y));