使用libgdx渲染的3d对象没有使用Blender创建时使用的颜色 [英] Rendered 3d object using libgdx does not have colors as used to create using blender

查看:71
本文介绍了使用libgdx渲染的3d对象没有使用Blender创建时使用的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用搅拌器创建了3d对象.然后将其导出为g3db和gsdj类型,并与libgdx一起使用.一切正常,但对象的颜色未按预期呈现.

I have created a 3d object using a blender. and I exported it as a g3db and gsdj types and used with libgdx. everything works fine but the colors of the object are not rendering as expected.

我尝试使用各种方法来创建对象并使用搅拌器导出.过去,我尝试使用libgdx-fbx-conv将fbx转换为g3db.并且它也不起作用.

I tried using various ways to create an object and exporting with a blender. and In the past, I’ve tried libgdx-fbx-conv to convert fbx to g3db. and its also not working.

public class experiments extends ApplicationAdapter {

    private ModelBatch modelBatch;
    private Environment environment;
    private PerspectiveCamera cam;
    private Model model;
    private ModelInstance instance;
    private CameraInputController camController;

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

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

        G3dModelLoader loader = new G3dModelLoader(new UBJsonReader());
        model = loader.loadModel(Gdx.files.internal("test.g3db"));
        instance = new ModelInstance(model);

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

    @Override
    public void render() {
        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(instance, environment);
        modelBatch.end();
    }

    @Override
    public void dispose() {
    }
}

这是搅拌机显示的 https://drive.google.com/open?id=1WAjrP_Z4IVjohk-CZSFeLk5st8PNOQGz

这就是我所拥有的

https://drive.google.com/open?id=1AbRGLathCuESesTpcTFvKue49V1k533Z

推荐答案

这很可能与呈现方式有关.Blender使用Cycles或Eevee(使用Belender 2.8)进行渲染,而LibGDX使用OpenGl.就像您用两个不同的相机拍摄同一物体的照片一样.

That has most likely just something to do with the way it is being rendered. Blender renders it with either Cycles or Eevee (with Belender 2.8), while LibGDX uses OpenGl. It's like you make a photograph of the same object with two different cameras.

这篇关于使用libgdx渲染的3d对象没有使用Blender创建时使用的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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