I'm developing a game using Android OpenGLES2. Making use of .obj files to draw 3D models, and the load time is too much because of the size of .obj file i.e., 3MB. Please suggest a method to minimize the obj file size
- First option, reduce the complexity of the object by cutting the number of triangles that form it
- Second option, try to read the OBJ file in a single chunk instead of line by line. This would benefit the read time from the device
- Third option, try to build a basic converter for OBJ into binary format. This sounds silly but it can very easy to be implemented since you already do the initial conversion (text to binary) when you load the model in memory. At this point, you just need to dump the binary in memory to a file. From there, you write the new loader (which is identical in logic to the dumper).
- Fourth option. It is very unpractical, try to compress with you own algorithm the content of the file on disk. Read it compressed. Expand in memory. This is pretty much what happens in the apk file. Theoretically it is a lot of efforts that could result at the end of the day in a waste of time and in poor performances.
These are the only options available unfortunately
You should use ready binary data instead of parsing .OBJ
files on mobile device - that's way too slow.
Suggestion #1
I realize this is an older post, but in case it helps anyone...
I was able to substantially reduce the file size of OBJ files using AccuTrans 3D. https://www.softpedia.com/get/Multimedia/Graphic/Graphic-Others/AccuTrans-3D.shtml
It can convert 3D files to many different file formats. If you export as OBJ and choose to set your own options, you can reduce the number of decimal places of vertices, set a scale factor, and include or eliminate things like vertex normals, texture UVs, and group names. Playing with these options can cut some file sizes in half depending on the level of detail, precision, or smoothing you're comfortable with.
Just be careful and play with it a little till you understand the options. Eliminating vertex normals removes object smoothing, which may or may not be acceptable for your application. Reducing vertex coordinate precision can create some pixelation depending on the settings you use.
Disclaimer: I am not affiliated with AccuTrans or it's owners in any way. It was recommended by one of the online 3D printing services I use.
Suggestion #2
On your server, if you serve the OBJ file as mime type text/plain, you can use gzip compression.
© 2022 - 2024 — McMap. All rights reserved.