コード例 #1
0
    protected override void ExecuteThread()
    {
        Intmap surfaceIntmap = new Intmap(alphamapWidth, alphamapWidth);

        while (areasQueue.Count() > 0)
        {
            Area area = areasQueue.Dequeue();

            if (area.Nodes.Length < 3)
            {
                continue;
            }

            Point2D[] points = new Point2D[area.Nodes.Length];

            for (int i = 0; i < points.Length; i++)
            {
                points[i] = GetTerrainMapPoint(area.Nodes[i]);
            }

            surfaceIntmap.DrawFilledPolygon(points, GetTerrainLayerByName(Enum.GetName(typeof(Area.AreaType), area.Type)));
        }

        while (roadsQueue.Count() > 0)
        {
            Road road = roadsQueue.Dequeue();

            if (road.Nodes.Length < 2)
            {
                continue;
            }

            for (int i = 1; i < road.Nodes.Length; i++)
            {
                Point2D point1 = GetTerrainMapPoint(road.Nodes[i - 1]);
                Point2D point2 = GetTerrainMapPoint(road.Nodes[i]);

                surfaceIntmap.DrawLine(point1, point2,
                                       GetTerrainLayerByName(Enum.GetName(typeof(Road.RoadType), road.Type)),
                                       MetersToTerrainMapCells(road.GetRoadWidth()));
            }
        }

        Alphamap = new float[alphamapWidth, alphamapWidth, alphamapLayers];

        for (int x = 0; x < Alphamap.GetLength(0); x++)
        {
            for (int y = 0; y < Alphamap.GetLength(1); y++)
            {
                Alphamap[y, x, surfaceIntmap.Map[x, y]] = 1;
            }
        }
    }
コード例 #2
0
    protected override void ExecuteThread()
    {
        Intmap surfaceIntmap = new Intmap(mapWidth, mapWidth);

        while (areasQueue.Count() > 0)
        {
            Area area = areasQueue.Dequeue();

            if (area.Nodes.Length < 3)
            {
                continue;
            }

            Point2D[] points = new Point2D[area.Nodes.Length];

            for (int i = 0; i < points.Length; i++)
            {
                points[i] = GetSurfaceMapCell(area.Nodes[i]);
            }

            surfaceIntmap.DrawFilledPolygon(points, GetSurfaceLayerByName(Enum.GetName(typeof(Area.AreaType), area.Type)));
        }

        while (roadsQueue.Count() > 0)
        {
            Road road = roadsQueue.Dequeue();

            if (road.Nodes.Length < 2)
            {
                continue;
            }

            for (int i = 1; i < road.Nodes.Length; i++)
            {
                Point2D point1 = GetSurfaceMapCell(road.Nodes[i - 1]);
                Point2D point2 = GetSurfaceMapCell(road.Nodes[i]);

                surfaceIntmap.DrawLine(point1, point2,
                                       GetSurfaceLayerByName(Enum.GetName(typeof(Road.RoadType), road.Type)),
                                       MetersToSurfaceMapCells(road.GetRoadWidth()));
            }
        }

        SurfaceMap = surfaceIntmap.Map;
    }