4

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?

Sam R.
  • 16,027
  • 12
  • 69
  • 122
jack
  • 41
  • 1

1 Answers1

4

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]);
Sam R.
  • 16,027
  • 12
  • 69
  • 122
  • I have added cameraMatrix.rotateX((float)Math.PI) but it does not work. Do you mind share your code which is working? Thanks. – jack Jan 05 '13 at 12:56