Esempio n. 1
0
    def addObjects(self):

        self.div_count = len(self.guide.apos) - 1

        #
        
        # FK controlers ------------------------------------
        self.fk_ctl = []
        self.fk_ref = []
        self.dir_ref = []
        fk_ctl_parent = self.root
        fk_ref_parent = self.root
        dir_ref_parent = self.root
        for i, t in enumerate(tra.getChainTransform(self.guide.apos, self.normal, self.negate)):

            # ctl
            dist = vec.getDistance(self.guide.apos[i], self.guide.apos[i+1])
            fk_ctl = self.addCtl(fk_ctl_parent, "fk%s_ctl"%i, t, self.color_fk, "cube", w=dist, h=self.size*.25, d=self.size*.25, po=XSIMath.CreateVector3(dist*.5*self.n_factor,0,0))
            xsi.SetNeutralPose(fk_ctl)
            par.setKeyableParameters(fk_ctl)
            fk_ctl_parent = fk_ctl

            self.fk_ctl.append(fk_ctl)

            self.addShadow(fk_ctl, i)

            # ref
            fk_ref = pri.addNull(fk_ref_parent, self.getName("fk%s_ref"%i), t, self.size*.1)
            fk_ref_parent = fk_ref

            self.fk_ref.append(fk_ref)

            dir_ref = pri.addNull(dir_ref_parent, self.getName("dir%s_ref"%i), t, self.size*.1)
            dir_ref_parent = dir_ref

            self.dir_ref.append(dir_ref)

        end_ref = pri.addNullFromPos(self.dir_ref[-1], self.getName("dir%s_ref"%(i+1)), self.guide.apos[-1], self.size*.1)
        self.dir_ref.append(end_ref)

        self.addToGroup(self.fk_ref, "hidden")
        self.addToGroup(self.dir_ref, "hidden")

        parent = self.root
        self.ref_chn = []
        for i in range(self.div_count):
            pos = [self.guide.apos[i], self.guide.apos[i+1]]
            ref_chn =  pri.add2DChain(parent, self.getName("ref%s"%i), pos, self.normal, self.negate, self.size*.1, True)
            self.addToGroup(ref_chn.all, "hidden")

            parent = ref_chn.eff
            
            self.ref_chn.append(ref_chn)
Esempio n. 2
0
    def addObjects(self):

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

        self.division = len(self.guide.apos)-1

        # FK controlers ------------------------------------
        self.fk_ctl = []
        parent = self.root
        for i, t in enumerate(tra.getChainTransform(self.guide.apos, self.normal, self.negate)):
            dist = vec.getDistance(self.guide.apos[i], self.guide.apos[i+1])
            fk_ctl = self.addCtl(parent, "fk%s_ctl"%i, t, self.color_fk, "cube", w=dist, h=self.size*.25, d=self.size*.25, po=XSIMath.CreateVector3(dist*.5*self.n_factor,0,0))
            xsi.SetNeutralPose(fk_ctl, c.siTrn)
            par.setKeyableParameters(fk_ctl)
            par.addLocalParamToCollection(self.inv_params, fk_ctl, ["posx", "posy", "posz"])

            parent = fk_ctl
            self.fk_ctl.append(fk_ctl)

        xsi.SetNeutralPose(self.fk_ctl[0])

        # Chain -------------------------------------------
        parent = self.fk_ctl[0]
        self.chain = []
        for i in range(self.division):
            pos = [self.guide.apos[i], self.guide.apos[i+1]]
            chain = pri.add2DChain(parent, self.getName("spring%s"%i), pos, self.normal, self.negate, self.size*.25, True)
            self.addToGroup(chain.all, "hidden")

            eff_ref = pri.addNull(chain.root, self.getName("eff%s_ref"%i), chain.eff.Kinematics.Global.Transform, self.size*.1)
            eff_ref.AddChild(chain.eff)
            self.addToGroup(eff_ref, "hidden")

            self.addShadow(chain.bones[0], i)

            self.chain.append(chain)
            parent = chain.bones[0]

        # Plot Reference ----------------------------------
        self.ref = pri.addNullChain(self.root, self.getName("#_ref"), self.guide.apos, self.normal, self.negate, self.size * .1)
        self.addToGroup(self.ref, "hidden")
        xsi.SetNeutralPose(self.ref[0])
