簡體   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