繁体   English   中英

将纹理绑定到libGDX中的网格?

[英]Bind texture to mesh in libGDX?

我有一个从Renderables中的数据生成的网格。 环境已设定。 Material是一个简单的new Material()

            ... /*init renderable*/

    /*set mesh parameters*/
    renderable.mesh = new Mesh(false, 
            (int)(meshVertexArray.length/SurfaceBuilder.__ELEMENTSPERVERTEX__), /*!vertices, not cordinates*/ 
            meshIndexArray.length,
            new VertexAttribute(Usage.Position,3,"a_position"),
            new VertexAttribute(Usage.Normal,3,"a_normal"),
            new VertexAttribute(Usage.TextureCoordinates,2,"a_texCoords"),
            new VertexAttribute(Usage.ColorPacked,4, "a_color")
    );

            ... /*set vertices*/

网格已正确生成,但是我看不到纹理,只有灰色(阴影)三角形。 我确实尝试过rtfm方法,但是到目前为止,我还没有办法绑定纹理,因此它只能在着色器中正确显示在libGDX中,并且我没有使用它们(实现此功能后我会继续关注它们)。 libGDX中是否有一种方法可以将纹理绑定到没有着色器的网格?

在没有看到纹理代码的情况下,也许尝试使用以下格式为材质指定纹理:

    Material mat = new Material();
    //set the diffuse channel on the texture using some texture
    mat.set(TextureAttribute.createDiffuse(new Texture("crate.jpg"))); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM