load 5 md2 models at the same time

Started by Davi, November 14, 2011, 08:56:33 AM

Previous topic - Next topic

Davi

Hello,I have 5 md2 models,each model is about 2M,I want to load them at the same time,I don't know how to load it correctly, maybe there will be out of memorry? I have no idea,please give me a hint. :-\

EgonOlsen


Davi

#2
yeh,that is file size,oh my mistake,each model about 600kB,and each texture picture about 100kB ,I have use a thread to load them at the same time. but when I load about the third one, my app is crashed,the log error is out of memory.my code as following:

for(int i=0;i<5;i++){
modelList.add(Loader.loadMD2(this.getResources().getAssets().open(modelName[i], AssetManager.ACCESS_UNKNOWN), 3f));
TextureManager.getInstance().addTexture(texturesName[i], 
new Texture(BitmapFactory.decodeResource(this.getResources(), texturePictureId[i])));
}


I know there must be a good way to deal with this situation like my question.can you help me how to do that?   

EgonOlsen

Maybe this thread helps: http://www.jpct.net/forum2/index.php/topic,2361.0.html

However, keyframe animations are expensive memory wise. That's the trade-off that you do: You trade memory for performance. I'm not sure if there's a way to make all your models fit into memory. If the idea of calling strip() on the animation like the thread mentions it doesn't work out, the only way would be to reduce the complexity of the animation. I suggest to serialize them with the desktop version to see if you can load them in that form. The serialization process already strips them, so they come in the smallest form possible that way (you might have to load them via a ZipInputStream, because serializes meshes tend to create large files).
If nothing else helps, have a look at Bones for skeletal animation instead...