diff options
author | Adam Frisby | 2007-07-02 15:45:09 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-02 15:45:09 +0000 |
commit | c25a2fea59dc502519f81062c4122e96abd0f3c3 (patch) | |
tree | fa180dac0f2f1fd4f6ed0d09d901f73d26927c86 /OpenSim/Region/Terrain.BasicTerrain | |
parent | * Fixed Issue #161 by using PhysicsScene.Null instead of BasePhysicsScene (diff) | |
download | opensim-SC_OLD-c25a2fea59dc502519f81062c4122e96abd0f3c3.zip opensim-SC_OLD-c25a2fea59dc502519f81062c4122e96abd0f3c3.tar.gz opensim-SC_OLD-c25a2fea59dc502519f81062c4122e96abd0f3c3.tar.bz2 opensim-SC_OLD-c25a2fea59dc502519f81062c4122e96abd0f3c3.tar.xz |
* Added support for SL-style RAW export similar to the official simulators operation (low resolution)
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs index c2d7e86..bf5e776 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -291,6 +291,10 @@ namespace OpenSim.Region.Terrain | |||
291 | heightmap.saveImage(args[2]); | 291 | heightmap.saveImage(args[2]); |
292 | break; | 292 | break; |
293 | 293 | ||
294 | case "raw": | ||
295 | writeToFileRAW(args[2]); | ||
296 | break; | ||
297 | |||
294 | default: | 298 | default: |
295 | resultText = "Unknown image or data format"; | 299 | resultText = "Unknown image or data format"; |
296 | return false; | 300 | return false; |
@@ -527,6 +531,70 @@ namespace OpenSim.Region.Terrain | |||
527 | } | 531 | } |
528 | 532 | ||
529 | /// <summary> | 533 | /// <summary> |
534 | /// A very fast LL-RAW file output mechanism - lower precision mechanism but wont take 5 minutes to run either. | ||
535 | /// </summary> | ||
536 | /// <param name="filename">Filename to write to</param> | ||
537 | public void writeToFileRAW(string filename) | ||
538 | { | ||
539 | System.IO.FileInfo file = new System.IO.FileInfo(filename); | ||
540 | System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write); | ||
541 | System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s); | ||
542 | |||
543 | int x, y; | ||
544 | |||
545 | // Used for the 'green' channel. | ||
546 | byte avgMultiplier = (byte)heightmap.avg(); | ||
547 | byte backupMultiplier = (byte)revertmap.avg(); | ||
548 | |||
549 | // Limit the multiplier so it can represent points >64m. | ||
550 | if (avgMultiplier > 196) | ||
551 | avgMultiplier = 196; | ||
552 | if(backupMultiplier > 196) | ||
553 | backupMultiplier = 196; | ||
554 | // Make sure it's at least one to prevent a div by zero | ||
555 | if (avgMultiplier < 1) | ||
556 | avgMultiplier = 1; | ||
557 | if(backupMultiplier < 1) | ||
558 | backupMultiplier = 1; | ||
559 | |||
560 | for (x = 0; x < w; x++) | ||
561 | { | ||
562 | for (y = 0; y < h; y++) | ||
563 | { | ||
564 | byte red = (byte)(heightmap.get(x, y) / ((double)avgMultiplier / 128.0)); | ||
565 | byte green = avgMultiplier; | ||
566 | byte blue = (byte)watermap.get(x, y); | ||
567 | byte alpha1 = 0; // Land Parcels | ||
568 | byte alpha2 = 0; // For Sale Land | ||
569 | byte alpha3 = 0; // Public Edit Object | ||
570 | byte alpha4 = 0; // Public Edit Land | ||
571 | byte alpha5 = 255; // Safe Land | ||
572 | byte alpha6 = 255; // Flying Allowed | ||
573 | byte alpha7 = 255; // Create Landmark | ||
574 | byte alpha8 = 255; // Outside Scripts | ||
575 | byte alpha9 = (byte)(revertmap.get(x, y) / ((double)backupMultiplier / 128.0)); | ||
576 | byte alpha10 = backupMultiplier; | ||
577 | |||
578 | bs.Write(red); | ||
579 | bs.Write(green); | ||
580 | bs.Write(blue); | ||
581 | bs.Write(alpha1); | ||
582 | bs.Write(alpha2); | ||
583 | bs.Write(alpha3); | ||
584 | bs.Write(alpha4); | ||
585 | bs.Write(alpha5); | ||
586 | bs.Write(alpha6); | ||
587 | bs.Write(alpha7); | ||
588 | bs.Write(alpha8); | ||
589 | bs.Write(alpha9); | ||
590 | bs.Write(alpha10); | ||
591 | } | ||
592 | } | ||
593 | bs.Close(); | ||
594 | s.Close(); | ||
595 | } | ||
596 | |||
597 | /// <summary> | ||
530 | /// Sets the random seed to be used by procedural functions which involve random numbers. | 598 | /// Sets the random seed to be used by procedural functions which involve random numbers. |
531 | /// </summary> | 599 | /// </summary> |
532 | /// <param name="val">The desired seed</param> | 600 | /// <param name="val">The desired seed</param> |