Changeset View
Changeset View
Standalone View
Standalone View
io_export_unreal_psk_psa.py
| Context not available. | |||||
| def get_valid_smoothgroup_id(self): | def get_valid_smoothgroup_id(self): | ||||
| temp_id = 1 | temp_id = 1 | ||||
| for group in self.neighboring_groups: | for group in self.neighboring_groups: | ||||
| if group != None and group.id == temp_id: | if group is not None and group.id == temp_id: | ||||
| if temp_id < 0x80000000: | if temp_id < 0x80000000: | ||||
| temp_id = temp_id << 1 | temp_id = temp_id << 1 | ||||
| else: | else: | ||||
| Context not available. | |||||
| edge_id = find_edges(mesh, key) | edge_id = find_edges(mesh, key) | ||||
| if edge_id != None: | if edge_id is not None: | ||||
| # not sharp | # not sharp | ||||
| if not( mesh.edges[edge_id].use_edge_sharp): | if not( mesh.edges[edge_id].use_edge_sharp): | ||||
| Context not available. | |||||
| count = 0 #reset count | count = 0 #reset count | ||||
| for count in range(len( selectedobjects)): | for count in range(len( selectedobjects)): | ||||
| #print("Index:",count) | #print("Index:",count) | ||||
| if selectedobjects[count] != None: | if selectedobjects[count] is not None: | ||||
| me_da = selectedobjects[count].data.copy() #copy data | me_da = selectedobjects[count].data.copy() #copy data | ||||
| me_ob = selectedobjects[count].copy() #copy object | me_ob = selectedobjects[count].copy() #copy object | ||||
| #note two copy two types else it will use the current data or mesh | #note two copy two types else it will use the current data or mesh | ||||
| Context not available. | |||||
| verbose("Armature object: {} Armature data: {}".format(armature.name, armature.data.name)) | verbose("Armature object: {} Armature data: {}".format(armature.name, armature.data.name)) | ||||
| # generate a list of root bone candidates | # generate a list of root bone candidates | ||||
| root_candidates = [b for b in armature.data.bones if b.parent == None and b.use_deform == True] | root_candidates = [b for b in armature.data.bones if b.parent is None and b.use_deform == True] | ||||
| # should be a single, unambiguous result | # should be a single, unambiguous result | ||||
| if len(root_candidates) == 0: | if len(root_candidates) == 0: | ||||
| Context not available. | |||||
| status = "No effect" | status = "No effect" | ||||
| # calc parented bone transform | # calc parented bone transform | ||||
| if bone.parent != None: | if bone.parent is not None: | ||||
| quat = make_fquat(bone.matrix.to_quaternion()) | quat = make_fquat(bone.matrix.to_quaternion()) | ||||
| quat_parent = bone.parent.matrix.to_quaternion().inverted() | quat_parent = bone.parent.matrix.to_quaternion().inverted() | ||||
| parent_head = quat_parent * bone.parent.head | parent_head = quat_parent * bone.parent.head | ||||
| Context not available. | |||||
| print("Scene: {} FPS: {} Frames: {} to {}".format(context.scene.name, anim_rate, context.scene.frame_start, context.scene.frame_end)) | print("Scene: {} FPS: {} Frames: {} to {}".format(context.scene.name, anim_rate, context.scene.frame_start, context.scene.frame_end)) | ||||
| print("Processing {} action(s)".format(len(actions_to_export))) | print("Processing {} action(s)".format(len(actions_to_export))) | ||||
| print() | print() | ||||
| if armature.animation_data == None: #if animation data was not create for the armature it will skip the exporting action set(s) | if armature.animation_data is None: #if animation data was not create for the armature it will skip the exporting action set(s) | ||||
| print("None Actions Set! skipping...") | print("None Actions Set! skipping...") | ||||
| return | return | ||||
| restoreAction = armature.animation_data.action # Q: is animation_data always valid? | restoreAction = armature.animation_data.action # Q: is animation_data always valid? | ||||
| Context not available. | |||||
| pose_bone = bone_data[1] | pose_bone = bone_data[1] | ||||
| pose_bone_matrix = mathutils.Matrix(pose_bone.matrix) | pose_bone_matrix = mathutils.Matrix(pose_bone.matrix) | ||||
| if pose_bone.parent != None: | if pose_bone.parent is not None: | ||||
| pose_bone_parent_matrix = mathutils.Matrix(pose_bone.parent.matrix) | pose_bone_parent_matrix = mathutils.Matrix(pose_bone.parent.matrix) | ||||
| pose_bone_matrix = pose_bone_parent_matrix.inverted() * pose_bone_matrix | pose_bone_matrix = pose_bone_parent_matrix.inverted() * pose_bone_matrix | ||||
| head = pose_bone_matrix.to_translation() | head = pose_bone_matrix.to_translation() | ||||
| quat = pose_bone_matrix.to_quaternion().normalized() | quat = pose_bone_matrix.to_quaternion().normalized() | ||||
| if pose_bone.parent != None: | if pose_bone.parent is not None: | ||||
| quat = make_fquat(quat) | quat = make_fquat(quat) | ||||
| else: | else: | ||||
| quat = make_fquat_default(quat) | quat = make_fquat_default(quat) | ||||
| Context not available. | |||||
| raise Error("No mesh parented to armature") | raise Error("No mesh parented to armature") | ||||
| verbose("Found mesh: {}".format(mesh.name)) | verbose("Found mesh: {}".format(mesh.name)) | ||||
| if mesh == None or armature == None: | if mesh is None or armature is None: | ||||
| raise Error("Check Mesh and Armature are list!") | raise Error("Check Mesh and Armature are list!") | ||||
| #if len(armature.pose.bones) == len(mesh.vertex_groups): | #if len(armature.pose.bones) == len(mesh.vertex_groups): | ||||
| #print("Armature and Mesh Vertex Groups matches Ok!") | #print("Armature and Mesh Vertex Groups matches Ok!") | ||||
| Context not available. | |||||
| uv_layer = mmesh.tessface_uv_textures.active | uv_layer = mmesh.tessface_uv_textures.active | ||||
| for face in mmesh.tessfaces: | for face in mmesh.tessfaces: | ||||
| smoothings.append(face.use_smooth)#smooth or flat in boolean | smoothings.append(face.use_smooth)#smooth or flat in boolean | ||||
| if uv_layer != None:#check if there texture data exist | if uv_layer is not None:#check if there texture data exist | ||||
| faceUV = uv_layer.data[face.index] | faceUV = uv_layer.data[face.index] | ||||
| uvs = [] | uvs = [] | ||||
| for uv in faceUV.uv: | for uv in faceUV.uv: | ||||
| Context not available. | |||||
| bpy.ops.object.mode_set(mode='EDIT') | bpy.ops.object.mode_set(mode='EDIT') | ||||
| for bone in obj.data.edit_bones: | for bone in obj.data.edit_bones: | ||||
| if bone.parent != None: | if bone.parent is not None: | ||||
| currentbone.append([bone.name,bone.roll]) | currentbone.append([bone.name,bone.roll]) | ||||
| else: | else: | ||||
| currentbone.append([bone.name,bone.roll]) | currentbone.append([bone.name,bone.roll]) | ||||
| Context not available. | |||||
| if bone.name == bonelist[0]: | if bone.name == bonelist[0]: | ||||
| newbone.roll = bonelist[1] | newbone.roll = bonelist[1] | ||||
| break | break | ||||
| if bone.parent != None: | if bone.parent is not None: | ||||
| parentbone = ob_new.data.edit_bones[bone.parent.name] | parentbone = ob_new.data.edit_bones[bone.parent.name] | ||||
| newbone.parent = parentbone | newbone.parent = parentbone | ||||
| ob_new.animation_data_create()#create animation data | ob_new.animation_data_create()#create animation data | ||||
| if obj.animation_data != None:#check for animation | if obj.animation_data is not None:#check for animation | ||||
| ob_new.animation_data.action = obj.animation_data.action #just make sure it here to do the animations if exist | ob_new.animation_data.action = obj.animation_data.action #just make sure it here to do the animations if exist | ||||
| print("Armature Object Name:",ob_new.name) | print("Armature Object Name:",ob_new.name) | ||||
| return ob_new | return ob_new | ||||
| Context not available. | |||||
| bpy.ops.mesh.select_all(action='DESELECT') | bpy.ops.mesh.select_all(action='DESELECT') | ||||
| bpy.context.tool_settings.mesh_select_mode = (True, False, False) #select vertices | bpy.context.tool_settings.mesh_select_mode = (True, False, False) #select vertices | ||||
| if objmesh != None: | if objmesh is not None: | ||||
| print("found mesh") | print("found mesh") | ||||
| print(objmesh) | print(objmesh) | ||||
| print(objmesh.data.tessfaces) | print(objmesh.data.tessfaces) | ||||
| Context not available. | |||||
| if len(armatureselected) == 1: | if len(armatureselected) == 1: | ||||
| armature = armatureselected[0] | armature = armatureselected[0] | ||||
| if armature != None: | if armature is not None: | ||||
| for bone in armature.pose.bones: | for bone in armature.pose.bones: | ||||
| bones.append(bone.name) | bones.append(bone.name) | ||||
| Context not available. | |||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| return context.active_object != None | return context.active_object is not None | ||||
| def execute(self, context): | def execute(self, context): | ||||
| scene = bpy.context.scene | scene = bpy.context.scene | ||||
| Context not available. | |||||