• <tfoot id='b1M9V'></tfoot>
  • <legend id='b1M9V'><style id='b1M9V'><dir id='b1M9V'><q id='b1M9V'></q></dir></style></legend>

        <i id='b1M9V'><tr id='b1M9V'><dt id='b1M9V'><q id='b1M9V'><span id='b1M9V'><b id='b1M9V'><form id='b1M9V'><ins id='b1M9V'></ins><ul id='b1M9V'></ul><sub id='b1M9V'></sub></form><legend id='b1M9V'></legend><bdo id='b1M9V'><pre id='b1M9V'><center id='b1M9V'></center></pre></bdo></b><th id='b1M9V'></th></span></q></dt></tr></i><div id='b1M9V'><tfoot id='b1M9V'></tfoot><dl id='b1M9V'><fieldset id='b1M9V'></fieldset></dl></div>

          <bdo id='b1M9V'></bdo><ul id='b1M9V'></ul>

      1. <small id='b1M9V'></small><noframes id='b1M9V'>

      2. 用于 3D 游戏的 Libgdx 渲染地板

        时间:2023-05-19
        <legend id='YnGAp'><style id='YnGAp'><dir id='YnGAp'><q id='YnGAp'></q></dir></style></legend>

        1. <small id='YnGAp'></small><noframes id='YnGAp'>

          <i id='YnGAp'><tr id='YnGAp'><dt id='YnGAp'><q id='YnGAp'><span id='YnGAp'><b id='YnGAp'><form id='YnGAp'><ins id='YnGAp'></ins><ul id='YnGAp'></ul><sub id='YnGAp'></sub></form><legend id='YnGAp'></legend><bdo id='YnGAp'><pre id='YnGAp'><center id='YnGAp'></center></pre></bdo></b><th id='YnGAp'></th></span></q></dt></tr></i><div id='YnGAp'><tfoot id='YnGAp'></tfoot><dl id='YnGAp'><fieldset id='YnGAp'></fieldset></dl></div>
            • <bdo id='YnGAp'></bdo><ul id='YnGAp'></ul>

                <tbody id='YnGAp'></tbody>

              <tfoot id='YnGAp'></tfoot>
                • 本文介绍了用于 3D 游戏的 Libgdx 渲染地板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  在我的第一个 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 Decals.

                  贴花是我要找的吗?我该如何使用它们?或者您有其他解决方案.

                  Are Decals 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 = 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();

                  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

                  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());
                      }
                  

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

                  texture can be added as attribute to material

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

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

                  for transparent plane that has alpha add to other attribute

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

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

                  Init the ModelInstance to get model that returned

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

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

                  render in render() with ModelBatch object

                  modelBatch.render(modelInstance );
                  

                  也可以查看这些链接.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 渲染地板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:LibGDX 项目找不到资产文件夹 下一篇:如何在 Libgdx 中支持 OpenGL ES GL10、GL11 和 GL20?

                  相关文章

                  最新文章

                    • <bdo id='P8Re4'></bdo><ul id='P8Re4'></ul>
                  1. <i id='P8Re4'><tr id='P8Re4'><dt id='P8Re4'><q id='P8Re4'><span id='P8Re4'><b id='P8Re4'><form id='P8Re4'><ins id='P8Re4'></ins><ul id='P8Re4'></ul><sub id='P8Re4'></sub></form><legend id='P8Re4'></legend><bdo id='P8Re4'><pre id='P8Re4'><center id='P8Re4'></center></pre></bdo></b><th id='P8Re4'></th></span></q></dt></tr></i><div id='P8Re4'><tfoot id='P8Re4'></tfoot><dl id='P8Re4'><fieldset id='P8Re4'></fieldset></dl></div>
                    <tfoot id='P8Re4'></tfoot>

                    1. <small id='P8Re4'></small><noframes id='P8Re4'>

                      <legend id='P8Re4'><style id='P8Re4'><dir id='P8Re4'><q id='P8Re4'></q></dir></style></legend>