Esempio n. 3
0
    def addObjects(self):

        self.normal = self.getNormalFromPos(self.guide.apos[1:])

        self.length0 = vec.getDistance(self.guide.apos[0], self.guide.apos[1])
        self.length1 = vec.getDistance(self.guide.apos[1], self.guide.apos[2])
        self.length2 = vec.getDistance(self.guide.apos[2], self.guide.apos[3])
        self.length3 = vec.getDistance(self.guide.apos[3], self.guide.apos[4])

        # FK Controlers ------------------------------------
        t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[1], self.normal, "xz", self.negate)
        self.fk0_ctl = self.addCtl(self.root, "fk0_ctl", t, self.color_fk, "cube", w=1, h=self.size*.1, d=self.size*.1, po=XSIMath.CreateVector3(.5*self.n_factor,0,0))
        self.fk0_ctl.Kinematics.Global.Parameters("SclX").Value = self.length0
        xsi.SetNeutralPose(self.fk0_ctl)
        par.setKeyableParameters(self.fk0_ctl)
        par.addLocalParamToCollection(self.inv_params, self.fk0_ctl, ["posx", "posy", "posz"])

        t = tra.getTransformLookingAt(self.guide.apos[1], self.guide.apos[2], self.normal, "xz", self.negate)
        self.fk1_ctl = self.addCtl(self.fk0_ctl, "fk1_ctl", t, self.color_fk, "cube", w=1, h=self.size*.1, d=self.size*.1, po=XSIMath.CreateVector3(.5*self.n_factor,0,0))
        self.fk1_ctl.Kinematics.Global.Parameters("SclX").Value = self.length1
        xsi.SetNeutralPose(self.fk1_ctl, c.siST)
        par.setKeyableParameters(self.fk1_ctl)
        par.addLocalParamToCollection(self.inv_params, self.fk1_ctl, ["posx", "posy", "posz"])

        t = tra.getTransformLookingAt(self.guide.apos[2], self.guide.apos[3], self.normal, "xz", self.negate)
        self.fk2_ctl = self.addCtl(self.fk1_ctl, "fk2_ctl", t, self.color_fk, "cube", w=1, h=self.size*.1, d=self.size*.1, po=XSIMath.CreateVector3(.5*self.n_factor,0,0))
        self.fk2_ctl.Kinematics.Global.Parameters("SclX").Value = self.length2
        xsi.SetNeutralPose(self.fk2_ctl, c.siST)
        par.setKeyableParameters(self.fk2_ctl)
        par.addLocalParamToCollection(self.inv_params, self.fk2_ctl, ["posx", "posy", "posz"])

        t = tra.getTransformLookingAt(self.guide.apos[3], self.guide.apos[4], self.normal, "xz", self.negate)
        self.fk3_ctl = self.addCtl(self.fk2_ctl, "fk3_ctl", t, self.color_fk, "cube", w=self.length3, h=self.size*.1, d=self.size*.1, po=XSIMath.CreateVector3(self.length3*.5*self.n_factor,0,0))
        xsi.SetNeutralPose(self.fk3_ctl, c.siST)
        par.setKeyableParameters(self.fk3_ctl)
        par.addLocalParamToCollection(self.inv_params, self.fk3_ctl, ["posx", "posy", "posz"])

        # IK Controlers ------------------------------------
        self.ik_cns = pri.addNullFromPos(self.root, self.getName("ik_cns"), self.guide.apos[3], self.size * .02)
        self.addToGroup(self.ik_cns, "hidden")

        self.ikcns_ctl = self.addCtl(self.ik_cns, "ikcns_ctl", self.ik_cns.Kinematics.Global.Transform, self.color_ik, "null", h=self.size*.2)
        self.addToCtlGroup(self.ikcns_ctl)
        par.setKeyableParameters(self.ikcns_ctl)
        par.addLocalParamToCollection(self.inv_params, self.ikcns_ctl, ["posx", "rotx", "rotz"])

        t = tra.getTransformLookingAt(self.guide.apos[3], self.guide.apos[4], self.x_axis, "zx", False)
        self.ik_ctl = self.addCtl(self.ikcns_ctl, "ik_ctl", t, self.color_ik, "cube", h=self.size*.12, w=self.size*.12, d=self.length2, po=XSIMath.CreateVector3(0,0,self.length2*.5))
        par.setKeyableParameters(self.ik_ctl)
        par.addLocalParamToCollection(self.inv_params, self.ik_ctl, ["posx"])

        # Upv
        v = XSIMath.CreateVector3()
        v.Sub(self.guide.apos[2], self.guide.apos[0])
        v.Cross(self.normal, v)
        v.NormalizeInPlace()
        v.ScaleInPlace(self.size * -.5)
        v.AddInPlace(self.guide.apos[1])
        self.upv_cns = pri.addNullFromPos(self.root, self.getName("upv_cns"), v, self.size*.02)
        self.addToGroup(self.upv_cns, "hidden")

        self.upv_ctl = self.addCtl(self.upv_cns, "upv_ctl", self.upv_cns.Kinematics.Global.Transform, self.color_ik, "leash", h=self.size*.05, ap=self.guide.apos[1])
        par.setKeyableParameters(self.upv_ctl, self.t_params)
        par.addLocalParamToCollection(self.inv_params, self.upv_ctl, ["posx"])

        # References ---------------------------------------
        # Ik ref
        self.ik_ref = pri.addNull(self.ik_ctl, self.getName("ik_ref"), self.ik_ctl.Kinematics.Global.Transform, self.size * .1)
        self.addToGroup(self.ik_ref, "hidden")

        # Fk ref
        self.fk_ref = pri.addNull(self.fk3_ctl, self.getName("fk_ref"), self.ik_ref.Kinematics.Global.Transform, self.size * .1)
        self.addToGroup(self.fk_ref, "hidden")

        # Roll Controler -----------------------------------
        if self.settings["roll"] == 0: # Roll with a controler
            self.roll_ctl = self.addCtl(self.root, "roll_ctl", self.ik_ctl.Kinematics.Global.Transform, self.color_ik, "bendedarrow2", w=self.length2*.5*self.n_factor, po=XSIMath.CreateVector3(0,self.length2*.5*self.n_factor,0))
            if self.negate:
                self.roll_ctl.Kinematics.Local.Parameters("rotx").Value = 180
                xsi.SetNeutralPose(self.roll_ctl)
            par.setKeyableParameters(self.roll_ctl, self.r_params)

        # Chain --------------------------------------------
        self.ref_chn = pri.add2DChain(self.root, self.getName("ref"), self.guide.apos[:3], self.normal, self.negate, self.size*.1, True)
        self.addToGroup(self.ref_chn.all, "hidden")

        self.end_chn = pri.add2DChain(self.ref_chn.bones[-1], self.getName("end"), self.guide.apos[2:4], self.normal, self.negate, self.size*.1, True)
        self.addToGroup(self.end_chn.all, "hidden")

        # Reference Nulls ---------------------------------
        self.ref_loc = []
        parent = self.root
        for i, ref in enumerate([self.fk0_ctl, self.fk1_ctl, self.fk2_ctl, self.fk_ref]):
            t = tra.getFilteredTransform(ref.Kinematics.Global.Transform, True, True, False)
            ref_loc = pri.addNull(parent, self.getName("ref%s_loc"%i), t, self.size*.1)
            self.addToGroup(ref_loc, "hidden")
            self.ref_loc.append(ref_loc)

            parent = ref_loc

        # Mid Controler ------------------------------------
        self.ctrn0_loc = pri.addNullFromPos(self.ref_loc[0], self.getName("ctrn0_loc"), self.guide.apos[1], self.size*.05)
        self.ctrn1_loc = pri.addNullFromPos(self.ref_loc[1], self.getName("ctrn1_loc"), self.guide.apos[2], self.size*.05)

        self.addToGroup([self.ctrn0_loc, self.ctrn1_loc], "hidden")

        self.mid0_ctl = self.addCtl(self.ctrn0_loc, "mid0_ctl", self.ctrn0_loc.Kinematics.Global.Transform, self.color_ik, "sphere", h=self.size*.1)
        par.addLocalParamToCollection(self.inv_params, self.mid0_ctl, ["posx", "posy", "posz"])
        self.mid1_ctl = self.addCtl(self.ctrn1_loc, "mid1_ctl", self.ctrn1_loc.Kinematics.Global.Transform, self.color_ik, "sphere", h=self.size*.1)
        par.addLocalParamToCollection(self.inv_params, self.mid1_ctl, ["posx", "posy", "posz"])

        # Twist references ---------------------------------
        t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[1], self.normal, "xz", self.negate)
        self.tws0_loc = pri.addNull(self.root, self.getName("tws0_loc"), t, self.size*.05)
        self.tws0_rot = pri.addNull(self.tws0_loc, self.getName("tws0_rot"), t)
        pri.setNullDisplay(self.tws0_rot, 0, self.size*.05, 2, 0, 0, 0, self.size*.01)

        self.tws1_loc = pri.addNull(self.ctrn0_loc, self.getName("tws1_loc"), self.ctrn0_loc.Kinematics.Global.Transform, self.size*.05)
        self.tws1_rot = pri.addNull(self.tws1_loc, self.getName("tws1_rot"), self.ctrn0_loc.Kinematics.Global.Transform)
        pri.setNullDisplay(self.tws1_rot, 0, self.size*.05, 2, 0, 0, 0, self.size*.01)

        self.tws2_loc = pri.addNull(self.ctrn1_loc, self.getName("tws2_loc"), self.ctrn1_loc.Kinematics.Global.Transform, self.size*.05)
        self.tws2_rot = pri.addNull(self.tws2_loc, self.getName("tws2_rot"), self.ctrn1_loc.Kinematics.Global.Transform)
        pri.setNullDisplay(self.tws2_rot, 0, self.size*.05, 2, 0, 0, 0, self.size*.01)

        t = tra.getFilteredTransform(self.ref_loc[-2].Kinematics.Global.Transform, True, True, False)
        t.SetTranslation(self.guide.apos[3])
        self.tws3_loc = pri.addNull(self.ref_loc[-1], self.getName("tws3_loc"), t, self.size*.05)
        self.tws3_rot = pri.addNull(self.tws3_loc, self.getName("tws3_rot"),t)
        self.tws3_rot.Kinematics.Global.Parameters("SclX").Value = .001
        pri.setNullDisplay(self.tws3_rot, 0, self.size*.05, 2, 0, 0, 0, self.size*.01)

        self.addToGroup([self.tws0_loc, self.tws0_rot, self.tws1_loc, self.tws1_rot, self.tws2_loc, self.tws2_rot, self.tws3_loc, self.tws3_rot], "hidden")

        # End reference ------------------------------------
        t = tra.getFilteredTransform(self.tws3_rot.Kinematics.Global.Transform, True, True, False)
        self.end_ref = pri.addNull(self.tws3_rot, self.getName("end_ref"), t, self.size*.2)
        self.addToGroup(self.end_ref, "hidden")
        self.addShadow(self.end_ref, "end")

        # Divisions ----------------------------------------
        # We have at least one division at the start, the end and one for the elbow.
        self.divisions = self.settings["div0"] + self.settings["div1"] + self.settings["div2"] + 4

        self.div_cns = []
        for i in range(self.divisions):

            div_cns = pri.addNull(self.tws0_loc, self.getName("div%s_loc"%i), XSIMath.CreateTransform())
            pri.setNullDisplay(div_cns, 1, self.size*.02, 10, 0, 0, 0, 1, 1, 2)
            self.addToGroup(div_cns, "hidden")

            self.div_cns.append(div_cns)

            self.addShadow(div_cns, i)
