Reputation: 41
I have problem using Vuforia with jPCT.
I have successfully passed the modelViewMatrix
from Vuforia native code
QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(imageResult->getPose())
to Java.
And then I try to set the camera matrix of jPCT.
public void setCameraMatrix(float[] modelViewMatrixFromVuforia) {
float x = modelViewMatrixFromVuforia[12];
float y = modelViewMatrixFromVuforia[13];
float z = modelViewMatrixFromVuforia[14];
modelViewMatrixFromVuforia[12] = 0;
modelViewMatrixFromVuforia[13] = 0;
modelViewMatrixFromVuforia[14] = 0;
Matrix cameraMatrix = new Matrix();
cameraMatrix.setDump(modelViewMatrixFromVuforia);
cameraMatrix = cameraMatrix.invert();
camera.setBack(cameraMatrix);
camera.setPosition(x, y, z);
}
But the 3D Object is not being tracked properly. What have I missed?
Upvotes: 4
Views: 616
Reputation: 16450
I'm using this and it works perfectly:
private Matrix mMatrix = new Matrix();
...
mMatrix.setDump(modelViewMatrixFromVuforia); // float[16] sent from native code
mCamera.setBack(mMatrix);
But you have to rotate the matrix 180 degree around X axis before you send it to Java in order to match the coordinate system from Vuforia to jPCT.
Do the rotation in native codes as follows:
SampleUtils::rotatePoseMatrix(180.0f, 1.0f, 0, 0, &modelViewMatrix.data[0]);
Upvotes: 4