Menu

[025cc2]: / Misc / CreateSkyBoxTexture.py  Maximize  Restore  History

Download this file

59 lines (43 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
Used to create d3d11x.SkyBox compatible textures from Hazel Whorley's images.
Put into a directory containing individual images and run the script.
Requires PIL.
"""
import os
import Image
#1.0 == no scaling
SCALE = 1.0
OUTPUT = "result.bmp"
names = ["_north.bmp", "_east.bmp", "_south.bmp", "_west.bmp", "_up.bmp", "_down.bmp"]
fullimage = None
imageindex = 0
imagejump = 0
def addImage(name, f):
global fullimage, imageindex, imagejump
im = Image.open(f)
im = im.resize((int(im.size[0] * SCALE), int(im.size[1] * SCALE)), Image.ANTIALIAS)
if im.size[0] % 2 != 0 or im.size[1] % 2 != 0:
print("Note: image is not a power of two.")
if fullimage is None:
#First image, create the final image.
w = im.size[0] * 6
h = im.size[1]
print("Result texture: (%ix%i)" % (w, h))
fullimage = Image.new("RGB", (w, h))
imagejump = im.size[0]
fullimage.paste(im, (imageindex * imagejump, 0))
imageindex += 1
print("Added '%s'" % f)
files = set(os.listdir("."))
found = 0
for name in names:
for f in files:
if f.endswith(name):
addImage(name, f)
found += 1
break
if found != 6:
print("Some image files are missing, there should be 6!")
fullimage.save(OUTPUT)
print("Done '%s'. Press Enter to exit." % OUTPUT)
input()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.