コード例 #1
0
        public void Create(BBox <LatLon> bounds, BBox <Point> projBounds)
        {
            UpdateProgressMessage("[Terrain] Downloading DEM tiles");
            UpdateProgress(0);
            elevation.DownloadMissingFiles(bounds.Min, bounds.Max);
            UpdateProgress(1);

            var terrains = CreateTerrains(projBounds);

            LoadAndApplyElevations(terrains);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sk-zk/OsmProto
        private static void GetBoundsAndOffset(string osmPath)
        {
            // get an offset because we want the center of the osm file
            // to be the 0|0 point on the game map
            bounds = GetOsmBounds(osmPath);
            var projBoundsMin = projection.Project(
                bounds.Min.Latitude, bounds.Min.Longitude);
            var projBoundsMax = projection.Project(
                bounds.Max.Latitude, bounds.Max.Longitude);

            projectedBounds = new BBox <Point>(projBoundsMin, projBoundsMax);
            // change bounds to match the UV grid of the sat images
            projectedBounds.Min.X -= projectedBounds.Min.X % TerrainCreator.XSize;
            projectedBounds.Min.Y -= projectedBounds.Min.Y % TerrainCreator.YSize;
            CalculateOffset(bounds.Min, bounds.Max);
        }
コード例 #3
0
        private List <Terrain> CreateTerrains(BBox <Point> projBounds)
        {
            UpdateProgressMessage("[Terrain] Creating terrain items and materials");
            UpdateProgress(0);

            var stepSize = StepSize.Meters16;

            var terrains  = new List <Terrain>();
            var satMatSii = new SiiFile();
            var satMatIdx = 1;

            int i      = 0;
            int totalX = (int)Math.Ceiling((projBounds.Max.X - projBounds.Min.X) / XSize);
            int totalY = (int)Math.Ceiling((projBounds.Max.Y - projBounds.Min.Y) / YSize);

            int progressReportInterval = 5;

            for (double y = projBounds.Min.Y; y < projBounds.Max.Y; y += YSize)
            {
                for (double x = projBounds.Min.X; x < projBounds.Max.X; x += XSize)
                {
                    // create terrain item
                    var tPos = new Vector3((float)(x - offset.X), 0, (float)(y - offset.Y));
                    var trn  = AddTerrainGrid(stepSize, TerrainCols, TerrainRows, tPos);
                    trn.ViewDistance = 1500;
                    terrains.Add(trn);

                    LoadAndApplySatelliteImage(trn, satMatIdx++, satMatSii);

                    i++;
                    if (i % progressReportInterval == 0)
                    {
                        UpdateProgress((float)i / (totalX * totalY));
                    }
                }
            }

            var satMatSiiDir = Path.Combine(modDir, "def/world/");

            Directory.CreateDirectory(satMatSiiDir);
            satMatSii.Serialize(Path.Combine(satMatSiiDir, "terrain_material.osm_proto.sii"));

            UpdateProgress(1);

            return(terrains);
        }