<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://opensimulator.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://opensimulator.org/index.php?action=history&amp;feed=atom&amp;title=User%3ADyne</id>
		<title>User:Dyne - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://opensimulator.org/index.php?action=history&amp;feed=atom&amp;title=User%3ADyne"/>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/index.php?title=User:Dyne&amp;action=history"/>
		<updated>2026-04-21T13:51:19Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.19.9</generator>

	<entry>
		<id>http://opensimulator.org/index.php?title=User:Dyne&amp;diff=5754&amp;oldid=prev</id>
		<title>Dyne: Note about</title>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/index.php?title=User:Dyne&amp;diff=5754&amp;oldid=prev"/>
				<updated>2008-04-30T14:31:13Z</updated>
		
		<summary type="html">&lt;p&gt;Note about&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 14:31, 30 April 2008&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;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.&amp;#160; 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).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;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.&amp;#160; 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).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;This basically does the same thing as &amp;lt;code&amp;gt;script terrain load-tile&amp;lt;/code&amp;gt;, but since I wanted to use [http://www.spinmass.com/bailiwick 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.&amp;#160; Hopefully this will be useful.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Copy the script into your text editor and name the thing terrain-split.py (or whatever).&amp;#160;  Note that it requires that the [http://www.pythonware.com/products/pil/ Python Imaging Library] be installed, or it won't work.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Copy the script into your text editor and name the thing terrain-split.py (or whatever).&amp;#160;  Note that it requires that the [http://www.pythonware.com/products/pil/ Python Imaging Library] be installed, or it won't work.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dyne</name></author>	</entry>

	<entry>
		<id>http://opensimulator.org/index.php?title=User:Dyne&amp;diff=5750&amp;oldid=prev</id>
		<title>Dyne: Terrain splitting script</title>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/index.php?title=User:Dyne&amp;diff=5750&amp;oldid=prev"/>
				<updated>2008-04-30T13:46:27Z</updated>
		
		<summary type="html">&lt;p&gt;Terrain splitting script&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;I am posting this here for the time being; it will probably eventually be put somewhere else in the User Docs section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Copy the script into your text editor and name the thing terrain-split.py (or whatever).   Note that it requires that the [http://www.pythonware.com/products/pil/ Python Imaging Library] be installed, or it won't work.&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
Assuming that your input is a 512x512 pixel image at the following path (relative to the where you invoke the script):&lt;br /&gt;
&lt;br /&gt;
:mysims/multisim.png&lt;br /&gt;
&lt;br /&gt;
Then you'd run it like:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;python terrain-split.py mysims/multisim.png&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will do one of two things, depending on the value of the &amp;lt;code&amp;gt;__interactive__&amp;lt;/code&amp;gt; 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):&lt;br /&gt;
&lt;br /&gt;
* mysims/multisim.0.1.png (the northwest piece)&lt;br /&gt;
* mysims/multisim.1.1.png (the northeast piece)&lt;br /&gt;
* mysims/multisim.0.0.png (the southwest piece)&lt;br /&gt;
* mysims/multisim.1.0.png (the southeast piece)&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* NW: 1575, 635&lt;br /&gt;
* NE: 1576, 635&lt;br /&gt;
* SW: 1575, 634&lt;br /&gt;
* SE: 1576, 634&lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;code&amp;gt;__interactive__&amp;lt;/code&amp;gt; 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 &amp;quot;alice&amp;quot;, &amp;quot;bob&amp;quot;, &amp;quot;charles&amp;quot;, and &amp;quot;dan&amp;quot;, then it'd spit out these files:&lt;br /&gt;
&lt;br /&gt;
* mysims/alice.1575.635.png&lt;br /&gt;
* mysims/bob.1576.635.png&lt;br /&gt;
* mysims/charles.1575.634.png&lt;br /&gt;
* mysims/dan.1576.634.png&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
I left the noninteractive mode in, just in case someone wanted to use this in a more automatic fashion.&lt;br /&gt;
&lt;br /&gt;
This has ''not'' been fully tested, so there may well be stupid bugs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Script===&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;#!/usr/bin/python&lt;br /&gt;
'''This simple script takes the filename of an image that is a multiple of the tilesize (256 by default), and splits it into tiles of that size.&lt;br /&gt;
&lt;br /&gt;
USAGE: python terrain-split.py infile1 [infile2 ... infileN]&lt;br /&gt;
&lt;br /&gt;
Note that any extra pixels in the original image beyond an even multiple of the tilesize are ignored.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
__interactive__ = 1&lt;br /&gt;
&lt;br /&gt;
import Image, ImageOps&lt;br /&gt;
import os.path, sys&lt;br /&gt;
&lt;br /&gt;
tilesize=256&lt;br /&gt;
&lt;br /&gt;
for infile in sys.argv[1:]:&lt;br /&gt;
	try:&lt;br /&gt;
		myimage = Image.open(infile)&lt;br /&gt;
		path, filename = os.path.split(infile)&lt;br /&gt;
		basename, extension = os.path.splitext(filename)&lt;br /&gt;
		(width,height) = myimage.size&lt;br /&gt;
		tileswide = width // tilesize&lt;br /&gt;
		tileshigh = height // tilesize&lt;br /&gt;
		twremain = width % tilesize  # leftover pixels&lt;br /&gt;
		thremain = height % tilesize  # leftover pixels&lt;br /&gt;
&lt;br /&gt;
		print&lt;br /&gt;
		print &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
		print &amp;quot;Input file: &amp;quot; + infile&lt;br /&gt;
		print &amp;quot;Image dimensions: %s x %s pixels&amp;quot; % (width,height)&lt;br /&gt;
		print &amp;quot;Output: %s x %s tiles (%s files) of %s pixels square&amp;quot; % (tileswide, tileshigh, tileswide*tileshigh, tilesize)&lt;br /&gt;
		print &amp;quot;Pixels truncated: %s across, %s down&amp;quot; % (twremain, thremain)&lt;br /&gt;
		if __interactive__:&lt;br /&gt;
                        print&lt;br /&gt;
                        print &amp;quot;Note: Values in [brackets] are defaults.&amp;quot;&lt;br /&gt;
                        print&lt;br /&gt;
                        xin = raw_input(&amp;quot;What is the desired grid X coordinate of the lower-left sim [1000]? &amp;quot;)&lt;br /&gt;
                        if xin == &amp;quot;&amp;quot;:&lt;br /&gt;
                                basegridX = 1000&lt;br /&gt;
                        else:&lt;br /&gt;
                                basegridX = int(xin)&lt;br /&gt;
                        yin = raw_input(&amp;quot;What is the desired grid Y coordinate of the lower-left sim [1000]? &amp;quot;)&lt;br /&gt;
                        if yin == &amp;quot;&amp;quot;:&lt;br /&gt;
                                basegridY = 1000&lt;br /&gt;
                        else:&lt;br /&gt;
                                basegridY = int(yin)&lt;br /&gt;
		for y in range(tileshigh):&lt;br /&gt;
                        print&lt;br /&gt;
			print &amp;quot;Tiling Row #%s&amp;quot; % str(y+1)&lt;br /&gt;
			for x in range(tileswide):&lt;br /&gt;
				# Compute the upper left corner&lt;br /&gt;
				xnew = x * tilesize&lt;br /&gt;
				ynew = y * tilesize&lt;br /&gt;
				yrelative = tileshigh-y-1&lt;br /&gt;
&lt;br /&gt;
				# Decide how to name the file&lt;br /&gt;
				if __interactive__:  # the filename will be based on individual names and will include the actual grid coordinates&lt;br /&gt;
                                        nameprompt = &amp;quot;What is the name of the sim at row %s, column %s [%s]? &amp;quot; % (y+1, x+1, basename)&lt;br /&gt;
                                        simname = raw_input(nameprompt)&lt;br /&gt;
                                        if simname == &amp;quot;&amp;quot;:&lt;br /&gt;
                                                simname = basename&lt;br /&gt;
        				newfile = simname + &amp;quot;.&amp;quot; + str(x + basegridX) + &amp;quot;.&amp;quot; + str(basegridY+yrelative) + extension&lt;br /&gt;
                                else:  # the filename of our output tile is based on the input file and includes relative positions&lt;br /&gt;
        				newfile = basename + &amp;quot;.&amp;quot; + str(x) + &amp;quot;.&amp;quot; + str(yrelative) + extension&lt;br /&gt;
        			outfile = os.path.join(path, newfile)&lt;br /&gt;
				&lt;br /&gt;
				# Create the tile&lt;br /&gt;
				# Flip the tile along the way (transpose) to account for inverted Y axis.&lt;br /&gt;
				borders = (xnew, ynew, xnew+tilesize, ynew+tilesize)&lt;br /&gt;
				tile = Image.new(&amp;quot;RGB&amp;quot;, (tilesize, tilesize))&lt;br /&gt;
				region = myimage.crop(borders).transpose(Image.FLIP_TOP_BOTTOM)&lt;br /&gt;
				tile.paste(region, (0,0) )&lt;br /&gt;
&lt;br /&gt;
				# Attempt to save it				&lt;br /&gt;
				try:&lt;br /&gt;
					tile.save(outfile)&lt;br /&gt;
					print &amp;quot;Writing: File %s with coords %s - %s&amp;quot; % (outfile, (xnew,ynew), (xnew+tilesize-1, ynew+tilesize-1) )&lt;br /&gt;
				except IOError:&lt;br /&gt;
					print &amp;quot;Cannot open output file &amp;quot;, outfile&lt;br /&gt;
	except IOError:&lt;br /&gt;
		print &amp;quot;Cannot open file &amp;quot;, infile&lt;br /&gt;
	print &amp;quot;---------------------------------------------------------&amp;quot;&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dyne</name></author>	</entry>

	</feed>