Author Topic: Big data 3DS model loading  (Read 2919 times)

Offline karoshi

  • byte
  • *
  • Posts: 6
    • View Profile
Big data 3DS model loading
« on: February 27, 2014, 10:03:47 am »
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
« Last Edit: February 27, 2014, 10:38:34 am by karoshi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Big data 3DS model loading
« Reply #1 on: February 27, 2014, 10:48:31 am »
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.

Offline karoshi

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Big data 3DS model loading
« Reply #2 on: February 27, 2014, 11:46:21 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Big data 3DS model loading
« Reply #3 on: February 27, 2014, 11:58:59 am »
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.