Esempio n. 4
0
    def addObjects(self):

        self.normal = self.getNormalFromPos(self.guide.apos[1:])

        self.length0 = vec.getDistance(self.guide.apos[0], self.guide.apos[1])
        self.length1 = vec.getDistance(self.guide.apos[1], self.guide.apos[2])
        self.length2 = vec.getDistance(self.guide.apos[2], self.guide.apos[3])
        self.length3 = vec.getDistance(self.guide.apos[3], self.guide.apos[4])

        # FK Controlers ------------------------------------
        t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[1],
                                      self.normal, "xz", self.negate)
        self.fk0_ctl = self.addCtl(self.root,
                                   "fk0_ctl",
                                   t,
                                   self.color_fk,
                                   "cube",
                                   w=1,
                                   h=self.size * .1,
                                   d=self.size * .1,
                                   po=XSIMath.CreateVector3(
                                       .5 * self.n_factor, 0, 0))
        self.fk0_ctl.Kinematics.Global.Parameters("SclX").Value = self.length0
        xsi.SetNeutralPose(self.fk0_ctl)
        xsi.SetNeutralPose(self.fk0_ctl, c.siST)
        par.setKeyableParameters(self.fk0_ctl)

        t = tra.getTransformLookingAt(self.guide.apos[1], self.guide.apos[2],
                                      self.normal, "xz", self.negate)
        self.fk1_ctl = self.addCtl(self.fk0_ctl,
                                   "fk1_ctl",
                                   t,
                                   self.color_fk,
                                   "cube",
                                   w=1,
                                   h=self.size * .1,
                                   d=self.size * .1,
                                   po=XSIMath.CreateVector3(
                                       .5 * self.n_factor, 0, 0))
        self.fk1_ctl.Kinematics.Global.Parameters("SclX").Value = self.length1
        xsi.SetNeutralPose(self.fk1_ctl, c.siST)
        par.setKeyableParameters(self.fk1_ctl)

        t = tra.getTransformLookingAt(self.guide.apos[2], self.guide.apos[3],
                                      self.normal, "xz", self.negate)
        self.fk2_ctl = self.addCtl(self.fk1_ctl,
                                   "fk2_ctl",
                                   t,
                                   self.color_fk,
                                   "cube",
                                   w=1,
                                   h=self.size * .1,
                                   d=self.size * .1,
                                   po=XSIMath.CreateVector3(
                                       .5 * self.n_factor, 0, 0))
        self.fk2_ctl.Kinematics.Global.Parameters("SclX").Value = self.length2
        xsi.SetNeutralPose(self.fk2_ctl, c.siST)
        par.setKeyableParameters(self.fk2_ctl)

        t = tra.getTransformLookingAt(self.guide.apos[3], self.guide.apos[4],
                                      self.normal, "xz", self.negate)
        self.fk3_ctl = self.addCtl(self.fk2_ctl,
                                   "fk3_ctl",
                                   t,
                                   self.color_fk,
                                   "cube",
                                   w=self.length3,
                                   h=self.size * .1,
                                   d=self.size * .1,
                                   po=XSIMath.CreateVector3(
                                       self.length3 * .5 * self.n_factor, 0,
                                       0))
        xsi.SetNeutralPose(self.fk3_ctl, c.siST)
        par.setKeyableParameters(self.fk3_ctl)

        # IK Controlers ------------------------------------
        self.ik_cns = pri.addNullFromPos(self.root, self.getName("ik_cns"),
                                         self.guide.apos[3], self.size * .02)
        self.addToGroup(self.ik_cns, "hidden")

        self.ikcns_ctl = self.addCtl(self.ik_cns,
                                     "ikcns_ctl",
                                     self.ik_cns.Kinematics.Global.Transform,
                                     self.color_ik,
                                     "null",
                                     h=self.size * .2)
        self.addToCtlGroup(self.ikcns_ctl)
        par.setKeyableParameters(self.ikcns_ctl)

        t = tra.getTransformLookingAt(self.guide.apos[3], self.guide.apos[4],
                                      self.x_axis, "zx", False)
        self.ik_ctl = self.addCtl(self.ikcns_ctl,
                                  "ik_ctl",
                                  t,
                                  self.color_ik,
                                  "cube",
                                  h=self.size * .12,
                                  w=self.size * .12,
                                  d=self.length2,
                                  po=XSIMath.CreateVector3(
                                      0, 0, self.length2 * .5))
        par.setKeyableParameters(self.ik_ctl)

        # Upv
        v = XSIMath.CreateVector3()
        v.Sub(self.guide.apos[2], self.guide.apos[0])
        v.Cross(self.normal, v)
        v.NormalizeInPlace()
        v.ScaleInPlace(self.size * -.5)
        v.AddInPlace(self.guide.apos[1])
        self.upv_cns = pri.addNullFromPos(self.root, self.getName("upv_cns"),
                                          v, self.size * .02)
        self.addToGroup(self.upv_cns, "hidden")

        self.upv_ctl = self.addCtl(self.upv_cns,
                                   "upv_ctl",
                                   self.upv_cns.Kinematics.Global.Transform,
                                   self.color_ik,
                                   "leash",
                                   h=self.size * .05,
                                   ap=self.guide.apos[1])
        par.setKeyableParameters(self.upv_ctl, self.t_params)

        # References ---------------------------------------
        # Ik ref
        self.ik_ref = pri.addNull(self.ik_ctl, self.getName("ik_ref"),
                                  self.ik_ctl.Kinematics.Global.Transform,
                                  self.size * .1)
        self.addToGroup(self.ik_ref, "hidden")

        # Fk ref
        self.fk_ref = pri.addNull(self.fk2_ctl, self.getName("fk_ref"),
                                  self.ik_ref.Kinematics.Global.Transform,
                                  self.size * .1)
        self.addToGroup(self.fk_ref, "hidden")

        # Roll Controler -----------------------------------
        if self.settings["roll"] == 0:  # Roll with a controler
            self.roll_ctl = self.addCtl(
                self.ik_ref,
                "roll_ctl",
                self.ik_ref.Kinematics.Global.Transform,
                self.color_ik,
                "bendedarrow2",
                w=self.length2 * .5 * self.n_factor,
                po=XSIMath.CreateVector3(0, self.length2 * .5 * self.n_factor,
                                         0))
            if self.negate:
                self.roll_ctl.Kinematics.Local.Parameters("rotx").Value = 180
                xsi.SetNeutralPose(self.roll_ctl)
            par.setKeyableParameters(self.roll_ctl, self.r_params)

        # Chain --------------------------------------------
        self.ref_chn = pri.add2DChain(self.root, self.getName("ref"),
                                      self.guide.apos[:3], self.normal,
                                      self.negate, self.size * .1, True)
        self.addToGroup(self.ref_chn.all, "hidden")

        self.end_chn = pri.add2DChain(self.ref_chn.bones[-1],
                                      self.getName("end"),
                                      self.guide.apos[2:4], self.normal,
                                      self.negate, self.size * .1, True)
        self.addToGroup(self.end_chn.all, "hidden")

        # Reference Nulls ---------------------------------
        self.ref_loc = []
        parent = self.root
        for i, ref in enumerate(
            [self.fk0_ctl, self.fk1_ctl, self.fk2_ctl, self.fk_ref]):
            t = tra.getFilteredTransform(ref.Kinematics.Global.Transform, True,
                                         True, False)
            ref_loc = pri.addNull(parent, self.getName("ref%s_loc" % i), t,
                                  self.size * .1)
            self.addToGroup(ref_loc, "hidden")
            self.ref_loc.append(ref_loc)

            parent = ref_loc

        # Mid Controler ------------------------------------
        self.ctrn0_loc = pri.addNullFromPos(self.ref_loc[0],
                                            self.getName("ctrn0_loc"),
                                            self.guide.apos[1],
                                            self.size * .05)
        self.ctrn1_loc = pri.addNullFromPos(self.ref_loc[1],
                                            self.getName("ctrn1_loc"),
                                            self.guide.apos[2],
                                            self.size * .05)

        self.addToGroup([self.ctrn0_loc, self.ctrn1_loc], "hidden")

        self.mid0_ctl = self.addCtl(self.ctrn0_loc,
                                    "mid0_ctl",
                                    self.ctrn0_loc.Kinematics.Global.Transform,
                                    self.color_ik,
                                    "sphere",
                                    h=self.size * .1)
        self.mid1_ctl = self.addCtl(self.ctrn1_loc,
                                    "mid1_ctl",
                                    self.ctrn1_loc.Kinematics.Global.Transform,
                                    self.color_ik,
                                    "sphere",
                                    h=self.size * .1)

        # Twist references ---------------------------------
        t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[1],
                                      self.normal, "xz", self.negate)
        self.tws0_loc = pri.addNull(self.root, self.getName("tws0_loc"), t,
                                    self.size * .05)
        self.tws0_rot = pri.addNull(self.tws0_loc, self.getName("tws0_rot"), t)
        pri.setNullDisplay(self.tws0_rot, 0, self.size * .05, 2, 0, 0, 0,
                           self.size * .01)

        self.tws1_loc = pri.addNull(self.ctrn0_loc, self.getName("tws1_loc"),
                                    self.ctrn0_loc.Kinematics.Global.Transform,
                                    self.size * .05)
        self.tws1_rot = pri.addNull(self.tws1_loc, self.getName("tws1_rot"),
                                    self.ctrn0_loc.Kinematics.Global.Transform)
        pri.setNullDisplay(self.tws1_rot, 0, self.size * .05, 2, 0, 0, 0,
                           self.size * .01)

        self.tws2_loc = pri.addNull(self.ctrn1_loc, self.getName("tws2_loc"),
                                    self.ctrn1_loc.Kinematics.Global.Transform,
                                    self.size * .05)
        self.tws2_rot = pri.addNull(self.tws2_loc, self.getName("tws2_rot"),
                                    self.ctrn1_loc.Kinematics.Global.Transform)
        pri.setNullDisplay(self.tws2_rot, 0, self.size * .05, 2, 0, 0, 0,
                           self.size * .01)

        t = tra.getFilteredTransform(
            self.ref_loc[-2].Kinematics.Global.Transform, True, True, False)
        t.SetTranslation(self.guide.apos[3])
        self.tws3_loc = pri.addNull(self.ref_loc[-1], self.getName("tws3_loc"),
                                    t, self.size * .05)
        self.tws3_rot = pri.addNull(self.tws3_loc, self.getName("tws3_rot"), t)
        pri.setNullDisplay(self.tws3_rot, 0, self.size * .05, 2, 0, 0, 0,
                           self.size * .01)

        self.addToGroup([
            self.tws0_loc, self.tws0_rot, self.tws1_loc, self.tws1_rot,
            self.tws2_loc, self.tws2_rot, self.tws3_loc, self.tws3_rot
        ], "hidden")

        # Divisions ----------------------------------------
        # We have at least one division at the start, the end and one for the elbow.
        self.divisions = self.settings["div0"] + self.settings[
            "div1"] + self.settings["div2"] + 4

        self.div_cns = []
        for i in range(self.divisions):

            div_cns = pri.addNull(self.tws0_loc, self.getName("div%s_loc" % i),
                                  XSIMath.CreateTransform())
            pri.setNullDisplay(div_cns, 1, self.size * .02, 10, 0, 0, 0, 1, 1,
                               2)
            self.addToGroup(div_cns, "hidden")

            self.div_cns.append(div_cns)

            self.addShadow(div_cns, i)
