我已經使用libgdx完成了一個網格,並且試圖用某種顏色填充網格。在Android上使用libgdx創建多維數據集網格
create() {
if (bigMesh == null) {
bigMesh = new Mesh(true, 8, 8,
new VertexAttribute(Usage.Position, 3, "a_position"),
new VertexAttribute(Usage.ColorPacked, 4, "a_color"));
bigMesh.setVertices(new float[] {
0, -0.5f, -4, Color.toFloatBits(255, 0, 0, 255),
1, -0.5f, -4, Color.toFloatBits(255, 0, 0, 255),
1, 0.5f, -4, Color.toFloatBits(255, 0, 0, 255),
0, 0.5f, -4, Color.toFloatBits(255, 0, 0, 255),
1, 0.5f, -3, Color.toFloatBits(0, 255, 0, 255),
1, -0.5f, -3, Color.toFloatBits(0, 255, 0, 255),
0, -0.5f, -3, Color.toFloatBits(0, 255, 0, 255),
0, 0.5f,-3, Color.toFloatBits(0, 255, 0, 255)
});
bigMesh.setIndices(new short[] { 0, 1, 2, 3,4,5,6,7});
}
}
render(){
Gdx.gl.glClearColor(0,0,0,1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
bigMesh.render(GL10.GL_TRIANGLE_STRIP);
}
我應該使用哪種渲染參數?我正在使用PerspectiveCamera。
僅供參考,您的頂點和索引不會構成一個立方體。 – 2012-03-13 13:03:43