Skip to content

Commit

Permalink
complite the render prosess
Browse files Browse the repository at this point in the history
  • Loading branch information
Babel-TTT committed Aug 14, 2024
1 parent 7f9cb43 commit d8f62ad
Show file tree
Hide file tree
Showing 11 changed files with 1,577 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
*.grf
*.tar
chinasettrains-*
.gfxhash/
gfx/**/**/*.png
Binary file modified gfx/emucoach/3049stock-1c-tp_32bpp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/emucoach/3049stock-1c-tp_8bpp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/emucoach/3049stock-1c-tp_mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/emucoach/3049stock-tp_32bpp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/emucoach/3049stock-tp_8bpp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gfx/emucoach/3049stock-tp_mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"lighting_angle": 50,
"lighting_elevation": 45,
"depth_influence": 0,
"tiled_normals": false,
"soften_edges": 1.5,
"alpha_edge_threshold": 0.75,
"sampler": "square",
"accuracy": 8,
"overlap": 0.05,
"brightness": -0.025,
"contrast": 0.025,
"pad_to_full_length": false,
"detail_boost": 10.0,
"falloff_adjustment": 0.5,
"size": {
"x": 192,
"y": 48,
"z": 80
},
"render_elevation": 30,
"sprites": [
{
"angle": 0,
"width": 36,
"height": 160,
"flip": true,
"render_elevation": 33
},
{
"angle": 45,
"width": 120,
"height": 116,
"flip": true
},
{
"angle": 90,
"width": 192,
"height": 80,
"flip": true
},
{
"angle": 135,
"width": 120,
"height": 116,
"flip": true
},
{
"angle": 180,
"width": 36,
"height": 160,
"flip": true,
"render_elevation": 33
},
{
"angle": 225,
"width": 120,
"height": 116,
"flip": true
},
{
"angle": 270,
"width": 192,
"height": 80,
"flip": true
},
{
"angle": 315,
"width": 120,
"height": 116,
"flip": true
}
]
}
2 changes: 1 addition & 1 deletion mtr-make.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os, sys, re, subprocess, glob
import os, sys, re, subprocess, glob, hashlib

with open("chinaset-mtraddon.pnml","r",encoding='utf-8') as f:
files_content = f.read()
Expand Down
19 changes: 10 additions & 9 deletions test-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def get_vox_hash(vox_path):
return hasher.hexdigest()

def get_gfx_hash_path(gfx_path):
gfx_hash_path = ".gfxhash\\" + re.search(r'(.+\\)([^\\]+)(?=\.[^\\]+$)', gfx_path).group(0)
gfx_hash_path = re.search(r'(.+\\)([^\\]+)(?=\.[^\\]+$)', gfx_path).group(0)
return gfx_hash_path

search_pattern = os.path.join("gfx/", f'**/*.vox')
Expand All @@ -17,32 +17,33 @@ def get_gfx_hash_path(gfx_path):
for gfx in gfx_list: #读取hash并比较
gfx_hash_path = get_gfx_hash_path(gfx)
try:
with open(gfx_hash_path,"r",encoding='utf-8') as g:
with open(".gfxhash\\" + gfx_hash_path,"r",encoding='utf-8') as g:
vox_hash = g.read()
vox_real_hash = get_vox_hash(gfx)
if vox_hash == vox_real_hash:
pass
else:
result = subprocess.run("renderobject -i "+ gfx, shell=True, capture_output=True, text=True)
os.remove(gfx_hash_path +"_32bpp.png") #由于gorender特性,这时候先删除旧的图片
result = subprocess.run("renderobject -i "+ gfx +" -m manifest.json -palette ttd_palette.json", shell=True, capture_output=True, text=True)
print(result.stdout)
with open(gfx_hash_path +"_32bpp.png") as h:
pass
except FileNotFoundError: # 目标文件不存在
""" print(gfx_hash_path +"_32bpp.png") """
except FileNotFoundError: # 目标文件不存在时的处理
print(f"E: file:", gfx," not be found")
result = subprocess.run("renderobject -i "+ gfx, shell=True, capture_output=True, text=True)
result = subprocess.run("renderobject -i "+ gfx +" -m manifest.json -palette ttd_palette.json", shell=True, capture_output=True, text=True)
print(result.stdout)
except Exception as e:
print(f"E: {e}")



for gfx in gfx_list:
for gfx in gfx_list: #每次运行后生成新的hash表
gfx_hash_path = get_gfx_hash_path(gfx)
""" print(gfx_hash_path) """
parent_directory = os.path.dirname(gfx_hash_path)
parent_directory = os.path.dirname(".gfxhash\\" + gfx_hash_path)
if not os.path.exists(parent_directory):
os.makedirs(parent_directory)
with open(gfx_hash_path,"w",encoding='utf-8') as f:
with open(".gfxhash\\" + gfx_hash_path,"w",encoding='utf-8') as f:
f.write(get_vox_hash(gfx))


Loading

0 comments on commit d8f62ad

Please sign in to comment.