Example #1
0
    def addObjectsFkControl(self):

        parentdiv = self.root
        parentctl = self.root

        parent_twistRef = addTransform(self.root, self.getName("reference"),
                                       getTransform(self.root))

        self.jointList = []
        self.preiviousCtlTag = self.parentCtlTag
        chain = getChainTransform2(self.guide.apos, self.normal, self.negate)
        for i, t in enumerate(chain):
            parentdiv, parentctl = self._addObjectsFkControl(
                i, parentdiv, parentctl, t, parent_twistRef)
Example #2
0
    def addLengthCtrl(self, crv):
        t = getTransform(self.guide.root)
        t = self._getTransformWithRollByBlade(t)
        cvs = crv.length()
        tm = datatypes.TransformationMatrix(t)
        tm.addTranslation([0.0, cvs * 0.01, cvs * 1.4], om.MSpace.kObject)

        local_t = datatypes.Matrix(tm)
        self.length_npo = addTransform(self.aim_npo, self.getName("length_npo"), local_t)
        self.length_in = addTransform(self.length_npo, self.getName("sacle_in"), local_t)
        size = self.size
        w = size
        h = size
        d = size
        self.length_ctl = self.addCtl(
            self.length_in,
            "length_ctl",
            local_t,
            self.color_ik,
            "arrow",
            w=w,
            h=h,
            d=d,
            ro=datatypes.Vector([-math.pi / 2., math.pi / 2., 0.])
        )

        self.fk_upvectors = []
        chain = getChainTransform2(self.guide.apos, self.normal, self.negate)
        for i, t in enumerate(chain):
            upv_npo = addTransform(self.length_in, self.getName("%s_fkupv_npo" % i), t)
            self.fk_upvectors.append(upv_npo)

        # global input
        self.scale_npo = addTransform(self.root, self.getName("scale_npo"), local_t)
        self.scale_in = addTransform(self.scale_npo, self.getName("sacle_in"), local_t)

        self.scale_ctl = self.addCtl(
            self.scale_in,
            "scale_ctl",
            local_t,
            self.color_ik,
            "cube",
            w=w*.2,
            h=h*.2,
            d=d*.2,
            ro=datatypes.Vector([-math.pi / 2., 0., 0.])
        )

        ymt_util.setKeyableAttributesDontLockVisibility(self.scale_ctl, self.s_params)
        ymt_util.setKeyableAttributesDontLockVisibility(self.length_ctl, ["tx", "ty", "tz"])
    def addObjectsFkControl(self):

        parentdiv = self.root
        parentctl = self.root

        parent_twistRef = addTransform(
            self.root,
            self.getName("reference"),
            getTransform(self.root))

        self.jointList = []
        self.preiviousCtlTag = self.parentCtlTag
        chain = getChainTransform2(self.guide.apos, self.normal, self.negate)
        for i, t in enumerate(chain):
            parentdiv, parentctl = self._addObjectsFkControl(i, parentdiv, parentctl, t, parent_twistRef)

        # add visual reference
        icon.connection_display_curve(self.getName("visualFKRef"), self.fk_ctl)
Example #4
0
    def addObjects(self):
        """Add all the objects needed to create the component."""

        self.normal = self.guide.blades["blade"].z
        self.binormal = self.guide.blades["blade"].x

        # Chain of deformers -------------------------------
        self.locList = []
        self.npoList = []
        parent = self.root

        self.jointList = []
        for i, t in enumerate(
                transform.getChainTransform2(self.guide.apos, self.normal,
                                             self.negate)):

            lvl = primitive.addTransform(parent, self.getName("%s_lvl" % i), t)
            npo = primitive.addTransform(lvl, self.getName("%s_npo" % i), t)
            loc = primitive.addTransform(npo, self.getName("%s_loc" % i), t)
            self.jnt_pos.append([loc, i])

            self.locList.append(loc)
            self.npoList.append(npo)
            if i == len(self.guide.apos) - 1:
                ctl_npo = primitive.addTransform(self.root,
                                                 self.getName("ctl_npo"), t)

                self.meta_ctl = self.addCtl(ctl_npo,
                                            "ctl",
                                            t,
                                            self.color_fk,
                                            "cube",
                                            w=self.size * .5,
                                            h=self.size * .5,
                                            d=self.size * .5,
                                            tp=self.parentCtlTag)
