Fix missing animations when converting some FBX from json to binary #104911
@ -320,8 +320,8 @@ def get_shadeless_node(dest_node_tree):
|
||||
output_node = node_tree.nodes.new('NodeGroupOutput')
|
||||
input_node = node_tree.nodes.new('NodeGroupInput')
|
||||
|
||||
node_tree.outputs.new('NodeSocketShader', 'Shader')
|
||||
node_tree.inputs.new('NodeSocketColor', 'Color')
|
||||
node_tree.interface.new_socket('Shader', in_out='OUTPUT', socket_type='NodeSocketShader')
|
||||
node_tree.interface.new_socket('Color', in_out='INPUT', socket_type='NodeSocketColor')
|
||||
|
||||
# This could be faster as a transparent shader, but then no ambient occlusion
|
||||
diffuse_shader = node_tree.nodes.new('ShaderNodeBsdfDiffuse')
|
||||
@ -1079,7 +1079,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper):
|
||||
if self.shader in {'PRINCIPLED', 'SHADELESS'}:
|
||||
node_tree.links.new(core_shader.inputs[0], tex_image.outputs['Color'])
|
||||
elif self.shader == 'EMISSION':
|
||||
node_tree.links.new(core_shader.inputs['Emission'], tex_image.outputs['Color'])
|
||||
node_tree.links.new(core_shader.inputs['Emission Color'], tex_image.outputs['Color'])
|
||||
|
||||
if self.use_transparency:
|
||||
if self.shader in {'PRINCIPLED', 'EMISSION'}:
|
||||
|
@ -1651,7 +1651,7 @@ def save(operator, context, filepath="", scale_factor=1.0, use_scene_unit=False,
|
||||
gradient = next((lk.from_node.color_ramp.elements for lk in ntree if lk.from_node.type == 'VALTORGB' and lk.to_node.type in bgmixer), False)
|
||||
background_color_chunk.add_variable("color", _3ds_float_color(bg_color))
|
||||
background_chunk.add_subchunk(background_color_chunk)
|
||||
if bg_image:
|
||||
if bg_image and bg_image is not None:
|
||||
background_image = _3ds_chunk(BITMAP)
|
||||
background_flag = _3ds_chunk(USE_BITMAP)
|
||||
background_image.add_variable("image", _3ds_string(sane_name(bg_image.name)))
|
||||
@ -1938,11 +1938,10 @@ def save(operator, context, filepath="", scale_factor=1.0, use_scene_unit=False,
|
||||
obj_hierarchy_chunk = _3ds_chunk(OBJECT_HIERARCHY)
|
||||
obj_parent_chunk = _3ds_chunk(OBJECT_PARENT)
|
||||
obj_hierarchy_chunk.add_variable("hierarchy", _3ds_ushort(object_id[ob.name]))
|
||||
if ob.parent is None or (ob.parent.name not in object_id):
|
||||
obj_parent_chunk.add_variable("parent", _3ds_ushort(ROOT_OBJECT))
|
||||
else: # Get the parent ID from the object_id dict
|
||||
if ob.parent is not None and (ob.parent.name in object_id):
|
||||
obj_parent_chunk = _3ds_chunk(OBJECT_PARENT)
|
||||
obj_parent_chunk.add_variable("parent", _3ds_ushort(object_id[ob.parent.name]))
|
||||
obj_hierarchy_chunk.add_subchunk(obj_parent_chunk)
|
||||
obj_hierarchy_chunk.add_subchunk(obj_parent_chunk)
|
||||
object_chunk.add_subchunk(obj_hierarchy_chunk)
|
||||
|
||||
# Add light object and hierarchy chunks to object info
|
||||
@ -1976,11 +1975,10 @@ def save(operator, context, filepath="", scale_factor=1.0, use_scene_unit=False,
|
||||
obj_hierarchy_chunk = _3ds_chunk(OBJECT_HIERARCHY)
|
||||
obj_parent_chunk = _3ds_chunk(OBJECT_PARENT)
|
||||
obj_hierarchy_chunk.add_variable("hierarchy", _3ds_ushort(object_id[ob.name]))
|
||||
if ob.parent is None or (ob.parent.name not in object_id):
|
||||
obj_parent_chunk.add_variable("parent", _3ds_ushort(ROOT_OBJECT))
|
||||
else: # Get the parent ID from the object_id dict
|
||||
if ob.parent is not None and (ob.parent.name in object_id):
|
||||
obj_parent_chunk = _3ds_chunk(OBJECT_PARENT)
|
||||
obj_parent_chunk.add_variable("parent", _3ds_ushort(object_id[ob.parent.name]))
|
||||
obj_hierarchy_chunk.add_subchunk(obj_parent_chunk)
|
||||
obj_hierarchy_chunk.add_subchunk(obj_parent_chunk)
|
||||
object_chunk.add_subchunk(obj_hierarchy_chunk)
|
||||
|
||||
# Add light object and hierarchy chunks to object info
|
||||
|
@ -263,19 +263,19 @@ def add_texture_to_material(image, contextWrapper, pct, extend, alpha, scale, of
|
||||
img_wrap = contextWrapper.base_color_texture
|
||||
links.new(img_wrap.node_image.outputs['Color'], mixer.inputs[2])
|
||||
links.new(mixer.outputs['Color'], shader.inputs['Base Color'])
|
||||
elif mapto == 'ROUGHNESS':
|
||||
img_wrap = contextWrapper.roughness_texture
|
||||
elif mapto == 'METALLIC':
|
||||
shader.location = (300,300)
|
||||
img_wrap = contextWrapper.metallic_texture
|
||||
elif mapto == 'SPECULARITY':
|
||||
shader.location = (0,-300)
|
||||
img_wrap = contextWrapper.specular_tint_texture
|
||||
elif mapto == 'ALPHA':
|
||||
shader.location = (0, -300)
|
||||
shader.location = (300,300)
|
||||
img_wrap = contextWrapper.alpha_texture
|
||||
elif mapto == 'METALLIC':
|
||||
shader.location = (300, 300)
|
||||
img_wrap = contextWrapper.metallic_texture
|
||||
elif mapto == 'ROUGHNESS':
|
||||
shader.location = (300, 0)
|
||||
img_wrap = contextWrapper.roughness_texture
|
||||
elif mapto == 'EMISSION':
|
||||
shader.location = (-300, -600)
|
||||
shader.location = (0,-900)
|
||||
img_wrap = contextWrapper.emission_color_texture
|
||||
elif mapto == 'NORMAL':
|
||||
shader.location = (300, 300)
|
||||
@ -641,8 +641,6 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
temp_data = file.read(SZ_U_INT * 2)
|
||||
track_chunk.bytes_read += SZ_U_INT * 2
|
||||
nkeys = read_long(track_chunk)
|
||||
if nkeys == 0:
|
||||
keyframe_data[0] = default_data
|
||||
for i in range(nkeys):
|
||||
nframe = read_long(track_chunk)
|
||||
nflags = read_short(track_chunk)
|
||||
@ -657,8 +655,6 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
temp_data = file.read(SZ_U_SHORT * 5)
|
||||
track_chunk.bytes_read += SZ_U_SHORT * 5
|
||||
nkeys = read_long(track_chunk)
|
||||
if nkeys == 0:
|
||||
keyframe_angle[0] = default_value
|
||||
for i in range(nkeys):
|
||||
nframe = read_long(track_chunk)
|
||||
nflags = read_short(track_chunk)
|
||||
@ -815,7 +811,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
if contextWorld is None:
|
||||
path, filename = os.path.split(file.name)
|
||||
realname, ext = os.path.splitext(filename)
|
||||
newWorld = bpy.data.worlds.new("Fog: " + realname)
|
||||
contextWorld = bpy.data.worlds.new("Fog: " + realname)
|
||||
context.scene.world = contextWorld
|
||||
contextWorld.use_nodes = True
|
||||
links = contextWorld.node_tree.links
|
||||
@ -1333,7 +1329,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
|
||||
elif KEYFRAME and new_chunk.ID == COL_TRACK_TAG and tracking == 'AMBIENT': # Ambient
|
||||
keyframe_data = {}
|
||||
default_data = child.color[:]
|
||||
keyframe_data[0] = child.color[:]
|
||||
child.color = read_track_data(new_chunk)[0]
|
||||
ambinode.inputs[0].default_value[:3] = child.color
|
||||
ambilite.outputs[0].default_value[:3] = child.color
|
||||
@ -1347,7 +1343,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
|
||||
elif KEYFRAME and new_chunk.ID == COL_TRACK_TAG and tracking == 'LIGHT': # Color
|
||||
keyframe_data = {}
|
||||
default_data = child.data.color[:]
|
||||
keyframe_data[0] = child.data.color[:]
|
||||
child.data.color = read_track_data(new_chunk)[0]
|
||||
for keydata in keyframe_data.items():
|
||||
child.data.color = keydata[1]
|
||||
@ -1356,7 +1352,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
|
||||
elif KEYFRAME and new_chunk.ID == POS_TRACK_TAG and tracktype == 'OBJECT': # Translation
|
||||
keyframe_data = {}
|
||||
default_data = child.location[:]
|
||||
keyframe_data[0] = child.location[:]
|
||||
child.location = read_track_data(new_chunk)[0]
|
||||
if child.type in {'LIGHT', 'CAMERA'}:
|
||||
trackposition[0] = child.location
|
||||
@ -1408,12 +1404,11 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
|
||||
elif KEYFRAME and new_chunk.ID == ROT_TRACK_TAG and tracktype == 'OBJECT': # Rotation
|
||||
keyframe_rotation = {}
|
||||
keyframe_rotation[0] = child.rotation_axis_angle[:]
|
||||
tflags = read_short(new_chunk)
|
||||
temp_data = file.read(SZ_U_INT * 2)
|
||||
new_chunk.bytes_read += SZ_U_INT * 2
|
||||
nkeys = read_long(new_chunk)
|
||||
if nkeys == 0:
|
||||
keyframe_rotation[0] = child.rotation_axis_angle[:]
|
||||
if tflags & 0x8: # Flag 0x8 locks X axis
|
||||
child.lock_rotation[0] = True
|
||||
if tflags & 0x10: # Flag 0x10 locks Y axis
|
||||
@ -1446,7 +1441,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
|
||||
elif KEYFRAME and new_chunk.ID == SCL_TRACK_TAG and tracktype == 'OBJECT': # Scale
|
||||
keyframe_data = {}
|
||||
default_data = child.scale[:]
|
||||
keyframe_data[0] = child.scale[:]
|
||||
child.scale = read_track_data(new_chunk)[0]
|
||||
if contextTrack_flag & 0x8: # Flag 0x8 locks X axis
|
||||
child.lock_scale[0] = True
|
||||
@ -1466,7 +1461,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
|
||||
elif KEYFRAME and new_chunk.ID == ROLL_TRACK_TAG and tracktype == 'OBJECT': # Roll angle
|
||||
keyframe_angle = {}
|
||||
default_value = child.rotation_euler.y
|
||||
keyframe_angle[0] = child.rotation_euler.y
|
||||
child.rotation_euler.y = read_track_angle(new_chunk)[0]
|
||||
for keydata in keyframe_angle.items():
|
||||
child.rotation_euler.y = keydata[1]
|
||||
@ -1476,7 +1471,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
|
||||
elif KEYFRAME and new_chunk.ID == FOV_TRACK_TAG and tracking == 'CAMERA': # Field of view
|
||||
keyframe_angle = {}
|
||||
default_value = child.data.angle
|
||||
keyframe_angle[0] = child.data.angle
|
||||
child.data.angle = read_track_angle(new_chunk)[0]
|
||||
for keydata in keyframe_angle.items():
|
||||
child.data.lens = (child.data.sensor_width / 2) / math.tan(keydata[1] / 2)
|
||||
@ -1485,7 +1480,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
elif KEYFRAME and new_chunk.ID == HOTSPOT_TRACK_TAG and tracking == 'LIGHT' and spotting == 'SPOT': # Hotspot
|
||||
keyframe_angle = {}
|
||||
cone_angle = math.degrees(child.data.spot_size)
|
||||
default_value = cone_angle-(child.data.spot_blend * math.floor(cone_angle))
|
||||
keyframe_angle[0] = cone_angle-(child.data.spot_blend * math.floor(cone_angle))
|
||||
hot_spot = math.degrees(read_track_angle(new_chunk)[0])
|
||||
child.data.spot_blend = 1.0 - (hot_spot / cone_angle)
|
||||
for keydata in keyframe_angle.items():
|
||||
@ -1494,7 +1489,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, CONSTRAI
|
||||
|
||||
elif KEYFRAME and new_chunk.ID == FALLOFF_TRACK_TAG and tracking == 'LIGHT' and spotting == 'SPOT': # Falloff
|
||||
keyframe_angle = {}
|
||||
default_value = math.degrees(child.data.spot_size)
|
||||
keyframe_angle[0] = math.degrees(child.data.spot_size)
|
||||
child.data.spot_size = read_track_angle(new_chunk)[0]
|
||||
for keydata in keyframe_angle.items():
|
||||
child.data.spot_size = keydata[1]
|
||||
|
@ -5,7 +5,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": (4, 0, 32),
|
||||
"version": (4, 0, 34),
|
||||
'blender': (4, 0, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
@ -147,7 +147,6 @@ class ExportImage:
|
||||
|
||||
# Unhappy path = we need to create the image self.fills describes or self.stores describes
|
||||
if self.numpy_calc is None:
|
||||
print(">2")
|
||||
return self.__encode_unhappy(export_settings), None
|
||||
else:
|
||||
pixels, width, height, factor = self.numpy_calc(self.stored)
|
||||
|
@ -135,6 +135,7 @@ class BlenderNode():
|
||||
bpy.data.collections.new(BLENDER_GLTF_SPECIAL_COLLECTION)
|
||||
bpy.data.scenes[gltf.blender_scene].collection.children.link(bpy.data.collections[BLENDER_GLTF_SPECIAL_COLLECTION])
|
||||
bpy.data.collections[BLENDER_GLTF_SPECIAL_COLLECTION].hide_viewport = True
|
||||
bpy.data.collections[BLENDER_GLTF_SPECIAL_COLLECTION].hide_render = True
|
||||
|
||||
# Create an icosphere, and assign it to the collection
|
||||
bpy.ops.mesh.primitive_ico_sphere_add(radius=1, enter_editmode=False, align='WORLD', location=(0, 0, 0), scale=(1, 1, 1))
|
||||
@ -187,7 +188,10 @@ class BlenderNode():
|
||||
arma_mat = vnode.editbone_arma_mat
|
||||
editbone.head = arma_mat @ Vector((0, 0, 0))
|
||||
editbone.tail = arma_mat @ Vector((0, 1, 0))
|
||||
editbone.length = vnode.bone_length
|
||||
if gltf.import_settings['bone_heuristic'] == "BLENDER":
|
||||
editbone.length = vnode.bone_length / max(blender_arma.scale)
|
||||
else:
|
||||
editbone.length = vnode.bone_length
|
||||
editbone.align_roll(arma_mat @ Vector((0, 0, 1)) - editbone.head)
|
||||
|
||||
if isinstance(id, int):
|
||||
@ -225,7 +229,8 @@ class BlenderNode():
|
||||
|
||||
if gltf.import_settings['bone_heuristic'] == "BLENDER":
|
||||
pose_bone.custom_shape = bpy.data.objects[gltf.bone_shape]
|
||||
pose_bone.custom_shape_scale_xyz = Vector([0.1, 0.1, 0.1])
|
||||
armature_max_dim = max([blender_arma.dimensions[0] / blender_arma.scale[0], blender_arma.dimensions[1] / blender_arma.scale[1], blender_arma.dimensions[2] / blender_arma.scale[2]])
|
||||
pose_bone.custom_shape_scale_xyz = Vector([armature_max_dim * 0.2] * 3)
|
||||
|
||||
@staticmethod
|
||||
def create_mesh_object(gltf, vnode):
|
||||
|
@ -539,7 +539,7 @@ class NWPreviewNode(Operator, NWBase):
|
||||
|
||||
if not viewer_socket:
|
||||
# create viewer socket
|
||||
viewer_socket = node.node_tree.interface.new_socket(viewer_socket_name, in_out={'OUTPUT'}, socket_type=socket_type)
|
||||
viewer_socket = node.node_tree.interface.new_socket(viewer_socket_name, in_out='OUTPUT', socket_type=socket_type)
|
||||
viewer_socket.NWViewerSocket = True
|
||||
return viewer_socket
|
||||
|
||||
|
@ -99,9 +99,6 @@ class VIEW3D_MT_Pose(Menu):
|
||||
layout.operator("pose.quaternions_flip")
|
||||
layout.operator_context = 'INVOKE_AREA'
|
||||
layout.separator()
|
||||
layout.operator("armature.armature_layers", text="Change Armature Layers...")
|
||||
layout.operator("pose.bone_layers", text="Change Bone Layers...")
|
||||
layout.separator()
|
||||
layout.menu("VIEW3D_MT_pose_showhide")
|
||||
layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user