Skip to content

Commit

Permalink
Merge branch 'import' into import-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Exairnous authored Mar 24, 2024
2 parents 4f2f74a + 0fb5c34 commit e3b048c
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addons/io_hubs_addon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ def unregister():


def register_panel():
return gltf_exporter.register_export_panel()
return panels.register_panels()
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ...utils import delayed_gather
from .video_texture_source import VideoTextureSource


BLANK_ID = "pXph8WBzMu9fung"


Expand Down
2 changes: 1 addition & 1 deletion addons/io_hubs_addon/io/gltf_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def patched_BlenderNode_create_object(gltf, vnode_id):

import_hubs_components(node, vnode.blender_object, gltf)

#  Node hooks are not called for bones. Bones are created together with their armature.
# Node hooks are not called for bones. Bones are created together with their armature.
# Unfortunately the bones are created after this hook is called so we need to wait until all nodes have been created.
if vnode.is_arma:
store_bones_for_import(gltf, vnode)
Expand Down
121 changes: 121 additions & 0 deletions addons/io_hubs_addon/io/panels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import bpy
from bpy.props import PointerProperty, IntVectorProperty, BoolProperty


class HubsComponentsExtensionProperties(bpy.types.PropertyGroup):
enabled: bpy.props.BoolProperty(
name="Export Hubs Components",
description='Include this extension in the exported glTF file',
default=True
)
version: IntVectorProperty(size=3)


class HubsGLTFExportPanel(bpy.types.Panel):

bl_idname = "HBA_PT_Export_Panel"
bl_label = "Hubs Export Panel"
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOL_PROPS'
bl_label = "Hubs Components"
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.HubsComponentsExtensionProperties
self.layout.prop(props, 'enabled', text="")

def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False # No animation.

props = bpy.context.scene.HubsComponentsExtensionProperties
layout.active = props.enabled

box = layout.box()
box.label(text="No options yet")


class HubsGLTFImportPanel(bpy.types.Panel):

bl_idname = "HBA_PT_Import_Panel"
bl_label = "Hubs Import Panel"
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOL_PROPS'
bl_label = "Hubs Components"
bl_parent_id = "GLTF_PT_import_user_extensions"
bl_options = {'DEFAULT_CLOSED'}

@classmethod
def poll(cls, context):
sfile = context.space_data
operator = sfile.active_operator
return operator.bl_idname == "IMPORT_SCENE_OT_gltf"

def draw_header(self, context):
props = bpy.context.scene.hubs_import_properties
self.layout.prop(props, 'enabled', text="")

def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False # No animation.

props = bpy.context.scene.hubs_import_properties
layout.active = props.enabled

box = layout.box()
box.label(text="No options yet")


class HubsImportProperties(bpy.types.PropertyGroup):
enabled: BoolProperty(
name="Import Hubs Components",
description='Import Hubs components from the glTF file',
default=True
)

# called by gltf-blender-io after it has loaded


def register_panels():
try:
bpy.utils.register_class(HubsGLTFExportPanel)
bpy.utils.register_class(HubsGLTFImportPanel)
except Exception:
pass
return unregister_panels


def unregister_panels():
# Since panel is registered on demand, it is possible it is not registered
try:
bpy.utils.unregister_class(HubsGLTFImportPanel)
bpy.utils.unregister_class(HubsGLTFExportPanel)
except Exception:
pass


def register():
register_panels()
bpy.utils.register_class(HubsComponentsExtensionProperties)
bpy.types.Scene.HubsComponentsExtensionProperties = PointerProperty(
type=HubsComponentsExtensionProperties)
bpy.utils.register_class(HubsImportProperties)
bpy.types.Scene.hubs_import_properties = PointerProperty(
type=HubsImportProperties)


def unregister():
del bpy.types.Scene.HubsComponentsExtensionProperties
bpy.utils.unregister_class(HubsComponentsExtensionProperties)
del bpy.types.Scene.hubs_import_properties
bpy.utils.unregister_class(HubsImportProperties)
unregister_panels()

0 comments on commit e3b048c

Please sign in to comment.