Exemple #1
0
 // Converts the model's elevation number to a map of vertices which can be used by the view
 public void ConvertElevationToVertices()
 {
     for (int x = 0; x < WorldX + 1; x++)
     {
         for (int z = 0; z < WorldZ + 1; z++)
         {
             elevationVertices.worldArray[x, z] = VertexAverage(Support.CellsAroundVertex(x, z, WorldX, WorldZ, this.elevation.worldArray));
         }
     }
 }
Exemple #2
0
    // Create the Ocean Percentage Layer
    private SingleValueLayer CalculateOceanPercentage()
    {
        // Initialize a new layer
        SingleValueLayer oceanPer = new SingleValueLayer("Ocean Percentage", "Semi-static", 4);

        // Find the vertexes, sum th abs of all negative values and divide by sum of abs of all values.
        float[,] vertexArray = elevationVertices.worldArray;
        float[] corners;
        float   sumOfNegatives;
        float   sumOfAll;

        for (int x = 0; x < WorldX; x++)
        {
            for (int z = 0; z < WorldZ; z++)
            {
                corners                   = Support.CellsAroundVertex(x + 1, z + 1, WorldX, WorldZ, vertexArray);
                sumOfNegatives            = FindAbsOfNegatives(corners);
                sumOfAll                  = FindAbsSum(corners);
                oceanPer.worldArray[x, z] = sumOfNegatives / sumOfAll;
            }
        }

        return(oceanPer);
    }