简体   繁体   中英

integrating JPCT-ae with QCAR(vuforia)

i know what i am going to ask is already discussed sometimes but after going through all of them i can't found my complete answer so i am asking a new question

when i tried integrating JPCT-ae with QCAR all goes well as expected, i got my modelview matrix from renderframe from jni and successfully transferred that in java to jpct model is shown perfectly as expected. but when i tried to pass this matrix to JPCT world camera my model disappear.

my code:in onsurfacechanged:

world = new World();
            world.setAmbientLight(20, 20, 20);
            sun = new Light(world);
            sun.setIntensity(250, 250, 250);
            cube = Primitives.getCube(1);
            cube.calcTextureWrapSpherical();
            cube.strip();
            cube.build();
            world.addObject(cube);
            cam = world.getCamera();
            cam.moveCamera(Camera.CAMERA_MOVEOUT, 10);
            cam.lookAt(cube.getTransformedCenter());
            SimpleVector sv = new SimpleVector();
            sv.set(cube.getTransformedCenter());
            sv.y -= 100;
            sv.z -= 100;
            sun.setPosition(sv);
            MemoryHelper.compact();

and in ondraw:

com.threed.jpct.Matrix mResult = new com.threed.jpct.Matrix();
            mResult.setDump(modelviewMatrix );  //modelviewMatrix i get from Qcar
            cube.setRotationMatrix(mResult);
            cam.setBack(mResult);
                     fb.clear(back);
        world.renderScene(fb);
        world.draw(fb);
        fb.display();

after some research i found that QCAR uses a right-handed coordinate system meaning that the X positive goes right, the Y positive goes up and the Z positive comes out of screen but in JPCT coordinate system the X positive goes right, the Y positive goes down and the Z positive goes into the screen.

Qcar coordinate system:

QCAR坐标系

i know that matrix QCar is giving is a 4*4 matrix having 3*3 rotational values and translation vector .

i am posting matrices to be more clear:

modelviewmatrix:

1.512537      -159.66255   -10.275316   0.0
-89.86529      -1.1592013   4.7839375            0.0
-8.619186     10.179538     -159.44305   0.0
59.182976        93.205956     437.2832            1.0

modelviewmatrix after reverse using cam.setBack(modelviewmatrix.invert(modelviewmatrix)) :

5.9083453E-5   -0.01109448   -3.3668696E-4   0.0
0.0040540528   -3.8752193E-4   0.0047518034   0.0
-0.004756433   -4.6811014E-4   0.0040459237   0.0
0.7533285     0.4116795            2.7063704   0.9999999

if i remove 13,14 and 15 matrix element assuming 3*3 rotation matrix...model is rotated properly but translation(in and out movement of image) is not there finally i dont know what changes translation vector is needed. so please suggest me what i am missing here?

QCAR::Matrix44F inverseMatrix = SampleMath::Matrix44FInverse(modelViewMatrix); QCAR::Matrix44F invTransposeMatrix = SampleMath::Matrix44FTranspose(inverseMatrix);

然后将invTransposeMatrix值传递给java

env->SetFloatArrayRegion(modelviewArray, 0, 16, invTransposeMatrix.data); env->CallVoidMethod(obj, method, modelviewArray);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM