def gear_DrawCnsCurve_Cubic_Execute(): if xsi.Selection.Count < 2: gear.log("Select enough centers", gear.sev_error) return cur.addCnsCurve(xsi.ActiveSceneRoot, "crvCns", xsi.Selection, False, 3)
def addDispCurve(self, name, centers=[], degree=1): crv = cur.addCnsCurve(centers[0], self.getName(name), centers, False, degree) self.addToGroup(crv, "unselectable") return crv
def addObjects(self): # Ik Controlers ------------------------------------ t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[1], self.guide.blades["blade"].z, "yx", self.negate) self.ik0_ctl = self.addCtl(self.root, "ik0_ctl", t, self.color_ik, "compas", w=self.size) par.setKeyableParameters(self.ik0_ctl) xsi.SetNeutralPose(self.ik0_ctl) par.addLocalParamToCollection(self.inv_params, self.ik0_ctl, ["posx", "roty", "rotz"]) par.setRotOrder(self.ik0_ctl, "XZY") t.SetTranslation(self.guide.apos[1]) self.ik1_ctl = self.addCtl(self.root, "ik1_ctl", t, self.color_ik, "compas", w=self.size) par.setKeyableParameters(self.ik1_ctl) xsi.SetNeutralPose(self.ik1_ctl) par.addLocalParamToCollection(self.inv_params, self.ik1_ctl, ["posx", "roty", "rotz"]) par.setRotOrder(self.ik1_ctl, "XZY") # Tangent controlers ------------------------------- t.SetTranslation(vec.linearlyInterpolate(self.guide.apos[0], self.guide.apos[1], .33)) self.tan0_ctl = self.addCtl(self.ik0_ctl, "tan0_ctl", t, self.color_ik, "sphere", w=self.size*.2) par.setKeyableParameters(self.tan0_ctl, self.t_params) xsi.SetNeutralPose(self.tan0_ctl, c.siTrn) par.addLocalParamToCollection(self.inv_params, self.ik1_ctl, ["posx"]) t.SetTranslation(vec.linearlyInterpolate(self.guide.apos[0], self.guide.apos[1], .66)) self.tan1_ctl = self.addCtl(self.ik1_ctl, "tan1_ctl", t, self.color_ik, "sphere", w=self.size*.2) par.setKeyableParameters(self.tan1_ctl, self.t_params) xsi.SetNeutralPose(self.tan1_ctl, c.siTrn) par.addLocalParamToCollection(self.inv_params, self.ik1_ctl, ["posx"]) # Curves ------------------------------------------- self.mst_crv = cur.addCnsCurve(self.root, self.getName("mst_crv"), [self.ik0_ctl, self.tan0_ctl, self.tan1_ctl, self.ik1_ctl], False, 3) self.slv_crv = cur.addCurve(self.root, self.getName("slv_crv"), [1]*10*4, False, 3) self.addToGroup([self.mst_crv, self.slv_crv], "hidden") # Division ----------------------------------------- # The user only define how many intermediate division he wants. # First and last divisions are an obligation. parentdiv = self.ik0_ctl parentctl = self.ik0_ctl self.div_cns = [] self.fk_ctl = [] for i in range(self.settings["division"]): # References div_cns = parentdiv.AddNull(self.getName("%s_cns"%i)) pri.setNullDisplay(div_cns, 1, self.size*.05, 10, 0, 0, 0, 1, 1, 2) self.addToGroup(div_cns, "hidden") self.div_cns.append(div_cns) parentdiv = div_cns # Controlers (First and last one are fake) if i in [0, self.settings["division"] - 1]: fk_ctl = pri.addNull(parentctl, self.getName("%s_loc"%i), parentctl.Kinematics.Global.Transform, self.size*.05) self.addToGroup(fk_ctl, "hidden") else: fk_ctl = self.addCtl(parentctl, "fk%s_ctl"%(i-1), parentctl.Kinematics.Global.Transform, self.color_fk, "cube", w=self.size*1, h=self.size*.05, d=self.size*1) self.addToGroup(fk_ctl, "controlers_01") par.addLocalParamToCollection(self.inv_params, fk_ctl, ["posx", "roty", "rotz"]) par.setRotOrder(fk_ctl, "XZY") self.fk_ctl.append(fk_ctl) parentctl = fk_ctl # Deformers (Shadow) self.addShadow(fk_ctl, (i)) # Connections (Hooks) ------------------------------ self.cnx0 = pri.addNull(self.root, self.getName("0_cnx"), self.root.Kinematics.Global.Transform, self.size*.2) self.cnx1 = pri.addNull(self.root, self.getName("1_cnx"), self.root.Kinematics.Global.Transform, self.size*.2) self.addToGroup([self.cnx0, self.cnx1], "hidden")
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, "cube", h=self.size*.1, w=1, d=self.size*.1, po=XSIMath.CreateVector3(.5*self.n_factor,0,0)) self.fk0_ctl.Parameters("SclX").Value = self.length0 tra.setRefPose(self.fk0_ctl, [-90,0,0], self.negate) xsi.SetNeutralPose(self.fk0_ctl, c.siSRT) 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", h=self.size*.1, w=1, d=self.size*.1, po=XSIMath.CreateVector3(.5*self.n_factor,0,0)) self.fk1_ctl.Parameters("SclX").Value = self.length1/self.length0 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", h=self.size*.1, w=self.length2, d=self.size*.1, po=XSIMath.CreateVector3(self.length2*.5*self.n_factor,0,0)) 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.normal, "xz", self.negate) self.ik_ctl = self.addCtl(self.ikcns_ctl, "ik_ctl", t, self.color_ik, "cube", h=self.size*.12, w=self.length2, d=self.size*.12, po=XSIMath.CreateVector3(self.length2*.5*self.n_factor,0,0)) tra.setRefPose(self.ik_ctl, [-90,0,0], self.negate) 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, "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"]) # Chain -------------------------------------------- self.bone0 = pri.addNull(self.root, self.getName("0_jnt"), self.fk0_ctl.Kinematics.Global.Transform) pri.setNullDisplay(self.bone0, 0, 1, 4, self.n_factor*.5, 0, 0, 1, self.size*.01, self.size*.01) self.bone0.Kinematics.Global.Parameters("sclx").Value = self.length0 self.bone1 = pri.addNull(self.bone0, self.getName("1_jnt"), self.fk1_ctl.Kinematics.Global.Transform) pri.setNullDisplay(self.bone1, 0, 1, 4, self.n_factor*.5, 0, 0, 1, self.size*.01, self.size*.01) self.bone1.Kinematics.Global.Parameters("sclx").Value = self.length1 self.ctrn_loc = pri.addNullFromPos(self.bone0, self.getName("ctrn_loc"), self.guide.apos[1], self.size*.05) self.eff_loc = pri.addNullFromPos(self.root, self.getName("eff_loc"), self.guide.apos[2], self.size*.05) self.addToGroup([self.bone0, self.bone1, self.ctrn_loc, self.eff_loc], "hidden") # Mid Controler ------------------------------------ self.mid_ctl = self.addCtl(self.ctrn_loc, "mid_ctl", self.ctrn_loc.Kinematics.Global.Transform, self.color_ik, "sphere", h=self.size*.05) par.addLocalParamToCollection(self.inv_params, self.mid_ctl, ["posx", "posy", "posz"]) # Membrane ----------------------------------------- self.memb_loc = pri.addNull(self.mid_ctl, self.getName("memb_loc"), self.mid_ctl.Kinematics.Global.Transform, self.size*.02) self.memb_crv = cur.addCnsCurve(self.memb_loc, self.getName("memb_crv"), [self.root, self.memb_loc, self.eff_loc], False, 3) # Twist references --------------------------------- t = tra.getFilteredTransform(self.fk0_ctl.Kinematics.Global.Transform, True, True, False) 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.ctrn_loc, self.getName("tws1_loc"), self.ctrn_loc.Kinematics.Global.Transform, self.size*.05) self.tws1_rot = pri.addNull(self.tws1_loc, self.getName("tws1_rot"), self.ctrn_loc.Kinematics.Global.Transform) pri.setNullDisplay(self.tws1_rot, 0, self.size*.05, 2, 0, 0, 0, self.size*.01) t = tra.getFilteredTransform(self.bone1.Kinematics.Global.Transform, True, True, False) t.SetTranslation(self.guide.apos[2]) self.tws2_loc = pri.addNull(self.bone1, self.getName("tws2_loc"), t, self.size*.05) self.tws2_rot = pri.addNull(self.tws2_loc, self.getName("tws2_rot"),t) self.tws2_rot.Kinematics.Global.Parameters("SclX").Value = .001 pri.setNullDisplay(self.tws2_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], "hidden") # End reference ------------------------------------ t = tra.getFilteredTransform(self.tws2_rot.Kinematics.Global.Transform, True, True, False) self.end_ref = pri.addNull(self.tws2_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"] + 3 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)
def addObjects(self): # Ik Controlers ------------------------------------ t = tra.getTransformLookingAt(self.guide.pos["tan1"], self.guide.pos["neck"], self.guide.blades["blade"].z, "yx", self.negate) t.SetTranslation(self.guide.pos["neck"]) self.ik_cns = pri.addNull(self.root, self.getName("ik_cns"), t, self.size*.02) self.addToGroup(self.ik_cns, "hidden") self.ik_ctl = self.addCtl(self.ik_cns, "ik_ctl", t, self.color_ik, "compas", w=self.size*.5) par.setKeyableParameters(self.ik_ctl) xsi.SetNeutralPose(self.ik_ctl, c.siTrn) # Tangents ----------------------------------------- t.SetTranslation(self.guide.pos["tan1"]) self.tan1_loc = pri.addNull(self.ik_ctl, self.getName("tan1_loc"), t, self.size*.1) par.setKeyableParameters(self.tan1_loc, self.t_params) xsi.SetNeutralPose(self.tan1_loc, c.siTrn) self.addToGroup(self.tan1_loc, "hidden") t = tra.getTransformLookingAt(self.guide.pos["root"], self.guide.pos["tan0"], self.guide.blades["blade"].z, "yx", self.negate) t.SetTranslation(self.guide.pos["tan0"]) self.tan0_loc = pri.addNull(self.root, self.getName("tan0_loc"), t, self.size*.1) xsi.SetNeutralPose(self.tan0_loc, c.siTrn) self.addToGroup(self.tan0_loc, "hidden") # Curves ------------------------------------------- self.mst_crv = cur.addCnsCurve(self.root, self.getName("mst_crv"), [self.root, self.tan0_loc, self.tan1_loc, self.ik_ctl], False, 3) self.slv_crv = cur.addCurve(self.root, self.getName("slv_crv"), [1]*10*4, False, 3) self.addToGroup([self.mst_crv, self.slv_crv], "hidden") # 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 = [] for i in range(self.settings["division"]): # References div_cns = parentdiv.AddNull(self.getName("%s_cns"%i)) pri.setNullDisplay(div_cns, 1, self.size*.05, 10, 0, 0, 0, 1, 1, 2) self.addToGroup(div_cns, "hidden") self.div_cns.append(div_cns) parentdiv = div_cns # Controlers if i == self.settings["division"]-1: fk_ctl = pri.addNull(parentctl, self.getName("fk%s_cns"%i), parentctl.Kinematics.Global.Transform, self.size*.2) self.addToGroup(fk_ctl, "hidden") else: fk_ctl = self.addCtl(parentctl, "fk%s_ctl"%i, parentctl.Kinematics.Global.Transform, self.color_fk, "cube", w=self.size*.5, h=self.size*.05, d=self.size*.5) self.fk_ctl.append(fk_ctl) parentctl = fk_ctl # Deformers (Shadow) self.addShadow(fk_ctl, i) # Head --------------------------------------------- t = tra.getTransformLookingAt(self.guide.pos["head"], self.guide.pos["eff"], self.guide.blades["blade"].z, "yx", self.negate) self.head_cns = pri.addNull(self.root, self.getName("head_cns"), t, self.size*.1) self.addToGroup(self.head_cns, "hidden") dist = vec.getDistance(self.guide.pos["head"], self.guide.pos["eff"]) self.head_ctl = self.addCtl(self.head_cns, "head_ctl", t, self.color_fk, "cube", w=self.size*.5, h=dist, d=self.size*.5, po=XSIMath.CreateVector3(0,dist*.5,0)) self.addShadow(self.head_ctl, "head")
def addObjects(self): # Ik Controlers ------------------------------------ t = tra.getTransformLookingAt(self.guide.pos["tan1"], self.guide.pos["neck"], self.guide.blades["blade"].z, "yx", self.negate) t.SetTranslation(self.guide.pos["neck"]) self.ik_cns = pri.addNull(self.root, self.getName("ik_cns"), t, self.size * .02) self.addToGroup(self.ik_cns, "hidden") self.ik_ctl = self.addCtl(self.ik_cns, "ik_ctl", t, self.color_ik, "compas", w=self.size * .5) par.setKeyableParameters(self.ik_ctl) xsi.SetNeutralPose(self.ik_ctl, c.siTrn) par.setRotOrder(self.ik_ctl, "XZY") # Tangents ----------------------------------------- t.SetTranslation(self.guide.pos["tan1"]) self.tan1_loc = pri.addNull(self.ik_ctl, self.getName("tan1_loc"), t, self.size * .1) par.setKeyableParameters(self.tan1_loc, self.t_params) xsi.SetNeutralPose(self.tan1_loc, c.siTrn) self.addToGroup(self.tan1_loc, "hidden") t = tra.getTransformLookingAt(self.guide.pos["root"], self.guide.pos["tan0"], self.guide.blades["blade"].z, "yx", self.negate) t.SetTranslation(self.guide.pos["tan0"]) self.tan0_loc = pri.addNull(self.root, self.getName("tan0_loc"), t, self.size * .1) xsi.SetNeutralPose(self.tan0_loc, c.siTrn) self.addToGroup(self.tan0_loc, "hidden") # Curves ------------------------------------------- self.mst_crv = cur.addCnsCurve( self.root, self.getName("mst_crv"), [self.root, self.tan0_loc, self.tan1_loc, self.ik_ctl], False, 3) self.slv_crv = cur.addCurve(self.root, self.getName("slv_crv"), [1] * 10 * 4, False, 3) self.addToGroup([self.mst_crv, self.slv_crv], "hidden") # 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 = [] for i in range(self.settings["division"]): # References div_cns = parentdiv.AddNull(self.getName("%s_cns" % i)) pri.setNullDisplay(div_cns, 1, self.size * .05, 10, 0, 0, 0, 1, 1, 2) self.addToGroup(div_cns, "hidden") self.div_cns.append(div_cns) parentdiv = div_cns # Controlers if i == self.settings["division"] - 1: fk_ctl = pri.addNull(parentctl, self.getName("fk%s_cns" % i), parentctl.Kinematics.Global.Transform, self.size * .2) self.addToGroup(fk_ctl, "hidden") else: fk_ctl = self.addCtl(parentctl, "fk%s_ctl" % i, parentctl.Kinematics.Global.Transform, self.color_fk, "cube", w=self.size * .5, h=self.size * .05, d=self.size * .5) par.setRotOrder(fk_ctl, "XZY") self.fk_ctl.append(fk_ctl) parentctl = fk_ctl # Deformers (Shadow) self.addShadow(fk_ctl, i) # Head --------------------------------------------- t = tra.getTransformLookingAt(self.guide.pos["head"], self.guide.pos["eff"], self.guide.blades["blade"].z, "yx", self.negate) self.head_cns = pri.addNull(self.root, self.getName("head_cns"), t, self.size * .1) self.addToGroup(self.head_cns, "hidden") dist = vec.getDistance(self.guide.pos["head"], self.guide.pos["eff"]) self.head_ctl = self.addCtl(self.head_cns, "head_ctl", t, self.color_fk, "cube", w=self.size * .5, h=dist, d=self.size * .5, po=XSIMath.CreateVector3(0, dist * .5, 0)) par.setRotOrder(self.head_ctl, "XZY") self.addShadow(self.head_ctl, "head")
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")
def addObjects(self): # Ik Controlers ------------------------------------ t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[1], self.guide.blades["blade"].z, "yx", self.negate) self.ik0_ctl = self.addCtl(self.root, "ik0_ctl", t, self.color_ik, "compas", w=self.size) par.setKeyableParameters(self.ik0_ctl) xsi.SetNeutralPose(self.ik0_ctl) par.addLocalParamToCollection(self.inv_params, self.ik0_ctl, ["posx", "roty", "rotz"]) par.setRotOrder(self.ik0_ctl, "XZY") t.SetTranslation(self.guide.apos[1]) self.ik1_ctl = self.addCtl(self.root, "ik1_ctl", t, self.color_ik, "compas", w=self.size) par.setKeyableParameters(self.ik1_ctl) xsi.SetNeutralPose(self.ik1_ctl) par.addLocalParamToCollection(self.inv_params, self.ik1_ctl, ["posx", "roty", "rotz"]) par.setRotOrder(self.ik1_ctl, "XZY") # Tangent controlers ------------------------------- t.SetTranslation( vec.linearlyInterpolate(self.guide.apos[0], self.guide.apos[1], .33)) self.tan0_ctl = self.addCtl(self.ik0_ctl, "tan0_ctl", t, self.color_ik, "sphere", w=self.size * .2) par.setKeyableParameters(self.tan0_ctl, self.t_params) xsi.SetNeutralPose(self.tan0_ctl, c.siTrn) par.addLocalParamToCollection(self.inv_params, self.ik1_ctl, ["posx"]) t.SetTranslation( vec.linearlyInterpolate(self.guide.apos[0], self.guide.apos[1], .66)) self.tan1_ctl = self.addCtl(self.ik1_ctl, "tan1_ctl", t, self.color_ik, "sphere", w=self.size * .2) par.setKeyableParameters(self.tan1_ctl, self.t_params) xsi.SetNeutralPose(self.tan1_ctl, c.siTrn) par.addLocalParamToCollection(self.inv_params, self.ik1_ctl, ["posx"]) # Curves ------------------------------------------- self.mst_crv = cur.addCnsCurve( self.root, self.getName("mst_crv"), [self.ik0_ctl, self.tan0_ctl, self.tan1_ctl, self.ik1_ctl], False, 3) self.slv_crv = cur.addCurve(self.root, self.getName("slv_crv"), [1] * 10 * 4, False, 3) self.addToGroup([self.mst_crv, self.slv_crv], "hidden") # Division ----------------------------------------- # The user only define how many intermediate division he wants. # First and last divisions are an obligation. parentdiv = self.ik0_ctl parentctl = self.ik0_ctl self.div_cns = [] self.fk_ctl = [] for i in range(self.settings["division"]): # References div_cns = parentdiv.AddNull(self.getName("%s_cns" % i)) pri.setNullDisplay(div_cns, 1, self.size * .05, 10, 0, 0, 0, 1, 1, 2) self.addToGroup(div_cns, "hidden") self.div_cns.append(div_cns) parentdiv = div_cns # Controlers (First and last one are fake) if i in [0, self.settings["division"] - 1]: fk_ctl = pri.addNull(parentctl, self.getName("%s_loc" % i), parentctl.Kinematics.Global.Transform, self.size * .05) self.addToGroup(fk_ctl, "hidden") else: fk_ctl = self.addCtl(parentctl, "fk%s_ctl" % (i - 1), parentctl.Kinematics.Global.Transform, self.color_fk, "cube", w=self.size * 1, h=self.size * .05, d=self.size * 1) self.addToGroup(fk_ctl, "controlers_01") par.addLocalParamToCollection(self.inv_params, fk_ctl, ["posx", "roty", "rotz"]) par.setRotOrder(fk_ctl, "XZY") self.fk_ctl.append(fk_ctl) parentctl = fk_ctl # Deformers (Shadow) self.addShadow(fk_ctl, (i)) # Connections (Hooks) ------------------------------ self.cnx0 = pri.addNull(self.root, self.getName("0_cnx"), self.root.Kinematics.Global.Transform, self.size * .2) self.cnx1 = pri.addNull(self.root, self.getName("1_cnx"), self.root.Kinematics.Global.Transform, self.size * .2) self.addToGroup([self.cnx0, self.cnx1], "hidden")