2
votes

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 coordinate system

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?

1
hi , could you tell me how to get the modelview matrix from renderframe via jni?Fugogugo
from jni in renderframe get modelview matrix and pass it to java like this:// Passing the Modelview matrix up to Java jclass javaClass = env->GetObjectClass(obj); jfloatArray modelviewArray = env->NewFloatArray(16); jmethodID method = env->GetMethodID(javaClass, "updateModelviewMatrix", "([F)V"); ... // Passing the ModelView matrix up to Java (cont.) env->SetFloatArrayRegion(modelviewArray, 0, 16, modelViewMatrix.data); env->CallObjectMethod(obj, method, modelviewArray); env->DeleteLocalRef(modelviewArray);in java you will get value in updateModelviewMatrix method,sorry for code formettingmrYogi
hey, how about set the camera position using 13, 14, 15 element you just removed?jaredzhang
how can i set cam position with these values?mrYogi
I know this was a while ago, but were you able to use JPCT? I tried originally and couldn't figure it out, so I'm using gamekit now. The tracking seems to be working correctly at least. If I remember correctly, one of the mods was saying JPCT didn't support direct matrix usage. Oh, I found this article though. Maybe it helps? jpct.net/wiki/index.php/Integrating_JPCT-AE_with_Vuforiampellegr

1 Answers

0
votes

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

then pass the invTransposeMatrix value to java

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