mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-12-23 08:04:10 +00:00
feat(blenvy):
* minor tweaks & improvements to assets handling * renamed a few auto export preferences for more coherence * "assets" folder is now mandatory again and used by the various sub asset types * blueprints/levels/materials paths in auto_export are not overwrite their relative values anymore, but added their "full" variants & changed code using full paths to use those * added back gltf exporter post export callback, in a cleaner fashion * changing (wip) the way the various relative folders are auto generated in the folder selection UI * lots of other minor tweaks & improvements
This commit is contained in:
parent
b8a7eba71d
commit
0fb35d6e6a
11
tools/blenvy/TODO.md
Normal file
11
tools/blenvy/TODO.md
Normal file
@ -0,0 +1,11 @@
|
||||
Auto export
|
||||
- [ ] the original blueprints & levels path are now left as is, and there is an auto injection of xxxpath_full for absolute paths
|
||||
- [ ] replace all uses of the paths with the correct ones above
|
||||
- [x] levels
|
||||
- [x] blueprints
|
||||
- [ ] materials
|
||||
- [x] move out the UI for "assets" folder out of "blueprints condition"
|
||||
- [ ] fix asset path calculations
|
||||
- root path => relative to blend file path
|
||||
- asset path => relative to root path
|
||||
- blueprints/levels/blueprints path => relative to assets path
|
@ -15,6 +15,7 @@ import bpy
|
||||
from bpy.app.handlers import persistent
|
||||
from bpy.props import (StringProperty)
|
||||
|
||||
|
||||
# components management
|
||||
from .bevy_components.components.operators import CopyComponentOperator, Fix_Component_Operator, OT_rename_component, RemoveComponentFromAllObjectsOperator, RemoveComponentOperator, GenerateComponent_From_custom_property_Operator, PasteComponentOperator, AddComponentOperator, RenameHelper, Toggle_ComponentVisibility
|
||||
|
||||
@ -29,6 +30,7 @@ from .bevy_components.components.definitions_list import (ComponentDefinitionsLi
|
||||
from .bevy_components.components.ui import (BEVY_COMPONENTS_PT_ComponentsPanel)
|
||||
|
||||
# auto export
|
||||
from .gltf_auto_export import gltf_post_export_callback
|
||||
from .gltf_auto_export.auto_export.operators import AutoExportGLTF
|
||||
from .gltf_auto_export.auto_export.tracker import AutoExportTracker
|
||||
from .gltf_auto_export.auto_export.preferences import (AutoExportGltfAddonPreferences)
|
||||
@ -65,11 +67,16 @@ from .core.ui import BLENVY_PT_SidePanel
|
||||
from .core.blenvy_manager import BlenvyManager
|
||||
from .core.operators import OT_switch_bevy_tooling
|
||||
|
||||
|
||||
# this needs to be here, as it is how Blender's gltf exporter callbacks are defined, at the add-on root level
|
||||
def glTF2_post_export_callback(data):
|
||||
gltf_post_export_callback(data)
|
||||
|
||||
|
||||
classes = [
|
||||
# blenvy
|
||||
BLENVY_PT_SidePanel,
|
||||
|
||||
|
||||
# bevy components
|
||||
AddComponentOperator,
|
||||
CopyComponentOperator,
|
||||
@ -181,6 +188,3 @@ def unregister():
|
||||
bpy.app.handlers.load_post.remove(post_load)
|
||||
bpy.app.handlers.depsgraph_update_post.remove(post_update)
|
||||
bpy.app.handlers.save_post.remove(post_save)
|
||||
|
||||
|
||||
print("TOTO")
|
@ -8,13 +8,13 @@ from bpy.props import (StringProperty, BoolProperty, FloatProperty, FloatVectorP
|
||||
|
||||
|
||||
def get_assets(scene, blueprints_data, addon_prefs):
|
||||
export_root_folder = getattr(addon_prefs, "export_root_folder")
|
||||
export_root_path = getattr(addon_prefs, "export_root_path")
|
||||
export_output_folder = getattr(addon_prefs,"export_output_folder")
|
||||
export_levels_path = getattr(addon_prefs,"export_levels_path")
|
||||
export_blueprints_path = getattr(addon_prefs, "export_blueprints_path")
|
||||
export_gltf_extension = getattr(addon_prefs, "export_gltf_extension")
|
||||
|
||||
relative_blueprints_path = os.path.relpath(export_blueprints_path, export_root_folder)
|
||||
relative_blueprints_path = os.path.relpath(export_blueprints_path, export_root_path)
|
||||
blueprint_instance_names_for_scene = blueprints_data.blueprint_instances_per_main_scene.get(scene.name, None)
|
||||
|
||||
blueprint_assets_list = []
|
||||
|
@ -50,7 +50,6 @@ class OT_add_bevy_asset(Operator):
|
||||
def execute(self, context):
|
||||
assets = []
|
||||
blueprint_assets = self.target_type == 'BLUEPRINT'
|
||||
print("FOOO", self.target_name, self.target_type)
|
||||
if blueprint_assets:
|
||||
assets = json.loads(bpy.data.collections[self.target_name].get('assets')) if 'assets' in bpy.data.collections[self.target_name] else []
|
||||
else:
|
||||
@ -60,12 +59,16 @@ class OT_add_bevy_asset(Operator):
|
||||
in_list = len(in_list) > 0
|
||||
if not in_list:
|
||||
assets.append({"name": self.asset_name, "type": self.asset_type, "path": self.asset_path, "internal": False})
|
||||
# reset controls
|
||||
context.window_manager.assets_registry.asset_name_selector = ""
|
||||
context.window_manager.assets_registry.asset_type_selector = "MODEL"
|
||||
context.window_manager.assets_registry.asset_path_selector = ""
|
||||
|
||||
if blueprint_assets:
|
||||
bpy.data.collections[self.target_name]["assets"] = json.dumps(assets)
|
||||
else:
|
||||
bpy.data.scenes[self.target_name]["assets"] = json.dumps(assets)
|
||||
#context.window_manager.assets_registry.add_asset(self.asset_name, self.asset_type, self.asset_path, False)
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
@ -141,8 +144,13 @@ class OT_Add_asset_filebrowser(Operator, ImportHelper):
|
||||
|
||||
def execute(self, context):
|
||||
current_auto_settings = load_settings(".gltf_auto_export_settings")
|
||||
export_root_folder = current_auto_settings.get("export_root_folder")
|
||||
asset_path = os.path.relpath(self.filepath, export_root_folder)
|
||||
export_root_path = current_auto_settings.get("export_root_path", "../")
|
||||
export_assets_path = current_auto_settings.get("export_assets_path", "assets")
|
||||
# FIXME: not sure
|
||||
print("export_root_path", export_root_path, "export_assets_path", export_assets_path)
|
||||
export_assets_path_absolute = os.path.join(export_root_path, export_assets_path)
|
||||
asset_path = os.path.relpath(self.filepath, export_assets_path_absolute)
|
||||
|
||||
|
||||
assets_registry = context.window_manager.assets_registry
|
||||
assets_registry.asset_path_selector = asset_path
|
||||
|
@ -0,0 +1,50 @@
|
||||
import os
|
||||
import json
|
||||
import bpy
|
||||
from .helpers.generate_complete_preferences_dict import generate_complete_preferences_dict_gltf
|
||||
|
||||
def cleanup_file():
|
||||
gltf_filepath = "/home/ckaos/projects/bevy/Blender_bevy_components_worklflow/testing/bevy_example/assets/____dummy____.glb"
|
||||
if os.path.exists(gltf_filepath):
|
||||
os.remove(gltf_filepath)
|
||||
return None
|
||||
else:
|
||||
return 1
|
||||
|
||||
def gltf_post_export_callback(data):
|
||||
#print("post_export", data)
|
||||
bpy.context.window_manager.auto_export_tracker.export_finished()
|
||||
|
||||
gltf_settings_backup = bpy.context.window_manager.gltf_settings_backup
|
||||
gltf_filepath = data["gltf_filepath"]
|
||||
gltf_export_id = data['gltf_export_id']
|
||||
if gltf_export_id == "gltf_auto_export":
|
||||
# some more absurdity: apparently the file is not QUITE done when the export callback is called, so we have to introduce this timer to remove the temporary file correctly
|
||||
bpy.context.window_manager.auto_export_tracker.dummy_file_path = gltf_filepath
|
||||
try:
|
||||
bpy.app.timers.unregister(cleanup_file)
|
||||
except:pass
|
||||
bpy.app.timers.register(cleanup_file, first_interval=1)
|
||||
|
||||
# get the parameters
|
||||
scene = bpy.context.scene
|
||||
if "glTF2ExportSettings" in scene:
|
||||
settings = scene["glTF2ExportSettings"]
|
||||
export_settings = bpy.data.texts[".gltf_auto_export_gltf_settings"] if ".gltf_auto_export_gltf_settings" in bpy.data.texts else bpy.data.texts.new(".gltf_auto_export_gltf_settings")
|
||||
# now write new settings
|
||||
export_settings.clear()
|
||||
|
||||
current_gltf_settings = generate_complete_preferences_dict_gltf(dict(settings))
|
||||
export_settings.write(json.dumps(current_gltf_settings))
|
||||
# now reset the original gltf_settings
|
||||
if gltf_settings_backup != "":
|
||||
scene["glTF2ExportSettings"] = json.loads(gltf_settings_backup)
|
||||
else:
|
||||
if "glTF2ExportSettings" in scene:
|
||||
del scene["glTF2ExportSettings"]
|
||||
bpy.context.window_manager.gltf_settings_backup = ""
|
||||
|
||||
# the absurd length one has to go through to RESET THE OPERATOR because it has global state !!!!! AAAAAHHH
|
||||
last_operator = bpy.context.window_manager.auto_export_tracker.last_operator
|
||||
last_operator.filepath = ""
|
||||
last_operator.gltf_export_id = ""
|
@ -33,9 +33,8 @@ def auto_export(changes_per_scene, changed_export_parameters, addon_prefs):
|
||||
blend_file_path = os.path.dirname(file_path)
|
||||
|
||||
# get the preferences for our addon
|
||||
export_root_folder = getattr(addon_prefs, "export_root_folder")
|
||||
export_output_folder = getattr(addon_prefs,"export_output_folder")
|
||||
export_models_path = os.path.join(blend_file_path, export_output_folder)
|
||||
export_root_path = getattr(addon_prefs, "export_root_path")
|
||||
export_assets_path = getattr(addon_prefs,"export_assets_path")
|
||||
|
||||
#should we use change detection or not
|
||||
export_change_detection = getattr(addon_prefs, "export_change_detection")
|
||||
@ -49,12 +48,6 @@ def auto_export(changes_per_scene, changed_export_parameters, addon_prefs):
|
||||
standard_gltf_exporter_settings = get_standard_exporter_settings()
|
||||
gltf_extension = standard_gltf_exporter_settings.get("export_format", 'GLB')
|
||||
gltf_extension = '.glb' if gltf_extension == 'GLB' else '.gltf'
|
||||
|
||||
# generate the actual complete output path
|
||||
export_blueprints_path = os.path.join(blend_file_path, export_root_folder, getattr(addon_prefs,"export_blueprints_path"))
|
||||
export_levels_path = os.path.join(blend_file_path, export_root_folder, getattr(addon_prefs, "export_levels_path"))
|
||||
|
||||
print("export_blueprints_path", export_blueprints_path)
|
||||
|
||||
# here we do a bit of workaround by creating an override # TODO: do this at the "UI" level
|
||||
print("collection_instances_combine_mode", addon_prefs.collection_instances_combine_mode)
|
||||
@ -71,15 +64,17 @@ def auto_export(changes_per_scene, changed_export_parameters, addon_prefs):
|
||||
|
||||
addon_prefs = SimpleNamespace(**tmp) #copy.deepcopy(addon_prefs)
|
||||
addon_prefs.__annotations__ = tmp"""
|
||||
addon_prefs.export_blueprints_path = export_blueprints_path
|
||||
addon_prefs.export_levels_path = export_levels_path
|
||||
# generate the actual complete output paths
|
||||
addon_prefs.export_assets_path_full = os.path.join(blend_file_path, export_root_path, export_assets_path)
|
||||
addon_prefs.export_blueprints_path_full = os.path.join(addon_prefs.export_assets_path_full, getattr(addon_prefs,"export_blueprints_path"))
|
||||
addon_prefs.export_levels_path_full = os.path.join(addon_prefs.export_assets_path_full, getattr(addon_prefs,"export_levels_path"))
|
||||
addon_prefs.export_materials_path = os.path.join(addon_prefs.export_assets_path_full, getattr(addon_prefs,"export_materials_path"))
|
||||
addon_prefs.export_gltf_extension = gltf_extension
|
||||
addon_prefs.export_models_path = export_models_path
|
||||
|
||||
[main_scene_names, level_scenes, library_scene_names, library_scenes] = get_scenes(addon_prefs)
|
||||
|
||||
print("main scenes", main_scene_names, "library_scenes", library_scene_names)
|
||||
print("export_output_folder", export_output_folder)
|
||||
print("export_assets_path", export_assets_path)
|
||||
|
||||
blueprints_data = blueprints_scan(level_scenes, library_scenes, addon_prefs)
|
||||
blueprints_per_scene = blueprints_data.blueprints_per_scenes
|
||||
|
@ -8,7 +8,7 @@ from ..helpers.helpers_scenes import clear_hollow_scene, copy_hollowed_collectio
|
||||
|
||||
|
||||
def export_blueprints(blueprints, blend_file_path, addon_prefs, blueprints_data):
|
||||
export_blueprints_path = getattr(addon_prefs,"export_blueprints_path")
|
||||
export_blueprints_path_full = getattr(addon_prefs,"export_blueprints_path_full")
|
||||
gltf_export_preferences = generate_gltf_export_preferences(addon_prefs)
|
||||
|
||||
try:
|
||||
@ -18,7 +18,7 @@ def export_blueprints(blueprints, blend_file_path, addon_prefs, blueprints_data)
|
||||
|
||||
for blueprint in blueprints:
|
||||
print("exporting collection", blueprint.name)
|
||||
gltf_output_path = os.path.join(export_blueprints_path, blueprint.name)
|
||||
gltf_output_path = os.path.join(export_blueprints_path_full, blueprint.name)
|
||||
export_settings = { **gltf_export_preferences, 'use_active_scene': True, 'use_active_collection': True, 'use_active_collection_with_nested':True}
|
||||
|
||||
# if we are using the material library option, do not export materials, use placeholder instead
|
||||
|
@ -11,9 +11,8 @@ from ..helpers.helpers_blueprints import inject_blueprints_list_into_main_scene,
|
||||
|
||||
def export_main_scene(scene, blend_file_path, addon_prefs, blueprints_data):
|
||||
gltf_export_preferences = generate_gltf_export_preferences(addon_prefs)
|
||||
export_root_folder = getattr(addon_prefs, "export_root_folder")
|
||||
export_output_folder = getattr(addon_prefs,"export_output_folder")
|
||||
export_levels_path = getattr(addon_prefs,"export_levels_path")
|
||||
export_assets_path_full = getattr(addon_prefs,"export_assets_path_full")
|
||||
export_levels_path_full = getattr(addon_prefs,"export_levels_path_full")
|
||||
|
||||
export_blueprints = getattr(addon_prefs,"export_blueprints")
|
||||
export_separate_dynamic_and_static_objects = getattr(addon_prefs, "export_separate_dynamic_and_static_objects")
|
||||
@ -28,7 +27,7 @@ def export_main_scene(scene, blend_file_path, addon_prefs, blueprints_data):
|
||||
}
|
||||
|
||||
if export_blueprints :
|
||||
gltf_output_path = os.path.join(export_levels_path, scene.name)
|
||||
gltf_output_path = os.path.join(export_levels_path_full, scene.name)
|
||||
|
||||
inject_blueprints_list_into_main_scene(scene, blueprints_data, addon_prefs)
|
||||
return
|
||||
@ -45,7 +44,7 @@ def export_main_scene(scene, blend_file_path, addon_prefs, blueprints_data):
|
||||
)
|
||||
|
||||
# then export all dynamic objects
|
||||
gltf_output_path = os.path.join(export_levels_path, scene.name+ "_dynamic")
|
||||
gltf_output_path = os.path.join(export_levels_path_full, scene.name+ "_dynamic")
|
||||
generate_and_export(
|
||||
addon_prefs,
|
||||
temp_scene_name=TEMPSCENE_PREFIX,
|
||||
@ -67,7 +66,7 @@ def export_main_scene(scene, blend_file_path, addon_prefs, blueprints_data):
|
||||
)
|
||||
|
||||
else:
|
||||
gltf_output_path = os.path.join(export_root_folder, export_output_folder, scene.name)
|
||||
gltf_output_path = os.path.join(export_assets_path_full, scene.name)
|
||||
print(" exporting gltf to", gltf_output_path, ".gltf/glb")
|
||||
export_gltf(gltf_output_path, export_settings)
|
||||
|
||||
|
@ -7,7 +7,7 @@ from ..helpers.helpers_blueprints import find_blueprints_not_on_disk
|
||||
def get_blueprints_to_export(changes_per_scene, changed_export_parameters, blueprints_data, addon_prefs):
|
||||
export_change_detection = getattr(addon_prefs, "export_change_detection")
|
||||
export_gltf_extension = getattr(addon_prefs, "export_gltf_extension", ".glb")
|
||||
export_blueprints_path = getattr(addon_prefs,"export_blueprints_path", "")
|
||||
export_blueprints_path_full = getattr(addon_prefs,"export_blueprints_path_full", "")
|
||||
collection_instances_combine_mode = getattr(addon_prefs, "collection_instances_combine_mode")
|
||||
|
||||
[main_scene_names, level_scenes, library_scene_names, library_scenes] = get_scenes(addon_prefs)
|
||||
@ -23,7 +23,7 @@ def get_blueprints_to_export(changes_per_scene, changed_export_parameters, bluep
|
||||
|
||||
# first check if all collections have already been exported before (if this is the first time the exporter is run
|
||||
# in your current Blender session for example)
|
||||
blueprints_not_on_disk = find_blueprints_not_on_disk(internal_blueprints, export_blueprints_path, export_gltf_extension)
|
||||
blueprints_not_on_disk = find_blueprints_not_on_disk(internal_blueprints, export_blueprints_path_full, export_gltf_extension)
|
||||
|
||||
for scene in library_scenes:
|
||||
if scene.name in changes_per_scene:
|
||||
|
@ -39,13 +39,13 @@ def changed_object_in_scene(scene_name, changes_per_scene, blueprints_data, coll
|
||||
def get_levels_to_export(changes_per_scene, changed_export_parameters, blueprints_data, addon_prefs):
|
||||
export_change_detection = getattr(addon_prefs, "export_change_detection")
|
||||
export_gltf_extension = getattr(addon_prefs, "export_gltf_extension")
|
||||
export_levels_path = getattr(addon_prefs, "export_levels_path")
|
||||
export_levels_path_full = getattr(addon_prefs, "export_levels_path_full")
|
||||
collection_instances_combine_mode = getattr(addon_prefs, "collection_instances_combine_mode")
|
||||
|
||||
[main_scene_names, level_scenes, library_scene_names, library_scenes] = get_scenes(addon_prefs)
|
||||
|
||||
# determine list of main scenes to export
|
||||
# we have more relaxed rules to determine if the main scenes have changed : any change is ok, (allows easier handling of changes, render settings etc)
|
||||
main_scenes_to_export = [scene_name for scene_name in main_scene_names if not export_change_detection or changed_export_parameters or scene_name in changes_per_scene.keys() or changed_object_in_scene(scene_name, changes_per_scene, blueprints_data, collection_instances_combine_mode) or not check_if_blueprint_on_disk(scene_name, export_levels_path, export_gltf_extension) ]
|
||||
main_scenes_to_export = [scene_name for scene_name in main_scene_names if not export_change_detection or changed_export_parameters or scene_name in changes_per_scene.keys() or changed_object_in_scene(scene_name, changes_per_scene, blueprints_data, collection_instances_combine_mode) or not check_if_blueprint_on_disk(scene_name, export_levels_path_full, export_gltf_extension) ]
|
||||
|
||||
return (main_scenes_to_export)
|
@ -32,8 +32,8 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences):#, ExportHelper):
|
||||
#list of settings (other than purely gltf settings) whose change should trigger a re-generation of gltf files
|
||||
white_list = [
|
||||
'auto_export',
|
||||
'export_root_folder',
|
||||
'export_output_folder',
|
||||
'export_root_path',
|
||||
'export_assets_path',
|
||||
'export_change_detection',
|
||||
'export_scene_settings',
|
||||
|
||||
@ -363,11 +363,9 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences):#, ExportHelper):
|
||||
section = layout.box()
|
||||
section.enabled = controls_enabled
|
||||
|
||||
draw_folder_browser(section, "Export root folder", self.export_root_folder, "export_root_folder")
|
||||
draw_folder_browser(section, "Export root folder", self.export_root_path, "export_root_path")
|
||||
row = section.row()
|
||||
draw_folder_browser(row, "Assets Folder (non blueprints mode only)", self.export_root_folder, "export_output_folder")
|
||||
row.enabled = not self.export_blueprints
|
||||
section.prop(operator, "export_blueprints")
|
||||
draw_folder_browser(row, "Assets Folder", self.export_root_path, "export_assets_path")
|
||||
section.prop(operator, "export_scene_settings")
|
||||
|
||||
"""header, panel = layout.panel("my_panel_id", default_closed=False)
|
||||
@ -437,17 +435,19 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences):#, ExportHelper):
|
||||
if self.show_blueprint_settings:
|
||||
section = layout.box()
|
||||
section.enabled = controls_enabled
|
||||
section.prop(operator, "export_blueprints")
|
||||
|
||||
section = section.box()
|
||||
section.enabled = controls_enabled and self.export_blueprints
|
||||
|
||||
# collections/blueprints
|
||||
draw_folder_browser(section, "Blueprints folder", self.export_root_folder, "export_blueprints_path")
|
||||
draw_folder_browser(section, "Blueprints folder", self.export_root_path, "export_blueprints_path")
|
||||
#section.prop(operator, "export_blueprints_path")
|
||||
section.prop(operator, "collection_instances_combine_mode")
|
||||
section.prop(operator, "export_marked_assets")
|
||||
section.separator()
|
||||
|
||||
draw_folder_browser(section, "Levels folder", self.export_root_folder, "export_levels_path")
|
||||
draw_folder_browser(section, "Levels folder", self.export_root_path, "export_levels_path")
|
||||
#section.prop(operator, "export_levels_path")
|
||||
|
||||
section.prop(operator, "export_separate_dynamic_and_static_objects")
|
||||
@ -457,7 +457,7 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences):#, ExportHelper):
|
||||
section.prop(operator, "export_materials_library")
|
||||
section = section.box()
|
||||
section.enabled = controls_enabled and self.export_materials_library
|
||||
draw_folder_browser(section, 'Materials folder', self.export_root_folder, "export_materials_path")
|
||||
draw_folder_browser(section, 'Materials folder', self.export_root_path, "export_materials_path")
|
||||
#section.prop(operator, "export_materials_path")
|
||||
|
||||
|
||||
|
@ -16,8 +16,8 @@ AutoExportGltfPreferenceNames = [
|
||||
|
||||
'show_general_settings',
|
||||
'auto_export',
|
||||
'export_root_folder',
|
||||
'export_output_folder',
|
||||
'export_root_path',
|
||||
'export_assets_path',
|
||||
'export_scene_settings',
|
||||
|
||||
'show_change_detection_settings',
|
||||
@ -45,9 +45,9 @@ AutoExportGltfPreferenceNames = [
|
||||
]
|
||||
|
||||
def on_export_output_folder_updated(self, context):
|
||||
#self.export_root_folder = os.path.relpath(self.export_root_folder)
|
||||
#self.export_output_folder = os.path.join(self.export_root_folder, self.export_output_folder)
|
||||
print("on_foo_updated", self.export_root_folder, self.export_output_folder)
|
||||
#self.export_root_path = os.path.relpath(self.export_root_path)
|
||||
#self.export_assets_path = os.path.join(self.export_root_path, self.export_assets_path)
|
||||
print("on_foo_updated", self.export_root_path, self.export_assets_path)
|
||||
|
||||
class AutoExportGltfAddonPreferences(AddonPreferences):
|
||||
# this must match the add-on name, use '__package__'
|
||||
@ -82,7 +82,7 @@ class AutoExportGltfAddonPreferences(AddonPreferences):
|
||||
default=True
|
||||
) # type: ignore
|
||||
|
||||
export_root_folder: StringProperty(
|
||||
export_root_path: StringProperty(
|
||||
name = "Project Root Path",
|
||||
description="The root folder of your (Bevy) project (not assets!)",
|
||||
# subtype='DIR_PATH',
|
||||
@ -90,7 +90,7 @@ class AutoExportGltfAddonPreferences(AddonPreferences):
|
||||
#update=on_export_output_folder_updated) # type: ignore
|
||||
)
|
||||
|
||||
export_output_folder: StringProperty(
|
||||
export_assets_path: StringProperty(
|
||||
name='Export folder',
|
||||
description='The root folder for all exports(relative to the root folder/path) Defaults to "assets" ',
|
||||
default='./assets',
|
||||
@ -143,15 +143,15 @@ class AutoExportGltfAddonPreferences(AddonPreferences):
|
||||
|
||||
export_blueprints_path: StringProperty(
|
||||
name='Blueprints path',
|
||||
description='path to export the blueprints to (relative to the export folder)',
|
||||
default='assets/blueprints',
|
||||
description='path to export the blueprints to (relative to the assets folder)',
|
||||
default='blueprints',
|
||||
#subtype='DIR_PATH'
|
||||
) # type: ignore
|
||||
|
||||
export_levels_path: StringProperty(
|
||||
name='Levels path',
|
||||
description='path to export the levels (main scenes) to (relative to the export folder)',
|
||||
default='assets/levels',
|
||||
description='path to export the levels (main scenes) to (relative to the assets folder)',
|
||||
default='levels',
|
||||
#subtype='DIR_PATH'
|
||||
) # type: ignore
|
||||
|
||||
@ -171,8 +171,8 @@ class AutoExportGltfAddonPreferences(AddonPreferences):
|
||||
|
||||
export_materials_path: StringProperty(
|
||||
name='Materials path',
|
||||
description='path to export the materials libraries to (relative to the export folder)',
|
||||
default='assets/materials',
|
||||
description='path to export the materials libraries to (relative to the assets folder)',
|
||||
default='materials',
|
||||
#subtype='DIR_PATH'
|
||||
) # type: ignore
|
||||
|
||||
|
@ -298,8 +298,8 @@ def add_scene_property(scene, property_name, property_data):
|
||||
|
||||
|
||||
def inject_blueprints_list_into_main_scene(scene, blueprints_data, addon_prefs):
|
||||
export_root_folder = getattr(addon_prefs, "export_root_folder")
|
||||
export_output_folder = getattr(addon_prefs,"export_output_folder")
|
||||
export_root_path = getattr(addon_prefs, "export_root_path")
|
||||
export_assets_path = getattr(addon_prefs,"export_assets_path")
|
||||
export_levels_path = getattr(addon_prefs,"export_levels_path")
|
||||
export_blueprints_path = getattr(addon_prefs, "export_blueprints_path")
|
||||
export_gltf_extension = getattr(addon_prefs, "export_gltf_extension")
|
||||
@ -328,7 +328,8 @@ def inject_blueprints_list_into_main_scene(scene, blueprints_data, addon_prefs):
|
||||
add_scene_property(scene, assets_list_name, assets_list_data)
|
||||
|
||||
|
||||
relative_blueprints_path = os.path.relpath(export_blueprints_path, export_root_folder)
|
||||
blueprints_path_full = os.path.join(export_assets_path, export_blueprints_path)
|
||||
relative_blueprints_path = os.path.relpath(export_blueprints_path, export_root_path)
|
||||
|
||||
blueprint_assets_list = []
|
||||
if blueprint_instance_names_for_scene:
|
||||
@ -338,7 +339,7 @@ def inject_blueprints_list_into_main_scene(scene, blueprints_data, addon_prefs):
|
||||
print("BLUEPRINT", blueprint)
|
||||
blueprint_exported_path = None
|
||||
if blueprint.local:
|
||||
blueprint_exported_path = os.path.join(relative_blueprints_path, f"{blueprint.name}{export_gltf_extension}")
|
||||
blueprint_exported_path = os.path.join(export_blueprints_path, f"{blueprint.name}{export_gltf_extension}")
|
||||
else:
|
||||
# get the injected path of the external blueprints
|
||||
blueprint_exported_path = blueprint.collection['Export_path'] if 'Export_path' in blueprint.collection else None
|
||||
|
@ -93,7 +93,7 @@ def clear_materials_scene(temp_scene):
|
||||
def export_materials(collections, library_scenes, folder_path, addon_prefs):
|
||||
gltf_export_preferences = generate_gltf_export_preferences(addon_prefs)
|
||||
export_materials_path = getattr(addon_prefs,"export_materials_path")
|
||||
export_root_folder = getattr(addon_prefs, "export_root_folder")
|
||||
export_root_path = getattr(addon_prefs, "export_root_path")
|
||||
|
||||
|
||||
used_material_names = get_all_materials(collections, library_scenes)
|
||||
@ -108,7 +108,7 @@ def export_materials(collections, library_scenes, folder_path, addon_prefs):
|
||||
'export_apply':True
|
||||
}
|
||||
|
||||
gltf_output_path = os.path.join(export_root_folder, export_materials_path, current_project_name + "_materials_library")
|
||||
gltf_output_path = os.path.join(export_root_path, export_materials_path, current_project_name + "_materials_library")
|
||||
|
||||
print(" exporting Materials to", gltf_output_path, ".gltf/glb")
|
||||
|
||||
|
@ -131,7 +131,7 @@ class GLTF_PT_auto_export_general(bpy.types.Panel):
|
||||
operator = sfile.active_operator
|
||||
|
||||
layout.active = operator.auto_export
|
||||
layout.prop(operator, "export_output_folder")
|
||||
layout.prop(operator, "export_assets_path")
|
||||
layout.prop(operator, "export_scene_settings")
|
||||
|
||||
|
||||
|
@ -128,21 +128,25 @@ class OT_OpenFolderbrowser(Operator, ImportHelper):
|
||||
# Get the folder
|
||||
blend_file_folder_path = os.path.dirname(blend_file_path)
|
||||
print("blend_file_folder_path", blend_file_folder_path)
|
||||
|
||||
print("new_path", self.directory, self.target_property, operator)
|
||||
|
||||
path_names = ['export_output_folder', 'export_blueprints_path', 'export_levels_path', 'export_materials_path']
|
||||
export_root_folder = operator.export_root_folder
|
||||
#export_root_path_absolute = os.path.join(blend_file_folder_path, export_root_folder)
|
||||
path_names = ['export_assets_path', 'export_blueprints_path', 'export_levels_path', 'export_materials_path']
|
||||
export_root_path = operator.export_root_path
|
||||
export_assets_path = operator.export_assets_path
|
||||
#export_root_path_absolute = os.path.join(blend_file_folder_path, export_root_path)
|
||||
export_assets_path_full = os.path.join(blend_file_folder_path, export_root_path, export_assets_path)
|
||||
print("export_assets_path_full", export_assets_path_full)
|
||||
|
||||
if target_path_name == 'export_root_folder':
|
||||
print("changing root new_path")
|
||||
#new_root_path = os.path.join(blend_file_folder_path, new_path)
|
||||
if target_path_name == 'export_root_path':
|
||||
new_root_path_relative = os.path.relpath(new_path, blend_file_folder_path)
|
||||
print("changing root new_path to", self.directory, blend_file_folder_path, new_root_path_relative)
|
||||
# we need to change all other relative paths before setting the new absolute path
|
||||
for path_name in path_names:
|
||||
# get absolute path
|
||||
relative_path = getattr(operator, path_name, None)
|
||||
if relative_path is not None:
|
||||
absolute_path = os.path.join(export_root_folder, relative_path)
|
||||
absolute_path = os.path.join(export_assets_path_full, relative_path)
|
||||
print("absolute path for", path_name, absolute_path)
|
||||
relative_path = os.path.relpath(absolute_path, new_path)
|
||||
setattr(operator, path_name, relative_path)
|
||||
@ -151,7 +155,7 @@ class OT_OpenFolderbrowser(Operator, ImportHelper):
|
||||
setattr(operator, target_path_name, new_path)
|
||||
|
||||
else:
|
||||
relative_path = os.path.relpath(new_path, export_root_folder)
|
||||
relative_path = os.path.relpath(new_path, export_assets_path_full)
|
||||
setattr(operator, target_path_name, relative_path)
|
||||
|
||||
#filename, extension = os.path.splitext(self.filepath)
|
||||
@ -172,4 +176,4 @@ def draw_folder_browser(layout, label, value, target_property):
|
||||
col.prop(bpy.context.active_operator, target_property, text="")
|
||||
|
||||
folder_selector = row.operator(OT_OpenFolderbrowser.bl_idname, icon="FILE_FOLDER", text="")
|
||||
folder_selector.target_property = target_property #"export_root_folder"
|
||||
folder_selector.target_property = target_property #"export_root_path"
|
@ -103,7 +103,7 @@ def test_export_complex(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(root_path),
|
||||
export_root_path = os.path.abspath(root_path),
|
||||
#export_blueprints_path = os.path.join("assets", "models", "library"),
|
||||
export_output_folder = os.path.join("assets", "models"), #"./models",
|
||||
#export_levels_path = os.path.join("assets", "models"),
|
||||
|
@ -53,7 +53,7 @@ def test_export_external_blueprints(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(root_path),
|
||||
export_root_path = os.path.abspath(root_path),
|
||||
#export_blueprints_path = os.path.join("assets", "models", "library"),
|
||||
#export_output_folder = os.path.join("assets", "models"), #"./models",
|
||||
#export_levels_path = os.path.join("assets", "models"),
|
||||
|
@ -82,7 +82,7 @@ def test_export_no_parameters(setup_data):
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_materials_library=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
)
|
||||
|
||||
@ -104,7 +104,7 @@ def test_export_auto_export_parameters_only(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_materials_library=True
|
||||
)
|
||||
@ -140,7 +140,7 @@ def test_export_changed_parameters(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
@ -159,7 +159,7 @@ def test_export_changed_parameters(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
@ -184,7 +184,7 @@ def test_export_changed_parameters(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
@ -200,7 +200,7 @@ def test_export_changed_parameters(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
@ -229,7 +229,7 @@ def test_export_changed_parameters(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
@ -245,7 +245,7 @@ def test_export_changed_parameters(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
|
@ -80,7 +80,7 @@ def test_export_do_not_export_blueprints(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="assets/models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=False,
|
||||
@ -107,7 +107,7 @@ def test_export_custom_blueprints_path(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
@ -133,7 +133,7 @@ def test_export_materials_library(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
@ -160,7 +160,7 @@ def test_export_materials_library_custom_path(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
@ -192,7 +192,7 @@ def test_export_collection_instances_combine_mode(setup_data): # There is more i
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_blueprints=True,
|
||||
collection_instances_combine_mode = 'Embed'
|
||||
@ -219,7 +219,7 @@ def test_export_do_not_export_marked_assets(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
@ -253,7 +253,7 @@ def test_export_separate_dynamic_and_static_objects(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
@ -281,7 +281,7 @@ def test_export_should_not_generate_orphan_data(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
|
@ -29,7 +29,7 @@ def run_auto_export(setup_data):
|
||||
auto_export_operator(
|
||||
auto_export=True,
|
||||
direct_mode=True,
|
||||
export_root_folder = os.path.abspath(setup_data["root_path"]),
|
||||
export_root_path = os.path.abspath(setup_data["root_path"]),
|
||||
export_output_folder="./models",
|
||||
export_scene_settings=True,
|
||||
export_blueprints=True,
|
||||
|
@ -121,10 +121,6 @@ classes = [
|
||||
AutoExportTracker,
|
||||
]
|
||||
|
||||
def glTF2_pre_export_callback(data):
|
||||
#print("pre_export", data)
|
||||
pass
|
||||
|
||||
def cleanup_file():
|
||||
gltf_filepath = "/home/ckaos/projects/bevy/Blender_bevy_components_worklflow/testing/bevy_example/assets/____dummy____.glb"
|
||||
if os.path.exists(gltf_filepath):
|
||||
|
@ -143,15 +143,15 @@ class AutoExportGltfAddonPreferences(AddonPreferences):
|
||||
|
||||
export_blueprints_path: StringProperty(
|
||||
name='Blueprints path',
|
||||
description='path to export the blueprints to (relative to the export folder)',
|
||||
default='assets/blueprints',
|
||||
description='path to export the blueprints to (relative to the assets folder)',
|
||||
default='blueprints',
|
||||
#subtype='DIR_PATH'
|
||||
) # type: ignore
|
||||
|
||||
export_levels_path: StringProperty(
|
||||
name='Levels path',
|
||||
description='path to export the levels (main scenes) to (relative to the export folder)',
|
||||
default='assets/levels',
|
||||
description='path to export the levels (main scenes) to (relative to the assets folder)',
|
||||
default='levels',
|
||||
#subtype='DIR_PATH'
|
||||
) # type: ignore
|
||||
|
||||
@ -172,7 +172,7 @@ class AutoExportGltfAddonPreferences(AddonPreferences):
|
||||
export_materials_path: StringProperty(
|
||||
name='Materials path',
|
||||
description='path to export the materials libraries to (relative to the export folder)',
|
||||
default='assets/materials',
|
||||
default='materials',
|
||||
#subtype='DIR_PATH'
|
||||
) # type: ignore
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user