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)
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])
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)
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])
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)
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)