Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About libgdx load model

Tags:

android

libgdx

I am a new libgdx programmer. I am developing on Android and i found some materials about libgdx。 Such as Xoppa blog, I see he write code to load model, e.x: public AssetManager asset;

        asset = new AssetManager();
        asset.load("xxx.obj",Model.class);
        Model model = asset.get("xxx.obj",Model.class);

..... it can correct load model to display.

But I used this code to load other obj file, such as room.obj by 3dMax, it can't correct display...why? the code is the same, only difference is file's name....can anyone tell me?or help me, thank you.

like image 612
user2182911 Avatar asked Aug 05 '26 10:08

user2182911


1 Answers

First in OnCreate method:

assets = new AssetManager();
    assets.load("data/yellow_note.obj", Model.class);
    loading = true;

add this method:

private void doneLoading() {
            Model ship = assets.get("data/yellow_note.obj", Model.class);
            //Here you add a model to you Array of Model Instance to render
            ModelInstance shipInstance = new ModelInstance(ship); 
            instances.add(shipInstance);
            loading = false;
        }

now in method OnRender:

if (loading && assets.update())
                doneLoading();

I find this solution here.

like image 168
Vinicius DSL Avatar answered Aug 06 '26 22:08

Vinicius DSL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!