aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorAdam Frisby2007-07-02 16:04:50 +0000
committerAdam Frisby2007-07-02 16:04:50 +0000
commit858e232cec35bab9681cd49945cd4ba31197dc8d (patch)
tree61704715a337d5906c7baf168ffcf5ecbdd1aef4 /OpenSim
parent* Started working on LlsdMethod for BaseHttpServer (diff)
downloadopensim-SC-858e232cec35bab9681cd49945cd4ba31197dc8d.zip
opensim-SC-858e232cec35bab9681cd49945cd4ba31197dc8d.tar.gz
opensim-SC-858e232cec35bab9681cd49945cd4ba31197dc8d.tar.bz2
opensim-SC-858e232cec35bab9681cd49945cd4ba31197dc8d.tar.xz
* Added "HiRAW" mode export for generating as precise outputs as possible in the .RAW format. Ideal for exporting a heightmap to a simulator only capable of reading the RAW format. If you are exporting between OpenSim regions, use F64 instead.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs81
1 files changed, 80 insertions, 1 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
index bf5e776..0ad60df 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -192,7 +192,7 @@ namespace OpenSim.Region.Terrain
192 resultText += "terrain voronoi <points> <blocksize> - generates a worley fractal with X points per block"; 192 resultText += "terrain voronoi <points> <blocksize> - generates a worley fractal with X points per block";
193 resultText += "terrain seed <seed> - sets the random seed value to <seed>\n"; 193 resultText += "terrain seed <seed> - sets the random seed value to <seed>\n";
194 resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n"; 194 resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n";
195 resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32', 'F64' or 'PNG'\n"; 195 resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32', 'F64', 'PNG', 'RAW' or 'HIRAW'\n";
196 resultText += "terrain save grdmap <filename> <gradient map> - creates a PNG snapshot of the region using a named gradient map\n"; 196 resultText += "terrain save grdmap <filename> <gradient map> - creates a PNG snapshot of the region using a named gradient map\n";
197 resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n"; 197 resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n";
198 resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest>\n"; 198 resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest>\n";
@@ -295,6 +295,10 @@ namespace OpenSim.Region.Terrain
295 writeToFileRAW(args[2]); 295 writeToFileRAW(args[2]);
296 break; 296 break;
297 297
298 case "hiraw":
299 writeToFileHiRAW(args[2]);
300 break;
301
298 default: 302 default:
299 resultText = "Unknown image or data format"; 303 resultText = "Unknown image or data format";
300 return false; 304 return false;
@@ -532,6 +536,7 @@ namespace OpenSim.Region.Terrain
532 536
533 /// <summary> 537 /// <summary>
534 /// A very fast LL-RAW file output mechanism - lower precision mechanism but wont take 5 minutes to run either. 538 /// A very fast LL-RAW file output mechanism - lower precision mechanism but wont take 5 minutes to run either.
539 /// (is also editable in an image application)
535 /// </summary> 540 /// </summary>
536 /// <param name="filename">Filename to write to</param> 541 /// <param name="filename">Filename to write to</param>
537 public void writeToFileRAW(string filename) 542 public void writeToFileRAW(string filename)
@@ -595,6 +600,80 @@ namespace OpenSim.Region.Terrain
595 } 600 }
596 601
597 /// <summary> 602 /// <summary>
603 /// Outputs to a LL compatible RAW in the most efficient manner possible
604 /// </summary>
605 /// <remarks>Does not calculate the revert map</remarks>
606 /// <param name="filename">The filename to output to</param>
607 public void writeToFileHiRAW(string filename)
608 {
609 System.IO.FileInfo file = new System.IO.FileInfo(filename);
610 System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
611 System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s);
612
613 // Generate a smegging big lookup table to speed the operation up (it needs it)
614 double[] lookupTable = new double[65536];
615 int i, j, x, y;
616 for (i = 0; i < 256; i++)
617 {
618 for (j = 0; j < 256; j++)
619 {
620 lookupTable[i + (j * 256)] = ((double)i * ((double)j / 127.0));
621 }
622 }
623
624 // Output the calculated raw
625 for (x = 0; x < w; x++)
626 {
627 for (y = 0; y < h; y++)
628 {
629 double t = heightmap.get(x, y);
630 double min = double.MaxValue;
631 int index = 0;
632
633 for (i = 0; i < 65536; i++)
634 {
635 if (Math.Abs(t - lookupTable[i]) < min)
636 {
637 min = Math.Abs(t - lookupTable[i]);
638 index = i;
639 }
640 }
641
642 byte red = (byte)(index & 0xFF);
643 byte green = (byte)((index >> 8) & 0xFF);
644 byte blue = (byte)watermap.get(x, y);
645 byte alpha1 = 0; // Land Parcels
646 byte alpha2 = 0; // For Sale Land
647 byte alpha3 = 0; // Public Edit Object
648 byte alpha4 = 0; // Public Edit Land
649 byte alpha5 = 255; // Safe Land
650 byte alpha6 = 255; // Flying Allowed
651 byte alpha7 = 255; // Create Landmark
652 byte alpha8 = 255; // Outside Scripts
653 byte alpha9 = red;
654 byte alpha10 = green;
655
656 bs.Write(red);
657 bs.Write(green);
658 bs.Write(blue);
659 bs.Write(alpha1);
660 bs.Write(alpha2);
661 bs.Write(alpha3);
662 bs.Write(alpha4);
663 bs.Write(alpha5);
664 bs.Write(alpha6);
665 bs.Write(alpha7);
666 bs.Write(alpha8);
667 bs.Write(alpha9);
668 bs.Write(alpha10);
669 }
670 }
671
672 bs.Close();
673 s.Close();
674 }
675
676 /// <summary>
598 /// Sets the random seed to be used by procedural functions which involve random numbers. 677 /// Sets the random seed to be used by procedural functions which involve random numbers.
599 /// </summary> 678 /// </summary>
600 /// <param name="val">The desired seed</param> 679 /// <param name="val">The desired seed</param>