def create_slot_node(root, slot, slot_type, set_fields=None): if isinstance(slot, Slot): bone_name = '%0X8' % int(slot.bone_name) if slot.bone_name in names: bone_name = names[slot.bone_name] slot_name = '%0X8' % int(slot.name) if slot.name in Slot.NAMES: slot_name = Slot.NAMES[slot.name] slot_node = create_sims3_content_node(bone_name, slot_type) slot_node.hide = False slot_node.empty_draw_type = 'ARROWS' slot_node.parent = root if set_fields: set_fields(slot_node) slot_matrix = s3py.blender.s3_4x3_to_Matrix(slot.transform) slot_node.rotation_quaternion = slot_matrix.to_quaternion() slot_node.location = slot_matrix.to_translation() bone_bind = slot_node.constraints.new(type='CHILD_OF') armature_bone = find_bone(armature.data.edit_bones, bone_name) if armature_bone: bone_bind.target = armature bone_bind.subtarget = armature_bone.name return slot_node else: raise Exception("Expected an instance of s3py.model.Slot")
def create_slot_node(root,slot,slot_type,set_fields=None): if isinstance(slot,Slot): bone_name = '%0X8'%int(slot.bone_name) if slot.bone_name in names: bone_name = names[slot.bone_name] slot_name = '%0X8'%int(slot.name) if slot.name in Slot.NAMES: slot_name = Slot.NAMES[slot.name] slot_node = create_sims3_content_node(bone_name,slot_type) slot_node.hide = False slot_node.empty_draw_type = 'ARROWS' slot_node.parent = root if set_fields: set_fields(slot_node) slot_matrix = s3py.blender.s3_4x3_to_Matrix(slot.transform) slot_node.rotation_quaternion = slot_matrix.to_quaternion() slot_node.location = slot_matrix.to_translation() bone_bind = slot_node.constraints.new(type='CHILD_OF') armature_bone = find_bone(armature.data.edit_bones,bone_name) if armature_bone: bone_bind.target = armature bone_bind.subtarget = armature_bone.name return slot_node else: raise Exception("Expected an instance of s3py.model.Slot")
def load_rslt(rslt,armature,names): if isinstance(rslt,SlotRig): slot_root = create_sims3_content_node('slot','SLOT',rslt.key) def create_slot_node(root,slot,slot_type,set_fields=None): if isinstance(slot,Slot): bone_name = '%0X8'%int(slot.bone_name) if slot.bone_name in names: bone_name = names[slot.bone_name] slot_name = '%0X8'%int(slot.name) if slot.name in Slot.NAMES: slot_name = Slot.NAMES[slot.name] slot_node = create_sims3_content_node(bone_name,slot_type) slot_node.hide = False slot_node.empty_draw_type = 'ARROWS' slot_node.parent = root if set_fields: set_fields(slot_node) slot_matrix = s3py.blender.s3_4x3_to_Matrix(slot.transform) slot_node.rotation_quaternion = slot_matrix.to_quaternion() slot_node.location = slot_matrix.to_translation() bone_bind = slot_node.constraints.new(type='CHILD_OF') armature_bone = find_bone(armature.data.edit_bones,bone_name) if armature_bone: bone_bind.target = armature bone_bind.subtarget = armature_bone.name return slot_node else: raise Exception("Expected an instance of s3py.model.Slot") for slot in rslt.container_slots: create_slot_node(slot_root,slot,'CONTAINER') for slot in rslt.routing_slots: create_slot_node(slot_root,slot,'ROUTE') for slot in rslt.target_slots: create_slot_node(slot_root,slot,'TARGET') for slot in rslt.effect_slots: create_slot_node(slot_root,slot,'EFFECT') for slot in rslt.cone_slots: create_slot_node(slot_root,slot,'CONE') return slot_root
def load_rslt(rslt, armature, names): if isinstance(rslt, SlotRig): slot_root = create_sims3_content_node('slot', 'SLOT', rslt.key) def create_slot_node(root, slot, slot_type, set_fields=None): if isinstance(slot, Slot): bone_name = '%0X8' % int(slot.bone_name) if slot.bone_name in names: bone_name = names[slot.bone_name] slot_name = '%0X8' % int(slot.name) if slot.name in Slot.NAMES: slot_name = Slot.NAMES[slot.name] slot_node = create_sims3_content_node(bone_name, slot_type) slot_node.hide = False slot_node.empty_draw_type = 'ARROWS' slot_node.parent = root if set_fields: set_fields(slot_node) slot_matrix = s3py.blender.s3_4x3_to_Matrix(slot.transform) slot_node.rotation_quaternion = slot_matrix.to_quaternion() slot_node.location = slot_matrix.to_translation() bone_bind = slot_node.constraints.new(type='CHILD_OF') armature_bone = find_bone(armature.data.edit_bones, bone_name) if armature_bone: bone_bind.target = armature bone_bind.subtarget = armature_bone.name return slot_node else: raise Exception("Expected an instance of s3py.model.Slot") for slot in rslt.container_slots: create_slot_node(slot_root, slot, 'CONTAINER') for slot in rslt.routing_slots: create_slot_node(slot_root, slot, 'ROUTE') for slot in rslt.target_slots: create_slot_node(slot_root, slot, 'TARGET') for slot in rslt.effect_slots: create_slot_node(slot_root, slot, 'EFFECT') for slot in rslt.cone_slots: create_slot_node(slot_root, slot, 'CONE') return slot_root