Esempio n. 1
0
        public void WaveHigh(clsHeightmap Source)
        {
            var  Y           = 0;
            var  X           = 0;
            long HeightRange = 0;
            long HeightMin   = 0;
            var  MinMax      = new sMinMax();

            Source.MinMaxGet(ref MinMax);
            HeightRange = Convert.ToInt64(MinMax.Max - MinMax.Min);
            HeightMin   = MinMax.Min;

            if (HeightRange == 0.0D)
            {
                return;
            }

            SizeCopy(Source);
            for (Y = 0; Y <= HeightData.SizeY - 1; Y++)
            {
                for (X = 0; X <= HeightData.SizeX - 1; X++)
                {
                    var val =
                        ((Math.Sin((Source.HeightData.Height[Y, X] - HeightMin) / (double)HeightRange * MathUtil.RadOf90Deg) * HeightRange + HeightMin) * Source.HeightScale / HeightScale)
                        .ToLong();

                    HeightData.Height[Y, X] = val;
                }
            }
        }
Esempio n. 2
0
        public void Rescale(clsHeightmap Source, double HeightMin, double HeightMax)
        {
            var Y      = 0;
            var X      = 0;
            var MinMax = new sMinMax();

            Source.MinMaxGet(ref MinMax);

            long   HeightRange = 0;
            long   Offset      = 0;
            double Ratio       = 0;
            long   lngTemp     = 0;

            SizeCopy(Source);
            HeightRange = Convert.ToInt64(MinMax.Max - MinMax.Min);
            Offset      = Convert.ToInt64(0 - MinMax.Min);
            if (HeightRange > 0)
            {
                Ratio   = (HeightMax - HeightMin) / (HeightRange * HeightScale);
                lngTemp = (HeightMin / HeightScale).ToLong();
                for (Y = 0; Y <= HeightData.SizeY - 1; Y++)
                {
                    for (X = 0; X <= HeightData.SizeX - 1; X++)
                    {
                        HeightData.Height[Y, X] =
                            Convert.ToInt64(lngTemp + Convert.ToInt32(Convert.ToDouble(Offset + Source.HeightData.Height[Y, X]) * Ratio));
                    }
                }
            }
            else
            {
                lngTemp = ((HeightMin + HeightMax) / 2.0D).ToLong();
                for (Y = 0; Y <= HeightData.SizeY - 1; Y++)
                {
                    for (X = 0; X <= HeightData.SizeX - 1; X++)
                    {
                        HeightData.Height[Y, X] = lngTemp;
                    }
                }
            }
        }
Esempio n. 3
0
        public void ShiftToZero(clsHeightmap Source)
        {
            var Y       = 0;
            var X       = 0;
            var MinMax  = new sMinMax();
            var dblTemp = Source.HeightScale / HeightScale;

            Source.MinMaxGet(ref MinMax);

            long Offset = 0;

            SizeCopy(Source);
            Offset = Convert.ToInt64(0 - MinMax.Min);
            for (Y = 0; Y <= HeightData.SizeY - 1; Y++)
            {
                for (X = 0; X <= HeightData.SizeX - 1; X++)
                {
                    HeightData.Height[Y, X] = Convert.ToInt32(Convert.ToDouble(Offset + Source.HeightData.Height[Y, X]) * dblTemp);
                }
            }
        }