Author Topic: Picking an Object placed on a Vuforia Marker  (Read 2105 times)

Offline frantxesco

  • byte
  • *
  • Posts: 3
    • View Profile
Picking an Object placed on a Vuforia Marker
« on: March 06, 2013, 05:19:15 pm »
Hi there,

I am developing an Augmented Reality App that makes use of Vuforia Qualcomm SDK to detect marker detection and JPCT to overlap some 3D object over the real-scene marker.

I am using Vuforia for Android as AR engine and passing the ModelViewMatrix up to Java in order to be used by JPCT-AE. I do everything following the tutorial at http://www.jpct.net/wiki/index.php/Integrating_JPCT-AE_with_Vuforia and it works fine.

I am now trying to detect if an object is "receiving" a touch event from the user, so to do some processing with it.
I guess what I am trying to do is something like things in this thread http://www.jpct.net/forum2/index.php?topic=2461.0.
Unfortunately I'm not being able to make it work, since the calcMinDistanceAndObject3D method always returns NULL.

Could you help me with it, maybe sharing some code?
Should I do anything with the ModelViewMatrix in the JNI before passing it to Java?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11899
    • View Profile
    • http://www.jpct.net
Re: Picking an Object placed on a Vuforia Marker
« Reply #1 on: March 06, 2013, 08:15:50 pm »
No, i don't see a reason for fiddling around with the matrix in native code. Basically, what you have to do is what the thread you linked to talks about. Any you have to make sure that your objects have the proper collision modes set. If you can't split the matrix into rotations and translations for whatever reason, consider to try this method: http://www.jpct.net/forum2/index.php/topic,2461.msg18062.html#msg18062

Offline frantxesco

  • byte
  • *
  • Posts: 3
    • View Profile
Re: Picking an Object placed on a Vuforia Marker
« Reply #2 on: March 12, 2013, 12:54:45 pm »
Hi,

I still get a "null" object.

I set the collision mode as .setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
and .setCollisionOptimization(true).

In the touch event handler I call
Code: [Select]
SimpleVector ray = reproject2D3DWS(cam, fb, (int)xpos, (int)ypos, toFill).normalize();where the function is written as in the post you linked.

Howevere, when I then call
Code: [Select]
Object[] result = objects[i].world.calcMinDistanceAndObject3D(cam.getPosition(), ray, 10000);but result[1] is always NULL, even if I point to the marker and the cube occupies the entire screen.

Probably I am missing something when I pass the matrix from native code to java code. For instance I never set the camera position.
Any idea?

thanks a lot

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11899
    • View Profile
    • http://www.jpct.net
Re: Picking an Object placed on a Vuforia Marker
« Reply #3 on: March 12, 2013, 01:08:28 pm »
Can you post an example of the content of the object's rotation and translation matrices?

Offline frantxesco

  • byte
  • *
  • Posts: 3
    • View Profile
Re: Picking an Object placed on a Vuforia Marker
« Reply #4 on: March 12, 2013, 01:30:48 pm »
As an example, when I point right to the marker the Model View Matrix I get from Native code is:

0.9893   0.0969    0.1082    0.0
0.0383   0.5448   -0.8376    0.0
-0.1401  0.8329  0.5353      0.0
38.0428 32.4253 206.1972   1.0

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11899
    • View Profile
    • http://www.jpct.net
Re: Picking an Object placed on a Vuforia Marker
« Reply #5 on: March 12, 2013, 03:34:01 pm »
I don't care much about the native matrix, but i would like to see the matrices that the Object3D has before executing the calcMinDistance-call.