rotation matrix error [ JPCT-AE + ARToolkit + AR Application]

Started by cefengxu, November 03, 2015, 01:26:48 PM

Previous topic - Next topic

cefengxu


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.

cefengxu

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

EgonOlsen

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


md2model.rotateX(...);


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

cefengxu

at the end , i have to change the rotation of the model in blender firstly, and then the rendering result is correct......

Thanks

cefengxu

Quote from: cefengxu 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.