Utils to armutils.

This commit is contained in:
Lubos Lenco 2016-10-27 01:11:11 +02:00
parent 0a00a28e1d
commit 509dc23ca3
21 changed files with 121 additions and 121 deletions

View file

@ -1,4 +1,4 @@
import utils
import armutils
import shutil
import os
@ -58,7 +58,7 @@ def invalidate_shader_cache(self, context):
global invalidate_enabled
if invalidate_enabled == False:
return
fp = utils.get_fp()
fp = armutils.get_fp()
if os.path.isdir(fp + '/build/compiled/ShaderDatas'):
shutil.rmtree(fp + '/build/compiled/ShaderDatas')
@ -66,13 +66,13 @@ def invalidate_compiled_data(self, context):
global invalidate_enabled
if invalidate_enabled == False:
return
fp = utils.get_fp()
fp = armutils.get_fp()
if os.path.isdir(fp + '/build/compiled/Assets'):
shutil.rmtree(fp + '/build/compiled/Assets')
if os.path.isdir(fp + '/build/compiled/ShaderDatas'):
shutil.rmtree(fp + '/build/compiled/ShaderDatas')
def invalidate_mesh_data(self, context):
fp = utils.get_fp()
fp = armutils.get_fp()
if os.path.isdir(fp + '/build/compiled/Assets/meshes'):
shutil.rmtree(fp + '/build/compiled/Assets/meshes')

View file

@ -1,6 +1,6 @@
# Translating operators from/to Armory player
import bpy
import utils
import armutils
try:
import barmory
except ImportError:
@ -27,7 +27,7 @@ def parse_operator(text):
def send_operator(op):
# Try to translate operator directly to armory
if utils.with_chromium() and bpy.context.object != None:
if armutils.with_chromium() and bpy.context.object != None:
objname = bpy.context.object.name
if op.name == 'Translate':
vec = bpy.context.object.location

View file

