简体   繁体   中英

How to create cube using single mesh in libgdx

To draw a cube which has 6 sides using libgdx need 6 meshes. But it increases time as per each mesh while rendering.

my code :

for(int i=0; i<6; i++)
{

    faces[i].setvertices(new float[] {x,y,z,color};
}

So, can we create a cube using single mesh rather than 6?

Thanks.

Sure you can create single mesh for cube. Check out SimpleVertexShader test in libGDX tests. It uses Shapes.genCube() to create cube mesh.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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