예제 #1
0
    public void CalculateData(ImplicitModuleBase module)
    {
        int width  = Values.GetLength(0);
        int length = Values.GetLength(1);

        for (int x = 0; x < width; x++)
        {
            for (int z = 0; z < length; z++)
            {
                float x1    = x / (float)width;
                float z1    = z / (float)length;
                float value = (float)module.Get(x1, z1);
                Values[x, z] = value;

                if (value > Max)
                {
                    Max = value;
                }
                if (value < Min)
                {
                    Min = value;
                }
            }
        }

        for (int x = 0; x < width; x++)
        {
            for (int z = 0; z < length; z++)
            {
                Values[x, z] = (Values[x, z] - Min) / (Max - Min);
            }
        }
    }
예제 #2
0
 public ImplicitBrightContrast(ImplicitModuleBase source, double brightness = 0.00, double contrastThreshold = 0.00, double contrastFactor = 1.00)
 {
     Source            = source;
     Brightness        = new ImplicitConstant(brightness);
     ContrastThreshold = new ImplicitConstant(contrastThreshold);
     ContrastFactor    = new ImplicitConstant(contrastFactor);
 }
    // Extract data from a noise module
    private void GetData(ImplicitModuleBase module, ref MapData mapData)
    {
        mapData = new MapData(Width, Height);

        // loop through each x,y point - get height value
        for (var x = 0; x < Width; x++)
        {
            for (var y = 0; y < Height; y++)
            {
                //Sample the noise at smaller intervals
                float x1 = x / (float)Width;
                float y1 = y / (float)Height;

                float value = (float)HeightMap.Get(x1, y1);

                //keep track of the max and min values found
                if (value > mapData.Max)
                {
                    mapData.Max = value;
                }
                if (value < mapData.Min)
                {
                    mapData.Min = value;
                }

                mapData.Data[x, y] = value;
            }
        }
    }
 public ImplicitSelect(ImplicitModuleBase source, double low = 0.00, double high = 0.00, double falloff = 0.00, double threshold = 0.00)
 {
     Source    = source;
     Low       = new ImplicitConstant(low);
     High      = new ImplicitConstant(high);
     Falloff   = new ImplicitConstant(falloff);
     Threshold = new ImplicitConstant(threshold);
 }
예제 #5
0
 public void SetScales(
     double xScale = 1.00, double yScale = 1.00, double zScale = 1.00,
     double wScale = 1.00, double uScale = 1.00, double vScale = 1.00)
 {
     XScale = new ImplicitConstant(xScale);
     YScale = new ImplicitConstant(yScale);
     ZScale = new ImplicitConstant(zScale);
     WScale = new ImplicitConstant(wScale);
     UScale = new ImplicitConstant(uScale);
     VScale = new ImplicitConstant(vScale);
 }
예제 #6
0
 public ImplicitScaleDomain(ImplicitModuleBase source,
                            double xScale = 1.00, double yScale = 1.00, double zScale = 1.00,
                            double wScale = 1.00, double uScale = 1.00, double vScale = 1.00)
 {
     Source = source;
     XScale = new ImplicitConstant(xScale);
     YScale = new ImplicitConstant(yScale);
     ZScale = new ImplicitConstant(zScale);
     WScale = new ImplicitConstant(wScale);
     UScale = new ImplicitConstant(uScale);
     VScale = new ImplicitConstant(vScale);
 }
예제 #7
0
 public ImplicitTranslateDomain(
     ImplicitModuleBase source,
     double xAxis = 0.00, double yAxis = 0.00, double zAxis = 0.00,
     double wAxis = 0.00, double uAxis = 0.00, double vAxis = 0.00)
 {
     Source = source;
     XAxis  = new ImplicitConstant(xAxis);
     YAxis  = new ImplicitConstant(yAxis);
     ZAxis  = new ImplicitConstant(zAxis);
     WAxis  = new ImplicitConstant(wAxis);
     UAxis  = new ImplicitConstant(uAxis);
     VAxis  = new ImplicitConstant(vAxis);
 }
예제 #8
0
 public void GetData(ImplicitModuleBase modul)
 {
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < length; y++)
         {
             float value = (float)modul.Get(x, y);
             if (value < Min)
             {
                 Min = value;
             }
             if (value > Max)
             {
                 Max = value;
             }
             val[x, y] = value;
         }
     }
 }
