Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'io_scene_gltf2/__init__.py')
-rwxr-xr-xio_scene_gltf2/__init__.py152
1 files changed, 129 insertions, 23 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index ce48f293..459a8795 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -4,7 +4,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
- "version": (3, 3, 5),
+ "version": (3, 4, 10),
'blender': (3, 3, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
@@ -259,6 +259,14 @@ class ExportGLTF2_Base:
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',
@@ -372,9 +380,17 @@ class ExportGLTF2_Base:
default=True
)
+ export_nla_strips_merged_animation_name: StringProperty(
+ name='Merged Animation Name',
+ description=(
+ "Name of single glTF animation to be exported"
+ ),
+ default='Animation'
+ )
+
export_def_bones: BoolProperty(
name='Export Deformation Bones Only',
- description='Export Deformation bones only (and needed bones for hierarchy)',
+ description='Export Deformation bones only',
default=False
)
@@ -387,6 +403,15 @@ class ExportGLTF2_Base:
default=False
)
+ export_anim_single_armature: BoolProperty(
+ name='Export all Armature Actions',
+ description=(
+ "Export all actions, bound to a single armature. "
+ "WARNING: Option does not support exports including multiple armatures"
+ ),
+ default=True
+ )
+
export_current_frame: BoolProperty(
name='Use Current Frame',
description='Export the scene in the current animation frame',
@@ -430,13 +455,6 @@ class ExportGLTF2_Base:
default=False
)
- export_displacement: BoolProperty(
- name='Displacement Textures (EXPERIMENTAL)',
- description='EXPERIMENTAL: Export displacement textures. '
- 'Uses incomplete "KHR_materials_displacement" glTF extension',
- default=False
- )
-
will_save_settings: BoolProperty(
name='Remember Export Settings',
description='Store glTF export settings in the Blender project',
@@ -547,6 +565,7 @@ class ExportGLTF2_Base:
export_settings['gltf_colors'] = self.export_colors
export_settings['gltf_cameras'] = self.export_cameras
+ export_settings['gltf_original_specular'] = self.export_original_specular
export_settings['gltf_visible'] = self.use_visible
export_settings['gltf_renderable'] = self.use_renderable
@@ -560,26 +579,28 @@ class ExportGLTF2_Base:
export_settings['gltf_apply'] = self.export_apply
export_settings['gltf_current_frame'] = self.export_current_frame
export_settings['gltf_animations'] = self.export_animations
+ export_settings['gltf_def_bones'] = self.export_def_bones
if self.export_animations:
export_settings['gltf_frame_range'] = self.export_frame_range
export_settings['gltf_force_sampling'] = self.export_force_sampling
- if self.export_force_sampling:
- export_settings['gltf_def_bones'] = self.export_def_bones
- else:
+ if not self.export_force_sampling:
export_settings['gltf_def_bones'] = False
export_settings['gltf_nla_strips'] = self.export_nla_strips
+ export_settings['gltf_nla_strips_merged_animation_name'] = self.export_nla_strips_merged_animation_name
export_settings['gltf_optimize_animation'] = self.optimize_animation_size
+ export_settings['gltf_export_anim_single_armature'] = self.export_anim_single_armature
else:
export_settings['gltf_frame_range'] = False
export_settings['gltf_move_keyframes'] = False
export_settings['gltf_force_sampling'] = False
- export_settings['gltf_def_bones'] = False
export_settings['gltf_optimize_animation'] = False
+ export_settings['gltf_export_anim_single_armature'] = False
export_settings['gltf_skins'] = self.export_skins
if self.export_skins:
export_settings['gltf_all_vertex_influences'] = self.export_all_influences
else:
export_settings['gltf_all_vertex_influences'] = False
+ export_settings['gltf_def_bones'] = False
export_settings['gltf_frame_step'] = self.export_frame_step
export_settings['gltf_morph'] = self.export_morph
if self.export_morph:
@@ -592,7 +613,6 @@ class ExportGLTF2_Base:
export_settings['gltf_morph_tangent'] = False
export_settings['gltf_lights'] = self.export_lights
- export_settings['gltf_displacement'] = self.export_displacement
export_settings['gltf_binary'] = bytearray()
export_settings['gltf_binaryfilename'] = (
@@ -738,6 +758,22 @@ class GLTF_PT_export_geometry(bpy.types.Panel):
return operator.bl_idname == "EXPORT_SCENE_OT_gltf"
def draw(self, context):
+ pass
+
+class GLTF_PT_export_geometry_mesh(bpy.types.Panel):
+ bl_space_type = 'FILE_BROWSER'
+ bl_region_type = 'TOOL_PROPS'
+ bl_label = "Mesh"
+ bl_parent_id = "GLTF_PT_export_geometry"
+ 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(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False # No animation.
@@ -757,11 +793,56 @@ class GLTF_PT_export_geometry(bpy.types.Panel):
col.prop(operator, 'use_mesh_edges')
col.prop(operator, 'use_mesh_vertices')
+
+class GLTF_PT_export_geometry_material(bpy.types.Panel):
+ bl_space_type = 'FILE_BROWSER'
+ bl_region_type = 'TOOL_PROPS'
+ bl_label = "Material"
+ bl_parent_id = "GLTF_PT_export_geometry"
+ 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(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.prop(operator, 'export_materials')
col = layout.column()
col.active = operator.export_materials == "EXPORT"
col.prop(operator, 'export_image_format')
+class GLTF_PT_export_geometry_original_pbr(bpy.types.Panel):
+ bl_space_type = 'FILE_BROWSER'
+ bl_region_type = 'TOOL_PROPS'
+ bl_label = "PBR Extensions"
+ bl_parent_id = "GLTF_PT_export_geometry_material"
+ 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(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.prop(operator, 'export_original_specular')
+
class GLTF_PT_export_geometry_compression(bpy.types.Panel):
bl_space_type = 'FILE_BROWSER'
@@ -863,13 +944,10 @@ class GLTF_PT_export_animation_export(bpy.types.Panel):
layout.prop(operator, 'export_frame_step')
layout.prop(operator, 'export_force_sampling')
layout.prop(operator, 'export_nla_strips')
+ if operator.export_nla_strips is False:
+ layout.prop(operator, 'export_nla_strips_merged_animation_name')
layout.prop(operator, 'optimize_animation_size')
-
- row = layout.row()
- row.active = operator.export_force_sampling
- row.prop(operator, 'export_def_bones')
- if operator.export_force_sampling is False and operator.export_def_bones is True:
- layout.label(text="Export only deformation bones is not possible when not sampling animation")
+ layout.prop(operator, 'export_anim_single_armature')
class GLTF_PT_export_animation_shapekeys(bpy.types.Panel):
@@ -937,6 +1015,12 @@ class GLTF_PT_export_animation_skinning(bpy.types.Panel):
layout.active = operator.export_skins
layout.prop(operator, 'export_all_influences')
+ row = layout.row()
+ row.active = operator.export_force_sampling
+ row.prop(operator, 'export_def_bones')
+ if operator.export_force_sampling is False and operator.export_def_bones is True:
+ layout.label(text="Export only deformation bones is not possible when not sampling animation")
+
class GLTF_PT_export_user_extensions(bpy.types.Panel):
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOL_PROPS'
@@ -1160,19 +1244,34 @@ class ImportGLTF2(Operator, ImportHelper):
self.loglevel = logging.NOTSET
+def gltf_variant_ui_update(self, context):
+ from .blender.com.gltf2_blender_ui import variant_register, variant_unregister
+ if self.KHR_materials_variants_ui is True:
+ # register all needed types
+ variant_register()
+ else:
+ variant_unregister()
+
class GLTF_AddonPreferences(bpy.types.AddonPreferences):
bl_idname = __package__
settings_node_ui : bpy.props.BoolProperty(
default= False,
- description="Displays glTF Settings node in Shader Editor (Menu Add > Ouput)"
+ description="Displays glTF Material Output node in Shader Editor (Menu Add > Output)"
)
+ KHR_materials_variants_ui : bpy.props.BoolProperty(
+ default= False,
+ description="Displays glTF UI to manage material variants",
+ update=gltf_variant_ui_update
+ )
+
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(self, "settings_node_ui", text="Shader Editor Add-ons")
+ row.prop(self, "KHR_materials_variants_ui", text="Material Variants")
def menu_func_import(self, context):
self.layout.operator(ImportGLTF2.bl_idname, text='glTF 2.0 (.glb/.gltf)')
@@ -1184,6 +1283,9 @@ classes = (
GLTF_PT_export_include,
GLTF_PT_export_transform,
GLTF_PT_export_geometry,
+ GLTF_PT_export_geometry_mesh,
+ GLTF_PT_export_geometry_material,
+ GLTF_PT_export_geometry_original_pbr,
GLTF_PT_export_geometry_compression,
GLTF_PT_export_animation,
GLTF_PT_export_animation_export,
@@ -1203,6 +1305,8 @@ def register():
# bpy.utils.register_module(__name__)
blender_ui.register()
+ if bpy.context.preferences.addons['io_scene_gltf2'].preferences.KHR_materials_variants_ui is True:
+ blender_ui.variant_register()
# add to the export / import menu
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
@@ -1211,6 +1315,10 @@ def register():
def unregister():
import io_scene_gltf2.blender.com.gltf2_blender_ui as blender_ui
+ blender_ui.unregister()
+ if bpy.context.preferences.addons['io_scene_gltf2'].preferences.KHR_materials_variants_ui is True:
+ blender_ui.variant_unregister()
+
for c in classes:
bpy.utils.unregister_class(c)
for f in exporter_extension_panel_unregister_functors:
@@ -1221,8 +1329,6 @@ def unregister():
f()
importer_extension_panel_unregister_functors.clear()
- blender_ui.unregister()
-
# bpy.utils.unregister_module(__name__)
# remove from the export / import menu