mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-22 11:50:53 +00:00
feat(auto_export): continued cleaning up overhaul
* added both gltf exporter button AND auto export button to side bar * added storage of gltf settings * auto_export now uses stored gltf settings * updated override strategies of defaults vs gltf settings * removed all gltf specific (not auto export) parameters from preferences * updated auto export operator params changed logic to use updated system * updated bevy integration test * ui improvements * various tweaks
This commit is contained in:
parent
4a0479fbf0
commit
73e81c2b64
@ -1,173 +1,192 @@
|
|||||||
import bpy
|
|
||||||
from bpy.props import (BoolProperty,
|
|
||||||
IntProperty,
|
|
||||||
StringProperty,
|
|
||||||
EnumProperty,
|
|
||||||
CollectionProperty
|
|
||||||
)
|
|
||||||
bl_info = {
|
bl_info = {
|
||||||
"name": "auto_export",
|
"name": "gltf_auto_export",
|
||||||
"category": "Generic",
|
"author": "kaosigh",
|
||||||
"version": (1, 0, 0),
|
"version": (0, 16, 0),
|
||||||
"blender": (2, 80, 0),
|
"blender": (3, 4, 0),
|
||||||
'location': 'File > Export > glTF 2.0',
|
"location": "File > Import-Export",
|
||||||
'description': 'Example addon to add a custom extension to an exported glTF file.',
|
"description": "glTF/glb auto-export",
|
||||||
'tracker_url': "https://github.com/KhronosGroup/glTF-Blender-IO/issues/", # Replace with your issue tracker
|
"warning": "",
|
||||||
'isDraft': False,
|
"wiki_url": "https://github.com/kaosat-dev/Blender_bevy_components_workflow",
|
||||||
'developer': "(Your name here)", # Replace this
|
"tracker_url": "https://github.com/kaosat-dev/Blender_bevy_components_workflow/issues/new",
|
||||||
'url': 'https://your_url_here', # Replace this
|
"category": "Import-Export"
|
||||||
}
|
}
|
||||||
|
import bpy
|
||||||
|
from bpy.types import Context
|
||||||
|
from bpy.props import (StringProperty, BoolProperty, PointerProperty)
|
||||||
|
|
||||||
# glTF extensions are named following a convention with known prefixes.
|
# from .extension import ExampleExtensionProperties, GLTF_PT_UserExtensionPanel, unregister_panel
|
||||||
# See: https://github.com/KhronosGroup/glTF/tree/main/extensions#about-gltf-extensions
|
|
||||||
# also: https://github.com/KhronosGroup/glTF/blob/main/extensions/Prefixes.md
|
|
||||||
glTF_extension_name = "EXT_auto_export"
|
|
||||||
|
|
||||||
# Support for an extension is "required" if a typical glTF viewer cannot be expected
|
from .auto_export.operators import AutoExportGLTF
|
||||||
# to load a given model without understanding the contents of the extension.
|
from .auto_export.tracker import AutoExportTracker
|
||||||
# For example, a compression scheme or new image format (with no fallback included)
|
from .auto_export.preferences import (AutoExportGltfAddonPreferences)
|
||||||
# would be "required", but physics metadata or app-specific settings could be optional.
|
|
||||||
extension_is_required = False
|
|
||||||
from io_scene_gltf2 import (GLTF_PT_export_main, GLTF_PT_export_include)
|
|
||||||
|
|
||||||
class ExampleExtensionProperties(bpy.types.PropertyGroup):
|
from .auto_export.internals import (SceneLink,
|
||||||
enabled: bpy.props.BoolProperty(
|
SceneLinks,
|
||||||
name=bl_info["name"],
|
CollectionToExport,
|
||||||
description='Include this extension in the exported glTF file.',
|
CollectionsToExport,
|
||||||
default=True
|
CUSTOM_PG_sceneName
|
||||||
)
|
)
|
||||||
|
from .ui.main import (GLTF_PT_auto_export_main,
|
||||||
auto_export_main_scene_name: StringProperty(
|
GLTF_PT_auto_export_root,
|
||||||
name='Main scene',
|
GLTF_PT_auto_export_general,
|
||||||
description='The name of the main scene/level/world to auto export',
|
GLTF_PT_auto_export_scenes,
|
||||||
default='Scene'
|
GLTF_PT_auto_export_blueprints,
|
||||||
)
|
GLTF_PT_auto_export_collections_list,
|
||||||
auto_export_output_folder: StringProperty(
|
GLTF_PT_auto_export_gltf,
|
||||||
name='Export folder (relative)',
|
SCENE_UL_GLTF_auto_export,
|
||||||
description='The root folder for all exports(relative to current file) Defaults to current folder',
|
|
||||||
default=''
|
|
||||||
)
|
|
||||||
auto_export_library_scene_name: StringProperty(
|
|
||||||
name='Library scene',
|
|
||||||
description='The name of the library scene to auto export',
|
|
||||||
default='Library'
|
|
||||||
)
|
|
||||||
# scene components
|
|
||||||
auto_export_scene_settings: BoolProperty(
|
|
||||||
name='Export scene settings',
|
|
||||||
description='Export scene settings ie AmbientLighting, Bloom, AO etc',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
# blueprint settings
|
HelloWorldOperator,
|
||||||
auto_export_blueprints: BoolProperty(
|
|
||||||
name='Export Blueprints',
|
|
||||||
description='Replaces collection instances with an Empty with a BlueprintName custom property',
|
|
||||||
default=True
|
|
||||||
)
|
|
||||||
auto_export_blueprints_path: StringProperty(
|
|
||||||
name='Blueprints path',
|
|
||||||
description='path to export the blueprints to (relative to the Export folder)',
|
|
||||||
default='library'
|
|
||||||
)
|
|
||||||
|
|
||||||
auto_export_materials_library: BoolProperty(
|
|
||||||
name='Export materials library',
|
|
||||||
description='remove materials from blueprints and use the material library instead',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
auto_export_materials_path: StringProperty(
|
|
||||||
name='Materials path',
|
|
||||||
description='path to export the materials libraries to (relative to the root folder)',
|
|
||||||
default='materials'
|
|
||||||
)
|
|
||||||
|
|
||||||
def register():
|
|
||||||
bpy.utils.register_class(ExampleExtensionProperties)
|
|
||||||
bpy.types.Scene.ExampleExtensionProperties = bpy.props.PointerProperty(type=ExampleExtensionProperties)
|
|
||||||
|
|
||||||
def register_panel():
|
|
||||||
# Register the panel on demand, we need to be sure to only register it once
|
|
||||||
# This is necessary because the panel is a child of the extensions panel,
|
|
||||||
# which may not be registered when we try to register this extension
|
|
||||||
try:
|
|
||||||
bpy.utils.register_class(GLTF_PT_UserExtensionPanel)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# If the glTF exporter is disabled, we need to unregister the extension panel
|
|
||||||
# Just return a function to the exporter so it can unregister the panel
|
|
||||||
return unregister_panel
|
|
||||||
|
|
||||||
|
|
||||||
def unregister_panel():
|
#GLTF_PT_export_data,
|
||||||
# Since panel is registered on demand, it is possible it is not registered
|
#GLTF_PT_export_data_scene
|
||||||
try:
|
)
|
||||||
bpy.utils.unregister_class(GLTF_PT_UserExtensionPanel)
|
from .ui.operators import (SCENES_LIST_OT_actions)
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
######################################################
|
||||||
unregister_panel()
|
""" there are two places where we load settings for auto_export from:
|
||||||
bpy.utils.unregister_class(ExampleExtensionProperties)
|
- in ui/main AutoExportGLTF -> invoke
|
||||||
del bpy.types.Scene.ExampleExtensionProperties
|
- in auto_export.py -> auto_export
|
||||||
|
This is a workaround needed because of the way the settings are stored , perhaps there is a better way to deal with it ? ie by calling the AutoExportGLTF operator from the auto_export function ?
|
||||||
|
"""
|
||||||
|
from io_scene_gltf2 import (ExportGLTF2, GLTF_PT_export_main, GLTF_PT_export_include)
|
||||||
|
|
||||||
class GLTF_PT_UserExtensionPanel(bpy.types.Panel):
|
|
||||||
|
|
||||||
bl_space_type = 'FILE_BROWSER'
|
class Testing_PT_MainPanel(bpy.types.Panel):
|
||||||
bl_region_type = 'TOOL_PROPS'
|
bl_idname = "Testing_PT_MainPanel"
|
||||||
bl_label = "Enabled"
|
bl_label = ""
|
||||||
bl_parent_id = "GLTF_PT_export_user_extensions"
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_region_type = 'UI'
|
||||||
|
bl_category = "Gltf auto_export"
|
||||||
|
bl_context = "objectmode"
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def poll(cls, context):
|
|
||||||
sfile = context.space_data
|
|
||||||
operator = sfile.active_operator
|
|
||||||
return operator.bl_idname == "EXPORT_SCENE_OT_gltf"
|
|
||||||
|
|
||||||
def draw_header(self, context):
|
def draw_header(self, context):
|
||||||
props = bpy.context.scene.ExampleExtensionProperties
|
layout = self.layout
|
||||||
self.layout.prop(props, 'enabled')
|
layout.label(text="Gltf auto export ")
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.use_property_split = True
|
layout.label(text="MAKE SURE TO KEEP 'REMEMBER EXPORT SETTINGS' !!")
|
||||||
layout.use_property_decorate = False # No animation.
|
op = layout.operator("EXPORT_SCENE_OT_gltf", text='Gltf Settings')#'glTF 2.0 (.glb/.gltf)')
|
||||||
|
#op.export_format = 'GLTF_SEPARATE'
|
||||||
props = bpy.context.scene.ExampleExtensionProperties
|
op.use_selection=True
|
||||||
layout.active = props.enabled
|
op.will_save_settings=True
|
||||||
|
op.use_visible=True # Export visible and hidden objects. See Object/Batch Export to skip.
|
||||||
props = bpy.context.scene.ExampleExtensionProperties
|
op.use_renderable=True
|
||||||
for bla in props.__annotations__:
|
op.use_active_collection = True
|
||||||
layout.prop(props, bla)
|
op.use_active_collection_with_nested=True
|
||||||
|
op.use_active_scene = True
|
||||||
|
op.filepath="dummy"
|
||||||
|
|
||||||
|
|
||||||
class glTF2ExportUserExtension:
|
op = layout.operator("EXPORT_SCENES_OT_auto_gltf", text="Auto Export Settings")
|
||||||
|
op.will_save_settings=True
|
||||||
|
|
||||||
def __init__(self):
|
#print("GLTF_PT_export_main", GLTF_PT_export_main.bl_parent_id)
|
||||||
# We need to wait until we create the gltf2UserExtension to import the gltf2 modules
|
|
||||||
# Otherwise, it may fail because the gltf2 may not be loaded yet
|
|
||||||
from io_scene_gltf2.io.com.gltf2_io_extensions import Extension
|
|
||||||
self.Extension = Extension
|
|
||||||
self.properties = bpy.context.scene.ExampleExtensionProperties
|
|
||||||
|
|
||||||
def gather_node_hook(self, gltf2_object, blender_object, export_settings):
|
|
||||||
if self.properties.enabled:
|
|
||||||
if gltf2_object.extensions is None:
|
|
||||||
gltf2_object.extensions = {}
|
|
||||||
print("bla bla")
|
|
||||||
gltf2_object.extensions[glTF_extension_name] = self.Extension(
|
|
||||||
name=glTF_extension_name,
|
|
||||||
extension={"auto_export_blueprints": self.properties.auto_export_blueprints},
|
|
||||||
required=extension_is_required
|
|
||||||
)
|
|
||||||
def pre_export_hook(self):
|
|
||||||
print("pre export callback")
|
|
||||||
|
|
||||||
def glTF2_pre_export_callback(data):
|
#see here for original gltf exporter infos https://github.com/KhronosGroup/glTF-Blender-IO/blob/main/addons/io_scene_gltf2/__init__.py
|
||||||
print("pre_export", data)
|
classes = [
|
||||||
|
SceneLink,
|
||||||
|
SceneLinks,
|
||||||
|
CUSTOM_PG_sceneName,
|
||||||
|
SCENE_UL_GLTF_auto_export,
|
||||||
|
SCENES_LIST_OT_actions,
|
||||||
|
|
||||||
def glTF2_post_export_callback(data):
|
AutoExportGLTF,
|
||||||
print("post_export", data)
|
#AutoExportGltfAddonPreferences,
|
||||||
|
|
||||||
|
HelloWorldOperator,
|
||||||
|
|
||||||
|
CollectionToExport,
|
||||||
|
CollectionsToExport,
|
||||||
|
|
||||||
|
GLTF_PT_auto_export_main,
|
||||||
|
GLTF_PT_auto_export_root,
|
||||||
|
GLTF_PT_auto_export_general,
|
||||||
|
GLTF_PT_auto_export_scenes,
|
||||||
|
GLTF_PT_auto_export_blueprints,
|
||||||
|
|
||||||
|
#GLTF_PT_auto_export_collections_list,
|
||||||
|
#GLTF_PT_auto_export_gltf,
|
||||||
|
#GLTF_PT_export_data,
|
||||||
|
#GLTF_PT_export_data_scene,
|
||||||
|
|
||||||
|
AutoExportTracker,
|
||||||
|
|
||||||
|
Testing_PT_MainPanel,
|
||||||
|
]
|
||||||
|
|
||||||
|
def menu_func_import(self, context):
|
||||||
|
self.layout.operator(AutoExportGLTF.bl_idname, text="glTF auto Export (.glb/gltf)")
|
||||||
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
|
@persistent
|
||||||
|
def post_update(scene, depsgraph):
|
||||||
|
bpy.context.window_manager.auto_export_tracker.deps_update_handler( scene, depsgraph)
|
||||||
|
|
||||||
|
@persistent
|
||||||
|
def post_save(scene, depsgraph):
|
||||||
|
bpy.context.window_manager.auto_export_tracker.save_handler( scene, depsgraph)
|
||||||
|
|
||||||
|
|
||||||
|
def invoke_override(self, context, event):
|
||||||
|
settings = context.scene.get(self.scene_key)
|
||||||
|
self.will_save_settings = False
|
||||||
|
if settings:
|
||||||
|
try:
|
||||||
|
for (k, v) in settings.items():
|
||||||
|
setattr(self, k, v)
|
||||||
|
self.will_save_settings = True
|
||||||
|
|
||||||
|
# Update filter if user saved settings
|
||||||
|
if hasattr(self, 'export_format'):
|
||||||
|
self.filter_glob = '*.glb' if self.export_format == 'GLB' else '*.gltf'
|
||||||
|
|
||||||
|
except (AttributeError, TypeError):
|
||||||
|
self.report({"ERROR"}, "Loading export settings failed. Removed corrupted settings")
|
||||||
|
del context.scene[self.scene_key]
|
||||||
|
|
||||||
|
import sys
|
||||||
|
preferences = bpy.context.preferences
|
||||||
|
for addon_name in preferences.addons.keys():
|
||||||
|
try:
|
||||||
|
if hasattr(sys.modules[addon_name], 'glTF2ExportUserExtension') or hasattr(sys.modules[addon_name], 'glTF2ExportUserExtensions'):
|
||||||
|
pass #exporter_extension_panel_unregister_functors.append(sys.modules[addon_name].register_panel())
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# self.has_active_exporter_extensions = len(exporter_extension_panel_unregister_functors) > 0
|
||||||
|
print("ovverride")
|
||||||
|
wm = context.window_manager
|
||||||
|
wm.fileselect_add(self)
|
||||||
|
return {'RUNNING_MODAL'}
|
||||||
|
|
||||||
|
|
||||||
|
def register():
|
||||||
|
for cls in classes:
|
||||||
|
bpy.utils.register_class(cls)
|
||||||
|
# for some reason, adding these directly to the tracker class in register() do not work reliably
|
||||||
|
bpy.app.handlers.depsgraph_update_post.append(post_update)
|
||||||
|
bpy.app.handlers.save_post.append(post_save)
|
||||||
|
|
||||||
|
# add our addon to the toolbar
|
||||||
|
bpy.types.TOPBAR_MT_file_export.append(menu_func_import)
|
||||||
|
|
||||||
|
bpy.types.WindowManager.gltf_exporter_running = BoolProperty(default=False)
|
||||||
|
bpy.types.WindowManager.gltf_settings_changed = BoolProperty(default=False)
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
for cls in classes:
|
||||||
|
bpy.utils.unregister_class(cls)
|
||||||
|
bpy.types.TOPBAR_MT_file_export.remove(menu_func_import)
|
||||||
|
|
||||||
|
bpy.app.handlers.depsgraph_update_post.remove(post_update)
|
||||||
|
bpy.app.handlers.save_post.remove(post_save)
|
||||||
|
del bpy.types.WindowManager.gltf_exporter_running
|
||||||
|
|
||||||
|
|
||||||
|
if "gltf_auto_export" == "__main__":
|
||||||
|
register()
|
||||||
|
173
tools/gltf_auto_export/__init___extension.py
Normal file
173
tools/gltf_auto_export/__init___extension.py
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
import bpy
|
||||||
|
from bpy.props import (BoolProperty,
|
||||||
|
IntProperty,
|
||||||
|
StringProperty,
|
||||||
|
EnumProperty,
|
||||||
|
CollectionProperty
|
||||||
|
)
|
||||||
|
bl_info = {
|
||||||
|
"name": "auto_export",
|
||||||
|
"category": "Generic",
|
||||||
|
"version": (1, 0, 0),
|
||||||
|
"blender": (2, 80, 0),
|
||||||
|
'location': 'File > Export > glTF 2.0',
|
||||||
|
'description': 'Example addon to add a custom extension to an exported glTF file.',
|
||||||
|
'tracker_url': "https://github.com/KhronosGroup/glTF-Blender-IO/issues/", # Replace with your issue tracker
|
||||||
|
'isDraft': False,
|
||||||
|
'developer': "(Your name here)", # Replace this
|
||||||
|
'url': 'https://your_url_here', # Replace this
|
||||||
|
}
|
||||||
|
|
||||||
|
# glTF extensions are named following a convention with known prefixes.
|
||||||
|
# See: https://github.com/KhronosGroup/glTF/tree/main/extensions#about-gltf-extensions
|
||||||
|
# also: https://github.com/KhronosGroup/glTF/blob/main/extensions/Prefixes.md
|
||||||
|
glTF_extension_name = "EXT_auto_export"
|
||||||
|
|
||||||
|
# Support for an extension is "required" if a typical glTF viewer cannot be expected
|
||||||
|
# to load a given model without understanding the contents of the extension.
|
||||||
|
# For example, a compression scheme or new image format (with no fallback included)
|
||||||
|
# would be "required", but physics metadata or app-specific settings could be optional.
|
||||||
|
extension_is_required = False
|
||||||
|
from io_scene_gltf2 import (GLTF_PT_export_main, GLTF_PT_export_include)
|
||||||
|
|
||||||
|
class ExampleExtensionProperties(bpy.types.PropertyGroup):
|
||||||
|
enabled: bpy.props.BoolProperty(
|
||||||
|
name=bl_info["name"],
|
||||||
|
description='Include this extension in the exported glTF file.',
|
||||||
|
default=True
|
||||||
|
)
|
||||||
|
|
||||||
|
auto_export_main_scene_name: StringProperty(
|
||||||
|
name='Main scene',
|
||||||
|
description='The name of the main scene/level/world to auto export',
|
||||||
|
default='Scene'
|
||||||
|
)
|
||||||
|
auto_export_output_folder: StringProperty(
|
||||||
|
name='Export folder (relative)',
|
||||||
|
description='The root folder for all exports(relative to current file) Defaults to current folder',
|
||||||
|
default=''
|
||||||
|
)
|
||||||
|
auto_export_library_scene_name: StringProperty(
|
||||||
|
name='Library scene',
|
||||||
|
description='The name of the library scene to auto export',
|
||||||
|
default='Library'
|
||||||
|
)
|
||||||
|
# scene components
|
||||||
|
auto_export_scene_settings: BoolProperty(
|
||||||
|
name='Export scene settings',
|
||||||
|
description='Export scene settings ie AmbientLighting, Bloom, AO etc',
|
||||||
|
default=False
|
||||||
|
)
|
||||||
|
|
||||||
|
# blueprint settings
|
||||||
|
auto_export_blueprints: BoolProperty(
|
||||||
|
name='Export Blueprints',
|
||||||
|
description='Replaces collection instances with an Empty with a BlueprintName custom property',
|
||||||
|
default=True
|
||||||
|
)
|
||||||
|
auto_export_blueprints_path: StringProperty(
|
||||||
|
name='Blueprints path',
|
||||||
|
description='path to export the blueprints to (relative to the Export folder)',
|
||||||
|
default='library'
|
||||||
|
)
|
||||||
|
|
||||||
|
auto_export_materials_library: BoolProperty(
|
||||||
|
name='Export materials library',
|
||||||
|
description='remove materials from blueprints and use the material library instead',
|
||||||
|
default=False
|
||||||
|
)
|
||||||
|
auto_export_materials_path: StringProperty(
|
||||||
|
name='Materials path',
|
||||||
|
description='path to export the materials libraries to (relative to the root folder)',
|
||||||
|
default='materials'
|
||||||
|
)
|
||||||
|
|
||||||
|
def register():
|
||||||
|
bpy.utils.register_class(ExampleExtensionProperties)
|
||||||
|
bpy.types.Scene.ExampleExtensionProperties = bpy.props.PointerProperty(type=ExampleExtensionProperties)
|
||||||
|
|
||||||
|
def register_panel():
|
||||||
|
# Register the panel on demand, we need to be sure to only register it once
|
||||||
|
# This is necessary because the panel is a child of the extensions panel,
|
||||||
|
# which may not be registered when we try to register this extension
|
||||||
|
try:
|
||||||
|
bpy.utils.register_class(GLTF_PT_UserExtensionPanel)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# If the glTF exporter is disabled, we need to unregister the extension panel
|
||||||
|
# Just return a function to the exporter so it can unregister the panel
|
||||||
|
return unregister_panel
|
||||||
|
|
||||||
|
|
||||||
|
def unregister_panel():
|
||||||
|
# Since panel is registered on demand, it is possible it is not registered
|
||||||
|
try:
|
||||||
|
bpy.utils.unregister_class(GLTF_PT_UserExtensionPanel)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
unregister_panel()
|
||||||
|
bpy.utils.unregister_class(ExampleExtensionProperties)
|
||||||
|
del bpy.types.Scene.ExampleExtensionProperties
|
||||||
|
|
||||||
|
class GLTF_PT_UserExtensionPanel(bpy.types.Panel):
|
||||||
|
|
||||||
|
bl_space_type = 'FILE_BROWSER'
|
||||||
|
bl_region_type = 'TOOL_PROPS'
|
||||||
|
bl_label = "Enabled"
|
||||||
|
bl_parent_id = "GLTF_PT_export_user_extensions"
|
||||||
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
return operator.bl_idname == "EXPORT_SCENE_OT_gltf"
|
||||||
|
|
||||||
|
def draw_header(self, context):
|
||||||
|
props = bpy.context.scene.ExampleExtensionProperties
|
||||||
|
self.layout.prop(props, 'enabled')
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.use_property_split = True
|
||||||
|
layout.use_property_decorate = False # No animation.
|
||||||
|
|
||||||
|
props = bpy.context.scene.ExampleExtensionProperties
|
||||||
|
layout.active = props.enabled
|
||||||
|
|
||||||
|
props = bpy.context.scene.ExampleExtensionProperties
|
||||||
|
for bla in props.__annotations__:
|
||||||
|
layout.prop(props, bla)
|
||||||
|
|
||||||
|
|
||||||
|
class glTF2ExportUserExtension:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
# We need to wait until we create the gltf2UserExtension to import the gltf2 modules
|
||||||
|
# Otherwise, it may fail because the gltf2 may not be loaded yet
|
||||||
|
from io_scene_gltf2.io.com.gltf2_io_extensions import Extension
|
||||||
|
self.Extension = Extension
|
||||||
|
self.properties = bpy.context.scene.ExampleExtensionProperties
|
||||||
|
|
||||||
|
def gather_node_hook(self, gltf2_object, blender_object, export_settings):
|
||||||
|
if self.properties.enabled:
|
||||||
|
if gltf2_object.extensions is None:
|
||||||
|
gltf2_object.extensions = {}
|
||||||
|
print("bla bla")
|
||||||
|
gltf2_object.extensions[glTF_extension_name] = self.Extension(
|
||||||
|
name=glTF_extension_name,
|
||||||
|
extension={"auto_export_blueprints": self.properties.auto_export_blueprints},
|
||||||
|
required=extension_is_required
|
||||||
|
)
|
||||||
|
def pre_export_hook(self):
|
||||||
|
print("pre export callback")
|
||||||
|
|
||||||
|
def glTF2_pre_export_callback(data):
|
||||||
|
print("pre_export", data)
|
||||||
|
|
||||||
|
def glTF2_post_export_callback(data):
|
||||||
|
print("post_export", data)
|
@ -1,189 +0,0 @@
|
|||||||
bl_info = {
|
|
||||||
"name": "gltf_auto_export",
|
|
||||||
"author": "kaosigh",
|
|
||||||
"version": (0, 16, 0),
|
|
||||||
"blender": (3, 4, 0),
|
|
||||||
"location": "File > Import-Export",
|
|
||||||
"description": "glTF/glb auto-export",
|
|
||||||
"warning": "",
|
|
||||||
"wiki_url": "https://github.com/kaosat-dev/Blender_bevy_components_workflow",
|
|
||||||
"tracker_url": "https://github.com/kaosat-dev/Blender_bevy_components_workflow/issues/new",
|
|
||||||
"category": "Import-Export"
|
|
||||||
}
|
|
||||||
import bpy
|
|
||||||
from bpy.types import Context
|
|
||||||
from bpy.props import (StringProperty, BoolProperty, PointerProperty)
|
|
||||||
|
|
||||||
from .extension import ExampleExtensionProperties, GLTF_PT_UserExtensionPanel, unregister_panel
|
|
||||||
|
|
||||||
from .auto_export.operators import AutoExportGLTF
|
|
||||||
from .auto_export.tracker import AutoExportTracker
|
|
||||||
from .auto_export.preferences import (AutoExportGltfAddonPreferences)
|
|
||||||
|
|
||||||
from .auto_export.internals import (SceneLink,
|
|
||||||
SceneLinks,
|
|
||||||
CollectionToExport,
|
|
||||||
CollectionsToExport,
|
|
||||||
CUSTOM_PG_sceneName
|
|
||||||
)
|
|
||||||
from .ui.main import (GLTF_PT_auto_export_main,
|
|
||||||
GLTF_PT_auto_export_root,
|
|
||||||
GLTF_PT_auto_export_blueprints,
|
|
||||||
GLTF_PT_auto_export_collections_list,
|
|
||||||
GLTF_PT_auto_export_gltf,
|
|
||||||
SCENE_UL_GLTF_auto_export,
|
|
||||||
|
|
||||||
|
|
||||||
#GLTF_PT_export_data,
|
|
||||||
#GLTF_PT_export_data_scene
|
|
||||||
)
|
|
||||||
from .ui.operators import (SCENES_LIST_OT_actions)
|
|
||||||
|
|
||||||
|
|
||||||
######################################################
|
|
||||||
""" there are two places where we load settings for auto_export from:
|
|
||||||
- in ui/main AutoExportGLTF -> invoke
|
|
||||||
- in auto_export.py -> auto_export
|
|
||||||
This is a workaround needed because of the way the settings are stored , perhaps there is a better way to deal with it ? ie by calling the AutoExportGLTF operator from the auto_export function ?
|
|
||||||
"""
|
|
||||||
from io_scene_gltf2 import (ExportGLTF2, GLTF_PT_export_main, GLTF_PT_export_include)
|
|
||||||
|
|
||||||
|
|
||||||
class Testing_PT_MainPanel(bpy.types.Panel):
|
|
||||||
bl_idname = "Testing_PT_MainPanel"
|
|
||||||
bl_label = ""
|
|
||||||
bl_space_type = 'VIEW_3D'
|
|
||||||
bl_region_type = 'UI'
|
|
||||||
bl_category = "Gltf auto_export"
|
|
||||||
bl_context = "objectmode"
|
|
||||||
|
|
||||||
|
|
||||||
def draw_header(self, context):
|
|
||||||
layout = self.layout
|
|
||||||
layout.label(text="Gltf auto export ")
|
|
||||||
|
|
||||||
def draw(self, context):
|
|
||||||
layout = self.layout
|
|
||||||
layout.label(text="MAKE SURE TO KEEP 'REMEMBER EXPORT SETTINGS' !!")
|
|
||||||
op = layout.operator("EXPORT_SCENE_OT_gltf", text='Gltf settings')#'glTF 2.0 (.glb/.gltf)')
|
|
||||||
#op.export_format = 'GLTF_SEPARATE'
|
|
||||||
op.use_selection=True
|
|
||||||
op.will_save_settings=True
|
|
||||||
op.use_visible=True # Export visible and hidden objects. See Object/Batch Export to skip.
|
|
||||||
op.use_renderable=True
|
|
||||||
op.use_active_collection = True
|
|
||||||
op.use_active_collection_with_nested=True
|
|
||||||
op.use_active_scene = True
|
|
||||||
op.filepath="dummy"
|
|
||||||
#print("GLTF_PT_export_main", GLTF_PT_export_main.bl_parent_id)
|
|
||||||
|
|
||||||
|
|
||||||
#see here for original gltf exporter infos https://github.com/KhronosGroup/glTF-Blender-IO/blob/main/addons/io_scene_gltf2/__init__.py
|
|
||||||
classes = [
|
|
||||||
SceneLink,
|
|
||||||
SceneLinks,
|
|
||||||
CUSTOM_PG_sceneName,
|
|
||||||
SCENE_UL_GLTF_auto_export,
|
|
||||||
SCENES_LIST_OT_actions,
|
|
||||||
|
|
||||||
AutoExportGLTF,
|
|
||||||
#AutoExportGltfAddonPreferences,
|
|
||||||
|
|
||||||
CollectionToExport,
|
|
||||||
CollectionsToExport,
|
|
||||||
|
|
||||||
GLTF_PT_auto_export_main,
|
|
||||||
GLTF_PT_auto_export_root,
|
|
||||||
GLTF_PT_auto_export_blueprints,
|
|
||||||
#GLTF_PT_auto_export_collections_list,
|
|
||||||
GLTF_PT_auto_export_gltf,
|
|
||||||
#GLTF_PT_export_data,
|
|
||||||
#GLTF_PT_export_data_scene,
|
|
||||||
|
|
||||||
AutoExportTracker,
|
|
||||||
|
|
||||||
#Testing_PT_MainPanel,
|
|
||||||
]
|
|
||||||
|
|
||||||
def menu_func_import(self, context):
|
|
||||||
self.layout.operator(AutoExportGLTF.bl_idname, text="glTF auto Export (.glb/gltf)")
|
|
||||||
from bpy.app.handlers import persistent
|
|
||||||
|
|
||||||
@persistent
|
|
||||||
def post_update(scene, depsgraph):
|
|
||||||
bpy.context.window_manager.auto_export_tracker.deps_update_handler( scene, depsgraph)
|
|
||||||
|
|
||||||
@persistent
|
|
||||||
def post_save(scene, depsgraph):
|
|
||||||
bpy.context.window_manager.auto_export_tracker.save_handler( scene, depsgraph)
|
|
||||||
|
|
||||||
|
|
||||||
def invoke_override(self, context, event):
|
|
||||||
settings = context.scene.get(self.scene_key)
|
|
||||||
self.will_save_settings = False
|
|
||||||
if settings:
|
|
||||||
try:
|
|
||||||
for (k, v) in settings.items():
|
|
||||||
setattr(self, k, v)
|
|
||||||
self.will_save_settings = True
|
|
||||||
|
|
||||||
# Update filter if user saved settings
|
|
||||||
if hasattr(self, 'export_format'):
|
|
||||||
self.filter_glob = '*.glb' if self.export_format == 'GLB' else '*.gltf'
|
|
||||||
|
|
||||||
except (AttributeError, TypeError):
|
|
||||||
self.report({"ERROR"}, "Loading export settings failed. Removed corrupted settings")
|
|
||||||
del context.scene[self.scene_key]
|
|
||||||
|
|
||||||
import sys
|
|
||||||
preferences = bpy.context.preferences
|
|
||||||
for addon_name in preferences.addons.keys():
|
|
||||||
try:
|
|
||||||
if hasattr(sys.modules[addon_name], 'glTF2ExportUserExtension') or hasattr(sys.modules[addon_name], 'glTF2ExportUserExtensions'):
|
|
||||||
pass #exporter_extension_panel_unregister_functors.append(sys.modules[addon_name].register_panel())
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# self.has_active_exporter_extensions = len(exporter_extension_panel_unregister_functors) > 0
|
|
||||||
print("ovverride")
|
|
||||||
wm = context.window_manager
|
|
||||||
wm.fileselect_add(self)
|
|
||||||
return {'RUNNING_MODAL'}
|
|
||||||
|
|
||||||
|
|
||||||
def register():
|
|
||||||
for cls in classes:
|
|
||||||
bpy.utils.register_class(cls)
|
|
||||||
# for some reason, adding these directly to the tracker class in register() do not work reliably
|
|
||||||
bpy.app.handlers.depsgraph_update_post.append(post_update)
|
|
||||||
bpy.app.handlers.save_post.append(post_save)
|
|
||||||
|
|
||||||
# add our addon to the toolbar
|
|
||||||
bpy.types.TOPBAR_MT_file_export.append(menu_func_import)
|
|
||||||
|
|
||||||
bpy.types.WindowManager.was_good_operator = BoolProperty(default=False)
|
|
||||||
bpy.types.Scene.was_good_operator = BoolProperty(default=False)
|
|
||||||
|
|
||||||
|
|
||||||
# ExportGLTF2.invoke = invoke_override
|
|
||||||
GLTF_PT_export_main.bl_parent_id = "GLTF_PT_auto_export_root"
|
|
||||||
|
|
||||||
bpy.utils.register_class(ExampleExtensionProperties)
|
|
||||||
bpy.utils.register_class(GLTF_PT_UserExtensionPanel)
|
|
||||||
|
|
||||||
bpy.types.Scene.ExampleExtensionProperties = bpy.props.PointerProperty(type=ExampleExtensionProperties)
|
|
||||||
|
|
||||||
def unregister():
|
|
||||||
for cls in classes:
|
|
||||||
bpy.utils.unregister_class(cls)
|
|
||||||
bpy.types.TOPBAR_MT_file_export.remove(menu_func_import)
|
|
||||||
|
|
||||||
bpy.app.handlers.depsgraph_update_post.remove(post_update)
|
|
||||||
bpy.app.handlers.save_post.remove(post_save)
|
|
||||||
|
|
||||||
unregister_panel()
|
|
||||||
bpy.utils.unregister_class(ExampleExtensionProperties)
|
|
||||||
del bpy.types.Scene.ExampleExtensionProperties
|
|
||||||
|
|
||||||
if "gltf_auto_export" == "__main__":
|
|
||||||
register()
|
|
@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
import traceback
|
import traceback
|
||||||
@ -33,6 +34,11 @@ def auto_export(changes_per_scene, changed_export_parameters, addon_prefs):
|
|||||||
|
|
||||||
[main_scene_names, level_scenes, library_scene_names, library_scenes] = get_scenes(addon_prefs)
|
[main_scene_names, level_scenes, library_scene_names, library_scenes] = get_scenes(addon_prefs)
|
||||||
|
|
||||||
|
# standard gltf export settings are stored differently
|
||||||
|
standard_gltf_exporter_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")
|
||||||
|
print("standard_gltf_exporter_settings", standard_gltf_exporter_settings.as_string())
|
||||||
|
standard_gltf_exporter_settings = json.loads(standard_gltf_exporter_settings.as_string())
|
||||||
|
|
||||||
print("main scenes", main_scene_names, "library_scenes", library_scene_names)
|
print("main scenes", main_scene_names, "library_scenes", library_scene_names)
|
||||||
print("export_output_folder", export_output_folder)
|
print("export_output_folder", export_output_folder)
|
||||||
|
|
||||||
@ -63,7 +69,8 @@ def auto_export(changes_per_scene, changed_export_parameters, addon_prefs):
|
|||||||
export_blueprints_path = os.path.join(folder_path, export_output_folder, getattr(addon_prefs,"export_blueprints_path")) if getattr(addon_prefs,"export_blueprints_path") != '' else folder_path
|
export_blueprints_path = os.path.join(folder_path, export_output_folder, getattr(addon_prefs,"export_blueprints_path")) if getattr(addon_prefs,"export_blueprints_path") != '' else folder_path
|
||||||
export_levels_path = os.path.join(folder_path, export_output_folder)
|
export_levels_path = os.path.join(folder_path, export_output_folder)
|
||||||
|
|
||||||
gltf_extension = getattr(addon_prefs, "export_format")
|
|
||||||
|
gltf_extension = standard_gltf_exporter_settings.get("export_format", 'GLB')
|
||||||
gltf_extension = '.glb' if gltf_extension == 'GLB' else '.gltf'
|
gltf_extension = '.glb' if gltf_extension == 'GLB' else '.gltf'
|
||||||
collections_not_on_disk = check_if_blueprints_exist(collections, export_blueprints_path, gltf_extension)
|
collections_not_on_disk = check_if_blueprints_exist(collections, export_blueprints_path, gltf_extension)
|
||||||
changed_collections = []
|
changed_collections = []
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
@ -7,7 +8,7 @@ from .preferences import (AutoExportGltfPreferenceNames)
|
|||||||
def generate_gltf_export_preferences(addon_prefs):
|
def generate_gltf_export_preferences(addon_prefs):
|
||||||
# default values
|
# default values
|
||||||
gltf_export_preferences = dict(
|
gltf_export_preferences = dict(
|
||||||
export_format= 'GLB', #'GLB', 'GLTF_SEPARATE', 'GLTF_EMBEDDED'
|
# export_format= 'GLB', #'GLB', 'GLTF_SEPARATE', 'GLTF_EMBEDDED'
|
||||||
check_existing=False,
|
check_existing=False,
|
||||||
|
|
||||||
use_selection=False,
|
use_selection=False,
|
||||||
@ -17,41 +18,48 @@ def generate_gltf_export_preferences(addon_prefs):
|
|||||||
use_active_collection_with_nested=False,
|
use_active_collection_with_nested=False,
|
||||||
use_active_scene = False,
|
use_active_scene = False,
|
||||||
|
|
||||||
export_texcoords=True,
|
|
||||||
export_normals=True,
|
|
||||||
# here add draco settings
|
|
||||||
export_draco_mesh_compression_enable = False,
|
|
||||||
|
|
||||||
export_tangents=False,
|
|
||||||
#export_materials
|
|
||||||
export_colors=True,
|
|
||||||
export_attributes=True,
|
|
||||||
#use_mesh_edges
|
|
||||||
#use_mesh_vertices
|
|
||||||
export_cameras=True,
|
export_cameras=True,
|
||||||
export_extras=True, # For custom exported properties.
|
export_extras=True, # For custom exported properties.
|
||||||
export_lights=True,
|
export_lights=True,
|
||||||
export_yup=True,
|
|
||||||
export_skins=True,
|
#export_texcoords=True,
|
||||||
export_morph=False,
|
#export_normals=True,
|
||||||
export_apply=False,
|
# here add draco settings
|
||||||
export_animations=False,
|
#export_draco_mesh_compression_enable = False,
|
||||||
export_optimize_animation_size=False
|
|
||||||
|
#export_tangents=False,
|
||||||
|
#export_materials
|
||||||
|
#export_colors=True,
|
||||||
|
#export_attributes=True,
|
||||||
|
#use_mesh_edges
|
||||||
|
#use_mesh_vertices
|
||||||
|
|
||||||
|
|
||||||
|
#export_yup=True,
|
||||||
|
#export_skins=True,
|
||||||
|
#export_morph=False,
|
||||||
|
#export_apply=False,
|
||||||
|
#export_animations=False,
|
||||||
|
#export_optimize_animation_size=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for key in addon_prefs.__annotations__.keys():
|
for key in addon_prefs.__annotations__.keys():
|
||||||
if str(key) not in AutoExportGltfPreferenceNames:
|
if str(key) not in AutoExportGltfPreferenceNames:
|
||||||
#print("overriding setting", key, "value", getattr(addon_prefs,key))
|
#print("overriding setting", key, "value", getattr(addon_prefs,key))
|
||||||
gltf_export_preferences[key] = getattr(addon_prefs, key)
|
gltf_export_preferences[key] = getattr(addon_prefs, key)
|
||||||
|
|
||||||
|
|
||||||
"""standard_gltf_exporter_settings = get_standard_exporter_settings()
|
standard_gltf_exporter_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")
|
||||||
|
standard_gltf_exporter_settings = json.loads(standard_gltf_exporter_settings.as_string())
|
||||||
|
"""standard_gltf_exporter_settings = get_standard_exporter_settings()"""
|
||||||
print("standard settings", standard_gltf_exporter_settings)
|
print("standard settings", standard_gltf_exporter_settings)
|
||||||
|
|
||||||
constant_keys = [
|
constant_keys = [
|
||||||
|
'use_selection',
|
||||||
|
'use_visible',
|
||||||
|
'use_active_collection',
|
||||||
|
'use_active_collection_with_nested',
|
||||||
|
'use_active_scene',
|
||||||
'export_cameras',
|
'export_cameras',
|
||||||
'export_extras', # For custom exported properties.
|
'export_extras', # For custom exported properties.
|
||||||
'export_lights',
|
'export_lights',
|
||||||
@ -61,8 +69,8 @@ def generate_gltf_export_preferences(addon_prefs):
|
|||||||
for key in standard_gltf_exporter_settings.keys():
|
for key in standard_gltf_exporter_settings.keys():
|
||||||
if str(key) not in constant_keys:
|
if str(key) not in constant_keys:
|
||||||
gltf_export_preferences[key] = standard_gltf_exporter_settings.get(key)
|
gltf_export_preferences[key] = standard_gltf_exporter_settings.get(key)
|
||||||
|
print("")
|
||||||
print("final export preferences", gltf_export_preferences)"""
|
print("final export preferences", gltf_export_preferences)
|
||||||
|
|
||||||
|
|
||||||
return gltf_export_preferences
|
return gltf_export_preferences
|
||||||
|
@ -10,7 +10,7 @@ from .auto_export import auto_export
|
|||||||
|
|
||||||
from io_scene_gltf2 import (ExportGLTF2, GLTF_PT_export_main,ExportGLTF2_Base, GLTF_PT_export_include)
|
from io_scene_gltf2 import (ExportGLTF2, GLTF_PT_export_main,ExportGLTF2_Base, GLTF_PT_export_include)
|
||||||
|
|
||||||
class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper, ExportGLTF2_Base):
|
class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper):
|
||||||
"""auto export gltf"""
|
"""auto export gltf"""
|
||||||
#bl_idname = "object.xxx"
|
#bl_idname = "object.xxx"
|
||||||
bl_idname = "export_scenes.auto_gltf"
|
bl_idname = "export_scenes.auto_gltf"
|
||||||
@ -86,10 +86,6 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper, Exp
|
|||||||
# FIXME: really weird having to do this
|
# FIXME: really weird having to do this
|
||||||
if k == "collection_instances_combine_mode":
|
if k == "collection_instances_combine_mode":
|
||||||
value = self.collection_instances_combine_mode
|
value = self.collection_instances_combine_mode
|
||||||
if k == "export_format":
|
|
||||||
value = self.export_format
|
|
||||||
if k == "export_image_format":
|
|
||||||
value = self.export_image_format
|
|
||||||
if k == "export_materials":
|
if k == "export_materials":
|
||||||
value = self.export_materials
|
value = self.export_materials
|
||||||
export_props[k] = value
|
export_props[k] = value
|
||||||
@ -147,19 +143,13 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper, Exp
|
|||||||
bpy.data.texts.remove(bpy.data.texts[".gltf_auto_export_settings"])
|
bpy.data.texts.remove(bpy.data.texts[".gltf_auto_export_settings"])
|
||||||
|
|
||||||
def did_export_settings_change(self):
|
def did_export_settings_change(self):
|
||||||
previous_export_settings = bpy.data.texts[".gltf_auto_export_gltf_settings"] if ".gltf_auto_export_gltf_settings" in bpy.data.texts else None
|
# compare both the auto export settings & the gltf settings
|
||||||
|
previous_export_settings = bpy.data.texts[".gltf_auto_export_settings"] if ".gltf_auto_export_settings" in bpy.data.texts else None
|
||||||
|
changed_gltf_settings = bpy.context.window_manager.gltf_settings_changed
|
||||||
# if there was no setting before, it is new, we need export
|
# if there was no setting before, it is new, we need export
|
||||||
|
print("changed settings", changed_gltf_settings, previous_export_settings.as_string())
|
||||||
if previous_export_settings == None:
|
if previous_export_settings == None:
|
||||||
export_settings = {}
|
return changed_gltf_settings
|
||||||
for (k, v) in self.properties.items():
|
|
||||||
if k not in AutoExportGltfPreferenceNames:
|
|
||||||
export_settings[k] = v
|
|
||||||
export_settings = str(export_settings)
|
|
||||||
# the actual gltf export settings, not those of auto export
|
|
||||||
stored_export_settings = bpy.data.texts.new(".gltf_auto_export_gltf_settings")
|
|
||||||
stored_export_settings.write(export_settings)
|
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
export_settings = {}
|
export_settings = {}
|
||||||
for (k, v) in self.properties.items():
|
for (k, v) in self.properties.items():
|
||||||
@ -167,14 +157,13 @@ class AutoExportGLTF(Operator, AutoExportGltfAddonPreferences, ExportHelper, Exp
|
|||||||
export_settings[k] = v
|
export_settings[k] = v
|
||||||
|
|
||||||
if len(export_settings.keys()) == 0: # first time after we already used the addon, since we already have export settings, but they have not yet been applied
|
if len(export_settings.keys()) == 0: # first time after we already used the addon, since we already have export settings, but they have not yet been applied
|
||||||
return False
|
return changed_gltf_settings
|
||||||
|
|
||||||
export_settings = str(export_settings)
|
# print("foo", json.loads(previous_export_settings.as_string()).items())
|
||||||
changed = export_settings != previous_export_settings.as_string()
|
changed = sorted(json.loads(previous_export_settings.as_string()).items()) != sorted(export_settings.items())
|
||||||
|
|
||||||
previous_export_settings.clear()
|
print("changed final", changed and changed_gltf_settings)
|
||||||
previous_export_settings.write(export_settings)
|
return changed and changed_gltf_settings
|
||||||
return changed
|
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
# disable change detection while the operator runs
|
# disable change detection while the operator runs
|
||||||
|
@ -39,7 +39,6 @@ AutoExportGltfPreferenceNames = [
|
|||||||
'main_scene_names',
|
'main_scene_names',
|
||||||
'library_scene_names',
|
'library_scene_names',
|
||||||
'previous_export_settings',
|
'previous_export_settings',
|
||||||
'filter_glob',
|
|
||||||
'will_save_settings',
|
'will_save_settings',
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -50,11 +49,6 @@ class AutoExportGltfAddonPreferences(AddonPreferences):
|
|||||||
bl_options = {'PRESET'}
|
bl_options = {'PRESET'}
|
||||||
|
|
||||||
#### these are for the operator
|
#### these are for the operator
|
||||||
filter_glob: StringProperty(
|
|
||||||
default='*.glb;*.gltf',
|
|
||||||
options={'HIDDEN'}
|
|
||||||
)
|
|
||||||
|
|
||||||
will_save_settings: BoolProperty(
|
will_save_settings: BoolProperty(
|
||||||
name='Remember Export Settings',
|
name='Remember Export Settings',
|
||||||
description='Store glTF export settings in the Blender project',
|
description='Store glTF export settings in the Blender project',
|
||||||
@ -166,252 +160,3 @@ class AutoExportGltfAddonPreferences(AddonPreferences):
|
|||||||
|
|
||||||
library_scenes: CollectionProperty(name="library scenes", type=CUSTOM_PG_sceneName)
|
library_scenes: CollectionProperty(name="library scenes", type=CUSTOM_PG_sceneName)
|
||||||
library_scenes_index: IntProperty(name = "Index for library scenes list", default = 0)
|
library_scenes_index: IntProperty(name = "Index for library scenes list", default = 0)
|
||||||
|
|
||||||
#####
|
|
||||||
export_format: EnumProperty(
|
|
||||||
name='Format',
|
|
||||||
items=(
|
|
||||||
('GLB', 'glTF Binary (.glb)',
|
|
||||||
'Exports a single file, with all data packed in binary form. '
|
|
||||||
'Most efficient and portable, but more difficult to edit later'),
|
|
||||||
('GLTF_SEPARATE', 'glTF Separate (.gltf + .bin + textures)',
|
|
||||||
'Exports multiple files, with separate JSON, binary and texture data. '
|
|
||||||
'Easiest to edit later')
|
|
||||||
),
|
|
||||||
description=(
|
|
||||||
'Output format and embedding options. Binary is most efficient, '
|
|
||||||
'but JSON (embedded or separate) may be easier to edit later'
|
|
||||||
),
|
|
||||||
default='GLB'
|
|
||||||
)
|
|
||||||
export_copyright: StringProperty(
|
|
||||||
name='Copyright',
|
|
||||||
description='Legal rights and conditions for the model',
|
|
||||||
default=''
|
|
||||||
)
|
|
||||||
|
|
||||||
export_image_format: EnumProperty(
|
|
||||||
name='Images',
|
|
||||||
items=(('AUTO', 'Automatic',
|
|
||||||
'Save PNGs as PNGs and JPEGs as JPEGs. '
|
|
||||||
'If neither one, use PNG'),
|
|
||||||
('JPEG', 'JPEG Format (.jpg)',
|
|
||||||
'Save images as JPEGs. (Images that need alpha are saved as PNGs though.) '
|
|
||||||
'Be aware of a possible loss in quality'),
|
|
||||||
('NONE', 'None',
|
|
||||||
'Don\'t export images'),
|
|
||||||
),
|
|
||||||
description=(
|
|
||||||
'Output format for images. PNG is lossless and generally preferred, but JPEG might be preferable for web '
|
|
||||||
'applications due to the smaller file size. Alternatively they can be omitted if they are not needed'
|
|
||||||
),
|
|
||||||
default='AUTO'
|
|
||||||
)
|
|
||||||
|
|
||||||
export_texture_dir: StringProperty(
|
|
||||||
name='Textures',
|
|
||||||
description='Folder to place texture files in. Relative to the .gltf file',
|
|
||||||
default='',
|
|
||||||
)
|
|
||||||
|
|
||||||
"""
|
|
||||||
export_jpeg_quality: IntProperty(
|
|
||||||
name='JPEG quality',
|
|
||||||
description='Quality of JPEG export',
|
|
||||||
default=75,
|
|
||||||
min=0,
|
|
||||||
max=100
|
|
||||||
)
|
|
||||||
"""
|
|
||||||
|
|
||||||
export_keep_originals: BoolProperty(
|
|
||||||
name='Keep original',
|
|
||||||
description=('Keep original textures files if possible. '
|
|
||||||
'WARNING: if you use more than one texture, '
|
|
||||||
'where pbr standard requires only one, only one texture will be used. '
|
|
||||||
'This can lead to unexpected results'
|
|
||||||
),
|
|
||||||
default=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
export_texcoords: BoolProperty(
|
|
||||||
name='UVs',
|
|
||||||
description='Export UVs (texture coordinates) with meshes',
|
|
||||||
default=True
|
|
||||||
)
|
|
||||||
|
|
||||||
export_normals: BoolProperty(
|
|
||||||
name='Normals',
|
|
||||||
description='Export vertex normals with meshes',
|
|
||||||
default=True
|
|
||||||
)
|
|
||||||
|
|
||||||
export_draco_mesh_compression_enable: BoolProperty(
|
|
||||||
name='Draco mesh compression',
|
|
||||||
description='Compress mesh using Draco',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
export_draco_mesh_compression_level: IntProperty(
|
|
||||||
name='Compression level',
|
|
||||||
description='Compression level (0 = most speed, 6 = most compression, higher values currently not supported)',
|
|
||||||
default=6,
|
|
||||||
min=0,
|
|
||||||
max=10
|
|
||||||
)
|
|
||||||
|
|
||||||
export_draco_position_quantization: IntProperty(
|
|
||||||
name='Position quantization bits',
|
|
||||||
description='Quantization bits for position values (0 = no quantization)',
|
|
||||||
default=14,
|
|
||||||
min=0,
|
|
||||||
max=30
|
|
||||||
)
|
|
||||||
|
|
||||||
export_draco_normal_quantization: IntProperty(
|
|
||||||
name='Normal quantization bits',
|
|
||||||
description='Quantization bits for normal values (0 = no quantization)',
|
|
||||||
default=10,
|
|
||||||
min=0,
|
|
||||||
max=30
|
|
||||||
)
|
|
||||||
|
|
||||||
export_draco_texcoord_quantization: IntProperty(
|
|
||||||
name='Texcoord quantization bits',
|
|
||||||
description='Quantization bits for texture coordinate values (0 = no quantization)',
|
|
||||||
default=12,
|
|
||||||
min=0,
|
|
||||||
max=30
|
|
||||||
)
|
|
||||||
|
|
||||||
export_draco_color_quantization: IntProperty(
|
|
||||||
name='Color quantization bits',
|
|
||||||
description='Quantization bits for color values (0 = no quantization)',
|
|
||||||
default=10,
|
|
||||||
min=0,
|
|
||||||
max=30
|
|
||||||
)
|
|
||||||
|
|
||||||
export_draco_generic_quantization: IntProperty(
|
|
||||||
name='Generic quantization bits',
|
|
||||||
description='Quantization bits for generic coordinate values like weights or joints (0 = no quantization)',
|
|
||||||
default=12,
|
|
||||||
min=0,
|
|
||||||
max=30
|
|
||||||
)
|
|
||||||
|
|
||||||
export_tangents: BoolProperty(
|
|
||||||
name='Tangents',
|
|
||||||
description='Export vertex tangents with meshes',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
export_materials: EnumProperty(
|
|
||||||
name='Materials',
|
|
||||||
items=(('EXPORT', 'Export',
|
|
||||||
'Export all materials used by included objects'),
|
|
||||||
('PLACEHOLDER', 'Placeholder',
|
|
||||||
'Do not export materials, but write multiple primitive groups per mesh, keeping material slot information'),
|
|
||||||
('NONE', 'No export',
|
|
||||||
'Do not export materials, and combine mesh primitive groups, losing material slot information')),
|
|
||||||
description='Export materials',
|
|
||||||
default='EXPORT'
|
|
||||||
)
|
|
||||||
|
|
||||||
export_original_specular: BoolProperty(
|
|
||||||
name='Export original PBR Specular',
|
|
||||||
description=(
|
|
||||||
'Export original glTF PBR Specular, instead of Blender Principled Shader Specular'
|
|
||||||
),
|
|
||||||
default=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
export_colors: BoolProperty(
|
|
||||||
name='Vertex Colors',
|
|
||||||
description='Export vertex colors with meshes',
|
|
||||||
default=True
|
|
||||||
)
|
|
||||||
|
|
||||||
export_attributes: BoolProperty(
|
|
||||||
name='Attributes',
|
|
||||||
description='Export Attributes (when starting with underscore)',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
use_mesh_edges: BoolProperty(
|
|
||||||
name='Loose Edges',
|
|
||||||
description=(
|
|
||||||
'Export loose edges as lines, using the material from the first material slot'
|
|
||||||
),
|
|
||||||
default=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
use_mesh_vertices: BoolProperty(
|
|
||||||
name='Loose Points',
|
|
||||||
description=(
|
|
||||||
'Export loose points as glTF points, using the material from the first material slot'
|
|
||||||
),
|
|
||||||
default=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
export_cameras: BoolProperty(
|
|
||||||
name='Cameras',
|
|
||||||
description='Export cameras',
|
|
||||||
default=True
|
|
||||||
)
|
|
||||||
|
|
||||||
use_selection: BoolProperty(
|
|
||||||
name='Selected Objects',
|
|
||||||
description='Export selected objects only',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
use_visible: BoolProperty(
|
|
||||||
name='Visible Objects',
|
|
||||||
description='Export visible objects only',
|
|
||||||
default=True
|
|
||||||
)
|
|
||||||
|
|
||||||
use_renderable: BoolProperty(
|
|
||||||
name='Renderable Objects',
|
|
||||||
description='Export renderable objects only',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
export_apply: BoolProperty(
|
|
||||||
name='Export Apply Modifiers',
|
|
||||||
description='Apply modifiers (excluding Armatures) to mesh objects -'
|
|
||||||
'WARNING: prevents exporting shape keys',
|
|
||||||
default=True
|
|
||||||
)
|
|
||||||
|
|
||||||
export_yup: BoolProperty(
|
|
||||||
name='+Y Up',
|
|
||||||
description='Export using glTF convention, +Y up',
|
|
||||||
default=True
|
|
||||||
)
|
|
||||||
|
|
||||||
use_visible: BoolProperty(
|
|
||||||
name='Visible Objects',
|
|
||||||
description='Export visible objects only',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
use_renderable: BoolProperty(
|
|
||||||
name='Renderable Objects',
|
|
||||||
description='Export renderable objects only',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
export_extras: BoolProperty(
|
|
||||||
name='Custom Properties',
|
|
||||||
description='Export custom properties as glTF extras',
|
|
||||||
default=True
|
|
||||||
)
|
|
||||||
|
|
||||||
export_animations: BoolProperty(
|
|
||||||
name='Animations',
|
|
||||||
description='Exports active actions and NLA tracks as glTF animations',
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import bpy
|
import bpy
|
||||||
from bpy.types import (PropertyGroup)
|
from bpy.types import (PropertyGroup)
|
||||||
from bpy.props import (PointerProperty)
|
from bpy.props import (PointerProperty)
|
||||||
@ -52,35 +53,47 @@ class AutoExportTracker(PropertyGroup):
|
|||||||
def gltf_exporter_handler(cls):
|
def gltf_exporter_handler(cls):
|
||||||
# FOr some reason, the active operator here is always None, so using a workaround
|
# FOr some reason, the active operator here is always None, so using a workaround
|
||||||
# active_operator = bpy.context.active_operator
|
# active_operator = bpy.context.active_operator
|
||||||
print("here", bpy.context.window_manager.was_good_operator)
|
print("here", bpy.context.window_manager.gltf_exporter_running)
|
||||||
|
|
||||||
if bpy.context.window_manager.was_good_operator:
|
if bpy.context.window_manager.gltf_exporter_running:
|
||||||
dummy_file_path = "/home/ckaos/projects/bevy/Blender_bevy_components_worklflow/testing/bevy_example/assets/dummy.glb"
|
try:
|
||||||
|
dummy_file_path = "/home/ckaos/projects/bevy/Blender_bevy_components_worklflow/testing/bevy_example/assets/dummy.glb"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
if os.path.exists(dummy_file_path):
|
if os.path.exists(dummy_file_path):
|
||||||
print("dummy file exists, assuming it worked")
|
print("dummy file exists, assuming it worked")
|
||||||
os.unlink(dummy_file_path)
|
os.unlink(dummy_file_path)
|
||||||
|
|
||||||
# get the parameters
|
# get the parameters
|
||||||
scene = bpy.context.scene
|
scene = bpy.context.scene
|
||||||
print("scene", scene["glTF2ExportSettings"])
|
|
||||||
if "glTF2ExportSettings" in scene:
|
|
||||||
settings = scene["glTF2ExportSettings"]
|
|
||||||
print("gltf settings", dict(settings))
|
|
||||||
|
|
||||||
# now reset the original gltf_settings
|
|
||||||
if getattr(cls, "existing_gltf_settings", None) != None:
|
|
||||||
print("resetting original gltf settings")
|
|
||||||
scene["glTF2ExportSettings"] = cls.existing_gltf_settings
|
|
||||||
else:
|
|
||||||
print("no pre_existing settings")
|
|
||||||
if "glTF2ExportSettings" in scene:
|
if "glTF2ExportSettings" in scene:
|
||||||
del scene["glTF2ExportSettings"]
|
settings = scene["glTF2ExportSettings"]
|
||||||
cls.existing_gltf_settings = None
|
formatted_settings = dict(settings)
|
||||||
|
|
||||||
bpy.context.window_manager.was_good_operator = False
|
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")
|
||||||
return None
|
|
||||||
|
#check if params have changed
|
||||||
|
bpy.context.window_manager.gltf_settings_changed = sorted(json.loads(export_settings.as_string()).items()) != sorted(formatted_settings.items())
|
||||||
|
|
||||||
|
print("gltf NEW settings", formatted_settings, "OLD settings", export_settings, "CHANGED ?", bpy.context.window_manager.gltf_settings_changed)
|
||||||
|
|
||||||
|
# now write new settings
|
||||||
|
export_settings.clear()
|
||||||
|
export_settings.write(json.dumps(formatted_settings))
|
||||||
|
|
||||||
|
|
||||||
|
# now reset the original gltf_settings
|
||||||
|
if getattr(cls, "existing_gltf_settings", None) != None:
|
||||||
|
print("resetting original gltf settings")
|
||||||
|
scene["glTF2ExportSettings"] = cls.existing_gltf_settings
|
||||||
|
else:
|
||||||
|
print("no pre_existing settings")
|
||||||
|
if "glTF2ExportSettings" in scene:
|
||||||
|
del scene["glTF2ExportSettings"]
|
||||||
|
cls.existing_gltf_settings = None
|
||||||
|
except:pass
|
||||||
|
bpy.context.window_manager.gltf_exporter_running = False
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -95,8 +108,9 @@ class AutoExportTracker(PropertyGroup):
|
|||||||
# print("change detection enabled", cls.change_detection_enabled)
|
# print("change detection enabled", cls.change_detection_enabled)
|
||||||
active_operator = bpy.context.active_operator
|
active_operator = bpy.context.active_operator
|
||||||
if active_operator:
|
if active_operator:
|
||||||
#print("Operator", active_operator.bl_label, active_operator.bl_idname)
|
print("Operator", active_operator.bl_label, active_operator.bl_idname, "bla", bpy.context.window_manager.gltf_exporter_running)
|
||||||
if active_operator.bl_idname == "EXPORT_SCENE_OT_gltf" and not bpy.context.window_manager.was_good_operator:
|
if active_operator.bl_idname == "EXPORT_SCENE_OT_gltf" and not bpy.context.window_manager.gltf_exporter_running:
|
||||||
|
print("matching")
|
||||||
try:
|
try:
|
||||||
bpy.app.timers.unregister(cls.gltf_exporter_handler)
|
bpy.app.timers.unregister(cls.gltf_exporter_handler)
|
||||||
except:pass
|
except:pass
|
||||||
@ -110,12 +124,12 @@ class AutoExportTracker(PropertyGroup):
|
|||||||
if "glTF2ExportSettings" in scene:
|
if "glTF2ExportSettings" in scene:
|
||||||
existing_setting = scene["glTF2ExportSettings"]
|
existing_setting = scene["glTF2ExportSettings"]
|
||||||
cls.existing_gltf_settings = existing_setting
|
cls.existing_gltf_settings = existing_setting
|
||||||
bpy.context.window_manager.was_good_operator = True
|
bpy.context.window_manager.gltf_exporter_running = True
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if bpy.context.window_manager.was_good_operator:
|
if bpy.context.window_manager.gltf_exporter_running:
|
||||||
bpy.context.window_manager.was_good_operator = False
|
bpy.context.window_manager.gltf_exporter_running = False
|
||||||
"""if active_operator.bl_idname == "EXPORT_SCENE_OT_gltf":
|
"""if active_operator.bl_idname == "EXPORT_SCENE_OT_gltf":
|
||||||
scene = bpy.context.scene
|
scene = bpy.context.scene
|
||||||
if "glTF2ExportSettings" in scene:
|
if "glTF2ExportSettings" in scene:
|
||||||
@ -154,7 +168,7 @@ class AutoExportTracker(PropertyGroup):
|
|||||||
|
|
||||||
# depsgraph = bpy.context.evaluated_depsgraph_get()
|
# depsgraph = bpy.context.evaluated_depsgraph_get()
|
||||||
for obj in depsgraph.updates:
|
for obj in depsgraph.updates:
|
||||||
print("depsgraph update", obj)
|
# print("depsgraph update", obj)
|
||||||
if isinstance(obj.id, bpy.types.Object):
|
if isinstance(obj.id, bpy.types.Object):
|
||||||
# get the actual object
|
# get the actual object
|
||||||
object = bpy.data.objects[obj.id.name]
|
object = bpy.data.objects[obj.id.name]
|
||||||
@ -178,9 +192,9 @@ class AutoExportTracker(PropertyGroup):
|
|||||||
else:
|
else:
|
||||||
cls.changed_objects_per_scene.clear()
|
cls.changed_objects_per_scene.clear()
|
||||||
|
|
||||||
depsgraph = bpy.context.evaluated_depsgraph_get()
|
"""depsgraph = bpy.context.evaluated_depsgraph_get()
|
||||||
for update in depsgraph.updates:
|
for update in depsgraph.updates:
|
||||||
print("update", update)
|
print("update", update)"""
|
||||||
|
|
||||||
def disable_change_detection(self,):
|
def disable_change_detection(self,):
|
||||||
self.change_detection_enabled = False
|
self.change_detection_enabled = False
|
||||||
|
@ -64,9 +64,19 @@ def test_export_complex(setup_data):
|
|||||||
"library_scene_names": ['Library'],
|
"library_scene_names": ['Library'],
|
||||||
# "export_format":'GLTF_SEPARATE'
|
# "export_format":'GLTF_SEPARATE'
|
||||||
}
|
}
|
||||||
stored_settings = bpy.data.texts[".gltf_auto_export_settings"] if ".gltf_auto_export_settings" in bpy.data.texts else bpy.data.texts.new(".gltf_auto_export_settings")
|
gltf_settings = {
|
||||||
stored_settings.clear()
|
"export_animations": True
|
||||||
stored_settings.write(json.dumps(export_props))
|
}
|
||||||
|
|
||||||
|
# store settings for the auto_export part
|
||||||
|
stored_auto_settings = bpy.data.texts[".gltf_auto_export_settings"] if ".gltf_auto_export_settings" in bpy.data.texts else bpy.data.texts.new(".gltf_auto_export_settings")
|
||||||
|
stored_auto_settings.clear()
|
||||||
|
stored_auto_settings.write(json.dumps(export_props))
|
||||||
|
|
||||||
|
# and store settings for the gltf part
|
||||||
|
stored_gltf_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")
|
||||||
|
stored_gltf_settings.clear()
|
||||||
|
stored_gltf_settings.write(str(gltf_settings))
|
||||||
|
|
||||||
# move the main cube
|
# move the main cube
|
||||||
bpy.data.objects["Cube"].location = [1, 0, 0]
|
bpy.data.objects["Cube"].location = [1, 0, 0]
|
||||||
@ -79,7 +89,6 @@ def test_export_complex(setup_data):
|
|||||||
export_scene_settings=True,
|
export_scene_settings=True,
|
||||||
export_blueprints=True,
|
export_blueprints=True,
|
||||||
export_legacy_mode=False,
|
export_legacy_mode=False,
|
||||||
export_animations=True,
|
|
||||||
export_materials_library=True
|
export_materials_library=True
|
||||||
)
|
)
|
||||||
# blueprint1 => has an instance, got changed, should export
|
# blueprint1 => has an instance, got changed, should export
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
from typing import Set
|
||||||
import bpy
|
import bpy
|
||||||
from bpy.types import Operator
|
from bpy.types import Context, Event, Operator
|
||||||
from bpy_extras.io_utils import ExportHelper
|
from bpy_extras.io_utils import ExportHelper
|
||||||
from bpy.props import (BoolProperty,
|
from bpy.props import (BoolProperty,
|
||||||
IntProperty,
|
IntProperty,
|
||||||
@ -65,11 +66,61 @@ class GLTF_PT_auto_export_root(bpy.types.Panel):
|
|||||||
|
|
||||||
layout.active = operator.auto_export
|
layout.active = operator.auto_export
|
||||||
layout.prop(operator, 'will_save_settings')
|
layout.prop(operator, 'will_save_settings')
|
||||||
layout.prop(operator, "export_change_detection")
|
|
||||||
|
class GLTF_PT_auto_export_general(bpy.types.Panel):
|
||||||
|
bl_space_type = 'FILE_BROWSER'
|
||||||
|
bl_region_type = 'TOOL_PROPS'
|
||||||
|
bl_label = "General"
|
||||||
|
bl_parent_id = "GLTF_PT_auto_export_root"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
return operator.bl_idname == "EXPORT_SCENES_OT_auto_gltf" #"EXPORT_SCENE_OT_gltf"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.use_property_split = True
|
||||||
|
layout.use_property_decorate = False # No animation.
|
||||||
|
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
layout.active = operator.auto_export
|
||||||
layout.prop(operator, "export_output_folder")
|
layout.prop(operator, "export_output_folder")
|
||||||
|
layout.prop(operator, "export_change_detection")
|
||||||
layout.prop(operator, "export_scene_settings")
|
layout.prop(operator, "export_scene_settings")
|
||||||
layout.prop(operator, "export_legacy_mode")
|
layout.prop(operator, "export_legacy_mode")
|
||||||
|
|
||||||
|
class GLTF_PT_auto_export_scenes(bpy.types.Panel):
|
||||||
|
bl_space_type = 'FILE_BROWSER'
|
||||||
|
bl_region_type = 'TOOL_PROPS'
|
||||||
|
bl_label = "Scenes"
|
||||||
|
bl_parent_id = "GLTF_PT_auto_export_root"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
return operator.bl_idname == "EXPORT_SCENES_OT_auto_gltf" #"EXPORT_SCENE_OT_gltf"
|
||||||
|
|
||||||
|
def draw_header(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
#layout.label(text="export scenes")#layout.prop(operator, "export_blueprints", text="")
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.use_property_split = True
|
||||||
|
layout.use_property_decorate = False # No animation.
|
||||||
|
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
# scene selectors
|
# scene selectors
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
col = row.column(align=True)
|
col = row.column(align=True)
|
||||||
@ -80,8 +131,9 @@ class GLTF_PT_auto_export_root(bpy.types.Panel):
|
|||||||
rows = 2
|
rows = 2
|
||||||
|
|
||||||
# main/level scenes
|
# main/level scenes
|
||||||
layout.label(text="main scenes")
|
row = layout.row()
|
||||||
layout.prop(context.window_manager, "main_scene", text='')
|
row.label(text="main scenes")
|
||||||
|
row.prop(context.window_manager, "main_scene", text='')
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.template_list("SCENE_UL_GLTF_auto_export", "level scenes", source, "main_scenes", source, "main_scenes_index", rows=rows)
|
row.template_list("SCENE_UL_GLTF_auto_export", "level scenes", source, "main_scenes", source, "main_scenes_index", rows=rows)
|
||||||
@ -105,8 +157,9 @@ class GLTF_PT_auto_export_root(bpy.types.Panel):
|
|||||||
#col.operator("scene_list.list_action", icon='TRIA_DOWN', text="").action = 'DOWN'
|
#col.operator("scene_list.list_action", icon='TRIA_DOWN', text="").action = 'DOWN'
|
||||||
|
|
||||||
# library scenes
|
# library scenes
|
||||||
layout.label(text="library scenes")
|
row = layout.row()
|
||||||
layout.prop(context.window_manager, "library_scene", text='')
|
row.label(text="library scenes")
|
||||||
|
row.prop(context.window_manager, "library_scene", text='')
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.template_list("SCENE_UL_GLTF_auto_export", "library scenes", source, "library_scenes", source, "library_scenes_index", rows=rows)
|
row.template_list("SCENE_UL_GLTF_auto_export", "library scenes", source, "library_scenes", source, "library_scenes_index", rows=rows)
|
||||||
@ -124,7 +177,7 @@ class GLTF_PT_auto_export_root(bpy.types.Panel):
|
|||||||
remove_operator.action = 'REMOVE'
|
remove_operator.action = 'REMOVE'
|
||||||
remove_operator.scene_type = 'library'
|
remove_operator.scene_type = 'library'
|
||||||
col.separator()
|
col.separator()
|
||||||
|
|
||||||
class GLTF_PT_auto_export_blueprints(bpy.types.Panel):
|
class GLTF_PT_auto_export_blueprints(bpy.types.Panel):
|
||||||
bl_space_type = 'FILE_BROWSER'
|
bl_space_type = 'FILE_BROWSER'
|
||||||
bl_region_type = 'TOOL_PROPS'
|
bl_region_type = 'TOOL_PROPS'
|
||||||
@ -194,6 +247,37 @@ class GLTF_PT_auto_export_collections_list(bpy.types.Panel):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.label(text=collection.name)
|
row.label(text=collection.name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class HelloWorldOperator(bpy.types.Operator):
|
||||||
|
bl_idname = "export_scenes.wrapper"
|
||||||
|
bl_label = "Minimal Operator"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
print("Hello World")
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
def invoke(self, context: Context, event: Event):
|
||||||
|
wm = context.window_manager
|
||||||
|
wm.fileselect_add(self)
|
||||||
|
|
||||||
|
return {'RUNNING_MODAL'}
|
||||||
|
|
||||||
|
|
||||||
|
def draw(self, context: Context):
|
||||||
|
layout = self.layout
|
||||||
|
op = layout.operator("EXPORT_SCENE_OT_gltf", text='Gltf settings')#'glTF 2.0 (.glb/.gltf)')
|
||||||
|
op.use_selection=True
|
||||||
|
op.will_save_settings=True
|
||||||
|
op.use_visible=True # Export visible and hidden objects. See Object/Batch Export to skip.
|
||||||
|
op.use_renderable=True
|
||||||
|
op.use_active_collection = True
|
||||||
|
op.use_active_collection_with_nested=True
|
||||||
|
op.use_active_scene = True
|
||||||
|
op.filepath="dummy"
|
||||||
|
#export_scenes.auto_gltf
|
||||||
|
|
||||||
|
|
||||||
class GLTF_PT_auto_export_gltf(bpy.types.Panel):
|
class GLTF_PT_auto_export_gltf(bpy.types.Panel):
|
||||||
bl_space_type = 'FILE_BROWSER'
|
bl_space_type = 'FILE_BROWSER'
|
||||||
bl_region_type = 'TOOL_PROPS'
|
bl_region_type = 'TOOL_PROPS'
|
||||||
@ -214,13 +298,20 @@ class GLTF_PT_auto_export_gltf(bpy.types.Panel):
|
|||||||
|
|
||||||
sfile = context.space_data
|
sfile = context.space_data
|
||||||
operator = sfile.active_operator
|
operator = sfile.active_operator
|
||||||
|
|
||||||
addon_prefs = operator
|
addon_prefs = operator
|
||||||
|
|
||||||
# we get the addon preferences from the standard gltf exporter & use those :
|
op = layout.operator("EXPORT_SCENES_OT_wrapper", text='Gltf settings')#'glTF 2.0 (.glb/.gltf)')
|
||||||
addon_prefs_gltf = preferences.addons["io_scene_gltf2"].preferences
|
|
||||||
|
|
||||||
#self.layout.operator("EXPORT_SCENE_OT_gltf", text='glTF 2.0 (.glb/.gltf)')
|
op = layout.operator("EXPORT_SCENE_OT_gltf", text='Gltf settings')#'glTF 2.0 (.glb/.gltf)')
|
||||||
|
#op.export_format = 'GLTF_SEPARATE'
|
||||||
|
op.use_selection=True
|
||||||
|
op.will_save_settings=True
|
||||||
|
op.use_visible=True # Export visible and hidden objects. See Object/Batch Export to skip.
|
||||||
|
op.use_renderable=True
|
||||||
|
op.use_active_collection = True
|
||||||
|
op.use_active_collection_with_nested=True
|
||||||
|
op.use_active_scene = True
|
||||||
|
op.filepath="dummy"
|
||||||
#bpy.ops.export_scene.gltf
|
#bpy.ops.export_scene.gltf
|
||||||
|
|
||||||
"""for key in addon_prefs.__annotations__.keys():
|
"""for key in addon_prefs.__annotations__.keys():
|
||||||
|
@ -65,8 +65,10 @@ class GLTF_PT_auto_export_root(bpy.types.Panel):
|
|||||||
|
|
||||||
sfile = context.space_data
|
sfile = context.space_data
|
||||||
operator = layout.operator("export_scenes.auto_gltf")#bpy.ops.export_scenes.auto_gltf #sfile.active_operator
|
operator = layout.operator("export_scenes.auto_gltf")#bpy.ops.export_scenes.auto_gltf #sfile.active_operator
|
||||||
|
layout.prop(context.window_manager.operator_properties_last("export_scenes.auto_gltf"), "export_change_detection")
|
||||||
|
layout.prop(context.window_manager.operator_properties_last("export_scenes.auto_gltf"), "export_output_folder")
|
||||||
|
|
||||||
layout.active = operator.auto_export
|
#layout.active = operator.auto_export
|
||||||
layout.prop(operator, 'will_save_settings')
|
layout.prop(operator, 'will_save_settings')
|
||||||
layout.prop(operator, "export_change_detection")
|
layout.prop(operator, "export_change_detection")
|
||||||
layout.prop(operator, "export_output_folder")
|
layout.prop(operator, "export_output_folder")
|
||||||
|
Loading…
Reference in New Issue
Block a user