diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs index b54f4fe..bfb4941 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -578,6 +578,48 @@ namespace OpenSim.Region.Terrain | |||
578 | } | 578 | } |
579 | 579 | ||
580 | /// <summary> | 580 | /// <summary> |
581 | /// Loads a section of a larger heightmap (F32) | ||
582 | /// </summary> | ||
583 | /// <param name="filename">File to load</param> | ||
584 | /// <param name="dimensionX">Size of the file</param> | ||
585 | /// <param name="dimensionY">Size of the file</param> | ||
586 | /// <param name="lowerboundX">Where do the region coords start for this terrain?</param> | ||
587 | /// <param name="lowerboundY">Where do the region coords start for this terrain?</param> | ||
588 | public void LoadFromFileF32(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY) | ||
589 | { | ||
590 | int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w); | ||
591 | int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h); | ||
592 | |||
593 | double[,] tempMap = new double[dimensionX, dimensionY]; | ||
594 | |||
595 | FileInfo file = new FileInfo(filename); | ||
596 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | ||
597 | BinaryReader bs = new BinaryReader(s); | ||
598 | |||
599 | int x, y; | ||
600 | for (x = 0; x < dimensionX; x++) | ||
601 | { | ||
602 | for (y = 0; y < dimensionY; y++) | ||
603 | { | ||
604 | tempMap[x,y] = (double)bs.ReadSingle(); | ||
605 | } | ||
606 | } | ||
607 | |||
608 | for (x = 0; x < w; x++) | ||
609 | { | ||
610 | for (y = 0; y < h; y++) | ||
611 | { | ||
612 | heightmap.Set(x, y, tempMap[x + sectionToLoadX, y + sectionToLoadY]); | ||
613 | } | ||
614 | } | ||
615 | |||
616 | bs.Close(); | ||
617 | s.Close(); | ||
618 | |||
619 | tainted++; | ||
620 | } | ||
621 | |||
622 | /// <summary> | ||
581 | /// Loads a file formatted in the SL .RAW Format used on the main grid | 623 | /// Loads a file formatted in the SL .RAW Format used on the main grid |
582 | /// </summary> | 624 | /// </summary> |
583 | /// <remarks>This file format stinks and is best avoided.</remarks> | 625 | /// <remarks>This file format stinks and is best avoided.</remarks> |