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();
}