Libgdx为3D游戏渲染地板

在我的第一个3D游戏中,我现在想渲染地板,实际上是y = 0的平面(不是libgdx Plane )。

我想为它添加一个Texture ,所以我可以在每个级别有不同的楼层。

现在我的问题是:创建和渲染这个纹理地板的最佳方法是什么?

我想过使用用ModelBuilder制作的基本Block Models ,然后添加了Texture ,但因为我只能看到6个面中的一个,2d Texture就够了,所以我想到了一个Plane

我可以在Plane添加Texture ,因为它在3D房间是无限的脸吗? 我当时想到的最后一件事是Decal

Decal是我要找的吗? 我该如何使用它们? 或者你有其他解决方案吗?

任何教程或其他帮助都会很棒。

谢谢

首先关于贴花,贴花就像精灵,但在3d坐标中,使用它像这样:

私人贴花贴花; 私人DecalBatch decalBatch;

在show()或create()中

 decalBatch = new DecalBatch(); CameraGroupStrategy cameraGroupStrategy = new CameraGroupStrategy(camera); decal = Decal.newDecal(textureRegion, true); decal.setPosition(5, 8, 1); decal.setScale(0.02f); decalBatch.setGroupStrategy(cameraGroupStrategy); 

在渲染()

 //Add all your decals then flush() decalBatch.add(decal); decalBatch.flush(); 

也可以使用decalBatch.dispose();

请注意,在未来贴花将成为3d的一部分,我个人不鼓励你使用贴花作为我自己使用3D平面,我看到它的一些问题,使用像这样的3D平面使用,我在这里粘贴我的一些代码

 private Model createPlaneModel(final float width, final float height, final Material material, final float u1, final float v1, final float u2, final float v2) { modelBuilder.begin(); MeshPartBuilder bPartBuilder = modelBuilder.part("rect", GL10.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates, material); //NOTE ON TEXTURE REGION, MAY FILL OTHER REGIONS, USE GET region.getU() and so on bPartBuilder.setUVRange(u1, v1, u2, v2); bPartBuilder.rect( -(width*0.5f), -(height*0.5f), 0, (width*0.5f), -(height*0.5f), 0, (width*0.5f), (height*0.5f), 0, -(width*0.5f), (height*0.5f), 0, 0, 0, -1); return (modelBuilder.end()); } 

纹理可以作为属性添加到材质中

 material.set(new TextureAttribute(TextureAttribute.Diffuse, texture) 

对于具有alpha添加到其他属性的透明平面

 attributes.add( new BlendingAttribute(color.getFloat(3))); attributes.add( new FloatAttribute(FloatAttribute.AlphaTest, 0.5f)); material.set(attributes); 

初始化ModelInstance以获取返回的模型

 modelInstance = new ModelInstance(createPlaneModel(...)) 

使用ModelBatch对象在render()中渲染

 modelBatch.render(modelInstance ); 

也看到这些链接。 http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=11884

这是我对Plane vs Decals的基准测试http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=12493