Esempio n. 1
0
    public void Triangulate(HexMesh mesh)
    {
        for (HexDirection direction = HexDirection.NE; direction <= HexDirection.NW; direction++)
        {
            Vector3      center = Position;
            EdgeVertices edge   = new EdgeVertices(
                Position + HexMetrics.GetFirstSolidCorner(direction),
                Position + HexMetrics.GetSecondSolidCorner(direction)
                );

            mesh.AddTriangle(Position, edge.v1, edge.v2);
            mesh.AddTriangleColor(Color, Color, Color);
            mesh.AddTriangle(Position, edge.v2, edge.v3);
            mesh.AddTriangleColor(Color, Color, Color);
            mesh.AddTriangle(Position, edge.v3, edge.v4);
            mesh.AddTriangleColor(Color, Color, Color);
            mesh.AddTriangle(Position, edge.v4, edge.v5);
            mesh.AddTriangleColor(Color, Color, Color);

            HexCell neighbor = GetNeighbor(direction);
            if (direction <= HexDirection.SE && neighbor != null)
            {
                edges[(int)direction] = HexEdge.Build(this, neighbor, direction);
                edges[(int)direction].Triangulate(mesh);

                HexCell nextNeighbor = GetNeighbor(direction.Next());
                if (direction <= HexDirection.E && nextNeighbor != null)
                {
                    corners[(int)direction] = Corner.Build(this, neighbor, nextNeighbor, direction);
                    corners[(int)direction].Triangulate(mesh);
                }
            }
        }
    }