예제 #1
0
    private void MakeFace(Directions dir, Vector3 position)
    {
        vertices.AddRange(VoxelMeshData.FaceVertices(dir, position));

        triangles.Add(trianglesIndex);
        triangles.Add(trianglesIndex + 1);
        triangles.Add(trianglesIndex + 2);
        triangles.Add(trianglesIndex);
        triangles.Add(trianglesIndex + 2);
        triangles.Add(trianglesIndex + 3);

        trianglesIndex += 4;
    }
    private static void CreateFace(Direction direction, float scale, Vector3 cubePosition)
    {
        vertices.AddRange(VoxelMeshData.FaceVertices(direction, scale, cubePosition));

        int triFirstVertCount = vertices.Count - 4; //every face have 4 vertices. for example there are 4 vertices, so we need to pass in triangles 012, 023 vertices

        //NUMBER IN VERTICES LIST. Vertex ACTUAL number can be, for example, 1472 (west). But triangles need 012, 023 => 147, 172

        triangles.Add(triFirstVertCount);
        triangles.Add(triFirstVertCount + 1);
        triangles.Add(triFirstVertCount + 2);
        triangles.Add(triFirstVertCount);
        triangles.Add(triFirstVertCount + 2);
        triangles.Add(triFirstVertCount + 3);
    }