forked from LeenkxTeam/LNXSDK
Repe [T3DU] Update - 31f26d171bba0355ce2a77031e3aad4c64dbc7e9
This commit is contained in:
@ -12,6 +12,7 @@ import shutil
|
||||
import subprocess
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
|
||||
import webbrowser
|
||||
import unicodedata
|
||||
|
||||
import numpy as np
|
||||
|
||||
@ -108,7 +109,23 @@ def write_lnx(filepath, output):
|
||||
else:
|
||||
filepath_json = filepath.split('.lnx')[0] + '.json'
|
||||
with open(filepath_json, 'w') as f:
|
||||
f.write(json.dumps(output, sort_keys=True, indent=4, cls=NumpyEncoder))
|
||||
f.write(json.dumps(output, sort_keys=True, ensure_ascii=False, indent=4, cls=NumpyEncoder))
|
||||
|
||||
if getattr(bpy.data.worlds['Lnx'], 'lnx_export_debug_json', False):
|
||||
try:
|
||||
base_dir = os.path.dirname(filepath)
|
||||
debug_dir = os.path.join(base_dir, 'debug_json')
|
||||
|
||||
if not os.path.exists(debug_dir):
|
||||
os.makedirs(debug_dir)
|
||||
|
||||
clean_name = os.path.basename(filepath).replace('.lnx', '').replace('.lz4', '')
|
||||
debug_path = os.path.join(debug_dir, clean_name + '.json')
|
||||
|
||||
with open(debug_path, 'w', encoding='utf-8') as f:
|
||||
f.write(json.dumps(output, sort_keys=True, ensure_ascii=False, indent=4, cls=NumpyEncoder))
|
||||
except Exception as e:
|
||||
print("Error with Debug JSON: " + str(e))
|
||||
|
||||
def unpack_image(image, path, file_format='JPEG'):
|
||||
print('Leenkx Info: Unpacking to ' + path)
|
||||
@ -488,10 +505,8 @@ def fetch_script_props(filename: str):
|
||||
|
||||
# Property type is annotated
|
||||
if p_type is not None:
|
||||
if p_type.startswith("iron.object."):
|
||||
p_type = p_type[12:]
|
||||
elif p_type.startswith("iron.math."):
|
||||
p_type = p_type[10:]
|
||||
if "." in p_type:
|
||||
p_type = p_type.split(".")[-1]
|
||||
|
||||
type_default_val = get_type_default_value(p_type)
|
||||
if type_default_val is None:
|
||||
@ -717,7 +732,7 @@ def to_hex(val):
|
||||
|
||||
def color_to_int(val) -> int:
|
||||
# Clamp values, otherwise the return value might not fit in 32 bit
|
||||
# (and later cause problems, e.g. in the .arm file reader)
|
||||
# (and later cause problems, e.g. in the .lnx file reader)
|
||||
val = [max(0.0, min(v, 1.0)) for v in val]
|
||||
return (int(val[3] * 255) << 24) + (int(val[0] * 255) << 16) + (int(val[1] * 255) << 8) + int(val[2] * 255)
|
||||
|
||||
@ -796,6 +811,8 @@ def safesrc(s):
|
||||
def safestr(s: str) -> str:
|
||||
"""Outputs a string where special characters have been replaced with
|
||||
'_', which can be safely used in file and path names."""
|
||||
s = unicodedata.normalize('NFD', s)
|
||||
s = "".join([c for c in s if not unicodedata.combining(c)])
|
||||
for c in r'''[]/\;,><&*:§$%=+@!#^()|?^'"''':
|
||||
s = s.replace(c, '_')
|
||||
return ''.join([i if ord(i) < 128 else '_' for i in s])
|
||||
@ -938,10 +955,10 @@ def is_bone_animation_enabled(bobject):
|
||||
if not has_actions and adata != None:
|
||||
if hasattr(adata, 'nla_tracks') and adata.nla_tracks != None:
|
||||
for track in adata.nla_tracks:
|
||||
if track.strips == None:
|
||||
if track.strips == None or track.mute:
|
||||
continue
|
||||
for strip in track.strips:
|
||||
if strip.action == None:
|
||||
if strip.action == None or strip.mute:
|
||||
continue
|
||||
has_actions = True
|
||||
break
|
||||
@ -957,7 +974,7 @@ def export_bone_data(bobject: bpy.types.Object) -> bool:
|
||||
return bobject.find_armature() and is_bone_animation_enabled(bobject) and get_rp().lnx_skin == 'On'
|
||||
|
||||
def export_morph_targets(bobject: bpy.types.Object) -> bool:
|
||||
if get_rp().lnx_morph_target != 'On':
|
||||
if get_rp().lnx_morph_target != 'On' or bobject.type == 'CURVE':
|
||||
return False
|
||||
|
||||
if not hasattr(bobject.data, 'shape_keys'):
|
||||
|
||||
Reference in New Issue
Block a user