forked from MrCheeze/botw-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
heightmap.py
40 lines (35 loc) · 1.04 KB
/
heightmap.py
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
from PIL import Image, ImageDraw
import os
img = Image.new("RGB", (0x100*6*2, 0x100*6*2))
i = 0
for folder, _, files in os.walk('terrain'):
if len(files) == 0:
continue
y_high = [0,0,0,1,2,1,
1,2,2,0,0,0,
1,1,2,2,1,2,
3,4,3,3,4,4,
5,5,5,3,3,4,
4,3,4,5,5,5][i] * 0x200
x_high = [0,1,2,0,0,1,
2,1,2,3,4,5,
3,4,3,4,5,5,
0,0,1,2,1,2,
0,1,2,3,4,3,
4,5,5,3,4,5][i] * 0x200
x_mid = 0
y_mid = 0
for file in files:
print(file)
f = open(folder+'/'+file, 'rb')
for y in range(y_high + y_mid, y_high + y_mid + 0x100):
for x in range(x_high + x_mid, x_high + x_mid + 0x100):
val = int.from_bytes(f.read(2),'little')
img.putpixel((x,y), (val//256, val//256, val//256))
f.close()
x_mid += 0x100
if x_mid == 0x200:
x_mid = 0
y_mid += 0x100
i += 1
img.save('heightmap.png')