Пример #1
0
 void Triangulate(HexCell cell)
 {
     for (HexDirection d = HexDirection.NE; d <= HexDirection.NW; d++)
     {
         if (cell != null)
         {
             Triangulate(d, cell);
         }
     }
     if (!cell.IsUnderwater && !cell.HasRiver && !cell.HasRoads)
     {
         features.AddFeature(cell.Position, cell);
     }
 }
Пример #2
0
 void AddFeatures(HexCell cell)
 {
     for (int i = 0; i <= 5; i++)
     {
         var direction = (HexDirection)i;
         if (!cell.IsUnderwater && !cell.HasRiverThroughEdge(direction) && !cell.HasRoadThroughEdge(direction))
         {
             var edge = cell.Edges[i];
             Features.AddFeature((cell.Center + edge.V1 + edge.V5) * (1f / 3f));
         }
     }
 }
    public void Triangulate(Cell cell)
    {
        Vector3 center = cell.Position;
        Vector3 v1     = center + Metrics.corners[0] * Metrics.solidFactor;
        Vector3 v2     = center + Metrics.corners[3] * Metrics.solidFactor;
        Vector3 v3     = center + Metrics.corners[1] * Metrics.solidFactor;
        Vector3 v4     = center + Metrics.corners[2] * Metrics.solidFactor;

        terrain.AddQuad(v1, v2, v3, v4);
        terrain.AddQuadUVFromXZ(v1, v2, v3, v4);
        // terrain.AddQuadColor(cell.Color, cell.Color, cell.Color, cell.Color);
        terrain.AddQuadColor(color1, color1, color1, color1);
        terrain.AddQuadTerrainTypes(new Vector4(cell.TerrainTypeIndex, 0f, 0f, 0f));

        if (cell.IsUnderwater)
        {
            Vector3 water_center = center;
            water_center.y = cell.WaterSurfaceY;
            water.AddQuad(
                water_center + Metrics.corners[0] * Metrics.solidFactor,
                water_center + Metrics.corners[3] * Metrics.solidFactor,
                water_center + Metrics.corners[1] * Metrics.solidFactor,
                water_center + Metrics.corners[2] * Metrics.solidFactor);
        }

        for (Direction d = Direction.W; d < Direction.E; d++)
        {
            TriangulateConnection(d, cell);
            if (cell.IsUnderwater)
            {
                TriangulateWaterConnection(d, cell);
            }
        }
        for (Direction d = Direction.W; d <= Direction.S; d++)
        {
            if (cell.IsUnderwater)
            {
                TriangulateWaterShore(d, cell);
            }
        }

        featureManager.AddFeature(cell);
    }