开发者

Save large size arrays to file on android

I am creating android application with 3D OpenGL ES view which will consist from 3D models imported from wavefront obj files. A typical Wavefront obj file will contain only triangulated objects and it might look like:

v 1.00000 1.00000 0
v 1.00000 -1.00000 0
v -1.00000 -1.00000 0
vt 1.00000 1.00000 0
vt 1.00000 -1.00000 0
vt -1.00000 -1.00000 0
vn 1.00000 1.00000 0
vn 1.00000 -1.00000 0
vn -1.00000 -1.00000 0
f 1/1/1 2/2/2 3/3/3

In the end it all will be converted into one single (one dimensional) array of floats. The problem is that this file is huge and loading it as strings and processing takes huge amount of time. (We need to load file into lines and then split them into tokens which takes alot of time and memory) I am looking开发者_开发问答 for alternative way and solution to store one ready array. The only Idea which I have is to read .obj file and create desired array. After that serialize the array and for every next execution of the application just read the serialized array. Is it a good idea or is there any other better way on android. Please remember that there are loads of data to handle! What I am looking for is good solution, I think that we dont need to care about space on HDD only care about load time and ram usage!


I faced this problem myself a while ago when I was developing my own app (https://market.android.com/details?id=de.hsrm.objectify) and the best solution to this AFAIK is to serialize the whole data and write it onto sd card. Saving and loading objects from external storage is not as slow as you might think.

Loading ~15.000 Vertices and Normals with texture takes about ~1 sec. at least in my case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