Example #5
0
    def addObjects(self):
        """Add all the objects needed to create the component."""
        self.normal = self.guide.blades["blade"].z * -1
        self.binormal = self.guide.blades["blade"].x

        self.WIP = self.options["mode"]

        if self.negate and self.settings["overrideNegate"]:
            self.negate = False
            self.n_factor = 1

        if self.settings["overrideNegate"]:
            self.mirror_conf = [0, 0, 1, 1, 1, 0, 0, 0, 0]
        else:
            self.mirror_conf = [0, 0, 0, 0, 0, 0, 0, 0, 0]

        # IK controls ---------------------------------------------
        self.ik_ctl = []
        # tOld = False
        self.previusTag = self.parentCtlTag
        for i, t in enumerate(
                transform.getChainTransform2(self.guide.apos, self.normal,
                                             self.negate)):

            ik_npo = primitive.addTransform(self.root,
                                            self.getName("ik%s_npo" % i), t)

            ik_ctl = self.addCtl(ik_npo,
                                 "ik%s_ctl" % i,
                                 t,
                                 self.color_ik,
                                 "square",
                                 w=self.size * .15,
                                 h=self.size * .15,
                                 d=self.size * .15,
                                 ro=datatypes.Vector([0, 0, 1.5708]),
                                 tp=self.previusTag,
                                 mirrorConf=self.mirror_conf)

            attribute.setKeyableAttributes(ik_ctl, self.tr_params)
            self.ik_ctl.append(ik_ctl)

        # Curves -------------------------------------------
        self.mst_crv = curve.addCnsCurve(self.root, self.getName("mst_crv"),
                                         self.ik_ctl, 3)
        self.slv_crv = curve.addCurve(self.root, self.getName("slv_crv"),
                                      [datatypes.Vector()] * 10, False, 3)
        self.mst_crv.setAttr("visibility", False)
        self.slv_crv.setAttr("visibility", False)

        # Division -----------------------------------------
        # The user only define how many intermediate division he wants.
        # First and last divisions are an obligation.
        parentdiv = self.root
        parentctl = self.root
        self.div_cns = []
        self.fk_ctl = []
        self.fk_npo = []
        self.scl_transforms = []
        self.twister = []
        self.ref_twist = []

        parent_twistRef = primitive.addTransform(
            self.root, self.getName("reference"),
            transform.getTransform(self.root))

        self.jointList = []
        self.preiviousCtlTag = self.parentCtlTag
        for i in range(self.settings["fkNb"]):
            # References
            div_cns = primitive.addTransform(parentdiv,
                                             self.getName("%s_cns" % i))
            pm.setAttr(div_cns + ".inheritsTransform", False)
            self.div_cns.append(div_cns)
            parentdiv = div_cns

            if i in [0, self.settings["fkNb"] - 1] and False:
                fk_ctl = primitive.addTransform(
                    parentctl, self.getName("%s_loc" % i),
                    transform.getTransform(parentctl))

                fk_npo = fk_ctl
                if i in [self.settings["fkNb"] - 1]:
                    self.fk_ctl.append(fk_ctl)
            else:
                m = transform.getTransform(self.root)
                t = transform.getTransform(parentctl)
                m.inverse()
                fk_npo = primitive.addTransform(parentctl,
                                                self.getName("fk%s_npo" % (i)),
                                                t)

                fk_ctl = self.addCtl(fk_npo,
                                     "fk%s_ctl" % (i),
                                     transform.getTransform(parentctl),
                                     self.color_fk,
                                     "cube",
                                     w=self.size * .1,
                                     h=self.size * .1,
                                     d=self.size * .1,
                                     tp=self.preiviousCtlTag,
                                     mirrorConf=self.mirror_conf)

                attribute.setKeyableAttributes(self.fk_ctl)
                attribute.setRotOrder(fk_ctl, "ZXY")
                self.fk_ctl.append(fk_ctl)
                self.preiviousCtlTag = fk_ctl

            self.fk_npo.append(fk_npo)
            parentctl = fk_ctl
            scl_ref = primitive.addTransform(parentctl,
                                             self.getName("%s_scl_ref" % i),
                                             transform.getTransform(parentctl))

            self.scl_transforms.append(scl_ref)

            # Deformers (Shadow)
            self.jnt_pos.append([scl_ref, i])

            # Twist references (This objects will replace the spinlookup
            # slerp solver behavior)
            t = transform.getTransformLookingAt(
                self.guide.apos[0], self.guide.apos[-1],
                self.guide.blades["blade"].z * -1, "yx", self.negate)

            twister = primitive.addTransform(parent_twistRef,
                                             self.getName("%s_rot_ref" % i), t)

            ref_twist = primitive.addTransform(parent_twistRef,
                                               self.getName("%s_pos_ref" % i),
                                               t)

            ref_twist.setTranslation(datatypes.Vector(1.0, 0, 0),
                                     space="preTransform")

            self.twister.append(twister)
            self.ref_twist.append(ref_twist)

            for x in self.fk_ctl[:-1]:
                attribute.setInvertMirror(x, ["tx", "rz", "ry"])
Example #6
0
    def addObjects(self):
        """Add all the objects needed to create the component."""

        self.normal = self.guide.blades["blade"].z
        self.binormal = self.guide.blades["blade"].x

        # Chain of deformers -------------------------------
        self.locList = []
        self.ctlList = []
        self.npoList = []
        parent = self.root

        self.jointList = []
        self.previusTag = self.parentCtlTag
        for i, t in enumerate(
                transform.getChainTransform2(self.guide.apos, self.normal,
                                             self.negate)):

            lvl = primitive.addTransform(parent, self.getName("%s_lvl" % i), t)
            npo = primitive.addTransform(lvl, self.getName("%s_npo" % i), t)
            loc = primitive.addTransform(npo, self.getName("%s_loc" % i), t)
            jnt_parent = loc

            if self.settings["metaCtl"]:

                if i:
                    guide_loc_ref = "{}_loc".format(str(i - 1))
                else:
                    guide_loc_ref = "root"
                meta_ctl = self.addCtl(loc,
                                       "meta%s_ctl" % i,
                                       t,
                                       self.color_ik,
                                       "cube",
                                       w=self.size * .2,
                                       h=self.size * .2,
                                       d=self.size * .2,
                                       tp=self.previusTag,
                                       guide_loc_ref=guide_loc_ref)

                self.ctlList.append(meta_ctl)
                self.previusTag = meta_ctl
                jnt_parent = meta_ctl

            if self.settings["jointChainCnx"]:
                self.jnt_pos.append([jnt_parent, i])
            else:
                self.jnt_pos.append([jnt_parent, i, "parent_relative_jnt"])

            self.locList.append(loc)
            self.npoList.append(npo)
            if i == len(self.guide.apos) - 1:
                ctl_npo = primitive.addTransform(self.root,
                                                 self.getName("ctl_npo"), t)

                self.meta_ctl = self.addCtl(ctl_npo,
                                            "ctl",
                                            t,
                                            self.color_fk,
                                            "cube",
                                            w=self.size * .5,
                                            h=self.size * .5,
                                            d=self.size * .5,
                                            tp=self.parentCtlTag)