1
當我在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中找到的? – Veljko
嘿。 StillModel是LibGDX類。它在舊的LibGDX 3D API中。我也不知道它是否在新的API中。 – kolek