Large obj file issue > 5mb

Started by annclew, May 07, 2017, 02:55:17 AM

Previous topic - Next topic

annclew

Hello,

We are using jPCT-AE in our AR application on Android, and are having a problem loading large files. We found that models are not displayed correctly when their size exceeds beyond some point. Image 1 shows a file of 3.9mb. As shown here, it shows weird reflection (large rectangular mark) and shading (small rectangular mark) at some parts.



For the test, we deleted a large amount of faces, so that the size of the model is less than 1mb (image 2). This time, everything left was shown correctly, without any reflection problem. Note that the staircase in image 1 is now shown correctly in image 2.



One solution seems to use serialize the obj files beforehand, but we cannot take this option because end users will just load their large obj files in runtime, so we cannot preprocess obj files. Can you recommend some good way of loading large obj files in runtime? I saw some android obj viewers, which quickly open very large files, so I think it must be possible to do so with jPCT-AE, but I have no idea how to do so.

By the way, thank you for the wonderful library. We really appreciate it.
Modify message

EgonOlsen

No idea...can you provide me with the model so that I can see for myself?


EgonOlsen

These models are not exported in the same way. While the "small" one seems to have normals in the way you want them to be (i.e. for a kind of flat shading), the large one has smoothed vertex normals similar to what jPCT-AE would calculate by default. I double checked this by loading both models into a viewer and the results were the same.

Oh, and just to be sure: if you are using the normals from the file, make sure to not use this faked flat shading option.

mayuran.r

Hi,

I also want to load a large .obj model(which is about >70mb) . This contains several small models, and merged and exported as a single .obj file. When i load that .obj file , i encountered a memory exception.  How can I able to load large .obj models.?
I tried converting same model to .3ds (which is about >20mb), but when i load that .3ds i can't be able to see anything on the screen.
Considering all these what will be the best solution?

Thanks in Advance.

EgonOlsen

The best solution would be to use smaller models in the first place. If that's not an option, serialized objects should help:

http://www.jpct.net/wiki/index.php?title=Differences_between_jPCT_and_jPCT-AE#Performance_and_memory_issues.2C_serialized_objects

Promyclon

Take into account that Android puts some restriction on files larger than 5MB. The solution is to pack them into a zip. These files, as well as i.e. mp3, can be larger than 5MB. Then use ZipInputStream to read them as ZipEntries.

Reading .obj files uses much memory because an entire file is read to the buffer first and is kept until all objects it contains are constructed by parsing lots of strings to floating point data. Reading serialized objects is more merciful for memory and is faster, although some data is ignored during serialization (I've still to check the new beta).

mayuran.r

Hi,

Thanks for your guidance. Sorry for the late reply.
Btw I am new to JPCT, I Managed to render the 3D models over the camera view. I have started trying out both the solution.

Thanks EgonOlsen, There are few doubts
1. Do we must need Eclipse to serialize the 3D models?
2. If we serialize the models, size of the model will be reduced?  [My Obj is comparably large (~73mb).]
3. If I have the code explanation to serialize model , it will be easy to follow and understand.

Thanks Promyclon, I am interested in this solution too.
1. I have compressed my 3D model, it came around 15mb.
2. But when I load the model , nothing is displayed. obj values are not retrieved it seems.
I could identify that by applying a texture for that model(Null value exception encountered)
If I get some code sample, I can try it out.

Also I have added  android:largeheap = true, in that scenario,
.obj values are read, but model is not rendered. I see a message in the stack as 'Suspending all threads took: 36.969ms'

I have tried out with .3ds model also(.obj converted as .3ds : ~20mb), in that case also ,
model is not rendered , but in the monitor I can see the values are read . Will it take too much of time? but in that case also I can see 'Suspending all threads took' message (but not often)

I am using Pixel for this purpose.
Hope you will guide me to a good solution

Thank you in Advance.

EgonOlsen

Serialized objects are actually larger at times, but they compress very will. You can zip them and then load them via ZipInputStream.

An no, you don't need Eclipse for that but some IDE that can execute desktop Java. Android Studio might not be the best choice for this task.

What you basically do is to load your object with desktop Java/jPCT, call build() on it and then do


new DeSerializer().serialize(obj, new FileOutputStream("storage/android/some_name.ser"), true);


You can then zip the result and load it in Android similar to this


zis = new ZipInputStream(<AssetManagerInstanz>.open("some_name.ser.zip"));
try {
zis.getNextEntry();
} catch (IOException e) {
throw new RuntimeException(e);
}

Object3D obj=Loader.loadSerializedObject(zis);

mayuran.r

Hi
I have done everything as you said.
But when I run, I got this error

"Can't deserialize object: [] - ERROR: Unsupported version: 6"

What could be the reason

Thanks

mayuran.r

Quote from: mayuran.r on September 08, 2017, 09:52:16 AM
Hi
I have done everything as you said.
But when I run, I got this error

"Can't deserialize object: [] - ERROR: Unsupported version: 6"

What could be the reason

Thanks


I found in the other Thread that I need to update the Version of JPCT-AE ,
JPCT Version 1.31 and JPCT-AE version was 1.26
So I updated the Version 1.31, it works.

Thanks