integrating JPCT-ae with QCAR(vuforia)

Started by MrYogi, October 18, 2012, 03:27:11 PM

Previous topic - Next topic

MrYogi

Hi All

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

when i tried integrating JPCT 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.

so please suggest me what i am missing here?

EgonOlsen

You can convert the matrices by simply rotating by PI around X. I've no idea if that fixes the problem though. It's a bit unlucky that QCAR returns a model view matrix. The camera's matrix is actually the rotational part of the view matrix. The model matrix is the one that transforms the object. Both combined are the modelview matrix, but that's actually not what the camera should contain. If done correctly, it'll work though...but it's still not the right way...

MrYogi

thanks for your reply...
i inverted modelview matrix and now it is responsive to position of image detected,but it is misplaced,assuming the coordinate system stated above it tried to rectify it but seems that axis positions are taking effect correctly but axis angles are not ...i tried everything from cam.rotateX() to invertmatrix.rotateX() but nothing is solving my issue,could you please explain how to get proper positioning by changes in angles? :(

MrYogi

#3
Quote from: EgonOlsen on October 18, 2012, 07:55:55 PM
You can convert the matrices by simply rotating by PI around X. I've no idea if that fixes the problem though. It's a bit unlucky that QCAR returns a model view matrix. The camera's matrix is actually the rotational part of the view matrix. The model matrix is the one that transforms the object. Both combined are the modelview matrix, but that's actually not what the camera should contain. If done correctly, it'll work though...but it's still not the right way...

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


exactly what matrix is needed to draw model ?Rotaional,model or view matrix and what is the role of FOV ?i am bit confuse between these,please help me out

MrYogi

#4
the coordinate system QCAR uses is:




please have a look at this thread for QCAR matrix:https://ar.qualcomm.at/content/how-get-quaternion-or-rotationmatrix-pose-matrix#comment-2014099


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..i am really stuck at this position,,can anyone help me? :( :( :(

EgonOlsen

Try to take these translation and apply it to the object via translate(...).

MrYogi

sorry i can't get you,which translation?
and exactly what matrix is needed to draw model ?Rotaional,model or view matrix? and what is the role of FOV ?

EgonOlsen

The elements that you removed from the matrix are the translation. In jPCT, you give the rotation and the translation. These two combined are basically are the model matrix. The same applies to the camera, where the form the view matrix. Both combined are the model view matrix.
Fov is the field of view. It's not related to the model view matrix but defines how wide/narrow your view is.

MrYogi

so what operation should be done on  translation values of default matrix ?

EgonOlsen

Remove them from the matrix and feed them into translate() (maybe after some required transformation between spaces).

MrYogi

Quote from: EgonOlsen on October 22, 2012, 08:37:45 AM
Remove them from the matrix and feed them into translate() (maybe after some required transformation between spaces).

what kind of  required transformation between spaces? because when i applied those values into translate() model disappears,sorry for bieng so novice in matrix terms.. :-\

EgonOlsen

The same transformation that you apply to the rotation matrix should be applied to the translation.