Esempio n. 5
0
    def addObjects(self):

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

        self.isFk = self.settings["type"] != 1
        self.isIk = self.settings["type"] != 0
        self.isFkIk = self.settings["type"] == 2

        # FK controlers ------------------------------------
        if self.isFk:
            self.fk_ctl = []
            parent = self.root
            for i, t in enumerate(tra.getChainTransform(self.guide.apos, self.normal, self.negate)):
                dist = vec.getDistance(self.guide.apos[i], self.guide.apos[i+1])
                fk_ctl = self.addCtl(parent, "fk%s_ctl"%i, t, self.color_fk, "cube", w=dist, h=self.size*.25, d=self.size*.25, po=XSIMath.CreateVector3(dist*.5*self.n_factor,0,0))
                xsi.SetNeutralPose(fk_ctl, c.siTrn)
                par.setKeyableParameters(fk_ctl)
                par.addLocalParamToCollection(self.inv_params, fk_ctl, ["posx", "posy", "posz"])

                parent = fk_ctl
                self.fk_ctl.append(fk_ctl)

            if self.settings["neutralpose"]:
                xsi.SetNeutralPose(self.fk_ctl)
            else:
                xsi.SetNeutralPose(self.fk_ctl[0])

        # IK controlers ------------------------------------
        if self.isIk:

            normal = vec.getTransposedVector(self.normal, [self.guide.apos[0], self.guide.apos[1]], [self.guide.apos[-2], self.guide.apos[-1]])
            t = tra.getTransformLookingAt(self.guide.apos[-2], self.guide.apos[-1], normal, "xy", self.negate)
            t.SetTranslation(self.guide.apos[-1])

            self.ik_cns = pri.addNull(self.root, self.getName("ik_cns"), t, self.size*.2)
            self.addToGroup(self.ik_cns, "hidden")

            self.ikcns_ctl = self.addCtl(self.ik_cns, "ikcns_ctl", t, self.color_ik, "null", h=self.size)
            par.setKeyableParameters(self.ikcns_ctl)

            self.ik_ctl = self.addCtl(self.ikcns_ctl, "ik_ctl", t, self.color_ik, "cube", h=self.size*.3, w=self.size*.3, d=self.size*.3)
            xsi.SetNeutralPose(self.ik_ctl)
            par.setKeyableParameters(self.ik_ctl, self.tr_params)

            v = XSIMath.CreateVector3()
            v.Sub(self.guide.apos[-1], self.guide.apos[0])
            v.Cross(self.normal, v)
            v.NormalizeInPlace()
            v.ScaleInPlace(self.size * 4)
            v.AddInPlace(self.guide.apos[1])
            self.upv_cns = pri.addNullFromPos(self.root, self.getName("upv_cns"), v, self.size*.1)
            self.addToGroup(self.upv_cns, "hidden")

            self.upv_ctl = self.addCtl(self.upv_cns, "upv_ctl", self.upv_cns.Kinematics.Global.Transform, self.color_ik, "leash", h=self.size*.2, ap=self.guide.apos[1])
            par.setKeyableParameters(self.upv_ctl, self.t_params)

            # Chain
            self.chain = pri.add2DChain(self.root, self.getName("chain"), self.guide.apos, self.normal, self.negate, self.size*.5, True)
            self.addToGroup(self.chain.all, "hidden")

        # Chain of deformers -------------------------------
        self.loc = pri.addNullChain(self.root, self.getName("#_loc"), self.guide.apos, self.normal, self.negate, self.size*.25)
        xsi.SetNeutralPose(self.loc, c.siTrn)
        self.addToGroup(self.loc, "hidden")

        for i, loc in enumerate(self.loc):
            self.addShadow(loc, i)
