Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce the size of 3D .obj file

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

like image 968
David Avatar asked Oct 21 '22 07:10

David


2 Answers

  • 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

like image 148
Maurizio Benedetti Avatar answered Oct 23 '22 02:10

Maurizio Benedetti


You should use ready binary data instead of parsing .OBJ files on mobile device - that's way too slow.

like image 40
keaukraine Avatar answered Oct 23 '22 03:10

keaukraine