Author Topic: [topic-1-2]how to use the jpct-ae matrix as well as the OPENGL ES 2.0  (Read 2487 times)

Offline cefengxu

  • int
  • **
  • Posts: 65
    • View Profile
i have fix this issue , i will post a tutorial later.

Question: and then , the model could not be change ( always be laid on the mark ,as shown as the attached ) even i use the function rotationMatirx ;

my code as belown:

Code: [Select]
    public void onDrawFrame(GL10 unused) {
float[] projection = ARNativeActivity.getProjectM();
Matrix projMatrix = new Matrix();
projMatrix.setDump(projection);
projMatrix.transformToGL();
SimpleVector translation = projMatrix.getTranslation();
SimpleVector dir = projMatrix.getZAxis();
SimpleVector up = projMatrix.getYAxis();
cam.setPosition(translation);
cam.setOrientation(dir, up);

float[] transformation = ARNativeActivity.getTransformationM();
Matrix dump = new Matrix();
dump.setDump(transformation);
dump.transformToGL();
alita.clearTranslation();
alita.translate(dump.getTranslation());
alita.setRotationMatrix(dump);

alita.setState(stat);
alita.animate(ticks);
}

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: [topic-1-2]how to use the jpct-ae matrix as well as the OPENGL ES 2.0
« Reply #1 on: October 27, 2015, 03:50:57 pm »
Not sure what you mean...you set a rotation matrix and the model should rotate accordingly. I don't see any other code that applies additional rotations....or what do you mean exactly?

Offline cefengxu

  • int
  • **
  • Posts: 65
    • View Profile
Re: [topic-1-2]how to use the jpct-ae matrix as well as the OPENGL ES 2.0
« Reply #2 on: October 28, 2015, 03:23:48 am »
according to the links  supplied from you , i can inject the code of JPCT-AE into the ARToolkit's Project [ Example name : ARNative ].

JPCT-AE  using the Matrix( "Projection Matrix" and "Transformation Matrix"  ) which output from ARToolkit  to render a model on the mark successfully. the center , scale of model can match the mark in every case ( as the attached shown ), but , the model alway lie in the mark. .

I have tried to use the Matrix.rotateX/Y/Z( float x ) to rotate the model but still no work .( the model still lie in the mark )

Code: [Select]
public void onDrawFrame(GL10 unused) {
  float[] projection_temp = ARNativeActivity.getProjectM();

  Matrix temp1 = new Matrix();
  temp1.setDump(projection_temp);
  [color=green]temp1.rotateY((float)Math.PI/2);              // the rotate have to be  used for diff. matrix [  "Projection Matrix" and "Transformation Matrix"    ]  as the same time , otherwise, the model   will miss[/color]
  float[] projection = temp1.getDump();

  Matrix projMatrix = new Matrix();
  projMatrix.setDump(projection);
  projMatrix.transformToGL();
  SimpleVector translation = projMatrix.getTranslation();
  SimpleVector dir = projMatrix.getZAxis();
  SimpleVector up = projMatrix.getYAxis();
  cam.setPosition(translation);
  cam.setOrientation(dir, up);

  float[] transformation_temp = ARNativeActivity.getTransformationM();

  Matrix temp2 = new Matrix();
  temp2.setDump(transformation_temp);
  [color=green]temp2.rotateY((float)Math.PI/2);      // the rotate have to be  used for diff. matrix [  "Projection Matrix" and "Transformation Matrix"    ]  as the same time , otherwise, the model will miss[/color]
  float[] transformation = temp2.getDump();

  Matrix dump = new Matrix();
  dump.setDump(transformation);
  dump.transformToGL();
  alita.clearTranslation();
  alita.translate(dump.getTranslation());
  alita.setRotationMatrix(dump);

  alita.setState(stat);
  alita.animate(ticks);

  world.renderScene(fb);
  world.draw(fb);
  fb.display();
}


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: [topic-1-2]how to use the jpct-ae matrix as well as the OPENGL ES 2.0
« Reply #3 on: October 28, 2015, 03:22:28 pm »
Well...applying the rotation after setting the rotation matrix should actually work. The other way won't work, because setting the matrix will reset all former rotations of the object. If you want to make the rotation permanent, you can rotate and then use rotateMesh() at load time...
I'm still not sure that I got your problem right...