No "Hello MousePick" for JME3?

Hi to all,

I am new on the site and this is my first post, so excuse me if this is not correct place to put it.

The issue is that I am trying to build a simple game app in which the user needs to see the mouse pointer and be able to use it to point and click on objects. Since I am new to the whole jmonkeyengine thing, I decided to start with learning the latest version JME3.

I found this tutorial: https://wiki.jmonkeyengine.org/legacy/doku.php/starter:hello_mousepick

But when I tried to use it, it turned out that 50% of the referenced classes are no longer in the JME.

My questions are:

  • Is this tutorial JME2 specific and is there a JME3 tutorial hiding somewhere?
  • If not, could some one provide example code how to play with mouse pointer on JME3?





    Thanks

    n

The following tutorial:



https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_picking



Will get you half way there. If you want mouse pick, you’ll need to create a ray from the mouse coordinate (translated to 3D space). You can use the following code:



[java]

Vector2f pos = new Vector2f(x, y);

Vector3f origin = cam.getWorldCoordinates(pos, 0.0f);

Vector3f direction = cam.getWorldCoordinates(pos, 0.3f);

direction.subtractLocal(origin).normalizeLocal();



Ray ray = new Ray(origin, direction);

[/java]



Where x and y are the mouse coordinate (or any arbitrary screen coordinates).

1 Like

Thanks batkid, I’ll check your code.



Thanks a lot,

n