用于 3D 游戏的 Libgdx 渲染地板
问题描述
在我的第一个 3D 游戏中,我现在想在 y = 0
上渲染地板,它实际上是一个平面(不是 libgdx Plane
).
In my first 3D game i now want to render the floor, which is actually a plane (not a libgdx Plane
) on y = 0
.
我想给它添加一个Texture
,这样我就可以在每一层都有不同的楼层了.
I want to add a Texture
to it, so i can have different floors in each level.
现在我的问题是:创建和渲染这种带纹理的地板的最佳方法是什么?
Now my question is: What is the best way to create and render this textured floor?
我考虑过使用由 ModelBuilder
制作的基本 Block Models
,然后添加了一个 Texture
,但因为我只能看到 6 个面孔中的 1 个一个 2d Texture
就足够了,所以我想到了一个 Plane
.
I thought about using basic Block Models
made with ModelBuilder
and then added a Texture
, but as i can only see 1 of 6 faces a 2d Texture
would be enough, so i thought about a Plane
.
我可以将 Texture
添加到 Plane
,因为它是 3D 房间中的无限面吗?然后我想到的最后一件事是Decal
.
Can i add a Texture
to a Plane
, as it is a infinite face in 3D room? The last thing i then thought about were the Decal
s.
贴花
是我要找的吗?我该如何使用它们?或者您有其他解决方案.
Are Decal
s what i am looking for? And how can i use them? Or do you have an other solution .
任何教程或其他帮助都会很棒.
Any tutorial or other help would be great.
谢谢
推荐答案
首先关于贴花,贴花就像精灵,但是在3d坐标中,这样使用它:
First about Decals, decals are like Sprites but in 3d coordinate, use it like this:
私人贴花贴花;私人贴花贴花贴花;
private Decal decal; private DecalBatch decalBatch;
在 show() 或 create() 中
in show() or create()
在渲染()中
也可以使用 decalBatch.dispose();
also dispose with decalBatch.dispose();
请注意,未来贴花将成为 3d 的一部分,我个人不鼓励您像我自己一样使用贴花使用 3d 平面,我发现它存在一些问题,要像这样使用 3d 平面,我粘贴了一些代码这里
notice that in future decal will be part of 3d, I personally do not encourage you to use Decals as myself using 3d plane and I saw some problems with it, to use 3d plane use like these, i paste some of my codes here
纹理可以作为属性添加到材质
texture can be added as attribute to material
对于具有 alpha 的透明平面添加到其他属性
for transparent plane that has alpha add to other attribute
初始化ModelInstance以获取返回的模型
Init the ModelInstance to get model that returned
使用 ModelBatch 对象在 render() 中渲染
render in render() with ModelBatch object
也可以查看这些链接.http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=11884
这是我在平面与贴花上的基准http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=12493
this is my benchmark on Plane vs Decals http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=12493
这篇关于用于 3D 游戏的 Libgdx 渲染地板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!