@ -18,7 +18,7 @@ import time
import ast
import write_probes
import assets
import utils
import armutils
import subprocess
import log
import make_material
@ -1225,7 +1225,7 @@ class ArmoryExporter:
else:
self.meshArray[objref]["objectTable"].append(bobject)
oid = utils.safe_filename(self.meshArray[objref]["structName"])
oid = armutils.safe_filename(self.meshArray[objref]["structName"])
if ArmoryExporter.option_mesh_per_file:
ext = ''
if self.is_compress(objref):
@ -1303,7 +1303,7 @@ class ArmoryExporter:
action = bpy.data.actions[bobject.start_action_name_prop]
else: # Use default
action = bobject.animation_data.action
armatureid = utils.safe_filename(armdata.name)
armatureid = armutils.safe_filename(armdata.name)
ext = ''
if self.is_compress(armdata):
ext = '.zip'
@ -1334,7 +1334,7 @@ class ArmoryExporter:
# Save bones separately
bones_obj = {}
bones_obj['objects'] = bones
utils.write_arm(fp, bones_obj)
armutils.write_arm(fp, bones_obj)
armdata.data_cached = True
if (parento == None):
@ -1526,7 +1526,7 @@ class ArmoryExporter:
if ArmoryExporter.option_mesh_per_file:
mesh_obj = {}
mesh_obj['mesh_datas'] = [o]
utils.write_arm(fp, mesh_obj)
armutils.write_arm(fp, mesh_obj)
bobject.data.mesh_cached = True
if bobject.type != 'FONT':
@ -1653,7 +1653,7 @@ class ArmoryExporter:
def do_export_mesh(self, objectRef, scene):
# This function exports a single mesh object
bobject = objectRef[1]["objectTable"][0]
oid = utils.safe_filename(objectRef[1]["structName"])
oid = armutils.safe_filename(objectRef[1]["structName"])
# Check if mesh is using instanced rendering
is_instanced, instance_offsets = self.object_process_instancing(bobject, objectRef[1]["objectTable"])
@ -2009,7 +2009,7 @@ class ArmoryExporter:
if objref.sound:
# Packed
if objref.sound.packed_file != None:
unpack_path = utils.get_fp() + '/build/compiled/Assets/unpacked'
unpack_path = armutils.get_fp() + '/build/compiled/Assets/unpacked'
if not os.path.exists(unpack_path):
os.makedirs(unpack_path)
unpack_filepath = unpack_path + '/' + objref.sound.name
@ -2019,10 +2019,10 @@ class ArmoryExporter:
assets.add(unpack_filepath)
# External
else:
assets.add(utils.safe_assetpath(objref.sound.filepath)) # Link sound to assets
assets.add(armutils.safe_assetpath(objref.sound.filepath)) # Link sound to assets
o['sound'] = utils.extract_filename(objref.sound.filepath)
o['sound'] = utils.safe_filename(o['sound'])
o['sound'] = armutils.extract_filename(objref.sound.filepath)
o['sound'] = armutils.safe_filename(o['sound'])
else:
o['sound'] = ''
o['muted'] = objref.muted
@ -2159,7 +2159,7 @@ class ArmoryExporter:
gpo = self.post_export_grease_pencil(gpRef)
gp_obj = {}
gp_obj['grease_pencil_datas'] = [gpo]
utils.write_arm(fp, gp_obj)
armutils.write_arm(fp, gp_obj)
gpRef.data_cached = True
def is_compress(self, obj):
@ -2222,7 +2222,7 @@ class ArmoryExporter:
self.process_skinned_meshes()
self.output['name'] = utils.safe_filename(self.scene.name)
self.output['name'] = armutils.safe_filename(self.scene.name)
if (self.filepath.endswith('.zip')):
self.output['name'] += '.zip'
@ -2235,7 +2235,7 @@ class ArmoryExporter:
if self.scene.camera != None:
self.output['camera_ref'] = self.scene.camera.name
else:
if utils.safe_filename(self.scene.name) == utils.get_project_scene_name():
if armutils.safe_filename(self.scene.name) == armutils.get_project_scene_name():
print('Armory Warning: No camera found in active scene')
self.output['material_datas'] = []
@ -2280,7 +2280,7 @@ class ArmoryExporter:
self.output['embedded_datas'].append(file)
# Write scene file
utils.write_arm(self.filepath, self.output)
armutils.write_arm(self.filepath, self.output)
print('Scene built in ' + str(time.time() - profile_time))
return {'FINISHED'}
@ -2429,13 +2429,13 @@ class ArmoryExporter:
x = {}
if t.type_prop == 'Logic Nodes' and t.nodes_name_prop != '':
x['type'] = 'Script'
x['class_name'] = bpy.data.worlds['Arm'].arm_project_package + '.node.' + utils.safe_filename(t.nodes_name_prop)
x['class_name'] = bpy.data.worlds['Arm'].arm_project_package + '.node.' + armutils.safe_filename(t.nodes_name_prop)
elif t.type_prop == 'JS Script' or t.type_prop == 'Python Script':
basename = t.jsscript_prop.split('.')[0]
x['type'] = 'Script'
x['class_name'] = 'armory.trait.internal.JSScript'
x['parameters'] = [utils.safe_filename(basename)]
scriptspath = utils.get_fp() + '/build/compiled/scripts/'
x['parameters'] = [armutils.safe_filename(basename)]
scriptspath = armutils.get_fp() + '/build/compiled/scripts/'
if not os.path.exists(scriptspath):
os.makedirs(scriptspath)
# Compile to JS
@ -2445,12 +2445,12 @@ class ArmoryExporter:
targetpath = scriptspath + basename_ext
with open(targetpath, 'w') as f:
f.write(bpy.data.texts[t.jsscript_prop].as_string())
sdk_path = utils.get_sdk_path()
sdk_path = armutils.get_sdk_path()
# Extract path to built-in python binary
if utils.get_os() == 'win':
if armutils.get_os() == 'win':
# Remove 'os.py' from path
python_path = os.__file__[:-5] + '../bin/python.exe'
elif utils.get_os() == 'mac':
elif armutils.get_os() == 'mac':
python_path = os.__file__[:-5] + '../../bin/python3.5m'
else:
python_path = os.__file__[:-5] + '../../bin/python3.5m'
@ -2467,7 +2467,7 @@ class ArmoryExporter:
else:
# Write js to file
assetpath = 'build/compiled/scripts/' + t.jsscript_prop + '.js'
targetpath = utils.get_fp() + '/' + assetpath
targetpath = armutils.get_fp() + '/' + assetpath
with open(targetpath, 'w') as f:
f.write(bpy.data.texts[t.jsscript_prop].as_string())
assets.add(assetpath)
@ -2775,9 +2775,9 @@ class ArmoryExporter:
if '_LDR' in defs:
for i in range(0, 3):
bgcol[i] = pow(bgcol[i], 1.0 / 2.2)
o['background_color'] = utils.color_to_int(bgcol)
o['background_color'] = armutils.color_to_int(bgcol)
wmat_name = utils.safe_filename(world.name) + '_material'
wmat_name = armutils.safe_filename(world.name) + '_material'
o['material_ref'] = wmat_name + '/' + wmat_name + '/world'
o['brdf'] = 'brdf.png'
o['probes'] = []

