Beispiel #1
0
        void PreprocessSphericalDem(InputMap source, string tempFolder, string destinationFolder)
        {
            if (DestinationTileSize % DestinationMinTileSize != 0)
            {
                throw new InvalidParameterException("DestinationTileSize must be a multiple of DestinationMinTileSize!");
            }

            var startTime       = Time.realtimeSinceStartup;
            var destinationSize = DestinationTileSize << DestinationMaxLevel;

            IHeightFunction2D function1 = new SphericalHeightFunction(source, ProjectionHelper.Projection1, destinationSize);
            IHeightFunction2D function2 = new SphericalHeightFunction(source, ProjectionHelper.Projection2, destinationSize);
            IHeightFunction2D function3 = new SphericalHeightFunction(source, ProjectionHelper.Projection3, destinationSize);
            IHeightFunction2D function4 = new SphericalHeightFunction(source, ProjectionHelper.Projection4, destinationSize);
            IHeightFunction2D function5 = new SphericalHeightFunction(source, ProjectionHelper.Projection5, destinationSize);
            IHeightFunction2D function6 = new SphericalHeightFunction(source, ProjectionHelper.Projection6, destinationSize);

            HeightMipmap mipmap1 = new HeightMipmap(function1, DestinationMinTileSize, destinationSize, DestinationTileSize, tempFolder);
            HeightMipmap mipmap2 = new HeightMipmap(function2, DestinationMinTileSize, destinationSize, DestinationTileSize, tempFolder);
            HeightMipmap mipmap3 = new HeightMipmap(function3, DestinationMinTileSize, destinationSize, DestinationTileSize, tempFolder);
            HeightMipmap mipmap4 = new HeightMipmap(function4, DestinationMinTileSize, destinationSize, DestinationTileSize, tempFolder);
            HeightMipmap mipmap5 = new HeightMipmap(function5, DestinationMinTileSize, destinationSize, DestinationTileSize, tempFolder);
            HeightMipmap mipmap6 = new HeightMipmap(function6, DestinationMinTileSize, destinationSize, DestinationTileSize, tempFolder);

            HeightMipmap.SetCube(mipmap1, mipmap2, mipmap3, mipmap4, mipmap5, mipmap6);

            mipmap1.Compute(); mipmap1.Generate(0, 0, 0, destinationFolder + "/" + FileName + "1" + ".dat");
            mipmap2.Compute(); mipmap2.Generate(0, 0, 0, destinationFolder + "/" + FileName + "2" + ".dat");
            mipmap3.Compute(); mipmap3.Generate(0, 0, 0, destinationFolder + "/" + FileName + "3" + ".dat");
            mipmap4.Compute(); mipmap4.Generate(0, 0, 0, destinationFolder + "/" + FileName + "4" + ".dat");
            mipmap5.Compute(); mipmap5.Generate(0, 0, 0, destinationFolder + "/" + FileName + "5" + ".dat");
            mipmap6.Compute(); mipmap6.Generate(0, 0, 0, destinationFolder + "/" + FileName + "6" + ".dat");

            Logger.Log(string.Format("PreProcessTerrain.PreprocessDem: Computation time: {0} s", (Time.realtimeSinceStartup - startTime)));
        }