Esempio n. 6
0
    def addObjects(self):

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

        self.division = len(self.guide.apos) - 1

        # FK controlers ------------------------------------
        self.fk_ctl = []
        parent = self.root
        for i, t in enumerate(
                tra.getChainTransform(self.guide.apos, self.normal,
                                      self.negate)):
            dist = vec.getDistance(self.guide.apos[i], self.guide.apos[i + 1])
            fk_ctl = self.addCtl(parent,
                                 "fk%s_ctl" % i,
                                 t,
                                 self.color_fk,
                                 "cube",
                                 w=dist,
                                 h=self.size * .25,
                                 d=self.size * .25,
                                 po=XSIMath.CreateVector3(
                                     dist * .5 * self.n_factor, 0, 0))
            xsi.SetNeutralPose(fk_ctl, c.siTrn)
            par.setKeyableParameters(fk_ctl)
            par.addLocalParamToCollection(self.inv_params, fk_ctl,
                                          ["posx", "posy", "posz"])

            parent = fk_ctl
            self.fk_ctl.append(fk_ctl)

        xsi.SetNeutralPose(self.fk_ctl[0])

        # Chain -------------------------------------------
        parent = self.fk_ctl[0]
        self.chain = []
        for i in range(self.division):
            pos = [self.guide.apos[i], self.guide.apos[i + 1]]
            chain = pri.add2DChain(parent, self.getName("spring%s" % i), pos,
                                   self.normal, self.negate, self.size * .25,
                                   True)
            self.addToGroup(chain.all, "hidden")

            eff_ref = pri.addNull(chain.root, self.getName("eff%s_ref" % i),
                                  chain.eff.Kinematics.Global.Transform,
                                  self.size * .1)
            eff_ref.AddChild(chain.eff)
            self.addToGroup(eff_ref, "hidden")

            self.addShadow(chain.bones[0], i)

            self.chain.append(chain)
            parent = chain.bones[0]

        # Plot Reference ----------------------------------
        self.ref = pri.addNullChain(self.root, self.getName("#_ref"),
                                    self.guide.apos, self.normal, self.negate,
                                    self.size * .1)
        self.addToGroup(self.ref, "hidden")
        xsi.SetNeutralPose(self.ref[0])
