Transform into render engine.
This commit is contained in:
parent
509dc23ca3
commit
48eba84031
|
@ -40,9 +40,10 @@ def get_sdk_path():
|
|||
addon_prefs = user_preferences.addons['armory'].preferences
|
||||
if with_chromium() and addon_prefs.sdk_bundled:
|
||||
if get_os() == 'mac':
|
||||
return bpy.path.abspath(os.__file__[:-5] + '../../../armory_sdk/')
|
||||
# blender.app/Contents/MacOS/blender
|
||||
return bpy.app.binary_path[:-34] + '/armory_sdk/'
|
||||
else:
|
||||
return bpy.path.abspath(os.__file__[:-5] + '../../armory_sdk/')
|
||||
return bpy.app.binary_path + '/armory_sdk/'
|
||||
else:
|
||||
return addon_prefs.sdk_path
|
||||
|
||||
|
@ -52,6 +53,9 @@ def get_ffmpeg_path():
|
|||
return addon_prefs.ffmpeg_path
|
||||
|
||||
def fetch_script_names():
|
||||
if bpy.data.filepath == "":
|
||||
return
|
||||
|
||||
sdk_path = get_sdk_path()
|
||||
wrd = bpy.data.worlds['Arm']
|
||||
wrd.bundled_scripts_list.clear()
|
||||
|
|
BIN
blender/data/data.blend
Executable file → Normal file
BIN
blender/data/data.blend
Executable file → Normal file
Binary file not shown.
|
@ -6,6 +6,8 @@ import space_armory
|
|||
import time
|
||||
import bridge
|
||||
import log
|
||||
import props
|
||||
from bpy.app.handlers import persistent
|
||||
try:
|
||||
import barmory
|
||||
except ImportError:
|
||||
|
@ -14,6 +16,7 @@ except ImportError:
|
|||
last_time = time.time()
|
||||
last_operator = None
|
||||
|
||||
@persistent
|
||||
def on_scene_update_post(context):
|
||||
global last_time
|
||||
global last_operator
|
||||
|
@ -101,13 +104,20 @@ def on_scene_update_post(context):
|
|||
elif edit_obj.type == 'ARMATURE':
|
||||
edit_obj.data.data_cached = False
|
||||
|
||||
def on_load_pre(context):
|
||||
bpy.ops.arm_addon.stop('EXEC_DEFAULT')
|
||||
@persistent
|
||||
def on_load_post(context):
|
||||
props.init_properties_on_load()
|
||||
|
||||
@persistent
|
||||
def on_save_pre(context):
|
||||
props.init_properties_on_save()
|
||||
|
||||
def register():
|
||||
bpy.app.handlers.scene_update_post.append(on_scene_update_post)
|
||||
bpy.app.handlers.load_pre.append(on_load_pre)
|
||||
bpy.app.handlers.save_pre.append(on_save_pre)
|
||||
bpy.app.handlers.load_post.append(on_load_post)
|
||||
|
||||
def unregister():
|
||||
bpy.app.handlers.scene_update_post.remove(on_scene_update_post)
|
||||
bpy.app.handlers.load_pre.remove(on_load_pre)
|
||||
bpy.app.handlers.save_pre.remove(on_save_pre)
|
||||
bpy.app.handlers.load_post.remove(on_load_post)
|
||||
|
|
|
@ -25,7 +25,7 @@ def init_properties():
|
|||
description='Build paltform')
|
||||
bpy.types.World.arm_project_target = target_prop
|
||||
bpy.types.World.arm_publish_target = target_prop
|
||||
bpy.types.World.arm_project_name = StringProperty(name="Name", description="Exported project name", default="ArmoryProject")
|
||||
bpy.types.World.arm_project_name = StringProperty(name="Name", description="Exported project name", default="")
|
||||
bpy.types.World.arm_project_package = StringProperty(name="Package", description="Package name for scripts", default="arm")
|
||||
bpy.types.World.arm_play_active_scene = BoolProperty(name="Play Active Scene", description="Load currently edited scene when launching player", default=True)
|
||||
bpy.types.World.arm_project_scene = StringProperty(name="Scene", description="Scene to load when launching player")
|
||||
|
@ -254,21 +254,24 @@ def init_properties():
|
|||
# For lamp
|
||||
bpy.types.Lamp.lamp_clip_start = bpy.props.FloatProperty(name="Clip Start", default=0.1)
|
||||
bpy.types.Lamp.lamp_clip_end = bpy.props.FloatProperty(name="Clip End", default=50.0)
|
||||
bpy.types.Lamp.lamp_fov = bpy.props.FloatProperty(name="Field of View", default=0.785)
|
||||
bpy.types.Lamp.lamp_fov = bpy.props.FloatProperty(name="Field of View", default=0.84)
|
||||
bpy.types.Lamp.lamp_shadows_bias = bpy.props.FloatProperty(name="Shadows Bias", description="Depth offset for shadow acne", default=0.0001)
|
||||
|
||||
# First run
|
||||
if not 'Arm' in bpy.data.worlds:
|
||||
wrd = bpy.data.worlds.new('Arm')
|
||||
wrd.use_fake_user = True # Store data world object, add fake user to keep it alive
|
||||
wrd.arm_version = '16.10'
|
||||
|
||||
def init_properties_on_save():
|
||||
wrd = bpy.data.worlds['Arm']
|
||||
if wrd.arm_project_name == '':
|
||||
# Take blend file name
|
||||
wrd.arm_project_name = bpy.path.basename(bpy.context.blend_data.filepath).rsplit('.')[0]
|
||||
wrd.arm_project_scene = bpy.data.scenes[0].name
|
||||
# Switch to Cycles
|
||||
for scene in bpy.data.scenes:
|
||||
if scene.render.engine != 'CYCLES':
|
||||
scene.render.engine = 'CYCLES'
|
||||
# if scene.render.engine != 'CYCLES':
|
||||
# scene.render.engine = 'CYCLES'
|
||||
scene.render.fps = 60 # Default to 60fps for chromium update loop
|
||||
# Force camera far to at least 200 units for now, to prevent fighting with light far plane
|
||||
for c in bpy.data.cameras:
|
||||
|
@ -279,8 +282,8 @@ def init_properties():
|
|||
loc = bpy.data.objects['Lamp'].location
|
||||
if int(loc.x) == 4 and int(loc.y) == 1 and int(loc.z) == 5:
|
||||
loc.x = 11.0
|
||||
loc.y = 3.7
|
||||
loc.z = 15.6
|
||||
loc.y = 4.0
|
||||
loc.z = 16.0
|
||||
# Use nodes
|
||||
for w in bpy.data.worlds:
|
||||
w.use_nodes = True
|
||||
|
@ -290,7 +293,12 @@ def init_properties():
|
|||
l.use_nodes = True
|
||||
for m in bpy.data.materials:
|
||||
m.use_nodes = True
|
||||
|
||||
init_properties_on_load()
|
||||
|
||||
def init_properties_on_load():
|
||||
armutils.fetch_script_names()
|
||||
|
||||
# Path for embedded player
|
||||
if armutils.with_chromium():
|
||||
barmory.set_url('file://' + armutils.get_fp() + '/build/html5/index.html')
|
||||
|
|
|
@ -386,6 +386,15 @@ class WorldPropsPanel(bpy.types.Panel):
|
|||
if wrd.voxelgi:
|
||||
layout.prop(wrd, 'voxelgi_dimensions')
|
||||
|
||||
class ArmoryHelpButton(bpy.types.Operator):
|
||||
'''Open a website in the web-browser'''
|
||||
bl_idname = "arm.help"
|
||||
bl_label = "Help"
|
||||
|
||||
def execute(self, context):
|
||||
webbrowser.open("http://armory3d.org/manual")
|
||||
return{"FINISHED"}
|
||||
|
||||
# Menu in render region
|
||||
class ArmoryPlayPanel(bpy.types.Panel):
|
||||
bl_label = "Armory Play"
|
||||
|
@ -412,6 +421,7 @@ class ArmoryPlayPanel(bpy.types.Panel):
|
|||
layout.prop(wrd, 'arm_play_live_patch')
|
||||
if wrd.arm_play_live_patch:
|
||||
layout.prop(wrd, 'arm_play_auto_build')
|
||||
layout.operator("arm.help")
|
||||
|
||||
class ArmoryBuildPanel(bpy.types.Panel):
|
||||
bl_label = "Armory Build"
|
||||
|
@ -480,6 +490,10 @@ class ArmoryPlayButton(bpy.types.Operator):
|
|||
bl_label = 'Play'
|
||||
|
||||
def execute(self, context):
|
||||
if bpy.data.filepath == "":
|
||||
self.report({"ERROR"}, "Save blend file first")
|
||||
return {"CANCELLED"}
|
||||
|
||||
assets.invalidate_enabled = False
|
||||
make.play_project(self, False)
|
||||
assets.invalidate_enabled = True
|
||||
|
@ -491,6 +505,10 @@ class ArmoryPlayInViewportButton(bpy.types.Operator):
|
|||
bl_label = 'Play in Viewport'
|
||||
|
||||
def execute(self, context):
|
||||
if bpy.data.filepath == "":
|
||||
self.report({"ERROR"}, "Save blend file first")
|
||||
return {"CANCELLED"}
|
||||
|
||||
assets.invalidate_enabled = False
|
||||
if state.playproc == None:
|
||||
log.clear()
|
||||
|
@ -522,6 +540,10 @@ class ArmoryBuildButton(bpy.types.Operator):
|
|||
bl_label = 'Build'
|
||||
|
||||
def execute(self, context):
|
||||
if bpy.data.filepath == "":
|
||||
self.report({"ERROR"}, "Save blend file first")
|
||||
return {"CANCELLED"}
|
||||
|
||||
assets.invalidate_enabled = False
|
||||
make.build_project()
|
||||
make.compile_project(watch=True)
|
||||
|
@ -546,6 +568,10 @@ class ArmoryFolderButton(bpy.types.Operator):
|
|||
bl_label = 'Project Folder'
|
||||
|
||||
def execute(self, context):
|
||||
if bpy.data.filepath == "":
|
||||
self.report({"ERROR"}, "Save blend file first")
|
||||
return {"CANCELLED"}
|
||||
|
||||
webbrowser.open('file://' + armutils.get_fp())
|
||||
return{'FINISHED'}
|
||||
|
||||
|
@ -565,6 +591,10 @@ class ArmoryKodeStudioButton(bpy.types.Operator):
|
|||
bl_description = 'Open Project in Kode Studio'
|
||||
|
||||
def execute(self, context):
|
||||
if bpy.data.filepath == "":
|
||||
self.report({"ERROR"}, "Save blend file first")
|
||||
return {"CANCELLED"}
|
||||
|
||||
make_utils.kode_studio()
|
||||
return{'FINISHED'}
|
||||
|
||||
|
@ -574,6 +604,10 @@ class ArmoryCleanButton(bpy.types.Operator):
|
|||
bl_label = 'Clean'
|
||||
|
||||
def execute(self, context):
|
||||
if bpy.data.filepath == "":
|
||||
self.report({"ERROR"}, "Save blend file first")
|
||||
return {"CANCELLED"}
|
||||
|
||||
make.clean_project()
|
||||
return{'FINISHED'}
|
||||
|
||||
|
@ -583,6 +617,10 @@ class ArmoryPublishButton(bpy.types.Operator):
|
|||
bl_label = 'Publish Project'
|
||||
|
||||
def execute(self, context):
|
||||
if bpy.data.filepath == "":
|
||||
self.report({"ERROR"}, "Save blend file first")
|
||||
return {"CANCELLED"}
|
||||
|
||||
make.publish_project()
|
||||
self.report({'INFO'}, 'Publishing project, check console for details.')
|
||||
return{'FINISHED'}
|
||||
|
|
Loading…
Reference in a new issue