Beispiel #2
0
        public static void SetCube(HeightMipmap hm1, HeightMipmap hm2, HeightMipmap hm3, HeightMipmap hm4, HeightMipmap hm5, HeightMipmap hm6)
        {
            // NOTE : Ffffffffrrrrrrraaaaaacccccttttaaalls!

            hm1.Left    = hm5;
            hm1.Right   = hm3;
            hm1.Bottom  = hm2;
            hm1.Top     = hm4;
            hm2.Left    = hm5;
            hm2.Right   = hm3;
            hm2.Bottom  = hm6;
            hm2.Top     = hm1;
            hm3.Left    = hm2;
            hm3.Right   = hm4;
            hm3.Bottom  = hm6;
            hm3.Top     = hm1;
            hm4.Left    = hm3;
            hm4.Right   = hm5;
            hm4.Bottom  = hm6;
            hm4.Top     = hm1;
            hm5.Left    = hm4;
            hm5.Right   = hm2;
            hm5.Bottom  = hm6;
            hm5.Top     = hm1;
            hm6.Left    = hm5;
            hm6.Right   = hm3;
            hm6.Bottom  = hm4;
            hm6.Top     = hm2;
            hm1.LeftR   = 3;
            hm1.RightR  = 1;
            hm1.BottomR = 0;
            hm1.TopR    = 2;
            hm2.LeftR   = 0;
            hm2.RightR  = 0;
            hm2.BottomR = 0;
            hm2.TopR    = 0;
            hm3.LeftR   = 0;
            hm3.RightR  = 0;
            hm3.BottomR = 1;
            hm3.TopR    = 3;
            hm4.LeftR   = 0;
            hm4.RightR  = 0;
            hm4.BottomR = 2;
            hm4.TopR    = 2;
            hm5.LeftR   = 0;
            hm5.RightR  = 0;
            hm5.BottomR = 3;
            hm5.TopR    = 1;
            hm6.LeftR   = 1;
            hm6.RightR  = 3;
            hm6.BottomR = 2;
            hm6.TopR    = 0;
        }
Beispiel #3
0
        public HeightMipmap(IHeightFunction2D heightFunction, int topLevelSize, int baseLevelSize, int tileSize, string tempFolder) : base(baseLevelSize, baseLevelSize, tileSize, 1, 200)
        {
            HeightFunction = heightFunction;
            TopLevelSize   = topLevelSize;
            BaseLevelSize  = baseLevelSize;

            TempFolder = tempFolder;

            Size     = tileSize;
            Scale    = 1.0f;
            MinLevel = 0;
            MaxLevel = 0;

            var size = tileSize;

            while (size > topLevelSize)
            {
                MinLevel += 1;
                size     /= 2;
            }

            size = baseLevelSize;

            while (size > topLevelSize)
            {
                MaxLevel += 1;
                size     /= 2;
            }

            MaxR         = new float[MaxLevel + 1];
            TileData     = new float[(tileSize + 5) * (tileSize + 5) * 1];
            ConstantTile = -1;

            Left   = null;
            Right  = null;
            Bottom = null;
            Top    = null;

            if (!Directory.Exists(TempFolder))
            {
                Directory.CreateDirectory(TempFolder);
            }

            Logger.Log(string.Format("HeightMipmap.ctor: TopLevelSize: {0}; BaseLevelSize: {1}; TileSize: {2}; Scale: {3}; MinLevel: {4}; MaxLevel: {5}", TopLevelSize,
                                     BaseLevelSize,
                                     Size,
                                     Scale,
                                     MinLevel,
                                     MaxLevel));
        }
Beispiel #4
0
        /// <summary>
        /// Preprocess a map into files that can be used with a <see cref="ResidualProducer"/>.
        /// </summary>
        /// <param name="source">The map to be preprocessed.</param>
        /// <param name="tempFolder">Where temporary files must be saved.</param>
        /// <param name="destinationFolder">Where the precomputed file must be saved.</param>
        void PreprocessDem(InputMap source, string tempFolder, string destinationFolder)
        {
            if (DestinationTileSize % DestinationMinTileSize != 0)
            {
                throw new InvalidParameterException("DestinationTileSize must be a multiple of DestinationMinTileSize!");
            }

            var startTime       = Time.realtimeSinceStartup;
            var destinationSize = DestinationTileSize << DestinationMaxLevel;

            IHeightFunction2D function = new PlaneHeightFunction(source, destinationSize);
            HeightMipmap      mipmap   = new HeightMipmap(function, DestinationMinTileSize, destinationSize, DestinationTileSize, tempFolder);

            mipmap.Compute();
            mipmap.Generate(0, 0, 0, destinationFolder + "/" + FileName + ".proland");

            Debug.Log(string.Format("PreProcessTerrain.PreprocessDem: Computation time: {0} s", (Time.realtimeSinceStartup - startTime)));
        }