Esempio n. 7
0
    def addObjects(self):

        self.normal = self.getNormalFromPos(self.guide.apos)

        self.length0 = vec.getDistance(self.guide.apos[0], self.guide.apos[1])
        self.length1 = vec.getDistance(self.guide.apos[1], self.guide.apos[2])
        self.length2 = vec.getDistance(self.guide.apos[2], self.guide.apos[3])

        # FK Controlers ------------------------------------
        t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[1], self.normal, "xz", self.negate)
        self.fk0_ctl = self.addCtl(self.root, "fk0_ctl", t, self.color_fk, "circle", w=self.size*.1, po=XSIMath.CreateVector3(.5*self.n_factor,0,0), ro=XSIMath.CreateRotation(0,0,3.1415*.5))
        xsi.SetNeutralPose(self.fk0_ctl)
        par.setKeyableParameters(self.fk0_ctl)
        par.addLocalParamToCollection(self.inv_params, self.fk0_ctl, ["posx", "posy", "posz"])

        t = tra.getTransformLookingAt(self.guide.apos[1], self.guide.apos[2], self.normal, "xz", self.negate)
        self.fk1_ctl = self.addCtl(self.fk0_ctl, "fk1_ctl", t, self.color_fk, "circle", w=self.size*.1, po=XSIMath.CreateVector3(.5*self.n_factor,0,0), ro=XSIMath.CreateRotation(0,0,3.1415*.5))
        xsi.SetNeutralPose(self.fk1_ctl, c.siST)
        par.setKeyableParameters(self.fk1_ctl)
        par.addLocalParamToCollection(self.inv_params, self.fk1_ctl, ["posx", "posy", "posz"])

        t = tra.getTransformLookingAt(self.guide.apos[2], self.guide.apos[3], self.normal, "xz", self.negate)
        self.fk2_ctl = self.addCtl(self.fk1_ctl, "fk2_ctl", t, self.color_fk, "circle", w=self.size*.1, ro=XSIMath.CreateRotation(0,0,3.1415*.5))
        xsi.SetNeutralPose(self.fk2_ctl, c.siST)
        par.setKeyableParameters(self.fk2_ctl)
        par.addLocalParamToCollection(self.inv_params, self.fk2_ctl, ["posx", "posy", "posz"])

        # IK Controlers ------------------------------------
        self.ik_cns = pri.addNullFromPos(self.root, self.getName("ik_cns"), self.guide.apos[2], self.size*.02)
        self.addToGroup(self.ik_cns, "hidden")

        self.ikcns_ctl = self.addCtl(self.ik_cns, "ikcns_ctl", self.ik_cns.Kinematics.Global.Transform, self.color_ik, "null", h=self.size*.2)
        par.setKeyableParameters(self.ikcns_ctl)
        par.addLocalParamToCollection(self.inv_params, self.ikcns_ctl, ["posx", "rotx", "rotz"])

        t = tra.getTransformLookingAt(self.guide.apos[2], self.guide.apos[3], self.x_axis, "zx", False)
        self.ik_ctl = self.addCtl(self.ikcns_ctl, "ik_ctl", t, self.color_ik, "circle", w=self.size*.2)
        self.addToCtlGroup(self.ik_ctl)
        par.setKeyableParameters(self.ik_ctl)
        par.addLocalParamToCollection(self.inv_params, self.ik_ctl, ["posx"])

        v = XSIMath.CreateVector3()
        v.Sub(self.guide.apos[2], self.guide.apos[0])
        v.Cross(self.normal, v)
        v.NormalizeInPlace()
        v.ScaleInPlace(self.size*.5)
        v.AddInPlace(self.guide.apos[1])
        self.upv_cns = pri.addNullFromPos(self.root, self.getName("upv_cns"), v, self.size*.02)
        self.addToGroup(self.upv_cns, "hidden")

        self.upv_ctl = self.addCtl(self.upv_cns, "upv_ctl", self.upv_cns.Kinematics.Global.Transform, self.color_ik, "diamond", w=self.size*.05)
        par.setKeyableParameters(self.upv_ctl, self.t_params)
        par.addLocalParamToCollection(self.inv_params, self.upv_ctl, ["posx"])

        self.ik_ref = pri.addNull(self.ik_ctl, self.getName("ik_ref"), self.ik_ctl.Kinematics.Global.Transform, self.size * .1)
        self.addToGroup(self.ik_ref, "hidden")

        # Chain --------------------------------------------
        self.chain = pri.add2DChain(self.root, self.getName(""), self.guide.apos[:-1], self.normal, self.negate, 1, False)
        self.ctrn_loc = pri.addNullFromPos(self.chain.bones[0], self.getName("ctrn_loc"), self.guide.pos["knee"], self.size*.1)
        self.addToGroup(self.chain.all, "hidden")
        self.addToGroup(self.ctrn_loc, "hidden")

        # leash
        self.leash_crv = cur.addCnsCurve(self.root, self.getName("leash_crv"), [self.chain.bones[1], self.upv_ctl], False, 1)
        self.addToGroup(self.leash_crv, "unselectable")

        # shadows
        self.settings["division0"] = 4
        self.settings["division1"] = 4

        self.div0_loc = []
        for i in range(self.settings["division0"]):
            d = min(i/(self.settings["division0"]-1.0), 1-(.5/(self.settings["division0"]-1.0)))

            t = self.chain.bones[0].Kinematics.Global.Transform
            t.SetTranslation(vec.linearlyInterpolate(self.guide.pos["root"], self.guide.pos["knee"], d))
            div_loc = pri.addNull(self.chain.bones[0], self.getName("div%s_loc"%(i)), t, self.size*.05)
            self.addShadow(div_loc, i)
            self.div0_loc.append(div_loc)

        self.addShadow(self.ctrn_loc, self.settings["division0"])

        self.div_loc = []
        for i in range(self.settings["division1"]):
            d = max(i/(self.settings["division1"]-1.0), .5/(self.settings["division1"]-1.0))

            t = self.chain.bones[1].Kinematics.Global.Transform
            t.SetTranslation(vec.linearlyInterpolate(self.guide.pos["knee"], self.guide.pos["ankle"], d))
            div_loc = pri.addNull(self.chain.bones[1], self.getName("div%s_loc"%(i+self.settings["division0"]+1)), t, self.size*.05)
            self.addShadow(div_loc, i+self.settings["division0"]+1)
            self.div_loc.append(div_loc)

        self.addToGroup(self.div0_loc, "hidden")
        self.addToGroup(self.div_loc, "hidden")

        # Hook ----------------------------------------------
        t = self.chain.bones[1].Kinematics.Global.Transform
        t.SetTranslation(self.guide.pos["ankle"])
        self.end_ref = pri.addNull(self.chain.bones[1], self.getName("end_ref"), t, self.size * .1)
        self.addToGroup(self.end_ref, "hidden")

        self.addShadow(self.end_ref, "end")
