Log in or register to post comments

3D Object

June 30, 2012 - 1:18am #1

Hi,

I would like to know if it is possible to set the 3D object that appear with my trackable as a Android Buttom. The idea is to go to another screen(Activity) when the user touch on the screen of his/hewr devices.

Thanks,

César

3D Object

June 30, 2012 - 9:26am #2

Yes you can. Take a look at the Dominoes sample for an example of how to project touches onto the target plane. This will enable you to determine whether a touch is within the bounds of a 3D object.

You can incorporate this functionality into your own project using the following steps:

 

  1. Copy SampleMath.h and SampleMath.cpp from the Dominoes sample to your project. On Android, be sure to add SampleMath.cpp to the LOCAL_SRC_FILES variable in Android.mk.
  2. Copy the projectScreenPointToPlane and linePlaneIntersection methods from Dominoes.cpp (Dominoes.mm on iOS) to your project.
  3. Create a "QCAR::Matrix44F modelViewMatrix" global variable, and set it in the renderFrame method.
  4. On Android, create a "QCAR::Matrix44F inverseProjMatrix" global variable, and set it after initializing the projection matrix (see the setProjectionMatrix method in QCARBase.cpp in the Dominoes sample).
  5. Call the projectScreenPointToPlane method as follows: 

QCAR::Vec3F intersection, lineStart, lineEnd;

projectScreenPointToPlane(QCAR::Vec2F(touch.x, touch.y), QCAR::Vec3F(0, 0, 0), QCAR::Vec3F(0, 0, 1), intersection, lineStart, lineEnd);

 

Log in or register to post comments