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:
我正在使用3D OpenGL ES视图创建Android应用程序,该视图将包含从wavefront obj文件导入的3D模型。典型的Wavefront obj文件将仅包含三角形对象,它可能如下所示:
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!
最后,它将被转换为一个单一(一维)浮点数组。问题是这个文件很大并且将它作为字符串加载并且处理需要花费大量时间。 (我们需要将文件加载到行中,然后将它们分成多个时间和内存的标记)我正在寻找存储一个就绪数组的替代方法和解决方案。我唯一的想法是阅读.obj文件并创建所需的数组。在序列化数组之后,对于应用程序的每次下一次执行,只需读取序列化数组。这是一个好主意还是在Android上还有其他更好的方法。请记住,有大量数据需要处理!我正在寻找的是很好的解决方案,我认为我们不需要关心硬盘上的空间只关心加载时间和内存使用情况!
1 个解决方案
#1
0
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.
我不久前在开发自己的应用程序时遇到了这个问题(https://market.android.com/details?id=de.hsrm.objectify),这个AFAIK的最佳解决方案是序列化整个数据和把它写在SD卡上。从外部存储保存和加载对象并不像您想象的那么慢。
Loading ~15.000 Vertices and Normals with texture takes about ~1 sec. at least in my case.
加载~15000个具有纹理的顶点和法线大约需要1秒。至少在我的情况下。
#1
0
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.
我不久前在开发自己的应用程序时遇到了这个问题(https://market.android.com/details?id=de.hsrm.objectify),这个AFAIK的最佳解决方案是序列化整个数据和把它写在SD卡上。从外部存储保存和加载对象并不像您想象的那么慢。
Loading ~15.000 Vertices and Normals with texture takes about ~1 sec. at least in my case.
加载~15000个具有纹理的顶点和法线大约需要1秒。至少在我的情况下。