View file

@ -1,5 +1,5 @@
import bpy
import utils
import armutils
import make
import make_state as state
import space_armory
@ -49,7 +49,7 @@ def on_scene_update_post(context):
make.compile_project()
# Check if chromium is running
if utils.with_chromium():
if armutils.with_chromium():
for area in bpy.context.screen.areas:
if area.type == 'VIEW_ARMORY':
# Read chromium console
@ -88,7 +88,7 @@ def on_scene_update_post(context):
if state.chromium_running:
barmory.call_js('armory.Scene.patch();')
# Or switch to armory space
elif utils.with_chromium() and state.in_viewport:
elif armutils.with_chromium() and state.in_viewport:
state.play_area.type = 'VIEW_ARMORY'
# Prevent immediate operator patch
if len(ops) > 0:

View file

@ -1,5 +1,5 @@
import os
import utils
import armutils
def write_data(res, defs, json_data, base_name):
# Define
@ -268,7 +268,7 @@ def save_data(path, base_name, subset, res):
r = {}
r['shader_datas'] = [res['shader_datas'][-1]]
utils.write_arm(path + '/' + res_name + '.arm', r)
armutils.write_arm(path + '/' + res_name + '.arm', r)
def make(base_name, json_data, fp, defs):

View file

@ -1,13 +1,13 @@
import props_ui
import space_armory
import utils
import armutils
progress = 100.0
tag_redraw = False
def clear():
props_ui.ArmoryProjectPanel.info_text = ''
if utils.with_chromium():
if armutils.with_chromium():
space_armory.ArmorySpaceHeader.info_text = ''
def format_text(text):

View file

