Log in or register to post comments

Hold the 3D object and place it somewhere else

August 29, 2012 - 12:54pm #1

Hi guys

I have been putting some effort in ImageTargets sample app and i have been able to dynamically change the 3D models at runtime.

Now my next task is to hold the 3D model(Like we touch the dominoes in camera view) and move it on the screen and it should stay even after i 

remove the marker image . Also i want to ask can we add sound in this as well ?

thanks in advance

Hold the 3D object and place it somewhere else

August 29, 2012 - 2:13pm #3

This thread provides instructions on how to freeze a model - https://ar.qualcomm.at/content/how-disable-pose-updates-rendered-model-aka-freezing-model-disabling-tracking

By default, the pose matrix will place content in the center of the target with X to the right, Y to the top, and Z coming out of the target: https://ar.qualcomm.at/resources/images/coordinateSystems.jpg We can apply translations, rotations, and scales to the pose matrix to make the final modelview matrix. The ImageTargets sample uses the following set of transforms:

SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,
SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
                            &modelViewMatrix.data[0] ,


Note that the transforms are applied from bottom to top. In this case, the model is scaled by kObjectScale and then translated up the Z axis by kObjectScale. You can obtain the trackable size of image targets and frame markers at runtime by casting the Trackable object to the specific class (ImageTarget or Marker) and calling the getSize() method. For MultiTargets you can query the size of individual Parts.

Hold the 3D object and place it somewhere else

August 29, 2012 - 2:13pm #2

In ImageTargets.java file where the modelViewMatrix is being defined on line 351 i added this line

modelViewMatrixforPos = modelViewMatrix;

With this i can use modelViewMatrixforPos in another custom function in JNI so i created this function :-


Java_com_qualcomm_QCARSamples_ImageTargetsSampleApp_ImageTargets_changePos(JNIEnv *, jobject , jfloat x, jfloat y)


SampleUtils::translatePoseMatrix(x, 0.0f, kObjectScale,


SampleUtils::translatePoseMatrix(0.0f, y, kObjectScale,



and in java i added this peice of code 

 private native void changePos(float x , float y);


    public boolean onTouchEvent(MotionEvent event) {

    // TODO Auto-generated method stub

    changePos(event.getX() , event.getY());

    Log.d("Event Postion ",event.getX()+"  "+event.getY());

    return super.onTouchEvent(event);



I am getting the log but the touch event doesnt moves the 3D Model . 

Log in or register to post comments