首先关于贴花,贴花像精灵,但在三维坐标,使用这样的:
私人贴花贴花; 私人DecalBatch decalBatch;
在显示
()或创建()
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)
对于已经阿尔法添加到其他属性透明平面
attributes.add(new BlendingAttribute(color.getFloat(3)));
attributes.add(new FloatAttribute(FloatAttribute.AlphaTest, 0.5f));
material.set(attributes);
初始化的ModelInstance与ModelBatch对象
modelBatch.render(modelInstance);
看到这些链接也得到一个返回
渲染渲染)模型(。 http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=11884
这是我对平面基准VS贴花 http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=12493
因此,在这一刻,我不应该使用贴花?使用MeshPartBuilder,我可以在3D空间中构建2D矩形?多数民众赞成我正在寻找,因为我想创建tilebased地板。通过这种方法,每块瓷砖都将作为材质的矩形。我对吗? – Springrbua
你可以使用任何你想要的东西,这取决于你的使用情况,如果你有很多的透明的然后使用飞机,否则使用贴花或模型,也注意如果你想渲染精灵,然后在模型批次后添加精灵,顺序是重要的,因为我写了你可以同时使用贴花和模型贴花有点记忆友好,但你应该测试两个看看什么对你有好处。请注意,如果您在u中添加更高的值,并且v您有重复的纹理。 – daniel
+1。非常感谢。我会尝试。 – Springrbua