Big data 3DS model loading

Started by karoshi, February 27, 2014, 10:03:47 AM

Previous topic - Next topic

karoshi

Dear,
I'm making a 3DS viewer using jPCT-AE.
I see 2 problems:
+ Memory consumption is very big for loading a 3DS model : I enabled large heap to use  availble memory for loading., it takes ~100MB memory to load ~5MB 3DS file.
+ Loading time is too long: If 3DS file is 5MB, it take some minutes to load.

I don't think 5MB is a big data for a tablet such as ASUS TF300T.
As a reference, my friend uses Ogre-Android to load ~2M Mesh file, it takes only ~1s.

So, can you share me what limitation of current jPCT-AE for big data? Maybe the issue is inside loader code or creating Object3D ( mergeObject, mergeAll,...)

Hardware: I'm using Transformer TF300T

Thank you

EgonOlsen

You can't really compare a loader written in native C with one written in Java. Not because of the performance of the languages and runtimes itself, but
because of the limitations of Java. In C, you can define structs and read the 3ds data directly into those. That's how the 3ds format is being build and it's is really fast (and error prone if the format is faulty, but that's another question).
In Java, there's no such thing. So you have to parse the binary data blob, which takes it's time and memory. That's why i added serialized objects. The idea is to load the model in native format by using the desktop version of jPCT, use the DeSerializer class to serialize it for Android (maybe zip it afterwards) and load that file on Android. It's much faster and uses much less memory than using 3ds or obj directly.

karoshi

Thanks ad.
Because I want to show 3DS file instantly after download from free source, it  must be 3DS format.
In that case, if I want to show 3DS file loading status, which API can I use?
In 3DS loading example, you use
  Object3D[] model = Loader.load3DS(is,scale);
           Object3D o3d = new Object3D(0);
           Object3D temp = null;
           for (int i = 0; i < model.length; i++) {
               temp = model;
               temp.setCenter(SimpleVector.ORIGIN);
               temp.rotateX((float)( -.5*Math.PI));
               temp.rotateMesh();
               temp.setRotationMatrix(new Matrix());
               o3d = Object3D.mergeObjects(o3d, temp); //almost time
               o3d.build();// almost time - redundant build
           }
It's possible to show status after each mergerObjects.

However, I improve loading time  and memory by :
Object3D[] model = Loader.load3DS(is,scale);
           Object3D temp = null;
           for (int i = 0; i < model.length; i++) {
               temp = model;
               temp.setCenter(SimpleVector.ORIGIN);
               temp.rotateX((float)( -.5*Math.PI));
               temp.rotateMesh();
               temp.setRotationMatrix(new Matrix());
           }
             o3d = Object3D.mergeAll(model);// almost time
          o3d.build();// almost time

All time is for mergeAll and build, is it impossible to get status during mergeAll and build?

EgonOlsen

Yes, merging them all at once if *much* faster than doing it one after the other. Unfortunately, there's no way to retrieve the status of this operation. Just use an ajax spinner like progess indicator or a faked (bouncing) progress bar instead. Another option be to try not to merge them at all.