Author Topic: integrating JPCT-ae with QCAR(vuforia)  (Read 7751 times)

Offline MrYogi

  • byte
  • *
  • Posts: 21
    • View Profile
integrating JPCT-ae with QCAR(vuforia)
« on: October 18, 2012, 03:27:11 pm »
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:
Code: [Select]
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:
Code: [Select]
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: integrating JPCT-ae with QCAR(vuforia)
« Reply #1 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...

Offline MrYogi

  • byte
  • *
  • Posts: 21
    • View Profile
Re: integrating JPCT-ae with QCAR(vuforia)
« Reply #2 on: October 19, 2012, 09:26:11 am »
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? :(

Offline MrYogi

  • byte
  • *
  • Posts: 21
    • View Profile
Re: integrating JPCT-ae with QCAR(vuforia)
« Reply #3 on: October 20, 2012, 11:20:04 am »
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
« Last Edit: October 20, 2012, 11:26:44 am by MrYogi »

Offline MrYogi

  • byte
  • *
  • Posts: 21
    • View Profile
Re: integrating JPCT-ae with QCAR(vuforia)
« Reply #4 on: October 20, 2012, 01:25:57 pm »
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? :( :( :(
« Last Edit: October 20, 2012, 02:11:37 pm by MrYogi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: integrating JPCT-ae with QCAR(vuforia)
« Reply #5 on: October 20, 2012, 02:08:58 pm »
Try to take these translation and apply it to the object via translate(...).

Offline MrYogi

  • byte
  • *
  • Posts: 21
    • View Profile
Re: integrating JPCT-ae with QCAR(vuforia)
« Reply #6 on: October 20, 2012, 02:19:21 pm »
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 ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: integrating JPCT-ae with QCAR(vuforia)
« Reply #7 on: October 20, 2012, 03:59:46 pm »
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.

Offline MrYogi

  • byte
  • *
  • Posts: 21
    • View Profile
Re: integrating JPCT-ae with QCAR(vuforia)
« Reply #8 on: October 22, 2012, 07:46:03 am »
so what operation should be done on  translation values of default matrix ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: integrating JPCT-ae with QCAR(vuforia)
« Reply #9 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).

Offline MrYogi

  • byte
  • *
  • Posts: 21
    • View Profile
Re: integrating JPCT-ae with QCAR(vuforia)
« Reply #10 on: October 22, 2012, 09:48:07 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.. :-\

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: integrating JPCT-ae with QCAR(vuforia)
« Reply #11 on: October 22, 2012, 10:36:12 am »
The same transformation that you apply to the rotation matrix should be applied to the translation.