@ -14,7 +14,7 @@ import make_utils
import make_state as state
import path_tracer
from exporter import ArmoryExporter
import utils
import armutils
import assets
import log
import lib.make_datas
@ -25,7 +25,7 @@ exporter = ArmoryExporter()
def compile_shader(raw_shaders_path, shader_name, defs):
os.chdir(raw_shaders_path + './' + shader_name)
fp = utils.get_fp()
fp = armutils.get_fp()
# Open json file
json_name = shader_name + '.shader.json'
@ -64,7 +64,7 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
for scene in bpy.data.scenes:
if scene.game_export:
ext = '.zip' if (scene.data_compressed and is_publish) else '.arm'
asset_path = 'build/compiled/Assets/' + utils.safe_filename(scene.name) + ext
asset_path = 'build/compiled/Assets/' + armutils.safe_filename(scene.name) + ext
exporter.execute(bpy.context, asset_path)
if physics_found == False and ArmoryExporter.export_physics:
physics_found = True
@ -125,18 +125,18 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
shutil.copy(ammojs_path, 'build/debug-html5')
def compile_project(target_name=None, is_publish=False, watch=False):
sdk_path = utils.get_sdk_path()
ffmpeg_path = utils.get_ffmpeg_path()
sdk_path = armutils.get_sdk_path()
ffmpeg_path = armutils.get_ffmpeg_path()
wrd = bpy.data.worlds['Arm']
# Set build command
if target_name == None:
target_name = wrd.arm_project_target
if utils.get_os() == 'win':
if armutils.get_os() == 'win':
node_path = sdk_path + '/nodejs/node.exe'
khamake_path = sdk_path + '/kode/win32/resources/app/extensions/kha/Kha/make'
elif utils.get_os() == 'mac':
elif armutils.get_os() == 'mac':
node_path = sdk_path + '/nodejs/node-osx'
khamake_path = sdk_path + '/kode/Kode Studio.app/Contents/Resources/app/extensions/kha/Kha/make'
else:
@ -150,7 +150,7 @@ def compile_project(target_name=None, is_publish=False, watch=False):
cmd.append('--ffmpeg')
cmd.append('"' + ffmpeg_path + '"')
if utils.get_os() == 'win': # OpenGL for now
if armutils.get_os() == 'win': # OpenGL for now
cmd.append('-g')
cmd.append('opengl2')
@ -182,8 +182,8 @@ def compile_project(target_name=None, is_publish=False, watch=False):
# For live patching
def patch_project():
sdk_path = utils.get_sdk_path()
fp = utils.get_fp()
sdk_path = armutils.get_sdk_path()
fp = armutils.get_fp()
os.chdir(fp)
export_data(fp, sdk_path, is_play=True)
@ -205,11 +205,11 @@ def build_project(is_play=False, is_publish=False, in_viewport=False):
break
# Get paths
sdk_path = utils.get_sdk_path()
sdk_path = armutils.get_sdk_path()
raw_shaders_path = sdk_path + '/armory/Shaders/'
# Set dir
fp = utils.get_fp()
fp = armutils.get_fp()
os.chdir(fp)
# Create directories
@ -299,7 +299,7 @@ def watch_patch():
state.compileproc_finished = True
def play_project(self, in_viewport):
if utils.with_chromium() and in_viewport and bpy.context.area.type == 'VIEW_3D':
if armutils.with_chromium() and in_viewport and bpy.context.area.type == 'VIEW_3D':
state.play_area = bpy.context.area
# Build data
@ -317,15 +317,15 @@ def play_project(self, in_viewport):
# Windowed player
x = 0
y = 0
w, h = utils.get_render_resolution()
w, h = armutils.get_render_resolution()
winoff = 0
else:
# Player dimensions
if utils.get_os() == 'win':
if armutils.get_os() == 'win':
psize = 1 # Scale in electron
xoff = 0
yoff = 6
elif utils.get_os() == 'mac':
elif armutils.get_os() == 'mac':
psize = bpy.context.user_preferences.system.pixel_size
xoff = 5
yoff = 22
@ -353,13 +353,13 @@ def play_project(self, in_viewport):
def on_compiled(mode): # build, play, play_viewport, publish
log.clear()
sdk_path = utils.get_sdk_path()
sdk_path = armutils.get_sdk_path()
# Print info
if mode == 'publish':
target_name = make_utils.get_kha_target(bpy.data.worlds['Arm'].arm_publish_target)
print('Project published')
files_path = utils.get_fp() + '/build/' + target_name
files_path = armutils.get_fp() + '/build/' + target_name
if target_name == 'html5':
print('HTML5 files are located in ' + files_path)
elif target_name == 'ios' or target_name == 'osx': # TODO: to macos
@ -373,14 +373,14 @@ def on_compiled(mode): # build, play, play_viewport, publish
return
# Launch project in new window or frameless electron
elif (mode =='play') or (mode == 'play_viewport' and utils.with_chromium() == False):
elif (mode =='play') or (mode == 'play_viewport' and armutils.with_chromium() == False):
wrd = bpy.data.worlds['Arm']
if wrd.arm_play_runtime == 'Electron':
electron_app_path = './build/electron.js'
if utils.get_os() == 'win':
if armutils.get_os() == 'win':
electron_path = sdk_path + 'kode/win32/Kode Studio.exe'
elif utils.get_os() == 'mac':
elif armutils.get_os() == 'mac':
# electron_path = sdk_path + 'kode/Kode Studio.app/Contents/MacOS/Electron'
electron_path = sdk_path + 'kode/Electron.app/Contents/MacOS/Electron'
else:
@ -390,7 +390,7 @@ def on_compiled(mode): # build, play, play_viewport, publish
watch_play()
elif wrd.arm_play_runtime == 'Browser':
# Start server
os.chdir(utils.get_fp())
os.chdir(armutils.get_fp())
t = threading.Thread(name='localserver', target=lib.server.run)
t.daemon = True
t.start()
@ -399,7 +399,7 @@ def on_compiled(mode): # build, play, play_viewport, publish
def clean_project():
os.chdir(utils.get_fp())
os.chdir(armutils.get_fp())
wrd = bpy.data.worlds['Arm']

