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 :-
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargetsSampleApp_ImageTargets_changePos(JNIEnv *, jobject , jfloat x, jfloat y)
{
SampleUtils::translatePoseMatrix(x, 0.0f, kObjectScale,
&modelViewMatrixforPos.data[0]);
SampleUtils::translatePoseMatrix(0.0f, y, kObjectScale,
&modelViewMatrixforPos.data[0]);
}
and in java i added this peice of code
private native void changePos(float x , float y);
@Override
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 .
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:
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.