示例#1
0
    def do_baking(self):
        try:
            ctl_instance = luna_rig.Control(self.control_field.text())
        except Exception:
            Logger.exception(
                "Failed to create control instance from {0}".format(
                    self.control_field.text()))
            raise RuntimeError("Invalid control object")

        step = self.step_field.value()
        if self.spaces_combobox.currentText() == self.custom_space_item_text:
            custom_object = self.custom_space_object_field.text()
            if not custom_object or not pm.objExists(custom_object):
                pm.displayError(
                    "Invalid custom space object: {0}".format(custom_object))
                return
            ctl_instance.bake_custom_space(
                custom_object,
                time_range=self.range_widget.get_range(),
                step=step)
        else:
            ctl_instance.bake_space(
                space_name=self.spaces_combobox.currentText(),
                time_range=self.range_widget.get_range(),
                step=step)
示例#2
0
 def update_spaces_box(self):
     self.spaces_combobox.clear()
     try:
         control_instance = luna_rig.Control(self.control_field.text())
     except Exception:
         Logger.exception("Failed to update {0} spaces".format(
             self.control_field.text()))
         return
     for space_name, space_index in control_instance.spaces:
         self.spaces_combobox.addItem(space_name, space_index)
     self.spaces_combobox.addItem(self.custom_space_item_text, None)
示例#3
0
 def __add_pose_actions(cls, root_menu, selection):
     selected_control = luna_rig.Control(selection[-1])
     pm.menuItem(p=root_menu,
                 l="Mirror pose (Behaviour)",
                 rp="SW",
                 c=lambda *args: [
                     luna_rig.Control(trs).mirror_pose(behavior=True,
                                                       direction="source")
                     for trs in selection
                     if luna_rig.Control.is_control(trs)
                 ])
     pm.menuItem(p=root_menu,
                 l="Mirror pose (No behaviour)",
                 rp="S",
                 c=lambda *args: [
                     luna_rig.Control(trs).mirror_pose(behavior=False,
                                                       direction="source")
                     for trs in selection
                     if luna_rig.Control.is_control(trs)
                 ])
     pm.menuItem(p=root_menu,
                 l="Asset bind pose",
                 rp="N",
                 c=lambda *args: selected_control.character.to_bind_pose(),
                 i=fileFn.get_icon_path("bindpose.png"))
     pm.menuItem(p=root_menu,
                 l="Component bind pose",
                 rp="NE",
                 c=lambda *args: selected_control.connected_component.
                 to_bind_pose(),
                 i=fileFn.get_icon_path("bodyPart.png"))
     pm.menuItem(p=root_menu,
                 l="Control bind pose",
                 rp="E",
                 c=lambda *args: [
                     luna_rig.Control(trs).to_bind_pose()
                     for trs in selection
                     if luna_rig.Control.is_control(trs)
                 ],
                 i=fileFn.get_icon_path("control.png"))
示例#4
0
    def add_space(self):
        space_object = self.space_obj_field.text()
        space_name = self.space_name_field.text()
        control_name = self.control_field.text()

        if not pm.objExists(control_name) or not pm.objExists(
                space_object) or not space_name:
            return

        ctl = luna_rig.Control(control_name)
        ctl.add_space(space_object,
                      space_name,
                      via_matrix=self.use_offset_matrix_checkbox.isChecked())
示例#5
0
    def __add_rigger_control_actions(cls, root_menu, selection):
        selected_control = luna_rig.Control(selection[-1])

        pm.menuItem(p=root_menu,
                    l="Select CVs",
                    rp="W",
                    c=lambda *args: curveFn.select_cvs(),
                    i=fileFn.get_icon_path("cvs.png"))
        # Adjust shape sub menu
        adjust_shape_menu = pm.subMenuItem(p=root_menu, l="Shape", rp="N")
        cls.__add_shape_actions(adjust_shape_menu, selection)
        pose_menu = pm.subMenuItem(p=root_menu, l="Pose", rp="E")
        cls.__add_pose_actions(pose_menu, selection)
        # Component menu
        cls.__add_component_actions(root_menu, selected_control)
示例#6
0
 def __add_animator_control_actions(cls, root_menu, selection):
     selected_control = luna_rig.Control(selection[-1])
     pm.menuItem(p=root_menu,
                 l="Select component controls",
                 rp="E",
                 c=lambda *args: selected_control.connected_component.
                 select_controls())
     pm.menuItem(p=root_menu,
                 l="Key component controls",
                 rp="W",
                 c=lambda *args: selected_control.connected_component.
                 key_controls())
     # Bind pose sub menu
     pose_menu = pm.subMenuItem(p=root_menu, l="Pose", rp="N")
     cls.__add_pose_actions(pose_menu, selection)
     # Component actions
     cls.__add_component_actions(root_menu, selected_control)
示例#7
0
    def test_instance_ctor(self):
        ctl1 = luna_rig.Control.create(name="arm_ik",
                                       side="r",
                                       attributes="tr",
                                       joint=1,
                                       tag="test")

        inst = luna_rig.Control(ctl1.transform)
        self.assertTrue(luna_rig.Control.is_control(inst.transform))
        self.assertEqual(inst.side, ctl1.side)
        self.assertEqual(inst.name, ctl1.name)
        self.assertEqual(inst.group, ctl1.group)
        self.assertListEqual(inst.offset_list, ctl1.offset_list)
        self.assertEqual(inst.offset, ctl1.offset)
        self.assertEqual(inst.transform, ctl1.transform)
        self.assertEqual(inst.joint, ctl1.joint)
        self.assertEqual(inst.tag, ctl1.tag)
示例#8
0
 def __add_shape_actions(cls, root_menu, selection):
     selected_control = luna_rig.Control(selection[-1])
     pm.menuItem(
         p=root_menu,
         l="Load shape",
         rp="E",
         c=lambda *args: importexport.CtlShapeManager.load_shape_from_lib(),
         i=fileFn.get_icon_path("library.png"))
     pm.menuItem(p=root_menu,
                 l="Copy shape",
                 rp="N",
                 c=shape_manager.ShapeManager.copy_shape,
                 i=fileFn.get_icon_path("copyCurve.png"))
     pm.menuItem(
         p=root_menu,
         l="Paste shape",
         rp="NE",
         c=lambda *args: shape_manager.ShapeManager.paste_shape(selection),
         i=fileFn.get_icon_path("pasteCurve.png"))
     pm.menuItem(p=root_menu,
                 l="Copy color",
                 rp="S",
                 c=lambda *args: shape_manager.ShapeManager.copy_color(),
                 i=fileFn.get_icon_path("copyColor.png"))
     pm.menuItem(p=root_menu,
                 l="Paste color",
                 rp="SE",
                 c=lambda *args: shape_manager.ShapeManager.paste_color(),
                 i=fileFn.get_icon_path("pasteColor.png"))
     pm.menuItem(p=root_menu,
                 l="Mirror shape YZ",
                 rp="W",
                 c=lambda *args: selected_control.mirror_shape())
     pm.menuItem(
         p=root_menu,
         l="Flip shape YZ",
         rp="SW",
         c=lambda *args: curveFn.flip_shape(selected_control.transform))
     pm.menuItem(
         p=root_menu,
         l="Mirror shape to opposite control",
         rp="NW",
         c=lambda *args: selected_control.mirror_shape_to_opposite())