Esempio n. 8
0
    def addObjects(self):

        self.div_count = len(self.guide.apos) - 1

        #

        # FK controlers ------------------------------------
        self.fk_ctl = []
        self.fk_ref = []
        self.dir_ref = []
        fk_ctl_parent = self.root
        fk_ref_parent = self.root
        dir_ref_parent = self.root
        for i, t in enumerate(
                tra.getChainTransform(self.guide.apos, self.normal,
                                      self.negate)):

            # ctl
            dist = vec.getDistance(self.guide.apos[i], self.guide.apos[i + 1])
            fk_ctl = self.addCtl(fk_ctl_parent,
                                 "fk%s_ctl" % i,
                                 t,
                                 self.color_fk,
                                 "cube",
                                 w=dist,
                                 h=self.size * .25,
                                 d=self.size * .25,
                                 po=XSIMath.CreateVector3(
                                     dist * .5 * self.n_factor, 0, 0))
            xsi.SetNeutralPose(fk_ctl)
            par.setKeyableParameters(fk_ctl)
            fk_ctl_parent = fk_ctl

            self.fk_ctl.append(fk_ctl)

            self.addShadow(fk_ctl, i)

            # ref
            fk_ref = pri.addNull(fk_ref_parent, self.getName("fk%s_ref" % i),
                                 t, self.size * .1)
            fk_ref_parent = fk_ref

            self.fk_ref.append(fk_ref)

            dir_ref = pri.addNull(dir_ref_parent,
                                  self.getName("dir%s_ref" % i), t,
                                  self.size * .1)
            dir_ref_parent = dir_ref

            self.dir_ref.append(dir_ref)

        end_ref = pri.addNullFromPos(self.dir_ref[-1],
                                     self.getName("dir%s_ref" % (i + 1)),
                                     self.guide.apos[-1], self.size * .1)
        self.dir_ref.append(end_ref)

        self.addToGroup(self.fk_ref, "hidden")
        self.addToGroup(self.dir_ref, "hidden")

        parent = self.root
        self.ref_chn = []
        for i in range(self.div_count):
            pos = [self.guide.apos[i], self.guide.apos[i + 1]]
            ref_chn = pri.add2DChain(parent, self.getName("ref%s" % i), pos,
                                     self.normal, self.negate, self.size * .1,
                                     True)
            self.addToGroup(ref_chn.all, "hidden")

            parent = ref_chn.eff

            self.ref_chn.append(ref_chn)