View file

@ -1,7 +1,7 @@
import bpy
import math
import assets
import utils
import armutils
import os
import nodes
@ -86,7 +86,7 @@ def make_texture(self, id, image_node, material, image_format='RGBA32'):
if image != None:
if image.packed_file != None:
# Extract packed data
unpack_path = utils.get_fp() + '/build/compiled/Assets/unpacked'
unpack_path = armutils.get_fp() + '/build/compiled/Assets/unpacked'
if not os.path.exists(unpack_path):
os.makedirs(unpack_path)
unpack_filepath = unpack_path + '/' + image.name
@ -98,10 +98,10 @@ def make_texture(self, id, image_node, material, image_format='RGBA32'):
assets.add(unpack_filepath)
else:
# Link image path to assets
assets.add(utils.safe_assetpath(image.filepath))
assets.add(armutils.safe_assetpath(image.filepath))
# Reference image name
tex['file'] = utils.extract_filename(image.filepath)
tex['file'] = utils.safe_filename(tex['file'])
tex['file'] = armutils.extract_filename(image.filepath)
tex['file'] = armutils.safe_filename(tex['file'])
if image_format != 'RGBA32':
tex['format'] = image_format
interpolation = image_node.interpolation

View file

@ -8,7 +8,7 @@ import platform
import subprocess
import make_compositor
import assets
import utils
import armutils
import nodes
def build_node_trees(assets_path):
@ -59,7 +59,7 @@ def build_node_tree(cam, node_group):
buildNode(dat['stages'], rn, node_group)
asset_path = path + node_group_name + '.arm'
utils.write_arm(asset_path, output)
armutils.write_arm(asset_path, output)
assets.add(asset_path)
def make_set_target(stage, node_group, node, currentNode=None, target_index=1, viewport_scale=1.0):
@ -106,7 +106,7 @@ def make_clear_target(stage, color_val=None, depth_val=None, stencil_val=None):
if color_val == -1: # Clear to world background color
stage['params'].append('-1')
else:
stage['params'].append(str(utils.to_hex(color_val)))
stage['params'].append(str(armutils.to_hex(color_val)))
if depth_val != None:
stage['params'].append('depth')
stage['params'].append(str(depth_val))

View file

@ -1,18 +1,18 @@
import utils
import armutils
import subprocess
def kode_studio():
sdk_path = utils.get_sdk_path()
project_path = utils.get_fp()
sdk_path = armutils.get_sdk_path()
project_path = armutils.get_fp()
if utils.get_os() == 'win':
if armutils.get_os() == 'win':
kode_path = sdk_path + '/kode/win32/Kode Studio.exe'
elif utils.get_os() == 'mac':
elif armutils.get_os() == 'mac':
kode_path = '"' + sdk_path + '/kode/Kode Studio.app/Contents/MacOS/Electron"'
else:
kode_path = sdk_path + '/kode/linux64/kodestudio'
subprocess.Popen([kode_path + ' ' + utils.get_fp()], shell=True)
subprocess.Popen([kode_path + ' ' + armutils.get_fp()], shell=True)
def def_strings_to_array(strdefs):
defs = strdefs.split('_')

View file

