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:
authorJulien Duroure <julien.duroure@gmail.com>2019-05-07 11:49:53 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-05-07 11:49:53 +0300
commitca0c66f7bb72c665420628fe4951f3f0d7970518 (patch)
tree43ad13737aa8288f7be78b66c9d9ebbf2e112de8 /io_scene_gltf2
parentb3514b6710228dea6dbebbb13034d6214accb81e (diff)
glTF importer: Use debug value 100 to not convert Yup to Zup
Diffstat (limited to 'io_scene_gltf2')
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_scene.py102
1 files changed, 52 insertions, 50 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_scene.py b/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
index 400e66e4..e87912ff 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_scene.py
@@ -63,15 +63,16 @@ class BlenderScene():
gltf.blender_scene = scene.name
list_nodes = BlenderScene.get_root_nodes(gltf)
- # Create Yup2Zup empty
- obj_rotation = bpy.data.objects.new("Yup2Zup", None)
- obj_rotation.rotation_mode = 'QUATERNION'
- obj_rotation.rotation_quaternion = Quaternion((sqrt(2) / 2, sqrt(2) / 2, 0.0, 0.0))
-
- if gltf.blender_active_collection is not None:
- bpy.data.collections[gltf.blender_active_collection].objects.link(obj_rotation)
- else:
- bpy.data.scenes[gltf.blender_scene].collection.objects.link(obj_rotation)
+ if bpy.app.debug_value != 100:
+ # Create Yup2Zup empty
+ obj_rotation = bpy.data.objects.new("Yup2Zup", None)
+ obj_rotation.rotation_mode = 'QUATERNION'
+ obj_rotation.rotation_quaternion = Quaternion((sqrt(2) / 2, sqrt(2) / 2, 0.0, 0.0))
+
+ if gltf.blender_active_collection is not None:
+ bpy.data.collections[gltf.blender_active_collection].objects.link(obj_rotation)
+ else:
+ bpy.data.scenes[gltf.blender_scene].collection.objects.link(obj_rotation)
if list_nodes is not None:
for node_idx in list_nodes:
@@ -101,61 +102,62 @@ class BlenderScene():
for an in gltf.current_animation_names.values():
gltf.animation_managed.append(an)
- # Parent root node to rotation object
- if list_nodes is not None:
- exclude_nodes = []
- for node_idx in list_nodes:
- if gltf.data.nodes[node_idx].is_joint:
- # Do not change parent if root node is already parented (can be the case for skinned mesh)
- if not bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name].parent:
- bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name].parent = obj_rotation
- else:
- exclude_nodes.append(node_idx)
- else:
- # Do not change parent if root node is already parented (can be the case for skinned mesh)
- if not bpy.data.objects[gltf.data.nodes[node_idx].blender_object].parent:
- bpy.data.objects[gltf.data.nodes[node_idx].blender_object].parent = obj_rotation
+ if bpy.app.debug_value != 100:
+ # Parent root node to rotation object
+ if list_nodes is not None:
+ exclude_nodes = []
+ for node_idx in list_nodes:
+ if gltf.data.nodes[node_idx].is_joint:
+ # Do not change parent if root node is already parented (can be the case for skinned mesh)
+ if not bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name].parent:
+ bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name].parent = obj_rotation
+ else:
+ exclude_nodes.append(node_idx)
else:
- exclude_nodes.append(node_idx)
+ # Do not change parent if root node is already parented (can be the case for skinned mesh)
+ if not bpy.data.objects[gltf.data.nodes[node_idx].blender_object].parent:
+ bpy.data.objects[gltf.data.nodes[node_idx].blender_object].parent = obj_rotation
+ else:
+ exclude_nodes.append(node_idx)
- if gltf.animation_object is False:
+ if gltf.animation_object is False:
- # Avoid rotation bug if collection is hidden or disabled
- if gltf.blender_active_collection is not None:
- gltf.collection_hide_viewport = bpy.data.collections[gltf.blender_active_collection].hide_viewport
- bpy.data.collections[gltf.blender_active_collection].hide_viewport = False
- # TODO for visibility ... but seems not exposed on bpy for now
+ # Avoid rotation bug if collection is hidden or disabled
+ if gltf.blender_active_collection is not None:
+ gltf.collection_hide_viewport = bpy.data.collections[gltf.blender_active_collection].hide_viewport
+ bpy.data.collections[gltf.blender_active_collection].hide_viewport = False
+ # TODO for visibility ... but seems not exposed on bpy for now
- for node_idx in list_nodes:
+ for node_idx in list_nodes:
- if node_idx in exclude_nodes:
- continue # for root node that are parented by the process
- # for example skinned meshes
+ if node_idx in exclude_nodes:
+ continue # for root node that are parented by the process
+ # for example skinned meshes
- for obj_ in bpy.context.scene.objects:
- obj_.select_set(False)
- if gltf.data.nodes[node_idx].is_joint:
- bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name].select_set(True)
- bpy.context.view_layer.objects.active = bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name]
+ for obj_ in bpy.context.scene.objects:
+ obj_.select_set(False)
+ if gltf.data.nodes[node_idx].is_joint:
+ bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name].select_set(True)
+ bpy.context.view_layer.objects.active = bpy.data.objects[gltf.data.nodes[node_idx].blender_armature_name]
- else:
- bpy.data.objects[gltf.data.nodes[node_idx].blender_object].select_set(True)
- bpy.context.view_layer.objects.active = bpy.data.objects[gltf.data.nodes[node_idx].blender_object]
+ else:
+ bpy.data.objects[gltf.data.nodes[node_idx].blender_object].select_set(True)
+ bpy.context.view_layer.objects.active = bpy.data.objects[gltf.data.nodes[node_idx].blender_object]
- bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM')
+ bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM')
- # remove object
- #bpy.context.scene.collection.objects.unlink(obj_rotation)
- bpy.data.objects.remove(obj_rotation)
+ # remove object
+ #bpy.context.scene.collection.objects.unlink(obj_rotation)
+ bpy.data.objects.remove(obj_rotation)
- # Restore collection hiden / disabled values
- if gltf.blender_active_collection is not None:
- bpy.data.collections[gltf.blender_active_collection].hide_viewport = gltf.collection_hide_viewport
- # TODO restore visibility when expose in bpy
+ # Restore collection hiden / disabled values
+ if gltf.blender_active_collection is not None:
+ bpy.data.collections[gltf.blender_active_collection].hide_viewport = gltf.collection_hide_viewport
+ # TODO restore visibility when expose in bpy
# Make first root object the new active one
if list_nodes is not None: