User:Dyne

I am posting this here for the time being; it will probably eventually be put somewhere else in the User Docs section.

Below is a python script that takes one or more images (usually greyscale terrain maps, large enough for multiple sims) and splits them into sim-sized tiles. The tiles will be inverted along the Y axis to match OpenSim's axes (you could do this from L3DT, but I find it nicer to have a correctly-oriented full map handy).

This basically does the same thing as, but since I wanted to use Bailiwick to fiddle with the channels of the sim, and it doesn't take multi-sim input files, I needed to do it a different way. Hopefully this will be useful.

Copy the script into your text editor and name the thing terrain-split.py (or whatever). Note that it requires that the Python Imaging Library be installed, or it won't work.

Usage
Assuming that your input is a 512x512 pixel image at the following path (relative to the where you invoke the script):


 * mysims/multisim.png

Then you'd run it like:



This will do one of two things, depending on the value of the  variable (I haven't made that into a nice commandline switch yet). If it is 0, then the script will spit out these files (along with some text output):


 * mysims/multisim.0.1.png (the northwest piece)
 * mysims/multisim.1.1.png (the northeast piece)
 * mysims/multisim.0.0.png (the southwest piece)
 * mysims/multisim.1.0.png (the southeast piece)

The numbers there are intended to aid you in picking grid positions for those sims. You choose a grid position for the lower left/southwest sim ... say (1575, 634). Then, for each sim, just add those two numbers to the base grid X and Y respectively:


 * NW: 1575, 635
 * NE: 1576, 635
 * SW: 1575, 634
 * SE: 1576, 634

If the  variable is set to 1, the script will be slightly nicer and ask you for the base grid coordinate (always for the sim in the lower left corner) and then the name of each sim as it processes it. If I used the same input file and base coordinates as above, and named the above sims "alice", "bob", "charles", and "dan", then it'd spit out these files:


 * mysims/alice.1575.635.png
 * mysims/bob.1576.635.png
 * mysims/charles.1575.634.png
 * mysims/dan.1576.634.png

The tilesize is defined in the script (256 pixels by default, to match the required size for a sim texture at present). The script will take images of arbitrary size (so you could use a 768x1024 input, which will produce 12 sims, in 3 rows and 4 columns), but any pixels along the right or bottom edges that aren't large enough to be a full tile will get ignored. You can also specify multiple input files, and it'll loop through them one by one.

I left the noninteractive mode in, just in case someone wanted to use this in a more automatic fashion.

This has not been fully tested, so there may well be stupid bugs.