简体   繁体   English

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

[英]Bind texture to mesh in libGDX?

I have a mesh generated from data in Renderables. 我有一个从Renderables中的数据生成的网格。 Environment is set. 环境已设定。 Material is a simple new Material() . 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*/

The mesh is generated properly, but I can't see the textures, only the gray (shaded) triangles. 网格已正确生成,但是我看不到纹理,只有灰色(阴影)三角形。 I did try the rtfm method, but so far I saw no way to bind a texture, so it displays properly in libGDX, only with shaders, and I'm not using them (I'm catching up on them after this feature is implemented). 我确实尝试过rtfm方法,但是到目前为止,我还没有办法绑定纹理,因此它只能在着色器中正确显示在libGDX中,并且我没有使用它们(实现此功能后我会继续关注它们)。 Is there a way in libGDX to bind textures to a mesh without shaders? libGDX中是否有一种方法可以将纹理绑定到没有着色器的网格?

Without seeing your texturing code, maybe try specify a texture for your material using the following format: 在没有看到纹理代码的情况下,也许尝试使用以下格式为材质指定纹理:

    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