@ -5,7 +5,7 @@ import os
import json
import write_probes
import assets
import utils
import armutils
import nodes
def build_node_trees(active_worlds):
@ -29,7 +29,7 @@ def build_node_tree(world):
output = {}
dat = {}
output['material_datas'] = [dat]
dat['name'] = utils.safe_filename(world.name) + '_material'
dat['name'] = armutils.safe_filename(world.name) + '_material'
context = {}
dat['contexts'] = [context]
context['name'] = 'world'
@ -63,7 +63,7 @@ def build_node_tree(world):
# Percentage closer soft shadows
if wrd.generate_pcss:
wrd.world_defs += '_PCSS'
sdk_path = utils.get_sdk_path()
sdk_path = armutils.get_sdk_path()
assets.add(sdk_path + 'armory/Assets/noise64.png')
assets.add_embedded_data('noise64.png')
@ -99,7 +99,7 @@ def write_output(output):
# Write material json
path = 'build/compiled/Assets/materials/'
asset_path = path + dat['name'] + '.arm'
utils.write_arm(asset_path, output)
armutils.write_arm(asset_path, output)
assets.add(asset_path)
def parse_world_output(world, node, context):
@ -140,7 +140,7 @@ def parse_color(world, node, context, envmap_strength_const):
if image.packed_file != None:
# Extract packed data
filepath = '/build/compiled/Assets/unpacked'
unpack_path = utils.get_fp() + filepath
unpack_path = armutils.get_fp() + filepath
if not os.path.exists(unpack_path):
os.makedirs(unpack_path)
unpack_filepath = unpack_path + '/' + image.name
@ -150,11 +150,11 @@ def parse_color(world, node, context, envmap_strength_const):
assets.add(unpack_filepath)
else:
# Link image path to assets
assets.add(utils.safe_assetpath(image.filepath))
assets.add(armutils.safe_assetpath(image.filepath))
# Reference image name
texture['file'] = utils.extract_filename(image.filepath)
texture['file'] = utils.safe_filename(texture['file'])
texture['file'] = armutils.extract_filename(image.filepath)
texture['file'] = armutils.safe_filename(texture['file'])
# Generate prefiltered envmaps
generate_radiance = bpy.data.worlds['Arm'].generate_radiance
@ -200,7 +200,7 @@ def parse_color(world, node, context, envmap_strength_const):
if bpy.data.worlds['Arm'].generate_radiance_sky and bpy.data.worlds['Arm'].generate_radiance:
bpy.data.worlds['Arm'].world_defs += '_Rad'
sdk_path = utils.get_sdk_path()
sdk_path = armutils.get_sdk_path()
# Use fake maps for now
assets.add(sdk_path + 'armory/Assets/hosek/hosek_radiance.hdr')
for i in range(0, 8):

View file

@ -1,7 +1,7 @@
import bpy
from bpy.types import NodeTree, Node, NodeSocket
from bpy.props import *
import utils
import armutils
class CGPipelineTree(NodeTree):
'''Render path nodes'''
@ -832,7 +832,7 @@ def reload_blend_data():
pass
def load_library():
sdk_path = utils.get_sdk_path()
sdk_path = armutils.get_sdk_path()
data_path = sdk_path + '/armory/blender/data/data.blend'
data_names = ['forward_path', 'forward_path_low', 'deferred_path', 'deferred_path_low', 'deferred_path_high', 'hybrid_path', 'vr_path', 'pathtrace_path', 'grease_pencil_path', 'Armory PBR']

View file

@ -5,7 +5,7 @@ from props_traits_action import *
import props_ui
import assets
import log
import utils
import armutils
try:
import barmory
except ImportError:
@ -290,10 +290,10 @@ def init_properties():
l.use_nodes = True
for m in bpy.data.materials:
m.use_nodes = True
utils.fetch_script_names()
armutils.fetch_script_names()
# Path for embedded player
if utils.with_chromium():
barmory.set_url('file://' + utils.get_fp() + '/build/html5/index.html')
if armutils.with_chromium():
barmory.set_url('file://' + armutils.get_fp() + '/build/html5/index.html')
def register():
init_properties()

View file

