libgdx Android不显示模式(黑屏) [英] libgdx android doesn't show model (black screen)

查看:339
本文介绍了libgdx Android不显示模式(黑屏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的LibGDX。 我试图运用一些教程中,我已经看了网上加载一个模型libGDX。 问题是,我有一个黑色的屏幕时,应用程序是在我的Galaxy Nexus的(安卓4.3),根据LogCat中没有错误加载。 在code是这样的:

I'm new in LibGDX. I've tried to apply some tutorial I've read online to load a model in libGDX. The problem is that I have a black screen when the app is loaded on my Galaxy Nexus (Android 4.3), no error according to LogCat. The code is this:

@Override
public void create() {
    modelBatch = new ModelBatch();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(7f, 7f, 7f);
    cam.lookAt(0,0,0);
    cam.near = 1f;
    cam.far = 300f;
    cam.update();

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



    camController = new CameraInputController(cam);
    Gdx.input.setInputProcessor(camController);
}

private void doneLoading() {       
       Model I_model = assets.get("data/skeleton.g3db", Model.class);
       ModelInstance I_instance = new ModelInstance(I_model);
       I_instance.transform.setToTranslation(-5f, 0, -5f);
       instances.add(I_instance);
       loading = false;
    }

@Override
public void render() {
    if (loading && assets.update())
        doneLoading();
    camController.update();

    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

    modelBatch.begin(cam);
    modelBatch.render(instances, environment);
    modelBatch.end();
}

@Override
public void dispose() {
    modelBatch.dispose();
    model.dispose();
    assets.dispose();
}

@Override
public void resize(int width, int height) {
}

@Override
public void pause() {
}

@Override
public void resume() {
}

}

该模型的骨架是在线作为.FBX并转换在.g3db与FBX-CONV。 是一个code或模型误差? 任何帮助是AP preciated,谢谢。

The model "skeleton" is taken online as .fbx and converted in .g3db with fbx-conv. Is a code or model error? Any help is appreciated, thanks.

推荐答案

我认为这个问题是光的方向,因为我觉得两点灯光在这里讲,该模型具有纹理出现。

I think the problem is the direction of the light, because I think two points of lighting here telling that the model has textures appear.

是可能的模式越来越光线不好, 使用;

is possible that the model is getting bad light, use;

点光源设置(浮动R,浮克,浮B,浮动的x,浮Y,浮Z,浮强度)

PointLight set (float r, float g, float b, float x, float y, float z, float intensity)

float intensity = 1f;

environment.add(new PointLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.8f, intensity));

和托盘更换可变intesity在试验中,例如100;

and tray change variable intesity in test for example 100;

这篇关于libgdx Android不显示模式(黑屏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