Author Topic: Load large file to Android device  (Read 3170 times)

Offline nmhung1507

  • byte
  • *
  • Posts: 2
    • View Profile
Load large file to Android device
« on: February 05, 2021, 06:23:40 am »
Hi,
I need to load and render a relatively large (~10Mb) 3DS file to android device.
The link to download file: https://free3d.com/3d-model/vw-touareg-72326.html
I've tried to serialize it, zipped it and load it to android device but it seems that the model has not been rendered correctly (missing a lot of component). With smaller file, it's OK.
My question is: is it feasible to load ~10Mb model using JPCT?
I've read your old comment (since 2011) in this forum that >3.5Mb is too large file to mobile device, but I think that with the power of hardware nowadays, 10Mb is not a real problem.
Thanks!
« Last Edit: February 05, 2021, 07:39:48 am by nmhung1507 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Load large file to Android device
« Reply #1 on: February 05, 2021, 08:05:37 am »
There is no actual limit on what you can load and display as long as loading times are feasible and it fits into memory. So there's no "cut off after 4 MB"-setting or anything like it.

In your case, it might be a problem with the model itself, with the 3ds loader, with the way in which you serialize/deserialize the object or, maybe most likely, this setting: https://www.jpct.net/jpct-ae/doc/com/threed/jpct/Config.html#maxPolysVisible

You might want to adjust this first to see if that does any good. When you load the object, there should be some log output that tells you, how many sub-objects the object compiler has created . If that number exceeds this setting, you'll lose parts of the model when rendering it as a whole. If you can't find this information, just double the value to see if that changes something.

If that doesn't help, a screenshot of the issue might give an indication of what might be wrong.

Offline nmhung1507

  • byte
  • *
  • Posts: 2
    • View Profile
Re: Load large file to Android device
« Reply #2 on: February 05, 2021, 09:32:19 am »
I checked the model in Windows and I can view it perfectly. I also checked the maxPolysVisible, the constant defined is 512 and the number of sub-object is only 241. I tried to increase it to 1024 but nothing difference.
This is the screen shoot: https://imgur.com/a/uQZcJaU
It look like the camera is too near the object. I used
Code: [Select]
Camera.moveCamera(Camera.CAMERA_MOVEOUT, speed) to move camera far-away but there is no result.
Here is my desktop source to serialize the model:
Code: [Select]
Object3D[] obj = Loader.load3DS("car.3ds", 1);
for (int i = 0; i < obj.length; i++) {
    obj[i].build();
}
new DeSerializer().serializeArray(obj, new FileOutputStream("car.ser"), true);
Android source to load model:
Code: [Select]
zis = new ZipInputStream(assMan.open("models/car.ser.zip"));
zis.getNextEntry();
Object3D[] objs = Loader.loadSerializedObjectArray(zis);
Object3D o3d = Object3D.mergeAll(objs);
Log.d(TAG, "Num of sub object: " + objs.length); // THIS LOGGED 241 SUB-OBJECTS
o3d.build();
world.addObject(o3d);

Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 2000);
cam.lookAt(o3d.getTransformedCenter());

I also attached desktop log of serializing the model as well as android log of loading it. You can see it if you want more information.
Thank you very much indeed!
« Last Edit: February 05, 2021, 09:44:45 am by nmhung1507 »

Offline AeroShark333

  • float
  • ****
  • Posts: 319
    • View Profile
Re: Load large file to Android device
« Reply #3 on: February 05, 2021, 01:35:39 pm »
Looking from your logs you seems to have a lot more polygons than just 512 or 1024.
The amount of objects might be 241 but each of these objects seems to have somewhere between 50 to 18000 polygons...
Would it help to increase the Config#maxPolysVisible to let's say 150000 or something?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Load large file to Android device
« Reply #4 on: February 05, 2021, 10:48:56 pm »
As the docs state, the "max polygon" name is misleading and only called that way for compatibility with desktop jPCT. It actually means "max subobjects" on jPCT-AE and he should be fine with his settings.

Edit: However, this number isn't the number of array elements after loading the file. It's the number of unique data structures created to render the object. You can't determine that value from anywhere but by looking at the log output when the object gets compiled for the first time. But anyway, if increasing the value to 1024 doesn't help, it's most likely not the issue.
« Last Edit: February 05, 2021, 11:28:03 pm by EgonOlsen »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Load large file to Android device
« Reply #5 on: February 05, 2021, 10:52:08 pm »
That looks strange. Have you tried to render a simpler model like a sphere from the Primitives class and increase it's polgon count?