예제 #9
0
        private void Initialize(int seed, out ImplicitModuleBase HeightMap, out ImplicitModuleBase HeatMap, out ImplicitModuleBase MoistureMap)
        {
            FractalType randomFractalType = (FractalType)random.Next(0, 5);
            BasisType   randomBasisType   = (BasisType)random.Next(0, 4); // exclude white

            // HEIGHT
            // Multi, Billow, Fractional Brownian, Hybrid Multi, Ridged Multi
            // Simplex, Gradient, Gradient Value, Value
            //ImplicitFractal heightFractal = new ImplicitFractal(FractalType.Multi, BasisType.Simplex, InterpolationType.Quintic)
            ImplicitFractal heightFractal = new ImplicitFractal(randomFractalType, randomBasisType, InterpolationType.Quintic)
            {
                Octaves   = TerrainOctaves,
                Frequency = TerrainFrequency,
                Seed      = seed
            };

            HeightMap = heightFractal;

            // HEAT
            ImplicitGradient heatGradient = new ImplicitGradient(1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1);
            ImplicitFractal  heatFractal  = new ImplicitFractal(randomFractalType, randomBasisType, InterpolationType.Quintic)
            {
                Octaves   = HeatOctaves,
                Frequency = HeatFrequency,
                Seed      = seed
            };

            HeatMap = new ImplicitCombiner(CombinerType.Multiply);
            ((ImplicitCombiner)HeatMap).AddSource(heatGradient);
            ((ImplicitCombiner)HeatMap).AddSource(heatFractal);

            // MOISTURE
            MoistureMap = new ImplicitFractal(randomFractalType, randomBasisType, InterpolationType.Quintic)
            {
                Octaves   = MoistureOctaves,
                Frequency = MoistureFrequency,
                Seed      = seed
            };
        }
 public ImplicitGain(ImplicitModuleBase source, double gain = 0.00)
 {
     Source = source;
     Gain   = new ImplicitConstant(gain);
 }
 public ImplicitGain(ImplicitModuleBase source, ImplicitModuleBase gain)
 {
     Source = source;
     Gain   = gain;
 }
 public ImplicitBias(ImplicitModuleBase source, double bias)
 {
     Source = source;
     Bias   = new ImplicitConstant(bias);
 }
 public ImplicitBias(ImplicitModuleBase source, ImplicitModuleBase bias)
 {
     Source = source;
     Bias   = bias;
 }
예제 #14
0
    // Extract data from a noise module
    private void GetData(ImplicitModuleBase module, ref MapData mapData)
    {
        mapData = new MapData(Width, Height);

        // loop through each x,y point - get height value
        for (var x = 0; x < Width; x++)
        {
            for (var y = 0; y < Height; y++)
            {
                //Wrap on x-axis only
//				//Noise range
//				float x1 = 0, x2 = 1;
//				float y1 = 0, y2 = 1;
//				float dx = x2 - x1;
//				float dy = y2 - y1;
//
//				//Sample noise at smaller intervals
//				float s = x / (float)Width;
//				float t = y / (float)Height;
//
//				// Calculate our 3D coordinates
//				float nx = x1 + Mathf.Cos (s * 2 * Mathf.PI) * dx / (2 * Mathf.PI);
//				float ny = x1 + Mathf.Sin (s * 2 * Mathf.PI) * dx / (2 * Mathf.PI);
//				float nz = t;
//
//				float heightValue = (float)HeightMap.Get (nx, ny, nz);
//
//				// keep track of the max and min values found
//				if (heightValue > mapData.Max)
//					mapData.Max = heightValue;
//				if (heightValue < mapData.Min)
//					mapData.Min = heightValue;
//
//				mapData.Data [x, y] = heightValue;



                // WRAP ON BOTH AXIS
                // Noise range
                float x1 = 0, x2 = 2;
                float y1 = 0, y2 = 2;
                float dx = x2 - x1;
                float dy = y2 - y1;

                // Sample noise at smaller intervals
                float s = x / (float)Width;
                float t = y / (float)Height;


                // Calculate our 4D coordinates
                float nx = x1 + Mathf.Cos(s * 2 * Mathf.PI) * dx / (2 * Mathf.PI);
                float ny = y1 + Mathf.Cos(t * 2 * Mathf.PI) * dy / (2 * Mathf.PI);
                float nz = x1 + Mathf.Sin(s * 2 * Mathf.PI) * dx / (2 * Mathf.PI);
                float nw = y1 + Mathf.Sin(t * 2 * Mathf.PI) * dy / (2 * Mathf.PI);

                float heightValue = (float)HeightMap.Get(nx, ny, nz, nw);
                // keep track of the max and min values found
                if (heightValue > mapData.Max)
                {
                    mapData.Max = heightValue;
                }
                if (heightValue < mapData.Min)
                {
                    mapData.Min = heightValue;
                }

                mapData.Data[x, y] = heightValue;
            }
        }
    }
