Hi. Sorry for my english but i think you will understand
i'm working on augmented reality application, where i have four instances of Object3D and they are added/removed from world according to state of image fom camera. Problem is that the application sometimes crashes on onDrawFrame() method and I can't find out why.
There is a log(it is allways the same)
FATAL EXCEPTION: GLThread 42496
java.lang.RuntimeException: [ 1414843865465 ] - ERROR: java.lang.NullPointerException
at com.threed.jpct.Object3D.transformVertices(Object3D.java:5879)
at com.threed.jpct.World.renderScene(World.java:1070)
at com.example.app.views.AppRenderer.onDrawFrame(AppRenderer.java:84)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
at com.threed.jpct.Logger.log(Logger.java:193)
at com.threed.jpct.Logger.log(Logger.java:150)
at com.threed.jpct.World.renderScene(World.java:1085)
at com.example.app.views.AppRenderer.onDrawFrame(AppRenderer.java:84)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)and there is code of onDrawFrame() method:
@Override
public void onDrawFrame(GL10 gl) {
while (!CameraModel.getInstance().mBackgroundLoaded) {
Thread.yield();
}
fb.clear(back);
CameraModel model = CameraModel.getInstance();
mBackgroundTex.overrideTexelData(model.getBackground());
fb.blit(mBackgroundTex, 0, 0, 0, 0, (int) model.mPow2width,
(int) model.mPow2Height, model.mCamWidth, model.mCamHeight, -1,
false);
world.renderScene(fb); //app crashes on this line
world.draw(fb);
fb.display();
if (mSaveScene) {
int[] array = fb.getPixels();
IntBuffer dst = IntBuffer.wrap(array);
dst.rewind();
Bitmap bmp = Bitmap.createBitmap(fb.getWidth(), fb.getHeight(),
Bitmap.Config.ARGB_8888);
bmp.copyPixelsFromBuffer(dst);
saveScene(bmp);
mSaveScene = false;
}
}
Adding and removing object:
public void addObject(Object3D obj) {
world.addObject(obj);
}
public void removeObject(Object3D obj) {
world.removeObject(obj);
}
this happening in openGL thread
Have you any ideas what I'm doing wrong ?
Thanks