Example #1
0
        public void FadeMultiple(clsHeightmap hmSource, ref sHeightmaps AlterationMaps, ref sHeights AlterationHeights)
        {
            var   Level     = 0;
            var   Y         = 0;
            var   X         = 0;
            float srcHeight = 0;
            float Ratio     = 0;
            var   AlterationHeight_Ubound = AlterationHeights.Heights.GetUpperBound(0);
            var   intTemp = 0;
            float TempA   = 0;
            float TempB   = 0;

            SizeCopy(hmSource);
            for (Y = 0; Y <= HeightData.SizeY - 1; Y++)
            {
                for (X = 0; X <= HeightData.SizeX - 1; X++)
                {
                    srcHeight = Convert.ToSingle(hmSource.HeightData.Height[Y, X] * hmSource.HeightScale);
                    for (Level = 0; Level <= AlterationHeight_Ubound; Level++)
                    {
                        if (srcHeight <= AlterationHeights.Heights[Level])
                        {
                            break;
                        }
                    }
                    if (Level == 0)
                    {
                        HeightData.Height[Y, X] =
                            Convert.ToInt32(
                                Convert.ToDouble(AlterationMaps.Heightmaps[Level].HeightData.Height[Y, X] * AlterationMaps.Heightmaps[Level].HeightScale) /
                                HeightScale);
                    }
                    else if (Level > AlterationHeight_Ubound)
                    {
                        HeightData.Height[Y, X] =
                            Convert.ToInt32(
                                Convert.ToDouble(AlterationMaps.Heightmaps[AlterationHeight_Ubound].HeightData.Height[Y, X] *
                                                 AlterationMaps.Heightmaps[AlterationHeight_Ubound].HeightScale) / HeightScale);
                    }
                    else
                    {
                        intTemp = Level - 1;
                        TempA   = AlterationHeights.Heights[intTemp];
                        TempB   = AlterationHeights.Heights[Level];
                        Ratio   = (srcHeight - TempA) / (TempB - TempA);
                        HeightData.Height[Y, X] =
                            Convert.ToInt32(
                                Convert.ToDouble(
                                    Convert.ToDouble(AlterationMaps.Heightmaps[intTemp].HeightData.Height[Y, X] * AlterationMaps.Heightmaps[intTemp].HeightScale *
                                                     (1.0F - Ratio)) +
                                    Convert.ToDouble(AlterationMaps.Heightmaps[Level].HeightData.Height[Y, X] * AlterationMaps.Heightmaps[Level].HeightScale *
                                                     Ratio)) / HeightScale);
                    }
                }
            }
        }
Example #2
0
        public void FadeMultiple(clsHeightmap hmSource, sHeightmaps AlterationMaps, sHeights AlterationHeights)
        {
            int Level = 0;
            int Y = 0;
            int X = 0;
            float srcHeight = 0;
            float Ratio = 0;
            int AlterationHeight_Ubound = AlterationHeights.Heights.GetUpperBound(0);
            int intTemp = 0;
            float TempA = 0;
            float TempB = 0;

            SizeCopy(hmSource);
            for ( Y = 0; Y <= HeightData.SizeY - 1; Y++ )
            {
                for ( X = 0; X <= HeightData.SizeX - 1; X++ )
                {
                    srcHeight = Convert.ToSingle(hmSource.HeightData.Height[Y, X] * hmSource.HeightScale);
                    for ( Level = 0; Level <= AlterationHeight_Ubound; Level++ )
                    {
                        if ( srcHeight <= AlterationHeights.Heights[Level] )
                        {
                            break;
                        }
                    }
                    if ( Level == 0 )
                    {
                        HeightData.Height[Y, X] =
                            Convert.ToInt32(
                                Convert.ToDouble(AlterationMaps.Heightmaps[Level].HeightData.Height[Y, X] * AlterationMaps.Heightmaps[Level].HeightScale) /
                                HeightScale);
                    }
                    else if ( Level > AlterationHeight_Ubound )
                    {
                        HeightData.Height[Y, X] =
                            Convert.ToInt32(
                                Convert.ToDouble(AlterationMaps.Heightmaps[AlterationHeight_Ubound].HeightData.Height[Y, X] *
                                                        AlterationMaps.Heightmaps[AlterationHeight_Ubound].HeightScale) / HeightScale);
                    }
                    else
                    {
                        intTemp = Level - 1;
                        TempA = AlterationHeights.Heights[intTemp];
                        TempB = AlterationHeights.Heights[Level];
                        Ratio = (float)((srcHeight - TempA) / (TempB - TempA));
                        HeightData.Height[Y, X] =
                            Convert.ToInt32(
                                Convert.ToDouble(
                                    Convert.ToDouble(AlterationMaps.Heightmaps[intTemp].HeightData.Height[Y, X] * AlterationMaps.Heightmaps[intTemp].HeightScale *
                                                            (1.0F - Ratio)) +
                                    Convert.ToDouble(AlterationMaps.Heightmaps[Level].HeightData.Height[Y, X] * AlterationMaps.Heightmaps[Level].HeightScale *
                                                            Ratio)) / HeightScale);
                    }
                }
            }
        }
Example #3
0
 public void FadeMultiple(clsHeightmap hmSource, ref sHeightmaps AlterationMaps, ref sHeights AlterationHeights)
 {
     int upperBound = AlterationHeights.Heights.GetUpperBound(0);
     this.SizeCopy(hmSource);
     int num10 = this.HeightData.SizeY - 1;
     for (int i = 0; i <= num10; i++)
     {
         int num11 = this.HeightData.SizeX - 1;
         for (int j = 0; j <= num11; j++)
         {
             float num5 = (float) (hmSource.HeightData.Height[i, j] * hmSource.HeightScale);
             int num12 = upperBound;
             int index = 0;
             while (index <= num12)
             {
                 if (num5 <= AlterationHeights.Heights[index])
                 {
                     break;
                 }
                 index++;
             }
             if (index == 0)
             {
                 this.HeightData.Height[i, j] = (long) Math.Round((double) ((AlterationMaps.Heightmaps[index].HeightData.Height[i, j] * AlterationMaps.Heightmaps[index].HeightScale) / this.HeightScale));
             }
             else if (index > upperBound)
             {
                 this.HeightData.Height[i, j] = (long) Math.Round((double) ((AlterationMaps.Heightmaps[upperBound].HeightData.Height[i, j] * AlterationMaps.Heightmaps[upperBound].HeightScale) / this.HeightScale));
             }
             else
             {
                 int num2 = index - 1;
                 float num6 = AlterationHeights.Heights[num2];
                 float num7 = AlterationHeights.Heights[index];
                 float num4 = (num5 - num6) / (num7 - num6);
                 this.HeightData.Height[i, j] = (long) Math.Round((double) ((((AlterationMaps.Heightmaps[num2].HeightData.Height[i, j] * AlterationMaps.Heightmaps[num2].HeightScale) * (1f - num4)) + ((AlterationMaps.Heightmaps[index].HeightData.Height[i, j] * AlterationMaps.Heightmaps[index].HeightScale) * num4)) / this.HeightScale));
             }
         }
     }
 }