Picking an Object placed on a Vuforia Marker

Started by frantxesco, March 06, 2013, 05:19:15 PM

Previous topic - Next topic

frantxesco

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?

EgonOlsen

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

frantxesco

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
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
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

EgonOlsen

Can you post an example of the content of the object's rotation and translation matrices?

frantxesco

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

EgonOlsen

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.