Hello,
I implemented a pick : it picks the closest object .
On desktop it is working but on android not , no collision detected…
On android I get weird result :
[java]public void onTouch(String name, TouchEvent event, float tpf) {
if(event.getType() == TouchEvent.Type.TAP){
Vector2f coo = new Vector2f();
coo.setX(event.getX());
coo.setX(event.getY());
Vector3f origin = cam.getWorldCoordinates(coo, 0.0f);
Vector3f direction = cam.getWorldCoordinates(coo, 0.3f);
System.out.println(“origin” + origin);
System.out.println(“direction” + direction);
System.out.println("origin x,y “+event.getX() +” "+ event.getY() + " " );
System.out.println("origin x,y "+cam.getScreenCoordinates(origin));
…[/java]
for example
06-13 21:24:52.632: INFO/System.out(1853): origin(5.418574, 4.5857863, 19.000002)
06-13 21:24:52.632: INFO/System.out(1853): direction(5.597707, 4.4085197, 18.57204)
06-13 21:24:52.632: INFO/System.out(1853): origin x,y 471.08505 644.2105
06-13 21:24:52.632: INFO/System.out(1853): origin x,y (644.2112, -7.6293945E-4, -2.861023E-6)
the original coordinate are 471,644
but after calling cam.getWorldCoordinates and then cam.getScreenCoordinates I don’t get the original coordinate back the 644 in Y become the X and the 471 in X disapear.
Is there something wrong somewhere ?
thanks for help
Might it be that there is a difference between the screen coordinates system and the jME one ?
Maybe this:
coo.setX(event.getX());
coo.setX(event.getY());
shame on me
Ok now it is better, but I still have an issue :
top and down are inverted:
when I tap on the top of the screen it picks the object on the same X coordinate but at the bottom of the screen
same when I pick at the bottom it picks the objects at the top…
Its possible the touch events are generated incorrectly. jME3 assumes the origin for the GUI is on the bottom-left, all events should be generated in that space
Yes, thats a bug. I do the flip Y for the mouse events generation but left the touch events untouched
Will fix that, so that touch events are bottom left, too. Probably by tomorrow.
Until this gets into svn you could do a screenheight - event.getY()
build latest svn and now it is working fine !
larynx said:
Yes, thats a bug. I do the flip Y for the mouse events generation but left the touch events untouched :)
Will fix that, so that touch events are bottom left, too. Probably by tomorrow.
Until this gets into svn you could do a screenheight - event.getY()
I have the same problem with mouse clicks detected by Nifty GUI, they are also inverted top and bottom (click in top panels are detected at the bottom of the screen). I do not think we can do any workaround here?
Added mouseEventsInvertY to AndroidHarness:
true is default
I asume that the flycam in the demos will get inverted if set to false, but nifty should work then.
As long as the coords are generated in the proper space its ok. We can add the flipping to fly cam later (and ChaseCamera already has it anyway)