【发布时间】:2013-05-16 19:43:02
【问题描述】:
当我在 SpriteBatch 上绘制纹理并设置 TextureWrap.Repeat 时,一切正常。但是现在我有 3D 场景,我想要在模型/网格上重复地面和纹理,这根本行不通。
public static StillModel createPlainMesh(float xs, float zs, Texture texture) {
final Mesh mesh = new Mesh(true, 4, 6, new VertexAttribute(
Usage.Position, 3, "a_position"), new VertexAttribute(
Usage.TextureCoordinates, 2, "a_texCoords"));
mesh.setVertices(new float[]
{ xs, 0f, zs, 0, 0,
xs, 0f, -zs, 0, 1,
-xs, 0f, zs, 1, 0,
-xs, 0f, -zs , 1,1
});
mesh.setIndices(new short[] { 0, 1, 2, 1, 2, 3 });
final StillModel model = new StillModel(new StillSubMesh(
"ground", mesh, GL10.GL_TRIANGLES, new Material()));
texture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
model.setMaterial(new Material("material", new TextureAttribute(texture, 0, "s_tex")));
return model;
}
我有这个代码。 我使用 setWrap(TextureWrap.Repeat, TextureWrap.Repeat),但纹理仍然被拉伸。我不知道为什么,但它看起来很糟糕。
【问题讨论】:
-
嘿,我遇到了和你一样的问题。你能解释一下什么是 StillModel 类吗?是你的课还是你在 libgdx 中找到的?
-
嘿。 StillModel 是 LibGDX 类。它在旧的 LibGDX 3D API 中。我不知道它是否也在新 API 中。