this is the render loop in renderer,
/** Called to draw the current frame. */
public void onDrawFrame(GL10 gl)
{
if (!mIsActive)
return;
if (mActivity.touchTurnUp != 0 && mActivity.isadded != false) {
mActivity.new_thing.rotateZ(mActivity.touchTurnUp);
//cube.rotateX(0.1f);
mActivity.touchTurnUp = 0;
}
// Update render view (projection matrix and viewport) if needed:
mActivity.updateRenderView();
screenX1 = mActivity.screenX;
screenY1 = mActivity.screenX;
//mActivity.new_thing.animate(index, seq)
updateCamera();
renderFrame();
world.renderScene(fb);
world.draw(fb);
//thing.animate(1, 1);
fb.display();
}
and this is where I add new texture and model to world in my main activity, in background thread
try {
modelstrm = new FileInputStream(new File(imagePath));
mtlstrm = new FileInputStream(new File(MaterialPath));
texstrm = new FileInputStream(new File(TexturePath));
System.out.println("Start loading 3D model");
// fb = new FrameBuffer(mScreenWidth, mScreenHeight);
try {
System.out.println("Start loading Texture");
// old_texture = new
// Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.drawable.ic_launcher)),
// 64, 64));
TextureManager tm = TextureManager.getInstance();
if (!tm.containsTexture("new_texture")) {
new_texture = new Texture(BitmapHelper.rescale(
BitmapHelper.loadImage(texstrm), 512, 512));
// tm.unloadTexture(fb, new_texture);
// tm.r
// tm.replaceTexture("new_texture", old_texture);
new_texture.compress();
tm.addTexture("new_texture", new_texture);
} else {
old_texture = new Texture(BitmapHelper.rescale(
BitmapHelper.loadImage(texstrm), 512, 512));
// tm.addTexture("new_texture", new_texture);
old_texture.compress();
tm.replaceTexture("new_texture", old_texture);
}
// tm.unloadTexture(mRenderer.fb, old_texture);
System.out.println("End loading Texture");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (isadded) {
new_thing.clearObject();
new_thing = Object3D.mergeAll(Loader.loadOBJ(modelstrm,
mtlstrm, 1.0f));
new_thing.setTexture("new_texture"); // somtheing is wrong
// here
new_thing.scale(2.0f);
// isadded = true;
isadded = false;
}
new_thing = Object3D.mergeAll(Loader.loadOBJ(modelstrm,
mtlstrm, 1.0f));
new_thing.setTexture("new_texture"); // somtheing is wrong here
// new_thing.scale(2.0f);
isadded = true;
// new_thing.translate(0, 0, 50);
new_thing.rotateX(90);
System.out.println("End loading 3D model");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// dismissDialog(progress_bar_type);
if (inputStream != null)
Log.d("TAG", "It worked!");
mRenderer.world.addObject(new_thing);
pDialog.dismiss();
}
Its not the cleanest of codes so please bear with