2015-12-07 21:05:27 +01:00
|
|
|
import bpy
|
|
|
|
import os
|
2017-03-20 13:23:31 +01:00
|
|
|
import shutil
|
2017-03-15 12:30:14 +01:00
|
|
|
import arm.utils
|
|
|
|
import arm.assets as assets
|
|
|
|
import arm.make_state as state
|
2017-09-06 16:37:23 +02:00
|
|
|
import glob
|
2015-12-07 21:05:27 +01:00
|
|
|
|
2017-04-16 17:43:07 +02:00
|
|
|
check_dot_path = False
|
|
|
|
|
2016-08-12 02:29:09 +02:00
|
|
|
def add_armory_library(sdk_path, name):
|
2017-01-28 20:00:04 +01:00
|
|
|
return ('project.addLibrary("' + sdk_path + '/' + name + '");\n').replace('\\', '/')
|
2016-08-12 02:29:09 +02:00
|
|
|
|
2017-09-06 16:37:23 +02:00
|
|
|
def add_assets(path, quality=1.0):
|
2017-04-16 17:43:07 +02:00
|
|
|
global check_dot_path
|
|
|
|
if check_dot_path and '/.' in path: # Redirect path to local copy
|
2017-05-23 01:03:44 +02:00
|
|
|
armpath = arm.utils.build_dir() + '/compiled/ArmoryAssets/'
|
2017-04-16 17:43:07 +02:00
|
|
|
if not os.path.exists(armpath):
|
|
|
|
os.makedirs(armpath)
|
|
|
|
localpath = armpath + path.rsplit('/')[-1]
|
|
|
|
if not os.path.isfile(localpath):
|
|
|
|
shutil.copy(path, localpath)
|
|
|
|
path = localpath
|
2017-09-06 16:37:23 +02:00
|
|
|
|
|
|
|
s = 'project.addAssets("' + path + '"';
|
|
|
|
if quality < 1.0:
|
|
|
|
s += ', { quality: ' + str(quality) + ' }'
|
|
|
|
s += ');\n'
|
|
|
|
return s
|
2017-04-16 17:43:07 +02:00
|
|
|
|
2015-12-07 21:05:27 +01:00
|
|
|
# Write khafile.js
|
2017-08-10 14:10:37 +02:00
|
|
|
def write_khafilejs(is_play, export_physics, export_navigation, export_ui, is_publish, enable_dce, in_viewport, import_traits, import_logicnodes):
|
2017-04-16 17:43:07 +02:00
|
|
|
global check_dot_path
|
2017-03-15 12:30:14 +01:00
|
|
|
sdk_path = arm.utils.get_sdk_path()
|
2016-10-12 17:52:27 +02:00
|
|
|
wrd = bpy.data.worlds['Arm']
|
2016-01-17 22:38:46 +01:00
|
|
|
|
2016-06-30 13:22:05 +02:00
|
|
|
with open('khafile.js', 'w') as f:
|
|
|
|
f.write(
|
2015-12-07 21:05:27 +01:00
|
|
|
"""// Auto-generated
|
2017-05-13 17:17:43 +02:00
|
|
|
let project = new Project('""" + arm.utils.safestr(wrd.arm_project_name) + """');
|
2015-12-07 21:05:27 +01:00
|
|
|
|
|
|
|
project.addSources('Sources');
|
|
|
|
""")
|
2017-02-13 13:23:43 +01:00
|
|
|
|
2017-04-16 17:43:07 +02:00
|
|
|
# TODO: Khamake bug workaround - assets & shaders located in folder starting with '.' get discarded - copy them to project
|
|
|
|
check_dot_path = False
|
|
|
|
if '/.' in sdk_path:
|
|
|
|
check_dot_path = True
|
2017-05-23 01:03:44 +02:00
|
|
|
if not os.path.exists(arm.utils.build_dir() + '/compiled/KhaShaders'):
|
2017-04-16 17:43:07 +02:00
|
|
|
kha_shaders_path = arm.utils.get_kha_path() + '/Sources/Shaders'
|
2017-05-23 01:03:44 +02:00
|
|
|
shutil.copytree(kha_shaders_path, arm.utils.build_dir() + '/compiled/KhaShaders')
|
|
|
|
f.write("project.addShaders('" + arm.utils.build_dir() + "/compiled/KhaShaders/**');\n")
|
2017-04-16 17:43:07 +02:00
|
|
|
|
2017-02-13 13:23:43 +01:00
|
|
|
# Auto-add assets located in Bundled directory
|
|
|
|
if os.path.exists('Bundled'):
|
2017-09-06 16:50:30 +02:00
|
|
|
for file in glob.glob("Bundled/**", recursive=True):
|
|
|
|
if os.path.isfile(file):
|
|
|
|
assets.add(file)
|
2017-02-13 13:23:43 +01:00
|
|
|
|
2017-09-17 16:59:00 +02:00
|
|
|
if os.path.exists('Shaders'):
|
|
|
|
for file in glob.glob("Shaders/**", recursive=True):
|
|
|
|
if os.path.isfile(file):
|
|
|
|
assets.add_shader(file)
|
|
|
|
|
2017-09-05 00:36:16 +02:00
|
|
|
if not os.path.exists('Libraries/armory'):
|
2017-02-09 00:33:19 +01:00
|
|
|
f.write(add_armory_library(sdk_path, 'armory'))
|
|
|
|
|
2017-09-05 00:36:16 +02:00
|
|
|
if not os.path.exists('Libraries/iron'):
|
2017-02-09 00:33:19 +01:00
|
|
|
f.write(add_armory_library(sdk_path, 'iron'))
|
2017-03-06 02:29:03 +01:00
|
|
|
|
|
|
|
# Project libraries
|
2017-09-05 00:36:16 +02:00
|
|
|
if os.path.exists('Libraries'):
|
|
|
|
libs = os.listdir('Libraries')
|
|
|
|
for lib in libs:
|
|
|
|
if os.path.isdir('Libraries/' + lib):
|
|
|
|
f.write('project.addLibrary("{0}");\n'.format(lib))
|
2016-06-30 13:22:05 +02:00
|
|
|
|
2017-12-06 19:55:08 +01:00
|
|
|
if wrd.arm_audio == 'Disabled':
|
|
|
|
assets.add_khafile_def('arm_no_audio')
|
|
|
|
|
2016-09-08 14:08:31 +02:00
|
|
|
if export_physics:
|
2017-05-25 16:48:41 +02:00
|
|
|
assets.add_khafile_def('arm_physics')
|
2017-09-30 00:32:06 +02:00
|
|
|
if wrd.arm_physics == 'Bullet':
|
|
|
|
assets.add_khafile_def('arm_bullet')
|
|
|
|
if not os.path.exists('Libraries/haxebullet'):
|
|
|
|
f.write(add_armory_library(sdk_path + '/lib/', 'haxebullet'))
|
|
|
|
if state.target == 'krom' or state.target == 'html5' or state.target == 'node':
|
|
|
|
ammojs_path = sdk_path + '/lib/haxebullet/js/ammo/ammo.js'
|
|
|
|
ammojs_path = ammojs_path.replace('\\', '/')
|
|
|
|
f.write(add_assets(ammojs_path))
|
|
|
|
elif wrd.arm_physics == 'Oimo':
|
2017-09-30 02:15:21 +02:00
|
|
|
assets.add_khafile_def('arm_oimo')
|
2017-09-30 00:32:06 +02:00
|
|
|
if not os.path.exists('Libraries/oimo'):
|
|
|
|
f.write(add_armory_library(sdk_path + '/lib/', 'oimo'))
|
2016-08-21 20:00:37 +02:00
|
|
|
|
2016-12-07 02:01:42 +01:00
|
|
|
if export_navigation:
|
2017-05-25 16:48:41 +02:00
|
|
|
assets.add_khafile_def('arm_navigation')
|
2017-09-05 00:36:16 +02:00
|
|
|
if not os.path.exists('Libraries/haxerecast'):
|
2017-08-14 22:13:14 +02:00
|
|
|
f.write(add_armory_library(sdk_path + '/lib/', 'haxerecast'))
|
2016-12-07 02:01:42 +01:00
|
|
|
if state.target == 'krom' or state.target == 'html5':
|
|
|
|
recastjs_path = sdk_path + '/lib/haxerecast/js/recast/recast.js'
|
|
|
|
recastjs_path = recastjs_path.replace('\\', '/')
|
2017-04-16 17:43:07 +02:00
|
|
|
f.write(add_assets(recastjs_path))
|
2016-12-07 02:01:42 +01:00
|
|
|
|
2017-08-10 14:39:08 +02:00
|
|
|
if not is_publish:
|
|
|
|
f.write("""project.addParameter("--macro include('armory.trait')");\n""")
|
|
|
|
f.write("""project.addParameter("--macro include('armory.trait.internal')");\n""")
|
2017-09-30 00:32:06 +02:00
|
|
|
if export_physics:
|
|
|
|
f.write("""project.addParameter("--macro include('armory.trait.physics')");\n""")
|
|
|
|
if wrd.arm_physics == 'Bullet':
|
|
|
|
f.write("""project.addParameter("--macro include('armory.trait.physics.bullet')");\n""")
|
|
|
|
else:
|
|
|
|
f.write("""project.addParameter("--macro include('armory.trait.physics.oimo')");\n""")
|
|
|
|
if export_navigation:
|
|
|
|
f.write("""project.addParameter("--macro include('armory.trait.navigation')");\n""")
|
2017-08-10 14:39:08 +02:00
|
|
|
|
|
|
|
if import_logicnodes: # Live patching for logic nodes
|
|
|
|
f.write("""project.addParameter("--macro include('armory.logicnode')");\n""")
|
|
|
|
|
2017-06-20 15:50:06 +02:00
|
|
|
if enable_dce:
|
2017-08-10 14:10:37 +02:00
|
|
|
f.write("project.addParameter('-dce full');\n")
|
|
|
|
|
2017-11-20 15:16:52 +01:00
|
|
|
if in_viewport:
|
2017-11-28 19:30:46 +01:00
|
|
|
assets.add_khafile_def('arm_viewport')
|
2017-11-20 15:16:52 +01:00
|
|
|
import_traits.append('armory.trait.internal.Bridge')
|
|
|
|
|
2017-08-10 14:10:37 +02:00
|
|
|
import_traits = list(set(import_traits))
|
|
|
|
for i in range(0, len(import_traits)):
|
|
|
|
f.write("project.addParameter('" + import_traits[i] + "');\n")
|
|
|
|
f.write("""project.addParameter("--macro keep('""" + import_traits[i] + """')");\n""")
|
|
|
|
|
2017-06-26 15:37:10 +02:00
|
|
|
if state.is_render:
|
|
|
|
assets.add_khafile_def('arm_render')
|
2017-10-03 20:27:21 +02:00
|
|
|
if state.is_render_anim:
|
|
|
|
assets.add_khafile_def('arm_render_anim')
|
|
|
|
if not os.path.exists('Libraries/iron_format'):
|
|
|
|
f.write(add_armory_library(sdk_path + '/lib/', 'iron_format'))
|
2017-06-26 15:37:10 +02:00
|
|
|
|
2017-06-02 16:41:36 +02:00
|
|
|
shaderload = state.target == 'krom' or state.target == 'html5'
|
|
|
|
if wrd.arm_cache_compiler and shaderload and not is_publish:
|
2017-05-24 23:04:24 +02:00
|
|
|
# Load shaders manually
|
2017-06-02 16:41:36 +02:00
|
|
|
assets.add_khafile_def('arm_shaderload')
|
2017-05-24 23:04:24 +02:00
|
|
|
|
2017-07-02 20:48:19 +02:00
|
|
|
sceneload = state.target == 'krom'
|
|
|
|
if wrd.arm_play_live_patch and is_play and in_viewport and sceneload:
|
|
|
|
# Scene patch
|
|
|
|
assets.add_khafile_def('arm_sceneload')
|
|
|
|
|
2017-09-06 16:37:23 +02:00
|
|
|
shader_references = sorted(list(set(assets.shaders)))
|
2016-09-28 00:00:59 +02:00
|
|
|
for ref in shader_references:
|
2017-10-17 21:23:43 +02:00
|
|
|
ref = ref.replace('\\', '/')
|
2016-09-28 00:00:59 +02:00
|
|
|
f.write("project.addShaders('" + ref + "');\n")
|
2017-03-20 13:23:31 +01:00
|
|
|
|
2017-09-06 16:37:23 +02:00
|
|
|
shader_data_references = sorted(list(set(assets.shader_datas)))
|
2016-09-28 00:00:59 +02:00
|
|
|
for ref in shader_data_references:
|
|
|
|
ref = ref.replace('\\', '/')
|
2017-04-16 17:43:07 +02:00
|
|
|
f.write(add_assets(ref))
|
2016-09-28 00:00:59 +02:00
|
|
|
|
2017-09-06 16:37:23 +02:00
|
|
|
asset_references = sorted(list(set(assets.assets)))
|
2016-09-28 00:00:59 +02:00
|
|
|
for ref in asset_references:
|
2016-08-13 14:02:12 +02:00
|
|
|
ref = ref.replace('\\', '/')
|
2017-09-06 16:37:23 +02:00
|
|
|
quality = 1.0
|
|
|
|
s = ref.lower()
|
|
|
|
if s.endswith('.wav'):
|
|
|
|
quality = wrd.arm_sound_quality
|
|
|
|
elif s.endswith('.png') or s.endswith('.jpg'):
|
|
|
|
quality = wrd.arm_texture_quality
|
|
|
|
f.write(add_assets(ref, quality=quality))
|
|
|
|
|
|
|
|
if wrd.arm_sound_quality < 1.0 or state.target == 'html5':
|
|
|
|
assets.add_khafile_def('arm_soundcompress')
|
|
|
|
|
|
|
|
if wrd.arm_texture_quality < 1.0:
|
|
|
|
assets.add_khafile_def('arm_texcompress')
|
2015-12-07 21:05:27 +01:00
|
|
|
|
2016-10-17 00:02:51 +02:00
|
|
|
if wrd.arm_play_console:
|
2017-11-12 21:56:01 +01:00
|
|
|
assets.add_khafile_def('arm_debug')
|
|
|
|
f.write("project.addShaders('" + sdk_path + "/armory/Shaders/debug_draw/**');\n")
|
2017-01-02 22:46:18 +01:00
|
|
|
|
2017-06-20 11:35:24 +02:00
|
|
|
if export_ui:
|
2017-09-05 00:36:16 +02:00
|
|
|
if not os.path.exists('Libraries/zui'):
|
2017-08-14 22:13:14 +02:00
|
|
|
f.write(add_armory_library(sdk_path, 'lib/zui'))
|
2017-02-28 13:48:19 +01:00
|
|
|
p = sdk_path + '/armory/Assets/droid_sans.ttf'
|
2017-04-16 17:43:07 +02:00
|
|
|
f.write(add_assets(p.replace('\\', '/')))
|
2017-05-26 16:42:48 +02:00
|
|
|
assets.add_khafile_def('arm_ui')
|
2016-07-20 17:33:17 +02:00
|
|
|
|
2017-08-19 03:08:42 +02:00
|
|
|
if wrd.arm_hscript == 'Enabled':
|
2017-09-05 00:36:16 +02:00
|
|
|
if not os.path.exists('Libraries/hscript'):
|
2017-08-14 22:13:14 +02:00
|
|
|
f.write(add_armory_library(sdk_path, 'lib/hscript'))
|
2017-07-03 15:16:15 +02:00
|
|
|
assets.add_khafile_def('arm_hscript')
|
2017-04-08 00:34:45 +02:00
|
|
|
|
2018-01-24 22:57:54 +01:00
|
|
|
if wrd.arm_formatlib == 'Enabled':
|
|
|
|
if not os.path.exists('Libraries/iron_format'):
|
|
|
|
f.write(add_armory_library(sdk_path, 'lib/iron_format'))
|
|
|
|
|
2016-10-17 00:02:51 +02:00
|
|
|
if wrd.arm_minimize == False:
|
2017-05-25 16:48:41 +02:00
|
|
|
assets.add_khafile_def('arm_json')
|
2016-08-07 23:12:14 +02:00
|
|
|
|
2016-10-17 00:02:51 +02:00
|
|
|
if wrd.arm_deinterleaved_buffers == True:
|
2017-05-25 16:48:41 +02:00
|
|
|
assets.add_khafile_def('arm_deinterleaved')
|
2016-08-07 23:12:14 +02:00
|
|
|
|
2017-03-12 17:29:22 +01:00
|
|
|
if wrd.arm_batch_meshes == True:
|
2017-05-25 16:48:41 +02:00
|
|
|
assets.add_khafile_def('arm_batch')
|
2017-03-12 17:29:22 +01:00
|
|
|
|
2017-05-14 09:27:47 +02:00
|
|
|
if wrd.arm_stream_scene:
|
2017-05-25 16:48:41 +02:00
|
|
|
assets.add_khafile_def('arm_stream')
|
2017-05-14 09:27:47 +02:00
|
|
|
|
2017-10-10 09:57:23 +02:00
|
|
|
if wrd.arm_skin == 'CPU':
|
|
|
|
assets.add_khafile_def('arm_skin_cpu')
|
|
|
|
elif wrd.arm_skin == 'GPU (Matrix)':
|
|
|
|
assets.add_khafile_def('arm_skin_mat')
|
2016-08-23 22:55:46 +02:00
|
|
|
|
2017-11-10 14:53:40 +01:00
|
|
|
if arm.utils.get_viewport_controls() == 'azerty':
|
|
|
|
assets.add_khafile_def('arm_azerty')
|
|
|
|
|
2016-07-28 13:21:27 +02:00
|
|
|
for d in assets.khafile_defs:
|
|
|
|
f.write("project.addDefine('" + d + "');\n")
|
|
|
|
|
2016-10-17 00:02:51 +02:00
|
|
|
config_text = wrd.arm_khafile
|
2016-06-30 13:22:05 +02:00
|
|
|
if config_text != '':
|
|
|
|
f.write(bpy.data.texts[config_text].as_string())
|
2016-01-11 13:50:54 +01:00
|
|
|
|
2017-12-11 14:43:40 +01:00
|
|
|
if state.target == 'android-native':
|
2017-12-11 14:49:43 +01:00
|
|
|
f.write("project.targetOptions.android_native.package = 'org.armory3d.{0}';\n".format(arm.utils.safestr(wrd.arm_project_package)))
|
2017-12-11 14:43:40 +01:00
|
|
|
if wrd.arm_winorient != 'Multi':
|
2017-09-08 14:21:57 +02:00
|
|
|
f.write("project.targetOptions.android_native.screenOrientation = '{0}';\n".format(wrd.arm_winorient.lower()))
|
2017-12-11 14:49:43 +01:00
|
|
|
# if state.target == 'ios':
|
|
|
|
# f.write("project.targetOptions.ios.bundle = 'org.armory3d.{0}';\n".format(arm.utils.safestr(wrd.arm_project_package)))
|
2017-09-08 14:21:57 +02:00
|
|
|
|
2016-08-04 22:38:56 +02:00
|
|
|
f.write("\n\nresolve(project);\n")
|
2016-01-11 13:07:44 +01:00
|
|
|
|
2015-12-07 21:05:27 +01:00
|
|
|
# Write Main.hx
|
2017-11-08 10:34:27 +01:00
|
|
|
def write_main(scene_name, resx, resy, is_play, in_viewport, is_publish):
|
2016-09-02 23:11:04 +02:00
|
|
|
wrd = bpy.data.worlds['Arm']
|
2017-08-21 20:16:06 +02:00
|
|
|
rpdat = arm.utils.get_rp()
|
2017-08-21 12:17:55 +02:00
|
|
|
scene_ext = '.zip' if (bpy.data.scenes[scene_name].arm_compress and is_publish) else ''
|
2017-10-28 00:07:47 +02:00
|
|
|
winmode = str(wrd.arm_winmode)
|
2017-11-27 15:10:09 +01:00
|
|
|
asset_references = list(set(assets.assets))
|
2017-10-28 00:07:47 +02:00
|
|
|
# TODO: expose Krom.displayWidth() in barmory
|
|
|
|
if in_viewport:
|
|
|
|
winmode = 'Window'
|
2016-06-30 13:22:05 +02:00
|
|
|
#if not os.path.isfile('Sources/Main.hx'):
|
|
|
|
with open('Sources/Main.hx', 'w') as f:
|
|
|
|
f.write(
|
2015-12-07 21:05:27 +01:00
|
|
|
"""// Auto-generated
|
|
|
|
package ;
|
|
|
|
class Main {
|
2017-05-13 17:17:43 +02:00
|
|
|
public static inline var projectName = '""" + arm.utils.safestr(wrd.arm_project_name) + """';
|
|
|
|
public static inline var projectPackage = '""" + arm.utils.safestr(wrd.arm_project_package) + """';
|
2017-11-10 13:29:34 +01:00
|
|
|
public static inline var projectPath = '""" + arm.utils.get_fp().replace('\\', '\\\\') + """';
|
2017-11-27 15:10:09 +01:00
|
|
|
public static inline var projectAssets = """ + str(len(asset_references)) + """;
|
2017-10-28 00:07:47 +02:00
|
|
|
public static var projectWindowMode = kha.WindowMode.""" + winmode + """;
|
2017-07-18 19:50:33 +02:00
|
|
|
public static inline var projectWindowResize = """ + ('true' if wrd.arm_winresize else 'false') + """;
|
|
|
|
public static inline var projectWindowMaximize = """ + ('true' if wrd.arm_winmaximize else 'false') + """;
|
|
|
|
public static inline var projectWindowMinimize = """ + ('true' if wrd.arm_winminimize else 'false') + """;
|
2017-08-22 10:43:33 +02:00
|
|
|
public static var projectWidth = """ + str(resx) + """;
|
|
|
|
public static var projectHeight = """ + str(resy) + """;
|
2017-08-21 20:16:06 +02:00
|
|
|
static inline var projectSamplesPerPixel = """ + str(int(rpdat.arm_samples_per_pixel)) + """;
|
2017-05-12 23:18:49 +02:00
|
|
|
static inline var projectVSync = """ + ('true' if wrd.arm_vsync else 'false') + """;
|
2017-05-13 17:17:43 +02:00
|
|
|
static inline var projectScene = '""" + arm.utils.safestr(scene_name) + scene_ext + """';
|
2016-12-07 02:01:42 +01:00
|
|
|
static var state:Int;
|
2016-12-10 14:20:16 +01:00
|
|
|
#if js
|
2016-12-07 02:01:42 +01:00
|
|
|
static function loadLib(name:String) {
|
|
|
|
kha.LoaderImpl.loadBlobFromDescription({ files: [name] }, function(b:kha.Blob) {
|
|
|
|
untyped __js__("(1, eval)({0})", b.toString());
|
|
|
|
state--;
|
|
|
|
start();
|
|
|
|
});
|
|
|
|
}
|
2017-10-18 12:49:59 +02:00
|
|
|
static function loadLibAmmo(name:String) {
|
|
|
|
kha.LoaderImpl.loadBlobFromDescription({ files: [name] }, function(b:kha.Blob) {
|
|
|
|
var print = function(s:String) { trace(s); };
|
|
|
|
var loaded = function() { state--; start(); }
|
|
|
|
untyped __js__("(1, eval)({0})", b.toString());
|
|
|
|
untyped __js__("Ammo({print:print}).then(loaded)");
|
|
|
|
});
|
|
|
|
}
|
2017-08-10 14:10:37 +02:00
|
|
|
#end""")
|
|
|
|
|
2017-10-12 12:12:48 +02:00
|
|
|
if rpdat.rp_gi == 'Voxel GI' or rpdat.rp_gi == 'Voxel AO':
|
|
|
|
f.write("""
|
|
|
|
public static inline var voxelgiVoxelSize = """ + str(rpdat.arm_voxelgi_dimensions) + " / " + str(rpdat.rp_voxelgi_resolution) + """;
|
|
|
|
public static inline var voxelgiHalfExtents = """ + str(round(rpdat.arm_voxelgi_dimensions / 2.0)) + """;
|
|
|
|
""")
|
|
|
|
|
2017-07-03 15:16:15 +02:00
|
|
|
f.write("""
|
2017-08-10 14:10:37 +02:00
|
|
|
public static function main() {
|
2017-10-10 09:57:23 +02:00
|
|
|
iron.object.BoneAnimation.skinMaxBones = """ + str(wrd.arm_skin_max_bones) + """;
|
2017-11-15 13:34:51 +01:00
|
|
|
""")
|
|
|
|
if rpdat.rp_shadowmap_cascades != '1':
|
|
|
|
f.write("""
|
2017-11-17 14:50:54 +01:00
|
|
|
iron.object.LampObject.cascadeCount = """ + str(rpdat.rp_shadowmap_cascades) + """;
|
|
|
|
iron.object.LampObject.cascadeSplitFactor = """ + str(wrd.arm_shadowmap_split) + """;
|
2017-11-15 13:34:51 +01:00
|
|
|
""")
|
|
|
|
f.write("""
|
2016-12-07 02:01:42 +01:00
|
|
|
state = 1;
|
2017-10-18 12:49:59 +02:00
|
|
|
#if (js && arm_bullet) state++; loadLibAmmo("ammo.js"); #end
|
2016-12-07 02:01:42 +01:00
|
|
|
#if (js && arm_navigation) state++; loadLib("recast.js"); #end
|
|
|
|
state--; start();
|
2016-06-30 13:22:05 +02:00
|
|
|
}
|
2016-11-24 17:35:12 +01:00
|
|
|
static function start() {
|
2016-12-07 02:01:42 +01:00
|
|
|
if (state > 0) return;
|
2016-10-15 15:08:25 +02:00
|
|
|
armory.object.Uniforms.register();
|
2017-08-22 10:43:33 +02:00
|
|
|
if (projectWindowMode == kha.WindowMode.Fullscreen) { projectWindowMode = kha.WindowMode.BorderlessWindow; projectWidth = kha.Display.width(0); projectHeight = kha.Display.height(0); }
|
2018-01-23 12:25:37 +01:00
|
|
|
""")
|
|
|
|
if not in_viewport:
|
|
|
|
f.write("""
|
2018-01-18 21:38:02 +01:00
|
|
|
else { projectWidth = Std.int(Math.min(projectWidth, kha.Display.width(0))); projectHeight = Std.int(Math.min(projectHeight, kha.Display.height(0))); }
|
2018-01-23 12:25:37 +01:00
|
|
|
""")
|
|
|
|
f.write("""
|
2017-07-18 19:50:33 +02:00
|
|
|
kha.System.init({title: projectName, width: projectWidth, height: projectHeight, samplesPerPixel: projectSamplesPerPixel, vSync: projectVSync, windowMode: projectWindowMode, resizable: projectWindowResize, maximizable: projectWindowMaximize, minimizable: projectWindowMinimize}, function() {
|
2016-08-22 21:56:28 +02:00
|
|
|
iron.App.init(function() {
|
2016-11-07 23:06:08 +01:00
|
|
|
""")
|
2018-01-22 18:46:38 +01:00
|
|
|
if is_publish and wrd.arm_loadscreen:
|
|
|
|
loadscreen_class = 'armory.trait.internal.LoadingScreen'
|
|
|
|
if os.path.isfile(arm.utils.get_fp() + '/Sources/' + wrd.arm_project_package + '/LoadingScreen.hx'):
|
|
|
|
loadscreen_class = wrd.arm_project_package + '.LoadingScreen'
|
2017-11-27 15:10:09 +01:00
|
|
|
f.write("""
|
2018-01-22 18:46:38 +01:00
|
|
|
function drawLoading(g:kha.graphics2.Graphics) {
|
|
|
|
if (iron.Scene.active != null && iron.Scene.active.ready) iron.App.removeRender2D(drawLoading);
|
|
|
|
else """ + loadscreen_class + """.render(g, iron.data.Data.assetsLoaded, Main.projectAssets);
|
|
|
|
}
|
|
|
|
iron.App.notifyOnRender2D(drawLoading);
|
2017-11-22 21:17:36 +01:00
|
|
|
""")
|
2016-11-07 23:06:08 +01:00
|
|
|
|
|
|
|
f.write("""
|
2017-11-22 21:17:36 +01:00
|
|
|
iron.Scene.setActive(projectScene, function(object:iron.object.Object) {
|
|
|
|
""")
|
2017-03-15 12:30:14 +01:00
|
|
|
# if arm.utils.with_krom() and in_viewport and is_play:
|
2017-05-24 13:06:48 +02:00
|
|
|
if is_play or (state.target == 'html5' and not is_publish):
|
2016-09-23 00:34:42 +02:00
|
|
|
f.write("""
|
2017-11-22 21:17:36 +01:00
|
|
|
object.addTrait(new armory.trait.internal.SpaceArmory());
|
|
|
|
""")
|
|
|
|
|
2017-11-30 14:38:23 +01:00
|
|
|
# Detect custom render path
|
|
|
|
pathpack = 'armory'
|
|
|
|
if os.path.isfile(arm.utils.get_fp() + '/Sources/' + wrd.arm_project_package + '/renderpath/RenderPathCreator.hx'):
|
|
|
|
pathpack = wrd.arm_project_package
|
2018-01-03 15:09:55 +01:00
|
|
|
elif rpdat.rp_driver != 'Armory':
|
|
|
|
pathpack = rpdat.rp_driver.lower()
|
2017-11-30 14:38:23 +01:00
|
|
|
|
2017-11-27 15:10:09 +01:00
|
|
|
f.write("""
|
2017-11-30 14:38:23 +01:00
|
|
|
iron.RenderPath.setActive(""" + pathpack + """.renderpath.RenderPathCreator.get());
|
2017-11-22 21:17:36 +01:00
|
|
|
""")
|
|
|
|
|
2016-09-23 00:34:42 +02:00
|
|
|
f.write("""
|
2016-08-29 09:56:34 +02:00
|
|
|
});
|
2016-08-22 21:56:28 +02:00
|
|
|
});
|
2016-06-30 13:22:05 +02:00
|
|
|
});
|
|
|
|
}
|
2015-12-07 21:05:27 +01:00
|
|
|
}
|
|
|
|
""")
|
2016-07-10 00:51:39 +02:00
|
|
|
|
|
|
|
# Write index.html
|
2017-11-27 13:57:13 +01:00
|
|
|
def write_indexhtml(w, h, is_publish):
|
2017-12-11 14:47:55 +01:00
|
|
|
wrd = bpy.data.worlds['Arm']
|
2017-08-21 20:16:06 +02:00
|
|
|
rpdat = arm.utils.get_rp()
|
2017-11-27 13:57:13 +01:00
|
|
|
dest = '/html5' if is_publish else '/debug/html5'
|
|
|
|
if not os.path.exists(arm.utils.build_dir() + dest):
|
|
|
|
os.makedirs(arm.utils.build_dir() + dest)
|
|
|
|
with open(arm.utils.build_dir() + dest + '/index.html', 'w') as f:
|
2016-07-10 00:51:39 +02:00
|
|
|
f.write(
|
|
|
|
"""<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2017-04-26 14:21:22 +02:00
|
|
|
<meta charset="utf-8"/>""")
|
2017-12-11 14:47:55 +01:00
|
|
|
if rpdat.rp_stereo or wrd.arm_winmode == 'Fullscreen':
|
2017-04-26 14:21:22 +02:00
|
|
|
f.write("""
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
""")
|
|
|
|
f.write("""
|
2016-08-04 22:38:56 +02:00
|
|
|
<title>Armory</title>
|
2016-07-10 00:51:39 +02:00
|
|
|
</head>
|
2017-05-12 21:49:42 +02:00
|
|
|
<body style="margin: 0; padding: 0;">
|
2017-04-16 14:46:35 +02:00
|
|
|
""")
|
2017-12-11 14:47:55 +01:00
|
|
|
if rpdat.rp_stereo or wrd.arm_winmode == 'Fullscreen':
|
2017-04-16 14:46:35 +02:00
|
|
|
f.write("""
|
2017-04-26 14:21:22 +02:00
|
|
|
<canvas style="width: 100vw; height: 100vh; display: block;" id='khanvas'></canvas>
|
2017-04-16 14:46:35 +02:00
|
|
|
""")
|
|
|
|
else:
|
|
|
|
f.write("""
|
2017-04-26 14:21:22 +02:00
|
|
|
<p align="center"><canvas align="center" style="outline: none;" id='khanvas' width='""" + str(w) + """' height='""" + str(h) + """'></canvas></p>
|
2017-04-16 14:46:35 +02:00
|
|
|
""")
|
|
|
|
f.write("""
|
2016-07-10 00:51:39 +02:00
|
|
|
<script src='kha.js'></script>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
""")
|
|
|
|
|
2016-09-02 23:11:04 +02:00
|
|
|
def write_compiledglsl():
|
|
|
|
wrd = bpy.data.worlds['Arm']
|
2017-08-21 20:16:06 +02:00
|
|
|
rpdat = arm.utils.get_rp()
|
2017-11-22 21:17:36 +01:00
|
|
|
shadowmap_size = 0
|
|
|
|
if rpdat.rp_shadowmap != 'Off':
|
|
|
|
shadowmap_size = int(rpdat.rp_shadowmap)
|
2017-05-23 01:03:44 +02:00
|
|
|
with open(arm.utils.build_dir() + '/compiled/Shaders/compiled.glsl', 'w') as f:
|
2016-07-10 00:51:39 +02:00
|
|
|
f.write(
|
2016-10-17 17:39:40 +02:00
|
|
|
"""#ifndef _COMPILED_GLSL_
|
|
|
|
#define _COMPILED_GLSL_
|
|
|
|
const float PI = 3.1415926535;
|
2016-07-10 00:51:39 +02:00
|
|
|
const float PI2 = PI * 2.0;
|
|
|
|
const vec2 shadowmapSize = vec2(""" + str(shadowmap_size) + """, """ + str(shadowmap_size) + """);
|
2017-08-21 12:17:55 +02:00
|
|
|
const float shadowmapCubePcfSize = """ + str(round(wrd.arm_pcfsize * 10000) / 10000) + """;
|
2017-10-12 12:12:48 +02:00
|
|
|
const int shadowmapCascades = """ + str(rpdat.rp_shadowmap_cascades) + """;
|
2016-07-12 00:09:02 +02:00
|
|
|
""")
|
2017-08-21 20:16:06 +02:00
|
|
|
if rpdat.arm_clouds:
|
2016-07-12 00:09:02 +02:00
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float cloudsDensity = """ + str(round(wrd.arm_clouds_density * 100) / 100) + """;
|
|
|
|
const float cloudsSize = """ + str(round(wrd.arm_clouds_size * 100) / 100) + """;
|
|
|
|
const float cloudsLower = """ + str(round(wrd.arm_clouds_lower * 1000)) + """;
|
|
|
|
const float cloudsUpper = """ + str(round(wrd.arm_clouds_upper * 1000)) + """;
|
|
|
|
const vec2 cloudsWind = vec2(""" + str(round(wrd.arm_clouds_wind[0] * 1000) / 1000) + """, """ + str(round(wrd.arm_clouds_wind[1] * 1000) / 1000) + """);
|
|
|
|
const float cloudsSecondary = """ + str(round(wrd.arm_clouds_secondary * 100) / 100) + """;
|
|
|
|
const float cloudsPrecipitation = """ + str(round(wrd.arm_clouds_precipitation * 100) / 100) + """;
|
|
|
|
const float cloudsEccentricity = """ + str(round(wrd.arm_clouds_eccentricity * 100) / 100) + """;
|
2016-07-17 20:29:53 +02:00
|
|
|
""")
|
2017-09-19 11:29:01 +02:00
|
|
|
if rpdat.rp_ocean:
|
2016-07-17 20:29:53 +02:00
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float seaLevel = """ + str(round(wrd.arm_ocean_level * 100) / 100) + """;
|
|
|
|
const float seaMaxAmplitude = """ + str(round(wrd.arm_ocean_amplitude * 100) / 100) + """;
|
|
|
|
const float seaHeight = """ + str(round(wrd.arm_ocean_height * 100) / 100) + """;
|
|
|
|
const float seaChoppy = """ + str(round(wrd.arm_ocean_choppy * 100) / 100) + """;
|
|
|
|
const float seaSpeed = """ + str(round(wrd.arm_ocean_speed * 100) / 100) + """;
|
|
|
|
const float seaFreq = """ + str(round(wrd.arm_ocean_freq * 100) / 100) + """;
|
|
|
|
const vec3 seaBaseColor = vec3(""" + str(round(wrd.arm_ocean_base_color[0] * 100) / 100) + """, """ + str(round(wrd.arm_ocean_base_color[1] * 100) / 100) + """, """ + str(round(wrd.arm_ocean_base_color[2] * 100) / 100) + """);
|
|
|
|
const vec3 seaWaterColor = vec3(""" + str(round(wrd.arm_ocean_water_color[0] * 100) / 100) + """, """ + str(round(wrd.arm_ocean_water_color[1] * 100) / 100) + """, """ + str(round(wrd.arm_ocean_water_color[2] * 100) / 100) + """);
|
|
|
|
const float seaFade = """ + str(round(wrd.arm_ocean_fade * 100) / 100) + """;
|
2016-07-17 20:29:53 +02:00
|
|
|
""")
|
2017-11-27 20:35:23 +01:00
|
|
|
if rpdat.rp_ssgi == 'SSAO' or rpdat.rp_volumetriclight:
|
2017-11-04 16:16:07 +01:00
|
|
|
scale = 0.5 if rpdat.arm_ssao_half_res else 1.0
|
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float ssaoSize = """ + str(round(wrd.arm_ssao_size * 100) / 100) + """;
|
|
|
|
const float ssaoStrength = """ + str(round(wrd.arm_ssao_strength * 100) / 100) + """;
|
2017-03-14 20:43:54 +01:00
|
|
|
const float ssaoTextureScale = """ + str(scale) + """;
|
2016-07-17 20:29:53 +02:00
|
|
|
""")
|
2017-11-04 16:16:07 +01:00
|
|
|
if rpdat.rp_ssgi == 'RTGI' or rpdat.rp_ssgi == 'RTAO':
|
|
|
|
f.write(
|
|
|
|
"""const int ssgiMaxSteps = """ + str(wrd.arm_ssgi_max_steps) + """;
|
|
|
|
const float ssgiRayStep = 0.005 * """ + str(round(wrd.arm_ssgi_step_size * 100) / 100) + """;
|
|
|
|
const float ssgiStrength = """ + str(round(wrd.arm_ssgi_strength * 100) / 100) + """;
|
|
|
|
""")
|
|
|
|
|
|
|
|
if rpdat.rp_bloom:
|
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float bloomThreshold = """ + str(round(wrd.arm_bloom_threshold * 100) / 100) + """;
|
|
|
|
const float bloomStrength = """ + str(round(wrd.arm_bloom_strength * 100) / 100) + """;
|
|
|
|
const float bloomRadius = """ + str(round(wrd.arm_bloom_radius * 100) / 100) + """;
|
2016-07-18 20:28:52 +02:00
|
|
|
""")
|
2017-11-22 21:17:36 +01:00
|
|
|
if rpdat.rp_motionblur != 'Off':
|
2017-11-04 16:16:07 +01:00
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float motionBlurIntensity = """ + str(round(wrd.arm_motion_blur_intensity * 100) / 100) + """;
|
2016-07-18 20:28:52 +02:00
|
|
|
""")
|
2017-11-04 16:16:07 +01:00
|
|
|
if rpdat.rp_ssr:
|
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float ssrRayStep = """ + str(round(wrd.arm_ssr_ray_step * 100) / 100) + """;
|
|
|
|
const float ssrMinRayStep = """ + str(round(wrd.arm_ssr_min_ray_step * 100) / 100) + """;
|
|
|
|
const float ssrSearchDist = """ + str(round(wrd.arm_ssr_search_dist * 100) / 100) + """;
|
|
|
|
const float ssrFalloffExp = """ + str(round(wrd.arm_ssr_falloff_exp * 100) / 100) + """;
|
|
|
|
const float ssrJitter = """ + str(round(wrd.arm_ssr_jitter * 100) / 100) + """;
|
2017-01-17 14:48:47 +01:00
|
|
|
""")
|
|
|
|
|
2017-08-21 20:16:06 +02:00
|
|
|
if rpdat.arm_ssrs:
|
2017-01-17 14:48:47 +01:00
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float ssrsRayStep = """ + str(round(wrd.arm_ssrs_ray_step * 100) / 100) + """;
|
2017-12-04 19:49:06 +01:00
|
|
|
""")
|
|
|
|
|
|
|
|
if rpdat.arm_soft_shadows == 'On':
|
|
|
|
f.write(
|
|
|
|
"""const int penumbraScale = """ + str(rpdat.arm_soft_shadows_penumbra) + """;
|
|
|
|
const float penumbraDistance = """ + str(rpdat.arm_soft_shadows_distance) + """;
|
2016-09-08 14:08:31 +02:00
|
|
|
""")
|
|
|
|
|
2017-11-04 16:16:07 +01:00
|
|
|
if rpdat.rp_volumetriclight:
|
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float volumAirTurbidity = """ + str(round(wrd.arm_volumetric_light_air_turbidity * 100) / 100) + """;
|
|
|
|
const vec3 volumAirColor = vec3(""" + str(round(wrd.arm_volumetric_light_air_color[0] * 100) / 100) + """, """ + str(round(wrd.arm_volumetric_light_air_color[1] * 100) / 100) + """, """ + str(round(wrd.arm_volumetric_light_air_color[2] * 100) / 100) + """);
|
2018-01-07 20:01:43 +01:00
|
|
|
const int volumSteps = """ + str(wrd.arm_volumetric_light_steps) + """;
|
2017-11-18 22:52:41 +01:00
|
|
|
""")
|
|
|
|
|
|
|
|
if rpdat.rp_autoexposure:
|
|
|
|
f.write(
|
|
|
|
"""const float autoExposureStrength = """ + str(wrd.arm_autoexposure_strength) + """;
|
2016-08-15 23:45:03 +02:00
|
|
|
""")
|
|
|
|
|
2016-08-23 22:55:46 +02:00
|
|
|
# Compositor
|
2017-08-21 12:17:55 +02:00
|
|
|
if wrd.arm_letterbox:
|
2016-08-15 23:45:03 +02:00
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float compoLetterboxSize = """ + str(round(wrd.arm_letterbox_size * 100) / 100) + """;
|
2016-08-15 23:45:03 +02:00
|
|
|
""")
|
|
|
|
|
2017-08-21 12:17:55 +02:00
|
|
|
if wrd.arm_grain:
|
2016-08-15 23:45:03 +02:00
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float compoGrainStrength = """ + str(round(wrd.arm_grain_strength * 100) / 100) + """;
|
2016-08-15 23:45:03 +02:00
|
|
|
""")
|
|
|
|
|
|
|
|
if bpy.data.scenes[0].cycles.film_exposure != 1.0:
|
|
|
|
f.write(
|
|
|
|
"""const float compoExposureStrength = """ + str(round(bpy.data.scenes[0].cycles.film_exposure * 100) / 100) + """;
|
|
|
|
""")
|
|
|
|
|
2017-08-21 12:17:55 +02:00
|
|
|
if wrd.arm_fog:
|
2016-08-15 23:45:03 +02:00
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float compoFogAmountA = """ + str(round(wrd.arm_fog_amounta * 100) / 100) + """;
|
|
|
|
const float compoFogAmountB = """ + str(round(wrd.arm_fog_amountb * 100) / 100) + """;
|
|
|
|
const vec3 compoFogColor = vec3(""" + str(round(wrd.arm_fog_color[0] * 100) / 100) + """, """ + str(round(wrd.arm_fog_color[1] * 100) / 100) + """, """ + str(round(wrd.arm_fog_color[2] * 100) / 100) + """);
|
2016-08-15 23:45:03 +02:00
|
|
|
""")
|
|
|
|
|
2017-08-22 12:08:44 +02:00
|
|
|
if len(bpy.data.cameras) > 0 and bpy.data.cameras[0].dof_distance > 0.0:
|
2016-08-15 23:45:03 +02:00
|
|
|
f.write(
|
|
|
|
"""const float compoDOFDistance = """ + str(round(bpy.data.cameras[0].dof_distance * 100) / 100) + """;
|
2016-10-21 19:36:08 +02:00
|
|
|
const float compoDOFFstop = """ + str(round(bpy.data.cameras[0].gpu_dof.fstop * 100) / 100) + """;
|
2017-02-28 13:48:19 +01:00
|
|
|
const float compoDOFLength = 160.0;
|
|
|
|
""") # str(round(bpy.data.cameras[0].lens * 100) / 100)
|
2017-02-22 15:50:19 +01:00
|
|
|
|
2017-10-12 12:12:48 +02:00
|
|
|
if rpdat.rp_gi == 'Voxel GI' or rpdat.rp_gi == 'Voxel AO':
|
2017-10-23 01:55:47 +02:00
|
|
|
halfext = round(rpdat.arm_voxelgi_dimensions / 2.0)
|
2017-02-22 15:50:19 +01:00
|
|
|
f.write(
|
2017-10-23 01:55:47 +02:00
|
|
|
"""const ivec3 voxelgiResolution = ivec3(""" + str(rpdat.rp_voxelgi_resolution) + """, """ + str(rpdat.rp_voxelgi_resolution) + """, """ + str(int(int(rpdat.rp_voxelgi_resolution) * float(rpdat.rp_voxelgi_resolution_z))) + """);
|
|
|
|
const vec3 voxelgiHalfExtents = vec3(""" + str(halfext) + """, """ + str(halfext) + """, """ + str(round(halfext * float(rpdat.rp_voxelgi_resolution_z))) + """);
|
2017-08-21 12:17:55 +02:00
|
|
|
const float voxelgiDiff = """ + str(round(wrd.arm_voxelgi_diff * 100) / 100) + """;
|
|
|
|
const float voxelgiSpec = """ + str(round(wrd.arm_voxelgi_spec * 100) / 100) + """;
|
|
|
|
const float voxelgiOcc = """ + str(round(wrd.arm_voxelgi_occ * 100) / 100) + """;
|
|
|
|
const float voxelgiEnv = """ + str(round(wrd.arm_voxelgi_env * 100) / 100) + """;
|
|
|
|
const float voxelgiStep = """ + str(round(wrd.arm_voxelgi_step * 100) / 100) + """;
|
|
|
|
const float voxelgiRange = """ + str(round(wrd.arm_voxelgi_range * 100) / 100) + """;
|
2017-10-23 16:24:57 +02:00
|
|
|
const float voxelgiOffsetDiff = """ + str(round(wrd.arm_voxelgi_offset_diff * 100) / 100) + """;
|
|
|
|
const float voxelgiOffsetSpec = """ + str(round(wrd.arm_voxelgi_offset_spec * 100) / 100) + """;
|
|
|
|
const float voxelgiOffsetShadow = """ + str(round(wrd.arm_voxelgi_offset_shadow * 100) / 100) + """;
|
|
|
|
const float voxelgiOffsetRefract = """ + str(round(wrd.arm_voxelgi_offset_refract * 100) / 100) + """;
|
2017-05-23 15:01:56 +02:00
|
|
|
""")
|
|
|
|
|
2017-08-21 20:16:06 +02:00
|
|
|
if rpdat.rp_sss_state == 'On':
|
2017-05-23 15:01:56 +02:00
|
|
|
f.write(
|
2017-08-21 12:17:55 +02:00
|
|
|
"""const float sssWidth = """ + str(wrd.arm_sss_width / 10.0) + """;
|
2016-08-23 22:55:46 +02:00
|
|
|
""")
|
|
|
|
|
|
|
|
# Skinning
|
2017-10-10 09:57:23 +02:00
|
|
|
if wrd.arm_skin.startswith('GPU'):
|
2016-08-23 22:55:46 +02:00
|
|
|
f.write(
|
2017-10-10 09:57:23 +02:00
|
|
|
"""const int skinMaxBones = """ + str(wrd.arm_skin_max_bones) + """;
|
2016-07-10 00:51:39 +02:00
|
|
|
""")
|
|
|
|
|
2017-02-22 15:50:19 +01:00
|
|
|
f.write("""#endif // _COMPILED_GLSL_
|
|
|
|
""")
|
2016-10-17 17:39:40 +02:00
|
|
|
|
2016-07-10 00:51:39 +02:00
|
|
|
def write_traithx(class_name):
|
2016-09-02 23:11:04 +02:00
|
|
|
wrd = bpy.data.worlds['Arm']
|
2017-05-13 17:17:43 +02:00
|
|
|
package_path = arm.utils.get_fp() + '/Sources/' + arm.utils.safestr(wrd.arm_project_package)
|
2016-12-08 14:38:04 +01:00
|
|
|
if not os.path.exists(package_path):
|
|
|
|
os.makedirs(package_path)
|
|
|
|
with open(package_path + '/' + class_name + '.hx', 'w') as f:
|
2016-07-10 00:51:39 +02:00
|
|
|
f.write(
|
2017-05-13 17:17:43 +02:00
|
|
|
"""package """ + arm.utils.safestr(wrd.arm_project_package) + """;
|
2016-07-10 00:51:39 +02:00
|
|
|
|
2017-12-11 00:55:26 +01:00
|
|
|
class """ + class_name + """ extends iron.Trait {
|
2017-08-06 19:21:13 +02:00
|
|
|
\tpublic function new() {
|
|
|
|
\t\tsuper();
|
2016-07-10 00:51:39 +02:00
|
|
|
|
2017-08-06 19:21:13 +02:00
|
|
|
\t\t// notifyOnInit(function() {
|
|
|
|
\t\t// });
|
2016-07-10 00:51:39 +02:00
|
|
|
|
2017-08-06 19:21:13 +02:00
|
|
|
\t\t// notifyOnUpdate(function() {
|
|
|
|
\t\t// });
|
|
|
|
|
|
|
|
\t\t// notifyOnRemove(function() {
|
|
|
|
\t\t// });
|
|
|
|
\t}
|
2016-07-10 00:51:39 +02:00
|
|
|
}
|
|
|
|
""")
|
2017-05-26 16:05:14 +02:00
|
|
|
|
|
|
|
def write_canvasjson(canvas_name):
|
|
|
|
canvas_path = arm.utils.get_fp() + '/Bundled/canvas'
|
|
|
|
if not os.path.exists(canvas_path):
|
|
|
|
os.makedirs(canvas_path)
|
|
|
|
with open(canvas_path + '/' + canvas_name + '.json', 'w') as f:
|
|
|
|
f.write(
|
|
|
|
"""{ "name": "untitled", "x": 0.0, "y": 0.0, "width": 960, "height": 540, "elements": [], "assets": [] }""")
|
|
|
|
|
|
|
|
def write_canvasprefs(canvas_path):
|
|
|
|
sdk_path = arm.utils.get_sdk_path()
|
2017-07-25 17:37:46 +02:00
|
|
|
prefs_path = sdk_path + 'armory/tools/armorui/krom/prefs.json'
|
2017-05-26 16:05:14 +02:00
|
|
|
with open(prefs_path, 'w') as f:
|
|
|
|
f.write(
|
2017-05-28 18:14:25 +02:00
|
|
|
'{ "path": "' + canvas_path.replace('\\', '/') + '" }')
|