0

I have met some problem for integration the JPCT-AE with ARNative of ARToolkit's Project.
Purpose:
using jpct-ae to rendering model basic on ARToolkit;
Status :
i can render a model on the screen behind the preview data;
however, the model could no shown in correct position;
i do not know how the using the ProjectionMatrix from ARToolkit for JPCT-AE.

My code was shown belown:

public void onSurfaceCreated(GL10 unused, EGLConfig config) {                  
    ARNativeActivity.nativeSurfaceCreated();
}

public void onSurfaceChanged(GL10 unused, int width, int height) {       
    ARNativeActivity.nativeSurfaceChanged(width, height); 
    glViewport(0, 0, width, height);

    fb = new FrameBuffer( width, height); // OpenGL ES 1.x constructor

    world = new World();
    world.setAmbientLight(20, 20, 20);

    sun = new Light(world);
    sun.setIntensity(250, 250, 250);

    loadOBJ("cube.obj" , "cube.mtl" , "cube");

    world.addObject(cubeColor);

    cam = world.getCamera();
    cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
    cam.lookAt(cubeColor.getTransformedCenter());

    SimpleVector sv = new SimpleVector();
    sv.set(cubeColor.getTransformedCenter());
    sv.y -= 100;
    sv.z -= 100;
    sun.setPosition(sv);
    MemoryHelper.compact();

}


public void onDrawFrame(GL10 unused) {
    glClear(GL_COLOR_BUFFER_BIT);
    ARNativeActivity.nativeDrawFrame();

    float[] projection  = ARNativeActivity.getProjectMatrix();
    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);

    world.renderScene(fb);
    world.draw(fb);
    fb.display();
}  
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
Bio. X
  • 13
  • 3

1 Answers1

0

I think this question is pretty similar to a newer one you made: Rendering a model basic on JPCT-AE with ARToolkit in Android. It will most likely be duplicated. Anyway, I have still not enough privileges to mark it as duplicated, so I reference to the other and try to answer the slight differences. The only difference I can see is that here you still are not using the transformation matrix given by the artoolkit. You must get it by calling

ARNativeActivity.getTransformationM()

and put it in a JPCT matrix:

transformM.setIdentity();
transformM .setDump(ARNativeActivity.getTransformationM());
transformM .transformToGL();

As told, is already on the other question, so I suggest all users going there for a more complete answer and external references.

Community
  • 1
  • 1
sergigabol
  • 26
  • 3