diff options
author | Adam Frisby | 2007-08-01 21:46:48 +0000 |
---|---|---|
committer | Adam Frisby | 2007-08-01 21:46:48 +0000 |
commit | 61017d10d8ec045883e0a80bc12388390c16f95f (patch) | |
tree | c32817625521e68cd3a42af7c7689f15ba5eaf57 /OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | |
parent | Commiting whitespace changes, as this used hard tabs instead of the (diff) | |
download | opensim-SC_OLD-61017d10d8ec045883e0a80bc12388390c16f95f.zip opensim-SC_OLD-61017d10d8ec045883e0a80bc12388390c16f95f.tar.gz opensim-SC_OLD-61017d10d8ec045883e0a80bc12388390c16f95f.tar.bz2 opensim-SC_OLD-61017d10d8ec045883e0a80bc12388390c16f95f.tar.xz |
* F32 Terrain load function written to support loading tiles from a larger heightmap.
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> |