Esempio n. 9
0
    def addObjects(self):

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

        self.isFk = self.settings["type"] != 1
        self.isIk = self.settings["type"] != 0
        self.isFkIk = self.settings["type"] == 2

        # FK controlers ------------------------------------
        if self.isFk:
            self.fk_ctl = []
            parent = self.root
            for i, t in enumerate(
                    tra.getChainTransform(self.guide.apos, self.normal,
                                          self.negate)):
                dist = vec.getDistance(self.guide.apos[i],
                                       self.guide.apos[i + 1])
                fk_ctl = self.addCtl(parent,
                                     "fk%s_ctl" % i,
                                     t,
                                     self.color_fk,
                                     "cube",
                                     w=dist,
                                     h=self.size * .25,
                                     d=self.size * .25,
                                     po=XSIMath.CreateVector3(
                                         dist * .5 * self.n_factor, 0, 0))
                xsi.SetNeutralPose(fk_ctl, c.siTrn)
                par.setKeyableParameters(fk_ctl)
                par.addLocalParamToCollection(self.inv_params, fk_ctl,
                                              ["posx", "posy", "posz"])

                parent = fk_ctl
                self.fk_ctl.append(fk_ctl)

            if self.settings["neutralpose"]:
                xsi.SetNeutralPose(self.fk_ctl)
            else:
                xsi.SetNeutralPose(self.fk_ctl[0])

        # IK controlers ------------------------------------
        if self.isIk:

            normal = vec.getTransposedVector(
                self.normal, [self.guide.apos[0], self.guide.apos[1]],
                [self.guide.apos[-2], self.guide.apos[-1]])
            t = tra.getTransformLookingAt(self.guide.apos[-2],
                                          self.guide.apos[-1], normal, "xy",
                                          self.negate)
            t.SetTranslation(self.guide.apos[-1])

            self.ik_cns = pri.addNull(self.root, self.getName("ik_cns"), t,
                                      self.size * .2)
            self.addToGroup(self.ik_cns, "hidden")

            self.ikcns_ctl = self.addCtl(self.ik_cns,
                                         "ikcns_ctl",
                                         t,
                                         self.color_ik,
                                         "null",
                                         h=self.size)
            par.setKeyableParameters(self.ikcns_ctl)

            self.ik_ctl = self.addCtl(self.ikcns_ctl,
                                      "ik_ctl",
                                      t,
                                      self.color_ik,
                                      "cube",
                                      h=self.size * .3,
                                      w=self.size * .3,
                                      d=self.size * .3)
            xsi.SetNeutralPose(self.ik_ctl)
            par.setKeyableParameters(self.ik_ctl, self.tr_params)

            v = XSIMath.CreateVector3()
            v.Sub(self.guide.apos[-1], self.guide.apos[0])
            v.Cross(self.normal, v)
            v.NormalizeInPlace()
            v.ScaleInPlace(self.size * 4)
            v.AddInPlace(self.guide.apos[1])
            self.upv_cns = pri.addNullFromPos(self.root,
                                              self.getName("upv_cns"), v,
                                              self.size * .1)
            self.addToGroup(self.upv_cns, "hidden")

            self.upv_ctl = self.addCtl(
                self.upv_cns,
                "upv_ctl",
                self.upv_cns.Kinematics.Global.Transform,
                self.color_ik,
                "leash",
                h=self.size * .2,
                ap=self.guide.apos[1])
            par.setKeyableParameters(self.upv_ctl, self.t_params)

            # Chain
            self.chain = pri.add2DChain(self.root, self.getName("chain"),
                                        self.guide.apos, self.normal,
                                        self.negate, self.size * .5, True)
            self.addToGroup(self.chain.all, "hidden")

        # Chain of deformers -------------------------------
        self.loc = pri.addNullChain(self.root, self.getName("#_loc"),
                                    self.guide.apos, self.normal, self.negate,
                                    self.size * .25)
        xsi.SetNeutralPose(self.loc, c.siTrn)
        self.addToGroup(self.loc, "hidden")

        for i, loc in enumerate(self.loc):
            self.addShadow(loc, i)