Drag and drop with jME

Hi!



Does anyone already make this with jME:



I want to pick an object in the scene and with the mouse pressed, I want to drag this object and when I release the mouse, I drop it in another place.

I think like a 3D chess game: I pick one piece and drop it in another position.



Any help or advice would be greatfully received!



Thanks.

This is a good question… here’s how I would go about integrating it.


  1. Detect the selection using Picking, but only need Bounding accuracy (triangles don’t matter as we are moving the entire piece).
  2. While the mouse button is pressed, get the screen to world coordinates of the current mouse position on each update. Set the localTranslation of the selected item to this position.
  3. Continue doing this until the mouse button is released.



    Of course, this doesn’t take into account going through the board, or illegal moves, but that should work for moving the piece.

Hi!



With the absolute mouse, when you say to get the current mouse position is the HotSpotPosition, right? Then with this value, calculate the world coordinates with the getWorldCoordinates from the DisplaySystem and finally do the setLocalTranslation, correct?



Well, I tried but it seems not to work…



Can anyone help?



Thanks!

Hi SamiLakka!



That would be good! How can you send the code?





Thanks!

Hi!



Well, if someone else made something with drag and drop in the 3D scene, please, post here. I really need this.



Thanks.