@ -5,7 +5,7 @@ import json
from props_traits_params import *
from bpy.types import Menu, Panel, UIList
from bpy.props import *
import utils
import armutils
import write_data
import subprocess
@ -159,17 +159,17 @@ class ArmoryEditScriptButton(bpy.types.Operator):
bl_label = 'Edit Script'
def execute(self, context):
sdk_path = utils.get_sdk_path()
if utils.get_os() == 'win':
sdk_path = armutils.get_sdk_path()
if armutils.get_os() == 'win':
kode_path = sdk_path + '/kode/win32/Kode Studio.exe'
elif utils.get_os() == 'mac':
elif armutils.get_os() == 'mac':
kode_path = '"' + sdk_path + '/kode/Kode Studio.app/Contents/MacOS/Electron"'
else:
kode_path = sdk_path + '/kode/linux64/kodestudio'
project_path = utils.get_fp()
project_path = armutils.get_fp()
item = context.object.my_traitlist[context.object.traitlist_index]
hx_path = project_path + '/Sources/' + bpy.data.worlds['Arm'].arm_project_package + '/' + item.class_name_prop + '.hx'
subprocess.Popen([kode_path + ' ' + utils.get_fp() + ' ' + hx_path], shell=True)
subprocess.Popen([kode_path + ' ' + armutils.get_fp() + ' ' + hx_path], shell=True)
return{'FINISHED'}
class ArmoryNewScriptDialog(bpy.types.Operator):
@ -182,7 +182,7 @@ class ArmoryNewScriptDialog(bpy.types.Operator):
def execute(self, context):
self.class_name = self.class_name.replace(' ', '')
write_data.write_traithx(self.class_name)
utils.fetch_script_names()
armutils.fetch_script_names()
obj = context.object
item = obj.my_traitlist[obj.traitlist_index]
item.class_name_prop = self.class_name
@ -198,7 +198,7 @@ class ArmoryRefreshScriptsListButton(bpy.types.Operator):
bl_label = 'Refresh Scripts List'
def execute(self, context):
utils.fetch_script_names()
armutils.fetch_script_names()
return{'FINISHED'}
# Menu in tools region

View file

@ -4,7 +4,7 @@ import os
import json
from bpy.types import Menu, Panel, UIList
from bpy.props import *
from utils import to_hex
from armutils import to_hex
def object_picker_update(self, context):
o = context.object

View file

@ -5,7 +5,7 @@ from bpy.types import Menu, Panel, UIList
from bpy.props import *
from props_traits_clip import *
from props_traits_action import *
import utils
import armutils
import make
import make_utils
import make_state as state
@ -408,7 +408,7 @@ class ArmoryPlayPanel(bpy.types.Panel):
layout.prop(wrd, 'arm_play_advanced')
if wrd.arm_play_advanced:
layout.prop(wrd, 'arm_play_console')
if utils.with_chromium():
if armutils.with_chromium():
layout.prop(wrd, 'arm_play_live_patch')
if wrd.arm_play_live_patch:
layout.prop(wrd, 'arm_play_auto_build')
@ -546,7 +546,7 @@ class ArmoryFolderButton(bpy.types.Operator):
bl_label = 'Project Folder'
def execute(self, context):
webbrowser.open('file://' + utils.get_fp())
webbrowser.open('file://' + armutils.get_fp())
return{'FINISHED'}
class ArmoryCheckUpdatesButton(bpy.types.Operator):

View file

@ -2,7 +2,7 @@
import bpy
from bpy.types import Header
from bpy.app.translations import contexts as i18n_contexts
import utils
import armutils
import make
import make_state as state
import log
@ -60,9 +60,9 @@ class ArmorySpaceResumeButton(bpy.types.Operator):
return{'FINISHED'}
def register():
if utils.with_chromium():
if armutils.with_chromium():
bpy.utils.register_module(__name__)
def unregister():
if utils.with_chromium():
if armutils.with_chromium():
bpy.utils.unregister_module(__name__)

View file

@ -9,11 +9,11 @@ import props
import props_ui
import handlers
import space_armory
import utils
import armutils
import keymap
def register():
utils.register()
armutils.register()
props_traits_action.register()
props_traits_clip.register()
props.register()
@ -28,7 +28,7 @@ def register():
def unregister():
keymap.unregister()
utils.unregister()
armutils.unregister()
nodes_logic.unregister()
nodes_renderpath.unregister()
props_traits_params.unregister()

View file