예제 #15
0
        private void GetMapData(ImplicitModuleBase HeightMap, out float[,] heightMap, out float minHeight, out float maxHeight,
                                ImplicitModuleBase HeatMap, out float[,] heatMap, out float minHeat, out float maxHeat,
                                ImplicitModuleBase MoistureMap, out float[,] moistureMap, out float minMoisture, out float maxMoisture)
        {
            heightMap   = new float[Width, Height];
            heatMap     = new float[Width, Height];
            moistureMap = new float[Width, Height];
            minHeight   = float.MaxValue;
            maxHeight   = float.MinValue;
            minHeat     = float.MaxValue;
            maxHeat     = float.MinValue;
            minMoisture = float.MaxValue;
            maxMoisture = float.MinValue;
            // Get all the values to be used and track max/min to normalize when assigning to tiles
            for (var x = 0; x < Width; x++)
            {
                for (var y = 0; y < Height; y++)
                {
                    #region X-AXIS WRAPPING
                    // X-AXIS WRAPPING
                    //// noise range
                    //float x1 = 0, x2 = 1;
                    //float y1 = 0, y2 = 1;
                    //float dx = x2 - x1;
                    //float dy = y2 - y1;

                    //// Sample nosie at smaller intervals
                    //float s = x / (float)Width;
                    //float t = y / (float)Height;

                    //// Calculate 3D coordinates
                    //float nx = (float)(x1 + Math.Cos(s * 2 * Math.PI) * dx / (2 * Math.PI));
                    //float ny = (float)(x1 + Math.Sin(s * 2 * Math.PI) * dx / (2 * Math.PI));
                    //float nz = t;

                    //float heightValue = (float)HeightMap.Get(nx, ny, nz);

                    //// keep track of max and min
                    //if (heightValue > maxHeight) maxHeight = heightValue;
                    //if (heightValue < minHeight) minHeight = heightValue;

                    //heightMap[x, y] = heightValue;
                    #endregion

                    // X AND Y AXIS WRAPPING
                    // Noise range
                    float x1 = 0, x2 = 2;
                    float y1 = 0, y2 = 2;
                    float dx = x2 - x1;
                    float dy = y2 - y1;

                    // Sample noise at smaller intervals
                    float s = x / (float)Width;
                    float t = y / (float)Height;

                    // Calculate our 4D coordinates
                    float nx = (float)(x1 + Math.Cos(s * 2 * Math.PI) * dx / (2 * Math.PI));
                    float ny = (float)(y1 + Math.Cos(t * 2 * Math.PI) * dy / (2 * Math.PI));
                    float nz = (float)(x1 + Math.Sin(s * 2 * Math.PI) * dx / (2 * Math.PI));
                    float nw = (float)(y1 + Math.Sin(t * 2 * Math.PI) * dy / (2 * Math.PI));

                    float heightValue   = (float)HeightMap.Get(nx, ny, nz, nw);
                    float heatValue     = (float)HeatMap.Get(nx, ny, nz, nw);
                    float moistureValue = (float)MoistureMap.Get(nx, ny, nz, nw);

                    // keep track of the max and min values found
                    if (heightValue > maxHeight)
                    {
                        maxHeight = heightValue;
                    }
                    if (heightValue < minHeight)
                    {
                        minHeight = heightValue;
                    }

                    if (heatValue > maxHeat)
                    {
                        maxHeat = heatValue;
                    }
                    if (heatValue < minHeat)
                    {
                        minHeat = heatValue;
                    }

                    if (moistureValue > maxMoisture)
                    {
                        maxMoisture = moistureValue;
                    }
                    if (moistureValue < minMoisture)
                    {
                        minMoisture = moistureValue;
                    }

                    heightMap[x, y]   = heightValue;
                    heatMap[x, y]     = heatValue;
                    moistureMap[x, y] = moistureValue;
                }
            }
        }
예제 #16
0
 public ImplicitClamp(ImplicitModuleBase source, double low = 0.00, double high = 1.00)
 {
     Source = source;
     Low    = new ImplicitConstant(low);
     High   = new ImplicitConstant(high);
 }
 public ImplicitCache(ImplicitModuleBase source) => Source = source;
 public ImplicitInvert(ImplicitModuleBase source) => Source = source;
예제 #19
0
 public ImplicitScaleOffset(ImplicitModuleBase source, double scale = 1.00, double offset = 0.00)
 {
     Source = source;
     Scale  = new ImplicitConstant(scale);
     Offset = new ImplicitConstant(offset);
 }