Author Topic: [resolved]rendering a animating model via JPCT-Bones basic on ARToolkit Porject  (Read 680 times)

Offline cefengxu

  • int
  • **
  • Posts: 65
    • View Profile
Purpose:
rendering a animating model via JPCT-Bones basic on ARToolkit Porject for Augmented Reality Application.


According  for the demo you support(Bones-Android-Ninja) , I have injected the code another project about ARToolkit and the model can be rendered on the screen in front of preview data ,  as shown on fig1.


Question:
If I  want to render  the model witch stand on the mark in real-time, how to change the camera position , camera direction and the model position/rotation.

Actually, I can realize it with md2 model using JPCE-AE ( as shown in figure2 , the code was shown as bellow) : But , for JPCT-Bones, how to do ?

Code: [Select]
[size=12pt]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();
cube.clearTranslation();
cube.translate(dump.getTranslation());
cube.setRotationMatrix(dump);

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

world.renderScene(fb);
world.draw(fb);
fb.display();
}[/size]


« Last Edit: November 02, 2015, 09:51:25 am by cefengxu »

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
it's the same Bones, i.e. Animated3D extends Obejct3D so it inherits all the bevaviour

Code: [Select]
for (Animated3D a : group) {
  // ...
  a.clearTranslation();
  a.translate(dump.getTranslation());
  a.setRotationMatrix(dump); 
}