Author Topic: rotation matrix error [ JPCT-AE + ARToolkit + AR Application]  (Read 2736 times)

Offline cefengxu

  • int
  • **
  • Posts: 65
    • View Profile
rotation matrix error [ JPCT-AE + ARToolkit + AR Application]
« on: November 03, 2015, 01:26:48 pm »

hi master:


for the issue " the model rendered by JPCT always lied on the mark and can not be rotate basic the matrix output from ARToolkit "

actually, the matrix output from the ARToolkit::ARNativeActivity.getTransformationMatrix() is correctly and the result of matrix  be such like this:

  0.9592849       0.042872142   -0.27916315   0.0
0.161977        -0.8932123         0.41944835    0.0
-0.23136866   -0.44758964      -0.86379063    0.0
-58.357327     38.013783            381.9324        1.0

<< Orange Color : the rotation info[/size]  [/size]Green  Color: the translation info>>

so i think i just set the translation and  rotation for the model and the result should be right. and then i set up to  jpct-matrix and set into the model like this:

Matrix dump = new Matrix();
dump.setDump(ARNativeActivity.getTransformationM());
dump.transformToGL();
                 
a.clearTranslation();
a.translate(dump.getTranslation());      //   the translation could be sure that it's right because the model can translate through the mark on the screen
                 
a.clearRotation();

a.setRotationMatrix(dump);   // and then the model lied on the mark


dump.rotateX/Y/Z((float)Math.PI/2);    i try to use matrix rotation to rotate the model before process  a.setRotationMatrix(dump) , but no work , the model some time will missing

so , i think i can not handle it now , i have spend server day to deal with this issue but no work.

Offline cefengxu

  • int
  • **
  • Posts: 65
    • View Profile
Re: rotation matrix error [ JPCT-AE + ARToolkit + AR Application]
« Reply #1 on: November 03, 2015, 01:29:18 pm »
the code was shown below :

Matrix dump = new Matrix();
dump.setDump(ARNativeActivity.getTransformationM());
dump.transformToGL();
md2model.clearTranslation();
md2model.translate(dump.getTranslation());      //   the translation could be sure that it's right because the model can translate through the mark on the screen
md2model.clearRotation();
md2model.setRotationMatrix(dump);   // and then the model lied on the mark

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: rotation matrix error [ JPCT-AE + ARToolkit + AR Application]
« Reply #2 on: November 03, 2015, 02:10:14 pm »
Looks fine to me...except that you set the translational part again in the rotation matrix.

That's actually not how it's supposed to be. The transformation matrix has be split into a translation and a pure rotation i.e. basically a 3x3 matrix with 0,0,0,1 as forth row and column.

And then do something like

Code: [Select]
md2model.rotateX(...);

after all that. As long as your rotation pivot isn't way off, it should work.

Offline cefengxu

  • int
  • **
  • Posts: 65
    • View Profile
Re: rotation matrix error [ JPCT-AE + ARToolkit + AR Application]
« Reply #3 on: November 05, 2015, 07:47:40 am »
at the end , i have to change the rotation of the model in blender firstly, and then the rendering result is correct......

Thanks

Offline cefengxu

  • int
  • **
  • Posts: 65
    • View Profile
[resolved]rotation matrix error [ JPCT-AE + ARToolkit + AR Application]
« Reply #4 on: November 05, 2015, 07:47:59 am »

hi master:


for the issue " the model rendered by JPCT always lied on the mark and can not be rotate basic the matrix output from ARToolkit "

actually, the matrix output from the ARToolkit::ARNativeActivity.getTransformationMatrix() is correctly and the result of matrix  be such like this:

  0.9592849       0.042872142   -0.27916315   0.0
0.161977        -0.8932123         0.41944835    0.0
-0.23136866   -0.44758964      -0.86379063    0.0
-58.357327     38.013783            381.9324        1.0

<< Orange Color : the rotation info[/size]  [/size]Green  Color: the translation info>>

so i think i just set the translation and  rotation for the model and the result should be right. and then i set up to  jpct-matrix and set into the model like this:

Matrix dump = new Matrix();
dump.setDump(ARNativeActivity.getTransformationM());
dump.transformToGL();
                 
a.clearTranslation();
a.translate(dump.getTranslation());      //   the translation could be sure that it's right because the model can translate through the mark on the screen
                 
a.clearRotation();

a.setRotationMatrix(dump);   // and then the model lied on the mark


dump.rotateX/Y/Z((float)Math.PI/2);    i try to use matrix rotation to rotate the model before process  a.setRotationMatrix(dump) , but no work , the model some time will missing

so , i think i can not handle it now , i have spend server day to deal with this issue but no work.