【问题标题】:Libgdx Box not drawn with color, but with textureLibgdx Box 不是用颜色绘制的,而是用纹理绘制的
【发布时间】:2013-06-03 20:15:39
【问题描述】:

我使用来自 Libgdx new 3d Api 的 ModelBuilder 创建了简单的盒子。 我创建这样的盒子:

int block_size = 5;
Model cube = mBuilder.createBox(block_size, block_size, block_size,
        new Material(), Usage.Position | Usage.Color | Usage.Normal | Usage.TextureCoordinates);

然后我创建一个 ModelInstance 进行渲染,如下所示:

ModelInstance instance = new ModelInstance(cube);

然后我尝试设置材质:

instance.materials.first().set(TextureAttribute.createDiffuse(t)); //t is a Texture (works)

一切正常!但是如果我使用 ColorAttribute.createDiffuse(Color.RED) 什么都不会显示!该框不可见。我不知道为什么......

instance.materials.first().set(ColorAttribute.createDiffuse(Color.RED));

我尝试删除 Usage.TextureCoordinates,但它改变了任何东西。先感谢您。 制造商, 人造纤维

【问题讨论】:

  • 我自己解决了...奇怪的解决方案,但它有效!只需删除 Usage.Color ?!?!并显示了彩色块......我不知道这是否是正确的方式......我个人认为这是一个错误:)
  • 将其发布为您自己问题的答案

标签: java libgdx


【解决方案1】:

删除 Usage.Color

Model cube = mBuilder.createBox(block_size, block_size, block_size,
    new Material(), Usage.Position | Usage.Normal | Usage.TextureCoordinates);

【讨论】:

    猜你喜欢
    • 2019-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-05
    • 2018-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多