Beispiel #1
0
        private static void AddFaceToVbo(Block block, Vector3i blockPos, BlockFace blockFace, VertexArrayObject <Vector3> vao)
        {
            int indicesOffset = vao.GetBuffer(0).Length;

            for (int i = 0; i < 4; i++)
            {
                vao.Add(0, facePositions[(int)blockFace * 4 + i] + blockPos.AsVector3());
            }

            int textureIndex = block.GetTextureId(blockFace);

            for (int i = 0; i < 4; i++)
            {
                vao.Add(1, new Vector3(faceTexCoords[i])
                {
                    Z = textureIndex
                });
            }

            uint[] newIndices = new uint[faceIndices.Length];
            for (int i = 0; i < newIndices.Length; i++)
            {
                newIndices[i] = (uint)(faceIndices[i] + indicesOffset);
            }

            vao.AddIndices(newIndices);
        }