2015-12-07 21:05:27 +01:00
|
|
|
import bpy
|
|
|
|
import os
|
2017-03-20 13:23:31 +01:00
|
|
|
import shutil
|
2018-02-25 19:01:22 +01:00
|
|
|
import glob
|
|
|
|
import json
|
2018-05-01 13:58:36 +02:00
|
|
|
import stat
|
2017-03-15 12:30:14 +01:00
|
|
|
import arm.utils
|
|
|
|
import arm.assets as assets
|
|
|
|
import arm.make_state as state
|
2015-12-07 21:05:27 +01:00
|
|
|
|
2018-08-16 20:48:00 +02:00
|
|
|
def add_armory_library(sdk_path, name, rel_path=False):
|
|
|
|
if rel_path:
|
|
|
|
sdk_path = '../' + os.path.relpath(sdk_path, arm.utils.get_fp()).replace('\\', '/')
|
2018-07-10 16:05:38 +02:00
|
|
|
return ('project.addLibrary("' + sdk_path + '/' + name + '");\n').replace('\\', '/').replace('//', '/')
|
2016-08-12 02:29:09 +02:00
|
|
|
|
2018-08-16 20:48:00 +02:00
|
|
|
def add_assets(path, quality=1.0, use_data_dir=False, rel_path=False):
|
2018-04-14 15:07:05 +02:00
|
|
|
if not bpy.data.worlds['Arm'].arm_minimize and path.endswith('.arm'):
|
|
|
|
path = path[:-4] + '.json'
|
|
|
|
|
2018-08-16 20:48:00 +02:00
|
|
|
if rel_path:
|
|
|
|
path = os.path.relpath(path, arm.utils.get_fp()).replace('\\', '/')
|
|
|
|
|
2018-03-30 10:49:45 +02:00
|
|
|
notinlist = not path.endswith('.ttf') # TODO
|
2018-08-16 12:10:50 +02:00
|
|
|
s = 'project.addAssets("' + path + '", { notinlist: ' + str(notinlist).lower() + ' '
|
2017-09-06 16:37:23 +02:00
|
|
|
if quality < 1.0:
|
2018-03-30 10:49:45 +02:00
|
|
|
s += ', quality: ' + str(quality)
|
2018-07-04 10:04:00 +02:00
|
|
|
if use_data_dir:
|
2018-06-18 12:50:37 +02:00
|
|
|
s += ', destination: "data/{name}"'
|
2018-03-30 10:49:45 +02:00
|
|
|
s += '});\n'
|
2017-09-06 16:37:23 +02:00
|
|
|
return s
|
2017-04-16 17:43:07 +02:00
|
|
|
|
2018-08-16 20:48:00 +02:00
|
|
|
def add_shaders(path, rel_path=False):
|
|
|
|
if rel_path:
|
|
|
|
path = os.path.relpath(path, arm.utils.get_fp()).replace('\\', '/')
|
|
|
|
return 'project.addShaders("' + path + '");\n'
|
|
|
|
|
2018-05-01 13:58:36 +02:00
|
|
|
def remove_readonly(func, path, excinfo):
|
|
|
|
os.chmod(path, stat.S_IWRITE)
|
|
|
|
func(path)
|
|
|
|
|
2018-06-19 23:21:53 +02:00
|
|
|
def write_khafilejs(is_play, export_physics, export_navigation, export_ui, is_publish, enable_dce, is_viewport, import_traits, import_logicnodes):
|
2017-03-15 12:30:14 +01:00
|
|
|
sdk_path = arm.utils.get_sdk_path()
|
2018-08-16 20:48:00 +02:00
|
|
|
rel_path = arm.utils.get_relative_paths() # Convert absolute paths to relative
|
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
|
|
|
|
|
|
|
# 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'):
|
2018-04-25 22:38:52 +02:00
|
|
|
# Copy to enable includes
|
2018-05-01 13:58:36 +02:00
|
|
|
if os.path.exists(arm.utils.build_dir() + '/compiled/Shaders/Project'):
|
|
|
|
shutil.rmtree(arm.utils.build_dir() + '/compiled/Shaders/Project', onerror=remove_readonly)
|
2018-04-25 22:38:52 +02:00
|
|
|
shutil.copytree('Shaders', arm.utils.build_dir() + '/compiled/Shaders/Project')
|
|
|
|
f.write("project.addShaders('" + arm.utils.build_dir() + "/compiled/Shaders/Project/**');\n")
|
|
|
|
# for file in glob.glob("Shaders/**", recursive=True):
|
|
|
|
# if os.path.isfile(file):
|
|
|
|
# assets.add_shader(file)
|
2017-09-17 16:59:00 +02:00
|
|
|
|
2017-09-05 00:36:16 +02:00
|
|
|
if not os.path.exists('Libraries/armory'):
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_armory_library(sdk_path, 'armory', rel_path=rel_path))
|
2017-02-09 00:33:19 +01:00
|
|
|
|
2017-09-05 00:36:16 +02:00
|
|
|
if not os.path.exists('Libraries/iron'):
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_armory_library(sdk_path, 'iron', rel_path=rel_path))
|
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):
|
2018-07-10 16:05:38 +02:00
|
|
|
f.write('project.addLibrary("{0}");\n'.format(lib.replace('//', '/')))
|
2016-06-30 13:22:05 +02:00
|
|
|
|
2018-05-13 21:17:40 +02:00
|
|
|
# Subprojects, merge this with libraries
|
2018-05-13 22:21:22 +02:00
|
|
|
if os.path.exists('Subprojects'):
|
|
|
|
libs = os.listdir('Subprojects')
|
2018-05-13 21:17:40 +02:00
|
|
|
for lib in libs:
|
2018-05-13 22:21:22 +02:00
|
|
|
if os.path.isdir('Subprojects/' + lib):
|
|
|
|
f.write('await project.addProject("Subprojects/{0}");\n'.format(lib))
|
2018-05-13 21:17:40 +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')
|
2018-06-24 13:05:24 +02:00
|
|
|
if wrd.arm_physics_engine == 'Bullet':
|
2017-09-30 00:32:06 +02:00
|
|
|
assets.add_khafile_def('arm_bullet')
|
|
|
|
if not os.path.exists('Libraries/haxebullet'):
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_armory_library(sdk_path + '/lib/', 'haxebullet', rel_path=rel_path))
|
2018-03-22 22:41:25 +01:00
|
|
|
if state.target.startswith('krom') or state.target == 'html5' or state.target == 'node':
|
2017-09-30 00:32:06 +02:00
|
|
|
ammojs_path = sdk_path + '/lib/haxebullet/js/ammo/ammo.js'
|
2018-07-10 16:05:38 +02:00
|
|
|
ammojs_path = ammojs_path.replace('\\', '/').replace('//', '/')
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_assets(ammojs_path, rel_path=rel_path))
|
2018-02-18 19:10:14 +01:00
|
|
|
# haxe.macro.Compiler.includeFile(ammojs_path)
|
2018-06-24 13:05:24 +02:00
|
|
|
elif wrd.arm_physics_engine == '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'):
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_armory_library(sdk_path + '/lib/', 'oimo', rel_path=rel_path))
|
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'):
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_armory_library(sdk_path + '/lib/', 'haxerecast', rel_path=rel_path))
|
2018-03-22 22:41:25 +01:00
|
|
|
if state.target.startswith('krom') or state.target == 'html5':
|
2016-12-07 02:01:42 +01:00
|
|
|
recastjs_path = sdk_path + '/lib/haxerecast/js/recast/recast.js'
|
2018-07-10 16:05:38 +02:00
|
|
|
recastjs_path = recastjs_path.replace('\\', '/').replace('//', '/')
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_assets(recastjs_path, rel_path=rel_path))
|
2016-12-07 02:01:42 +01:00
|
|
|
|
2018-06-18 12:50:37 +02:00
|
|
|
if is_publish:
|
|
|
|
assets.add_khafile_def('arm_published')
|
2018-07-24 21:28:03 +02:00
|
|
|
if wrd.arm_asset_compression:
|
|
|
|
assets.add_khafile_def('arm_compress')
|
2018-06-18 12:50:37 +02:00
|
|
|
else:
|
|
|
|
pass
|
|
|
|
# f.write("""project.addParameter("--macro include('armory.trait')");\n""")
|
|
|
|
# f.write("""project.addParameter("--macro include('armory.trait.internal')");\n""")
|
|
|
|
# if export_physics:
|
|
|
|
# f.write("""project.addParameter("--macro include('armory.trait.physics')");\n""")
|
2018-06-24 13:05:24 +02:00
|
|
|
# if wrd.arm_physics_engine == 'Bullet':
|
2018-06-18 12:50:37 +02:00
|
|
|
# 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""")
|
|
|
|
|
|
|
|
# if import_logicnodes: # Live patching for logic nodes
|
|
|
|
# f.write("""project.addParameter("--macro include('armory.logicnode')");\n""")
|
2017-08-10 14:39:08 +02:00
|
|
|
|
2018-08-21 18:29:05 +02:00
|
|
|
if not wrd.arm_compiler_inline:
|
|
|
|
f.write("project.addParameter('--no-inline');\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")
|
|
|
|
|
2018-06-20 14:57:37 +02:00
|
|
|
if is_viewport or wrd.arm_play_console:
|
2018-06-18 16:00:27 +02:00
|
|
|
import_traits.append('armory.trait.internal.Bridge')
|
2017-11-20 15:16:52 +01:00
|
|
|
|
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-02 16:41:36 +02:00
|
|
|
shaderload = state.target == 'krom' or state.target == 'html5'
|
2018-03-24 14:46:54 +01:00
|
|
|
if arm.utils.get_player_gapi() != 'opengl': # TODO: shader from source for d3d11
|
|
|
|
shaderload = False
|
2017-06-02 16:41:36 +02:00
|
|
|
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
|
|
|
|
2018-08-30 15:42:25 +02:00
|
|
|
# Add compiled shaders all at once when threaded
|
|
|
|
threaded = arm.utils.get_khamake_threads() > 1
|
|
|
|
if threaded:
|
|
|
|
shaders_path = arm.utils.build_dir() + '/compiled/Shaders/*.glsl'
|
|
|
|
if rel_path:
|
|
|
|
shaders_path = os.path.relpath(shaders_path, arm.utils.get_fp()).replace('\\', '/')
|
|
|
|
f.write('project.addShaders("' + shaders_path + '");\n')
|
|
|
|
else:
|
|
|
|
shader_references = sorted(list(set(assets.shaders)))
|
|
|
|
for ref in shader_references:
|
|
|
|
ref = ref.replace('\\', '/').replace('//', '/')
|
|
|
|
f.write(add_shaders(ref, rel_path=rel_path))
|
|
|
|
# noprocessing for passthrough geom shader
|
|
|
|
# if ref.endswith('voxel.geom.glsl'):
|
|
|
|
# f.write(', { noprocessing: true }')
|
2018-07-04 10:04:00 +02:00
|
|
|
|
|
|
|
# Move assets for published game to /data folder
|
2018-07-10 13:00:56 +02:00
|
|
|
use_data_dir = is_publish and (state.target == 'krom-windows' or state.target == 'krom-linux' or state.target == 'windows' or state.target == 'linux')
|
2018-07-04 10:04:00 +02:00
|
|
|
if use_data_dir:
|
|
|
|
assets.add_khafile_def('arm_data_dir')
|
2017-03-20 13:23:31 +01:00
|
|
|
|
2018-08-30 15:42:25 +02:00
|
|
|
# Add compiled assets all at once when threaded
|
|
|
|
if threaded:
|
|
|
|
assets_path = arm.utils.build_dir() + '/compiled/Assets/**'
|
|
|
|
assets_path_sh = arm.utils.build_dir() + '/compiled/Shaders/*.arm'
|
|
|
|
if rel_path:
|
|
|
|
assets_path = os.path.relpath(assets_path, arm.utils.get_fp()).replace('\\', '/')
|
|
|
|
assets_path_sh = os.path.relpath(assets_path_sh, arm.utils.get_fp()).replace('\\', '/')
|
2018-09-11 22:16:07 +02:00
|
|
|
dest = ''
|
|
|
|
if use_data_dir:
|
2018-09-11 22:24:35 +02:00
|
|
|
dest += ', destination: "data/{name}"'
|
|
|
|
f.write('project.addAssets("' + assets_path + '", { notinlist: true ' + dest + '});\n')
|
|
|
|
f.write('project.addAssets("' + assets_path_sh + '", { notinlist: true ' + dest + '});\n')
|
2018-08-30 15:42:25 +02: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:
|
2018-07-10 16:05:38 +02:00
|
|
|
ref = ref.replace('\\', '/').replace('//', '/')
|
2018-08-30 15:42:25 +02:00
|
|
|
if threaded and '/compiled/' in ref: # Asset already included
|
|
|
|
continue
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_assets(ref, use_data_dir=use_data_dir, rel_path=rel_path))
|
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:
|
2018-07-10 16:05:38 +02:00
|
|
|
ref = ref.replace('\\', '/').replace('//', '/')
|
2018-08-30 15:42:25 +02:00
|
|
|
if threaded and '/compiled/' in ref: # Asset already included
|
|
|
|
continue
|
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
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_assets(ref, quality=quality, use_data_dir=use_data_dir, rel_path=rel_path))
|
2017-09-06 16:37:23 +02:00
|
|
|
|
|
|
|
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')
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_shaders(sdk_path + "/armory/Shaders/debug_draw/**", rel_path=rel_path))
|
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'):
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_armory_library(sdk_path, 'lib/zui', rel_path=rel_path))
|
2017-02-28 13:48:19 +01:00
|
|
|
p = sdk_path + '/armory/Assets/droid_sans.ttf'
|
2018-07-10 16:05:38 +02:00
|
|
|
p = p.replace('//', '/')
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_assets(p.replace('\\', '/'), use_data_dir=use_data_dir, rel_path=rel_path))
|
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'):
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_armory_library(sdk_path, 'lib/hscript', rel_path=rel_path))
|
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'):
|
2018-08-16 20:48:00 +02:00
|
|
|
f.write(add_armory_library(sdk_path, 'lib/iron_format', rel_path=rel_path))
|
2018-04-14 15:07:05 +02:00
|
|
|
|
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')
|
2018-04-14 15:07:05 +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
|
|
|
|
2018-03-15 16:02:56 +01:00
|
|
|
rpdat = arm.utils.get_rp()
|
|
|
|
if rpdat.arm_skin == 'CPU':
|
2017-10-10 09:57:23 +02:00
|
|
|
assets.add_khafile_def('arm_skin_cpu')
|
2018-03-15 16:02:56 +01:00
|
|
|
elif rpdat.arm_skin == 'GPU (Matrix)':
|
2017-10-10 09:57:23 +02:00
|
|
|
assets.add_khafile_def('arm_skin_mat')
|
2018-07-24 21:28:03 +02:00
|
|
|
if rpdat.arm_skin != 'Off':
|
|
|
|
assets.add_khafile_def('arm_skin')
|
2016-08-23 22:55:46 +02:00
|
|
|
|
2018-08-16 17:16:35 +02:00
|
|
|
if rpdat.arm_particles == 'GPU':
|
|
|
|
assets.add_khafile_def('arm_particles_gpu')
|
|
|
|
if rpdat.arm_particles != 'Off':
|
|
|
|
assets.add_khafile_def('arm_particles')
|
|
|
|
|
2018-09-08 12:34:12 +02:00
|
|
|
if rpdat.rp_draw_order == 'Distance':
|
|
|
|
assets.add_khafile_def('arm_draworder_dist')
|
|
|
|
|
2017-11-10 14:53:40 +01:00
|
|
|
if arm.utils.get_viewport_controls() == 'azerty':
|
|
|
|
assets.add_khafile_def('arm_azerty')
|
|
|
|
|
2018-08-26 18:42:10 +02:00
|
|
|
if os.path.exists(arm.utils.get_fp() + '/Bundled/config.arm'):
|
|
|
|
assets.add_khafile_def('arm_config')
|
|
|
|
|
|
|
|
if is_publish and wrd.arm_loadscreen:
|
|
|
|
assets.add_khafile_def('arm_loadscreen')
|
|
|
|
|
2018-06-15 12:25:53 +02:00
|
|
|
# if bpy.data.scenes[0].unit_settings.system_rotation == 'DEGREES':
|
|
|
|
# assets.add_khafile_def('arm_degrees')
|
|
|
|
|
2018-04-14 15:07:05 +02:00
|
|
|
assets.add_khafile_def('arm_fast')
|
|
|
|
|
2016-07-28 13:21:27 +02:00
|
|
|
for d in assets.khafile_defs:
|
|
|
|
f.write("project.addDefine('" + d + "');\n")
|
|
|
|
|
2018-02-25 19:01:22 +01:00
|
|
|
khafile_text = wrd.arm_khafile
|
|
|
|
if khafile_text != '':
|
|
|
|
f.write(bpy.data.texts[khafile_text].as_string())
|
2016-01-11 13:50:54 +01:00
|
|
|
|
2017-12-11 14:43:40 +01:00
|
|
|
if state.target == 'android-native':
|
2018-06-13 14:00:01 +02:00
|
|
|
bundle = 'org.armory3d.' + wrd.arm_project_package if wrd.arm_project_bundle == '' else wrd.arm_project_bundle
|
|
|
|
f.write("project.targetOptions.android_native.package = '{0}';\n".format(arm.utils.safestr(bundle)))
|
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()))
|
2018-06-13 14:00:01 +02:00
|
|
|
elif state.target == 'ios':
|
|
|
|
bundle = 'org.armory3d.' + wrd.arm_project_package if wrd.arm_project_bundle == '' else wrd.arm_project_bundle
|
|
|
|
f.write("project.targetOptions.ios.bundle = '{0}';\n".format(arm.utils.safestr(bundle)))
|
|
|
|
|
|
|
|
if wrd.arm_project_icon != '':
|
|
|
|
shutil.copy(bpy.path.abspath(wrd.arm_project_icon), arm.utils.get_fp() + '/icon.png')
|
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
|
|
|
|
2018-02-25 19:01:22 +01:00
|
|
|
def get_winmode(arm_winmode):
|
|
|
|
if arm_winmode == 'Window':
|
|
|
|
return 0
|
2018-07-15 19:55:36 +02:00
|
|
|
else: # Fullscreen
|
2018-02-25 19:01:22 +01:00
|
|
|
return 1
|
|
|
|
|
|
|
|
def write_config(resx, resy):
|
|
|
|
wrd = bpy.data.worlds['Arm']
|
|
|
|
p = arm.utils.get_fp() + '/Bundled'
|
|
|
|
if not os.path.exists(p):
|
|
|
|
os.makedirs(p)
|
|
|
|
output = {}
|
|
|
|
output['window_mode'] = get_winmode(wrd.arm_winmode)
|
2018-08-20 16:27:09 +02:00
|
|
|
output['window_w'] = int(resx)
|
|
|
|
output['window_h'] = int(resy)
|
2018-08-29 23:01:23 +02:00
|
|
|
output['window_resizable'] = wrd.arm_winresize
|
|
|
|
output['window_maximizable'] = wrd.arm_winmaximize
|
|
|
|
output['window_minimizable'] = wrd.arm_winminimize
|
|
|
|
output['window_vsync'] = wrd.arm_vsync
|
2018-02-25 19:01:22 +01:00
|
|
|
rpdat = arm.utils.get_rp()
|
2018-08-20 16:27:09 +02:00
|
|
|
output['window_msaa'] = int(rpdat.arm_samples_per_pixel)
|
2018-08-29 23:01:23 +02:00
|
|
|
output['window_scale'] = 1.0
|
|
|
|
output['rp_supersample'] = float(rpdat.rp_supersampling)
|
|
|
|
rp_shadowmap = 0 if rpdat.rp_shadowmap == 'Off' else int(rpdat.rp_shadowmap)
|
|
|
|
output['rp_shadowmap'] = rp_shadowmap
|
|
|
|
output['rp_ssgi'] = rpdat.rp_ssgi != 'Off'
|
|
|
|
output['rp_ssr'] = rpdat.rp_ssr != 'Off'
|
|
|
|
output['rp_bloom'] = rpdat.rp_bloom != 'Off'
|
|
|
|
output['rp_motionblur'] = rpdat.rp_motionblur != 'Off'
|
|
|
|
output['rp_gi'] = rpdat.rp_gi != 'Off'
|
2018-02-25 19:01:22 +01:00
|
|
|
with open(p + '/config.arm', 'w') as f:
|
|
|
|
f.write(json.dumps(output, sort_keys=True, indent=4))
|
|
|
|
|
2018-08-26 18:42:10 +02:00
|
|
|
def write_mainhx(scene_name, resx, resy, is_play, is_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 ''
|
2018-04-14 15:07:05 +02:00
|
|
|
if scene_ext == '' and not wrd.arm_minimize:
|
|
|
|
scene_ext = '.json'
|
2018-02-25 19:01:22 +01:00
|
|
|
winmode = get_winmode(wrd.arm_winmode)
|
2018-06-19 23:21:53 +02:00
|
|
|
if is_viewport:
|
2018-02-25 19:01:22 +01:00
|
|
|
winmode = 0
|
2018-08-26 18:42:10 +02: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
|
|
|
|
elif rpdat.rp_driver != 'Armory':
|
|
|
|
pathpack = rpdat.rp_driver.lower()
|
|
|
|
|
2016-06-30 13:22:05 +02:00
|
|
|
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) + """';
|
2018-08-26 18:42:10 +02:00
|
|
|
public static inline var projectPackage = '""" + arm.utils.safestr(wrd.arm_project_package) + """';""")
|
2017-08-10 14:10:37 +02:00
|
|
|
|
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) + """;
|
2018-08-26 18:42:10 +02:00
|
|
|
public static inline var voxelgiHalfExtents = """ + str(round(rpdat.arm_voxelgi_dimensions / 2.0)) + """;""")
|
2017-10-12 12:12:48 +02:00
|
|
|
|
2018-04-20 00:56:54 +02:00
|
|
|
if rpdat.arm_rp_resolution == 'Custom':
|
|
|
|
f.write("""
|
2018-08-26 18:42:10 +02:00
|
|
|
public static inline var resolutionSize = """ + str(rpdat.arm_rp_resolution_size) + """;""")
|
2018-04-20 00:56:54 +02:00
|
|
|
|
2017-07-03 15:16:15 +02:00
|
|
|
f.write("""
|
2018-08-26 18:42:10 +02:00
|
|
|
public static function main() {""")
|
2018-07-24 21:28:03 +02:00
|
|
|
if rpdat.arm_skin != 'Off':
|
|
|
|
f.write("""
|
2018-08-26 18:42:10 +02:00
|
|
|
iron.object.BoneAnimation.skinMaxBones = """ + str(rpdat.arm_skin_max_bones) + """;""")
|
2017-11-15 13:34:51 +01:00
|
|
|
if rpdat.rp_shadowmap_cascades != '1':
|
|
|
|
f.write("""
|
2018-08-28 15:10:28 +02:00
|
|
|
iron.object.LightObject.cascadeCount = """ + str(rpdat.rp_shadowmap_cascades) + """;
|
|
|
|
iron.object.LightObject.cascadeSplitFactor = """ + str(rpdat.arm_shadowmap_split) + """;""")
|
2018-07-04 10:04:00 +02:00
|
|
|
if rpdat.arm_shadowmap_bounds != 1.0:
|
|
|
|
f.write("""
|
2018-08-28 15:10:28 +02:00
|
|
|
iron.object.LightObject.cascadeBounds = """ + str(rpdat.arm_shadowmap_bounds) + """;""")
|
2018-01-22 18:46:38 +01:00
|
|
|
if is_publish and wrd.arm_loadscreen:
|
2018-02-25 19:01:22 +01:00
|
|
|
asset_references = list(set(assets.assets))
|
2018-01-22 18:46:38 +01:00
|
|
|
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-08-26 18:42:10 +02:00
|
|
|
armory.system.Starter.numAssets = """ + str(len(asset_references)) + """;
|
|
|
|
armory.system.Starter.drawLoading = """ + loadscreen_class + """.render;""")
|
2016-09-23 00:34:42 +02:00
|
|
|
f.write("""
|
2018-08-26 18:42:10 +02:00
|
|
|
armory.system.Starter.main(
|
|
|
|
'""" + arm.utils.safestr(scene_name) + scene_ext + """',
|
|
|
|
""" + str(winmode) + """,
|
|
|
|
""" + ('true' if wrd.arm_winresize else 'false') + """,
|
|
|
|
""" + ('true' if wrd.arm_winminimize else 'false') + """,
|
|
|
|
""" + ('true' if wrd.arm_winmaximize else 'false') + """,
|
|
|
|
""" + str(resx) + """,
|
|
|
|
""" + str(resy) + """,
|
|
|
|
""" + str(int(rpdat.arm_samples_per_pixel)) + """,
|
|
|
|
""" + ('true' if wrd.arm_vsync else 'false') + """,
|
|
|
|
""" + pathpack + """.renderpath.RenderPathCreator.get
|
|
|
|
);
|
2016-06-30 13:22:05 +02:00
|
|
|
}
|
2015-12-07 21:05:27 +01:00
|
|
|
}
|
|
|
|
""")
|
2016-07-10 00:51:39 +02:00
|
|
|
|
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>
|
|
|
|
""")
|
|
|
|
|
2018-02-27 20:27:27 +01:00
|
|
|
add_compiledglsl = ''
|
2018-02-18 19:10:14 +01:00
|
|
|
def write_compiledglsl(defs):
|
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)
|
2018-08-30 15:42:25 +02:00
|
|
|
with open(arm.utils.build_dir() + '/compiled/Shaders/compiled.inc', '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_
|
2018-02-18 19:10:14 +01:00
|
|
|
""")
|
|
|
|
for d in defs:
|
|
|
|
f.write("#define " + d + "\n")
|
|
|
|
f.write("""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) + """);
|
2018-03-15 16:02:56 +01:00
|
|
|
const float shadowmapCubePcfSize = """ + str((round(rpdat.arm_pcfsize * 100) / 100) / 1000) + """;
|
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(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float cloudsDensity = """ + str(round(rpdat.arm_clouds_density * 100) / 100) + """;
|
|
|
|
const float cloudsSize = """ + str(round(rpdat.arm_clouds_size * 100) / 100) + """;
|
|
|
|
const float cloudsLower = """ + str(round(rpdat.arm_clouds_lower * 1000)) + """;
|
|
|
|
const float cloudsUpper = """ + str(round(rpdat.arm_clouds_upper * 1000)) + """;
|
|
|
|
const vec2 cloudsWind = vec2(""" + str(round(rpdat.arm_clouds_wind[0] * 1000) / 1000) + """, """ + str(round(rpdat.arm_clouds_wind[1] * 1000) / 1000) + """);
|
|
|
|
const float cloudsSecondary = """ + str(round(rpdat.arm_clouds_secondary * 100) / 100) + """;
|
|
|
|
const float cloudsPrecipitation = """ + str(round(rpdat.arm_clouds_precipitation * 100) / 100) + """;
|
|
|
|
const float cloudsEccentricity = """ + str(round(rpdat.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(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float seaLevel = """ + str(round(rpdat.arm_ocean_level * 100) / 100) + """;
|
|
|
|
const float seaMaxAmplitude = """ + str(round(rpdat.arm_ocean_amplitude * 100) / 100) + """;
|
|
|
|
const float seaHeight = """ + str(round(rpdat.arm_ocean_height * 100) / 100) + """;
|
|
|
|
const float seaChoppy = """ + str(round(rpdat.arm_ocean_choppy * 100) / 100) + """;
|
|
|
|
const float seaSpeed = """ + str(round(rpdat.arm_ocean_speed * 100) / 100) + """;
|
|
|
|
const float seaFreq = """ + str(round(rpdat.arm_ocean_freq * 100) / 100) + """;
|
|
|
|
const vec3 seaBaseColor = vec3(""" + str(round(rpdat.arm_ocean_base_color[0] * 100) / 100) + """, """ + str(round(rpdat.arm_ocean_base_color[1] * 100) / 100) + """, """ + str(round(rpdat.arm_ocean_base_color[2] * 100) / 100) + """);
|
|
|
|
const vec3 seaWaterColor = vec3(""" + str(round(rpdat.arm_ocean_water_color[0] * 100) / 100) + """, """ + str(round(rpdat.arm_ocean_water_color[1] * 100) / 100) + """, """ + str(round(rpdat.arm_ocean_water_color[2] * 100) / 100) + """);
|
|
|
|
const float seaFade = """ + str(round(rpdat.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(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float ssaoSize = """ + str(round((rpdat.arm_ssgi_step / 16) * 100) / 100) + """;
|
|
|
|
const float ssaoStrength = """ + str(round((rpdat.arm_ssgi_strength / 10) * 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(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const int ssgiMaxSteps = """ + str(rpdat.arm_ssgi_max_steps) + """;
|
|
|
|
const float ssgiRayStep = 0.005 * """ + str(round(rpdat.arm_ssgi_step * 100) / 100) + """;
|
|
|
|
const float ssgiStrength = """ + str(round(rpdat.arm_ssgi_strength * 100) / 100) + """;
|
2017-11-04 16:16:07 +01:00
|
|
|
""")
|
|
|
|
|
|
|
|
if rpdat.rp_bloom:
|
|
|
|
f.write(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float bloomThreshold = """ + str(round(rpdat.arm_bloom_threshold * 100) / 100) + """;
|
|
|
|
const float bloomStrength = """ + str(round(rpdat.arm_bloom_strength * 100) / 100) + """;
|
|
|
|
const float bloomRadius = """ + str(round(rpdat.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(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float motionBlurIntensity = """ + str(round(rpdat.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(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float ssrRayStep = """ + str(round(rpdat.arm_ssr_ray_step * 100) / 100) + """;
|
|
|
|
const float ssrMinRayStep = """ + str(round(rpdat.arm_ssr_min_ray_step * 100) / 100) + """;
|
|
|
|
const float ssrSearchDist = """ + str(round(rpdat.arm_ssr_search_dist * 100) / 100) + """;
|
|
|
|
const float ssrFalloffExp = """ + str(round(rpdat.arm_ssr_falloff_exp * 100) / 100) + """;
|
|
|
|
const float ssrJitter = """ + str(round(rpdat.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(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float ssrsRayStep = """ + str(round(rpdat.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(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float volumAirTurbidity = """ + str(round(rpdat.arm_volumetric_light_air_turbidity * 100) / 100) + """;
|
|
|
|
const vec3 volumAirColor = vec3(""" + str(round(rpdat.arm_volumetric_light_air_color[0] * 100) / 100) + """, """ + str(round(rpdat.arm_volumetric_light_air_color[1] * 100) / 100) + """, """ + str(round(rpdat.arm_volumetric_light_air_color[2] * 100) / 100) + """);
|
|
|
|
const int volumSteps = """ + str(rpdat.arm_volumetric_light_steps) + """;
|
2017-11-18 22:52:41 +01:00
|
|
|
""")
|
|
|
|
|
|
|
|
if rpdat.rp_autoexposure:
|
|
|
|
f.write(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float autoExposureStrength = """ + str(rpdat.arm_autoexposure_strength) + """;
|
2016-08-15 23:45:03 +02:00
|
|
|
""")
|
|
|
|
|
2016-08-23 22:55:46 +02:00
|
|
|
# Compositor
|
2018-03-15 16:02:56 +01:00
|
|
|
if rpdat.arm_letterbox:
|
2016-08-15 23:45:03 +02:00
|
|
|
f.write(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float compoLetterboxSize = """ + str(round(rpdat.arm_letterbox_size * 100) / 100) + """;
|
2016-08-15 23:45:03 +02:00
|
|
|
""")
|
|
|
|
|
2018-03-15 16:02:56 +01:00
|
|
|
if rpdat.arm_grain:
|
2016-08-15 23:45:03 +02:00
|
|
|
f.write(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float compoGrainStrength = """ + str(round(rpdat.arm_grain_strength * 100) / 100) + """;
|
2018-03-02 17:02:27 +01:00
|
|
|
""")
|
|
|
|
|
2018-03-15 16:02:56 +01:00
|
|
|
if rpdat.arm_sharpen:
|
2018-03-02 17:02:27 +01:00
|
|
|
f.write(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float compoSharpenStrength = """ + str(round(rpdat.arm_sharpen_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) + """;
|
|
|
|
""")
|
|
|
|
|
2018-03-15 16:02:56 +01:00
|
|
|
if rpdat.arm_fog:
|
2016-08-15 23:45:03 +02:00
|
|
|
f.write(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float compoFogAmountA = """ + str(round(rpdat.arm_fog_amounta * 100) / 100) + """;
|
|
|
|
const float compoFogAmountB = """ + str(round(rpdat.arm_fog_amountb * 100) / 100) + """;
|
|
|
|
const vec3 compoFogColor = vec3(""" + str(round(rpdat.arm_fog_color[0] * 100) / 100) + """, """ + str(round(rpdat.arm_fog_color[1] * 100) / 100) + """, """ + str(round(rpdat.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))) + """);
|
2018-03-15 16:02:56 +01:00
|
|
|
const float voxelgiDiff = """ + str(round(rpdat.arm_voxelgi_diff * 100) / 100) + """;
|
|
|
|
const float voxelgiSpec = """ + str(round(rpdat.arm_voxelgi_spec * 100) / 100) + """;
|
|
|
|
const float voxelgiOcc = """ + str(round(rpdat.arm_voxelgi_occ * 100) / 100) + """;
|
|
|
|
const float voxelgiEnv = """ + str(round(rpdat.arm_voxelgi_env * 100) / 100) + """ / 10.0;
|
|
|
|
const float voxelgiStep = """ + str(round(rpdat.arm_voxelgi_step * 100) / 100) + """;
|
|
|
|
const float voxelgiRange = """ + str(round(rpdat.arm_voxelgi_range * 100) / 100) + """;
|
2018-03-26 00:30:24 +02:00
|
|
|
const float voxelgiOffset = """ + str(round(rpdat.arm_voxelgi_offset * 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(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const float sssWidth = """ + str(rpdat.arm_sss_width / 10.0) + """;
|
2016-08-23 22:55:46 +02:00
|
|
|
""")
|
|
|
|
|
|
|
|
# Skinning
|
2018-03-15 16:02:56 +01:00
|
|
|
if rpdat.arm_skin.startswith('GPU'):
|
2016-08-23 22:55:46 +02:00
|
|
|
f.write(
|
2018-03-15 16:02:56 +01:00
|
|
|
"""const int skinMaxBones = """ + str(rpdat.arm_skin_max_bones) + """;
|
2016-07-10 00:51:39 +02:00
|
|
|
""")
|
|
|
|
|
2018-02-27 20:27:27 +01:00
|
|
|
f.write(add_compiledglsl + '\n') # External defined constants
|
|
|
|
|
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(
|
2018-07-02 10:29:16 +02:00
|
|
|
"""{ "name": "untitled", "x": 0.0, "y": 0.0, "width": 1280, "height": 720, "elements": [], "assets": [] }""")
|