GetWorldPosition problem on ANDROID

edited November 2011 in Help request
I started investigating this problem because Picking was working correctly on the Windows build of my project but not on the Android build.
if(orxInput_IsActive("Touch")) {
   orxVECTOR mouse_pos;
   orxMouse_GetPosition(&mouse_pos);
			
   orxVECTOR world_mouse_pos;
   orxRender_GetWorldPosition(&mouse_pos, &world_mouse_pos);

   orxLOG("Mouse position: %f, %f", mouse_pos.fX, mouse_pos.fY);
   orxLOG("World mouse position: %f, %f", world_mouse_pos.fX, world_mouse_pos.fY);

   orxOBJECT *picked = orxObject_Pick(&world_mouse_pos);
			
   if (picked != orxNULL) {
      const orxSTRING name = orxObject_GetName(picked);
      orxLOG("Picked object name: %s", name);
   }
}

The symptom is orxObject_Pick does not work on the objects in my Android project unless I tap ~0.5 inch above the object on screen.

Also, there is an area of the screen where the coordinates are undefined. I used the above code in the OrxTest project as well and the behavior is the same. Here is what the orxLOG code above returns for World Position at a few different points on the screen: http://imgur.com/L0BDw

So there is an area at the bottom of the screen that returns bogus world coordinates. It looks like it is the same size as the status area on the top of the screen.

I reproduced it in portrait and landscape orientations.

Am I doing something wrong? Do I need to set the [Display], [Viewport], or [Camera] in a special way for Android?

The device in the screenshot is my HTC Incredible, 480x800 resolution (orxDisplay_GetScreenSize returns 405x800).

I don't believe the shattered screen (unfortunate!) contributes to the problem, since I've reproduced it in portrait and landscape orientations. The touchscreen is working fine on the OS and in other apps.

Thanks for any help.

Comments

  • edited November 2011
    Hi!

    Mmh, the issue could happen at different places. Did you check what orxMouse_GetPosition() was returning?
    Did it look correct as was it already wrong?
  • edited November 2011
    Thanks for replying.

    The numbers from orxMouse_GetPosition() look correct.
  • edited November 2011
    No worries, I didn't spend much time on the computer during the week end, hence my late reply. :)

    So by they look correct, you mean that (0, 0) matches the top left part of the screen with or without the status bar?
    And does the bottom right return (480, 800) or (405, 800)?
  • edited November 2011
    Here are my numbers for orxMouse_GetPosition()

    In the demo project (portrait orientation):

    (0, 0) matches the top left of the screen (touching the status bar)
    (456, 838) matches the bottom right of the screen. It's the last pixel I can touch with my finger before I accidentally press the buttons on the bottom

    In my project (landscape orientation):

    (29, 41) is the top leftmost pixel I can register without losing focus by touching the status bar
    (799, 467) is the last pixel I can touch on the bottom right without pressing the Home button

    I hope this makes sense.
  • edited November 2011
    Hi acksys,

    first thing to know, is : which version of orx are you using
    since orx-1.3.0 rc, there was alot of changes in android port (almost completely rewritten).

    So if you are not using the svn trunk and build from it, that's the first thing you should try (see the wiki on how to build orx)
  • edited November 2011
    Hi lydesik,

    Based on your reply to one of my first posts, I followed this tutorial to build Orx for Android: http://orx-project.org/wiki/en/orx/tutorials/setup_android

    I updated svn and built it around two weeks ago. That's the version I'm currently using.
  • edited November 2011
    there was indeed an issue with the mouse events in NvEvent.jar

    i've pushed an update on the svn

    try the demo and don't forget to update your NvEvent.jar in your project
  • edited November 2011
    Looking good. I did as you said and now screen coordinates make sense with world coordinates and my picking functions are working in my project. B)

    Areas in the status bar on my project (landscape mode) are shown as x==0, y==0 in World coordinates

    Whereas areas in the status bar and near the android buttons on the demo project (portrait mode) are still shown sometimes in bogus coordinates as described above.

    But again, the coordinates on the actual game area look good and Absolute Picking is working. I'll be doing more dev and testing on my project in a couple days, so I'll test it thoroughly.

    Thanks for the quick fix!
Sign In or Register to comment.