Exemple #1
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])
Exemple #2
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)
Exemple #3
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])
Exemple #4
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)