コード例 #1
0
ファイル: PreProcessTerrain.cs プロジェクト: zameran/SpaceW
        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)));
        }
コード例 #2
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)));
        }