TouchEvent getX getY (6 posts)

  • Profile picture of alex37 alex37 said 3 months, 2 weeks ago:

    I have the following problem.After implemented TouchListener, I want to select a Geometry with a single touch on the screen, and then, rotate the Geometry using TouchEvent parameter (getX() and getY() methods). Is it possible?

    Thanks in advance

  • Profile picture of normen normen1271p said 3 months, 2 weeks ago:

    sure

  • Profile picture of wezrule wezrule190p said 3 months, 2 weeks ago:

    you’ve got a nice binary rating going there @normen :)

  • Profile picture of alex37 alex37 said 3 months, 2 weeks ago:

    Thanks for your response, do you have a simple code example?

  • Profile picture of nehon nehon590p said 3 months, 2 weeks ago:

    Look at HelloPicking in the tutorials

    then instead of initializing your ray with the cam direction use the coordinates of the tap

    .....
            Vector2f coord = new Vector2f(event.getX(),event.getY());
            Vector3f origin = cam.getWorldCoordinates(coord, 0.0f);
            Vector3f direction = cam.getWorldCoordinates(coord, 0.3f);
            direction.subtractLocal(origin).normalizeLocal();
            Ray ray = new Ray(origin, direction);
    .....
    
  • Profile picture of alex37 alex37 said 3 months, 2 weeks ago:

    ok perfect, thank you