jPCT-AE - a 3d engine for Android > Support

load 5 md2 models at the same time

(1/1)

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:
2M is the file size of the md2?

Davi:
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:

--- Code: ---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])));
}

--- End code ---

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...

Navigation

[0] Message Index

Go to full version