@ -1,7 +1,7 @@
import bpy
import os
import assets
import utils
import armutils
def add_armory_library(sdk_path, name):
return ('project.addLibrary("../' + bpy.path.relpath(sdk_path + '/' + name)[2:] + '");\n').replace('\\', '/')
@ -9,7 +9,7 @@ def add_armory_library(sdk_path, name):
# Write khafile.js
def write_khafilejs(is_play, export_physics, dce_full=False):
sdk_path = utils.get_sdk_path()
sdk_path = armutils.get_sdk_path()
# Merge duplicates and sort
shader_references = sorted(list(set(assets.shaders)))
@ -78,8 +78,8 @@ project.addSources('Sources');
# Write Main.hx
def write_main(is_play, in_viewport, is_publish):
wrd = bpy.data.worlds['Arm']
resx, resy = utils.get_render_resolution()
scene_name = utils.get_project_scene_name()
resx, resy = armutils.get_render_resolution()
scene_name = armutils.get_project_scene_name()
scene_ext = '.zip' if (bpy.data.scenes[scene_name].data_compressed and is_publish) else ''
#if not os.path.isfile('Sources/Main.hx'):
with open('Sources/Main.hx', 'w') as f:
@ -124,7 +124,7 @@ class Main {
kha.System.init({title: projectName, width: projectWidth, height: projectHeight, samplesPerPixel: projectSamplesPerPixel}, function() {
iron.App.init(function() {
iron.Scene.setActive(projectScene, function(object:iron.object.Object) {""")
if utils.with_chromium() and in_viewport and is_play:
if armutils.with_chromium() and in_viewport and is_play:
f.write("""
object.addTrait(new armory.trait.internal.EditorSpace());""")
f.write("""
@ -155,7 +155,7 @@ function createWindow () { """)
let point = electron.screen.getCursorScreenPoint();
let targetDisplay = electron.screen.getDisplayNearestPoint(point);
""")
if utils.get_os() == 'mac': # Perform scale in python
if armutils.get_os() == 'mac': # Perform scale in python
f.write("""let scale = 1;""")
else:
f.write("""let scale = targetDisplay.scaleFactor;""")
@ -214,7 +214,7 @@ def write_indexhtml(w, h, in_viewport):
<canvas id='khanvas' width='""" + str(w) + """' height='""" + str(h) + """'></canvas>
<script src='kha.js'></script>
""")
if not (utils.with_chromium() and in_viewport):
if not (armutils.with_chromium() and in_viewport):
f.write(
""" <script>document.addEventListener('keypress', e => { if (e.code == "KeyZ" && e.shiftKey) close(); });</script>
""")

View file

@ -4,7 +4,7 @@ import sys
import subprocess
import json
import re
import utils
import armutils
import assets
def add_irr_assets(output_file_irr):
@ -37,12 +37,12 @@ def write_probes(image_filepath, disable_hdr, cached_num_mips, generate_radiance
return cached_num_mips
# Get paths
sdk_path = utils.get_sdk_path()
sdk_path = armutils.get_sdk_path()
if utils.get_os() == 'win':
if armutils.get_os() == 'win':
cmft_path = sdk_path + '/armory/tools/cmft/cmft.exe'
kraffiti_path = sdk_path + '/kode/win32/resources/app/extensions/kha/Kha/Kore/Tools/kraffiti/kraffiti.exe'
elif utils.get_os() == 'mac':
elif armutils.get_os() == 'mac':
cmft_path = sdk_path + '/armory/tools/cmft/cmft-osx'
kraffiti_path = sdk_path + '/kode/"Kode Studio.app"/Contents/Resources/app/extensions/kha/Kha/Kore/Tools/kraffiti/kraffiti-osx'
else:
@ -51,7 +51,7 @@ def write_probes(image_filepath, disable_hdr, cached_num_mips, generate_radiance
generated_files = []
output_gama_numerator = '1.0' if disable_hdr else '2.2'
input_file = utils.get_fp() + image_filepath #'Assets/' + image_name
input_file = armutils.get_fp() + image_filepath #'Assets/' + image_name
# Get input size
output = subprocess.check_output([ \
@ -202,7 +202,7 @@ def sh_to_json(sh_file):
sh_json = {}
sh_json['irradiance'] = irradiance_floats
utils.write_arm(sh_file + '.arm', sh_json)
armutils.write_arm(sh_file + '.arm', sh_json)
# Clean up .c
os.remove(sh_file + '.c')
@ -229,7 +229,7 @@ def write_sky_irradiance(base_name):
sh_json = {}
sh_json['irradiance'] = irradiance_floats
utils.write_arm(output_file + '.arm', sh_json)
armutils.write_arm(output_file + '.arm', sh_json)
assets.add(output_file + '.arm')
@ -246,6 +246,6 @@ def write_color_irradiance(base_name, col):
sh_json = {}
sh_json['irradiance'] = irradiance_floats
utils.write_arm(output_file + '.arm', sh_json)
armutils.write_arm(output_file + '.arm', sh_json)
assets.add(output_file + '.arm')