Hello, congratulations for this useful forum!
I'm creating an app based on JPCT demo to load and view obj files.
I have implemented funcions for load, pinch, drag and rotate objects.
As described in some other topic in this forum the Loader takes some time to load OBJ's, so I'm trying to insert a progressdialog to inform the user that loading is in progress.
I'm using an Object3D that i clear and reload as I need.
This is the code I've written inside the menu:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
case R.id.Ruota:
iF = 0;
break;
case R.id.Disegna:
iF = 1;
break;
case R.id.Cancella:
iF = 2;
break;
case R.id.Load:
ProgressDialog PrgD = new ProgressDialog(MainActivity.this);
PrgD.setTitle("mymessage1");
PrgD.setMessage("mymessage2");
PrgD.setCancelable(false);
PrgD.setIndeterminate(true);
PrgD.show();
Tm = true;
try {
world.removeObject(mesh);
mesh = null;
}catch (Exception e){
throw new RuntimeException(e.toString());
}
model = getResources().openRawResource(R.raw.model);
mtl = getResources().openRawResource(R.raw.material);
mesh = Object3D.mergeAll(Loader.loadOBJ(model, mtl, 1));
renderer.ObjLoad();
PrgD.dismiss();
break;
renderer.ObjLoad() is a void inside MyRenderer class where i set cameras, textures etc for the new model loaded.
Everithing works fine, i can read models from raw dir and display them with texture, but I can't see the progressdialog!
The dialog works fine untill i call Loader function inside my code (if i comment out the "mesh =..." line it works!).
If i put back the loader line the loader works, but instead of progressdialog i see empty screen..
I've also tried with an AsyncTask, calling the loader in Background, but the problem still remains: i'm not able to display the progress dialog...
I'm a beginner with coding, so maybe i'm doing some dumb error....can someone help me?
Thanks!