def addOperators(self): # Visibilities ------------------------------------- par.addExpression(self.fk0_ctl.Properties("visibility").Parameters("viewvis"), "1 - "+self.pBlend.FullName) par.addExpression(self.fk1_ctl.Properties("visibility").Parameters("viewvis"), "1 - "+self.pBlend.FullName) par.addExpression(self.fk2_ctl.Properties("visibility").Parameters("viewvis"), "1 - "+self.pBlend.FullName) par.addExpression(self.fk3_ctl.Properties("visibility").Parameters("viewvis"), "1 - "+self.pBlend.FullName) par.addExpression(self.upv_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) par.addExpression(self.ikcns_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName +" * "+ self.pIkCns.FullName) par.addExpression(self.ik_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) if self.settings["roll"] == 0: par.addExpression(self.roll_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) # Leash -------------------------------------------- aop.clsCtrOp(self.upv_ctl, self.mid0_ctl, [0]) # IK Solver----------------------------------------- self.roll_ctl.Kinematics.AddConstraint("Position", self.ik_ref, False) self.ref_chn.eff.Kinematics.AddConstraint("Pose", self.roll_ctl, True) self.end_chn.eff.Kinematics.AddConstraint("Pose", self.roll_ctl, True) op = xsi.ApplyOp("SkeletonUpVector", self.ref_chn.bones[0].FullName+";"+self.upv_ctl.FullName)[0] par.addExpression(self.ref_chn.roll, self.pIkRoll.FullName + " + 180") op = xsi.ApplyOp("SkeletonUpVector", self.end_chn.bones[0].FullName+";"+self.upv_ctl.FullName)[0] par.addExpression(self.end_chn.roll, self.pIkRoll.FullName + " + 180") # ctrn for s in "xyz": par.addExpression(self.ctrn0_loc.Kinematics.Local.Parameters("rot" + s), self.ref_loc[1].Kinematics.Local.Parameters("rot" + s).FullName + " * .5") par.addExpression(self.ctrn0_loc.Kinematics.Global.Parameters("scl" + s), self.root.Kinematics.Global.Parameters("scl" + s).FullName) par.addExpression(self.ctrn1_loc.Kinematics.Local.Parameters("rot" + s), self.ref_loc[2].Kinematics.Local.Parameters("rot" + s).FullName + " * .5") par.addExpression(self.ctrn1_loc.Kinematics.Global.Parameters("scl" + s), self.root.Kinematics.Global.Parameters("scl" + s).FullName) self.ctrn0_loc.Kinematics.AddConstraint("Position", self.ref_loc[1], False) self.ctrn1_loc.Kinematics.AddConstraint("Position", self.ref_loc[2], False) # References Nulls --------------------------------- fk_ref = [self.fk0_ctl, self.fk1_ctl, self.fk2_ctl, self.fk_ref] ik_ref = [self.ref_chn.bones[0], self.ref_chn.bones[1], self.end_chn.bones[0], self.ik_ref] for i, ref_loc in enumerate(self.ref_loc): # fk cns = ref_loc.Kinematics.AddConstraint("Orientation", fk_ref[i], False) if i != len(self.ref_loc)-1: cns = aop.dirCns(ref_loc, fk_ref[i+1], None, False, self.n_sign+"xz") par.addExpression(cns.Parameters("blendweight"), "1 - " + self.pBlend.FullName) #ik cns = ref_loc.Kinematics.AddConstraint("Orientation", ik_ref[i], False) par.addExpression(cns.Parameters("blendweight"), self.pBlend.FullName) for s in "xyz": par.addExpression(ref_loc.Kinematics.Local.Parameters("rot"+s), 0) par.addExpression(self.ref_loc[1].Kinematics.Local.Parameters("posx"), self.n_sign+" (ctr_dist(%s.kine.global, %s.kine.global) * (1 - %s) + ctr_dist(%s.kine.global, %s.kine.global) * %s)"%(self.fk0_ctl.FullName, self.fk1_ctl.FullName, self.pBlend.FullName, self.ref_chn.bones[0].FullName, self.ref_chn.bones[1].FullName, self.pBlend.FullName)) par.addExpression(self.ref_loc[2].Kinematics.Local.Parameters("posx"), self.n_sign+" (ctr_dist(%s.kine.global, %s.kine.global) * (1 - %s) + ctr_dist(%s.kine.global, %s.kine.global) * %s)"%(self.fk1_ctl.FullName, self.fk2_ctl.FullName, self.pBlend.FullName, self.ref_chn.bones[1].FullName, self.end_chn.bones[0], self.pBlend.FullName)) par.addExpression(self.ref_loc[3].Kinematics.Local.Parameters("posx"), self.n_sign+" (ctr_dist(%s.kine.global, %s.kine.global) * (1 - %s) + ctr_dist(%s.kine.global, %s.kine.global) * %s)"%(self.fk2_ctl.FullName, self.fk3_ctl.FullName, self.pBlend.FullName, self.end_chn.bones[0].FullName, self.end_chn.eff, self.pBlend.FullName)) # Twist references --------------------------------- par.addExpression(self.pDriver, "(ctr_dist(%s, %s) + ctr_dist(%s, %s) + ctr_dist(%s, %s)) / %s" %(self.tws0_loc.Kinematics.Global.FullName, self.tws1_loc.Kinematics.Global.FullName, self.tws1_loc.Kinematics.Global.FullName, self.tws2_loc.Kinematics.Global.FullName, self.tws2_loc.Kinematics.Global.FullName, self.tws3_loc.Kinematics.Global.FullName, self.root.Kinematics.Global.Parameters("sclx").FullName)) self.tws1_loc.Kinematics.AddConstraint("Position", self.mid0_ctl) self.tws1_loc.Kinematics.AddConstraint("Scaling", self.mid0_ctl) self.tws1_rot.Kinematics.AddConstraint("Orientation", self.mid0_ctl) par.addExpression(self.tws1_rot.Parameters("rotx"), 0) par.addExpression(self.tws1_rot.Parameters("roty"), 0) par.addExpression(self.tws1_rot.Parameters("rotz"), 0) self.tws2_loc.Kinematics.AddConstraint("Position", self.mid1_ctl) self.tws2_loc.Kinematics.AddConstraint("Scaling", self.mid1_ctl) self.tws2_rot.Kinematics.AddConstraint("Orientation", self.mid1_ctl) par.addExpression(self.tws2_rot.Parameters("rotx"), 0) par.addExpression(self.tws2_rot.Parameters("roty"), 0) par.addExpression(self.tws2_rot.Parameters("rotz"), 0) self.tws3_loc.Kinematics.AddConstraint("Position", self.ref_loc[-1]) #self.tws3_loc.Kinematics.AddConstraint("Scaling", self.eff_loc) aop.poseCns(self.tws3_rot, self.fk_ref, True, False, True, False) cns = aop.poseCns(self.tws3_rot, self.ik_ref, True, False, True, False) par.addExpression(cns.Parameters("blendweight"), self.pBlend.FullName) par.addExpression(self.tws3_rot.Parameters("rotx"), self.ik_ctl.Parameters("rotx").FullName + " * (1 - "+self.pBlend.FullName+") + " + self.fk3_ctl.Parameters("rotx").FullName + " * " + self.pBlend.FullName) par.addExpression(self.tws3_rot.Parameters("roty"), 0) par.addExpression(self.tws3_rot.Parameters("rotz"), 0) self.tws0_rot.SclX = .001 par.addExpression(self.tws1_rot.SclX, self.pRoundness.FullName + " + .001") par.addExpression(self.tws2_rot.SclX, self.pRoundness.FullName + " + .001") self.tws3_rot.SclX = .001 # Divisions ---------------------------------------- # at 0 or 1 the division will follow exactly the rotation of the controler.. and we wont have this nice tangent + roll for i, div_cns in enumerate(self.div_cns): if i < (self.settings["div0"]+1): perc = i / ((self.settings["div0"]+1.0)*3) elif i < (self.settings["div0"]+self.settings["div1"]+2): perc = (1/3.0) + ((i-self.settings["div0"]-1.0) / ((self.settings["div1"]+1.0)*3)) else: perc = (2/3.0) + ((i-self.settings["div0"]-self.settings["div1"]-2.0) / ((self.settings["div2"]+1.0)*3)) perc = max(.001, min(.999, perc)) if self.negate: op = aop.sn_rollsplinekine_op(div_cns, [self.tws3_rot, self.tws2_rot, self.tws1_rot, self.tws0_rot], 1-perc) else: op = aop.sn_rollsplinekine_op(div_cns, [self.tws0_rot, self.tws1_rot, self.tws2_rot, self.tws3_rot], perc) # Squash n Stretch op = aop.sn_squashstretch2_op(div_cns, self.root, self.pDriver.Value, "x") par.addExpression(op.Parameters("blend"), self.pVolume.FullName) par.addExpression(op.Parameters("driver"), self.pDriver.FullName) if self.options["mode"] == 1: # wip par.addExpression(op.Parameters("stretch"), self.pStretch[i]) par.addExpression(op.Parameters("squash"), self.pSquash[i]) else: op.Parameters("stretch").Value = self.st_value[i] op.Parameters("squash").Value = self.sq_value[i]
def addOperators(self): # Visibilities ------------------------------------- par.addExpression(self.fk0_ctl.Properties("visibility").Parameters("viewvis"), "1 - "+self.pBlend.FullName) par.addExpression(self.fk1_ctl.Properties("visibility").Parameters("viewvis"), "1 - "+self.pBlend.FullName) par.addExpression(self.fk2_ctl.Properties("visibility").Parameters("viewvis"), "1 - "+self.pBlend.FullName) par.addExpression(self.upv_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) par.addExpression(self.ikcns_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName +" * "+ self.pIkCns.FullName) par.addExpression(self.ik_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) # Leash -------------------------------------------- aop.clsCtrOp(self.upv_ctl, self.mid_ctl, [0]) # IK Solver----------------------------------------- out = [self.bone0, self.bone1, None, self.eff_loc] op = aop.sn_ikfk2bone_op(out, self.root, self.ik_ctl, self.upv_ctl, self.fk0_ctl, self.fk1_ctl, self.fk2_ctl, self.length0, self.length1, self.negate) par.addExpression(op.Parameters("blend"), self.pBlend.FullName) par.addExpression(op.Parameters("roll"), self.pIkRoll.FullName) par.addExpression(op.Parameters("scaleA"), self.pScale.FullName) par.addExpression(op.Parameters("scaleB"), self.pScale.FullName) par.addExpression(op.Parameters("maxstretch"), self.pMaxStretch.FullName) par.addExpression(op.Parameters("softness"), self.pSoftness.FullName) par.addExpression(op.Parameters("slide"), self.pSlide.FullName) par.addExpression(op.Parameters("reverse"), self.pReverse.FullName) # I'm not using the output of the solver to get the ctrn because it only has a +/-180 degree # With this simple expression I have a much better result # Also remove scaling from ctrn for s in "xyz": par.addExpression(self.ctrn_loc.Kinematics.Local.Parameters("rot"+s), self.bone1.Kinematics.Local.Parameters("rot"+s).FullName + " * .5") par.addExpression(self.ctrn_loc.Kinematics.Global.Parameters("scl"+s), self.root.Kinematics.Global.Parameters("scl"+s).FullName) # Membrane par.addExpression(self.memb_loc.Kinematics.Local.Parameters("posy"), self.pStartPos.FullName+" + ("+self.pEndPos.FullName+" - "+self.pStartPos.FullName+") * ( 1 - ( ctr_dist("+self.root.Kinematics.Global.FullName+","+self.eff_loc.Kinematics.Global.FullName+") / "+self.pRestDist.FullName+"))") # Twist references --------------------------------- self.pRestDist.Value = vec.getDistance2(self.root, self.eff_loc) par.addExpression(self.pDriver, "(ctr_dist(%s, %s) + ctr_dist(%s, %s)) / %s" %(self.tws0_loc.Kinematics.Global.FullName, self.tws1_loc.Kinematics.Global.FullName, self.tws1_loc.Kinematics.Global.FullName, self.tws2_loc.Kinematics.Global.FullName, self.root.Kinematics.Global.Parameters("sclx").FullName)) self.tws0_loc.Kinematics.AddConstraint("Pose", self.root, True) aop.dirCns(self.tws0_loc, self.mid_ctl, None, False, self.n_sign+"xy") self.tws1_loc.Kinematics.AddConstraint("Position", self.mid_ctl) self.tws1_loc.Kinematics.AddConstraint("Scaling", self.mid_ctl) self.tws1_rot.Kinematics.AddConstraint("Orientation", self.mid_ctl) par.addExpression(self.tws1_rot.Parameters("rotx"), 0) par.addExpression(self.tws1_rot.Parameters("roty"), 0) par.addExpression(self.tws1_rot.Parameters("rotz"), 0) self.tws2_loc.Kinematics.AddConstraint("Position", self.eff_loc) self.tws2_loc.Kinematics.AddConstraint("Scaling", self.eff_loc) aop.poseCns(self.tws2_rot, self.eff_loc, False, False, True, False) par.addExpression(self.tws2_rot.Parameters("rotx"), 0) par.addExpression(self.tws2_rot.Parameters("roty"), 0) par.addExpression(self.tws2_rot.Parameters("rotz"), 0) par.setRotOrder(self.tws2_rot, "YZX") self.tws0_rot.SclX = .001 par.addExpression(self.tws1_rot.SclX, self.pRoundness.FullName + " + .001") self.tws2_rot.SclX = .001 # Divisions ---------------------------------------- # at 0 or 1 the division will follow exactly the rotation of the controler.. and we wont have this nice tangent + roll for i, div_cns in enumerate(self.div_cns): if i < (self.settings["div0"]+1): perc = i*.5 / (self.settings["div0"]+1.0) else: perc = .5 + (i-self.settings["div0"]-1.0)*.5 / (self.settings["div1"]+1.0) perc = max(.001, min(.999, perc)) # Roll if self.negate: op = aop.sn_rollsplinekine_op(div_cns, [self.tws2_rot, self.tws1_rot, self.tws0_rot], 1-perc) else: op = aop.sn_rollsplinekine_op(div_cns, [self.tws0_rot, self.tws1_rot, self.tws2_rot], perc) # Squash n Stretch op = aop.sn_squashstretch2_op(div_cns, self.root, self.pDriver.Value, "x") par.addExpression(op.Parameters("blend"), self.pVolume.FullName) par.addExpression(op.Parameters("driver"), self.pDriver.FullName) if self.options["mode"] == 1: # wip par.addExpression(op.Parameters("stretch"), self.pStretch[i]) par.addExpression(op.Parameters("squash"), self.pSquash[i]) else: op.Parameters("stretch").Value = self.st_value[i] op.Parameters("squash").Value = self.sq_value[i]
def addOperators(self): cns = aop.dirCns(self.dir_cns, self.ik_ctl, self.upv_cns, False, "zy")
def addOperators(self): # Visibilities ------------------------------------- par.addExpression( self.fk0_ctl.Properties("visibility").Parameters("viewvis"), "1 - " + self.pBlend.FullName) par.addExpression( self.fk1_ctl.Properties("visibility").Parameters("viewvis"), "1 - " + self.pBlend.FullName) par.addExpression( self.fk2_ctl.Properties("visibility").Parameters("viewvis"), "1 - " + self.pBlend.FullName) par.addExpression( self.fk3_ctl.Properties("visibility").Parameters("viewvis"), "1 - " + self.pBlend.FullName) par.addExpression( self.upv_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) par.addExpression( self.ikcns_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName + " * " + self.pIkCns.FullName) par.addExpression( self.ik_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) if self.settings["roll"] == 0: par.addExpression( self.roll_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) # Leash -------------------------------------------- aop.clsCtrOp(self.upv_ctl, self.mid0_ctl, [0]) # IK Solver----------------------------------------- if self.settings["roll"] == 0: self.ref_chn.eff.Kinematics.AddConstraint("Pose", self.roll_ctl, True) self.end_chn.eff.Kinematics.AddConstraint("Pose", self.roll_ctl, True) else: self.ref_chn.eff.Kinematics.AddConstraint("Pose", self.ik_ref, True) self.end_chn.eff.Kinematics.AddConstraint("Pose", self.ik_ref, True) op = xsi.ApplyOp( "SkeletonUpVector", self.ref_chn.bones[0].FullName + ";" + self.upv_ctl.FullName)[0] par.addExpression(self.ref_chn.roll, self.pIkRoll.FullName + " + 180") op = xsi.ApplyOp( "SkeletonUpVector", self.end_chn.bones[0].FullName + ";" + self.upv_ctl.FullName)[0] par.addExpression(self.end_chn.roll, self.pIkRoll.FullName + " + 180") # Roll # cns = self.dir_ref.Kinematics.AddConstraint("Orientation", self.ik_ref, True) # cns = aop.dirCns(self.dir_ref, self.root, None, False, "yz") # # restLength = vec.getDistance(self.guide.apos[0], self.guide.apos[3]) # maxLength = self.ref_chn.length + self.end_chn.length # par.addExpression(cns.Parameters("blendweight"), "MIN(1, MAX(0, (ctr_dist("+self.root.FullName+".kine.global, "+self.ik_ref.FullName+".kine.global) - "+str(restLength)+") / " \ # +"("+str(maxLength - restLength)+")))") # ctrn for s in "xyz": par.addExpression( self.ctrn0_loc.Kinematics.Local.Parameters("rot" + s), self.ref_loc[1].Kinematics.Local.Parameters("rot" + s).FullName + " * .5") par.addExpression( self.ctrn0_loc.Kinematics.Global.Parameters("scl" + s), self.root.Kinematics.Global.Parameters("scl" + s).FullName) par.addExpression( self.ctrn1_loc.Kinematics.Local.Parameters("rot" + s), self.ref_loc[2].Kinematics.Local.Parameters("rot" + s).FullName + " * .5") par.addExpression( self.ctrn1_loc.Kinematics.Global.Parameters("scl" + s), self.root.Kinematics.Global.Parameters("scl" + s).FullName) self.ctrn0_loc.Kinematics.AddConstraint("Position", self.ref_loc[1], False) self.ctrn1_loc.Kinematics.AddConstraint("Position", self.ref_loc[2], False) # References Nulls --------------------------------- fk_ref = [ self.fk0_ctl, self.fk1_ctl, self.fk2_ctl, self.fk3_ctl, self.fk_ref ] ik_ref = [ self.ref_chn.bones[0], self.ref_chn.bones[1], self.end_chn.bones[0], self.ik_ref ] for i, ref_loc in enumerate(self.ref_loc): # fk cns = ref_loc.Kinematics.AddConstraint("Orientation", fk_ref[i], False) if i != len(self.ref_loc) - 1: cns = aop.dirCns(ref_loc, fk_ref[i + 1], None, False, self.n_sign + "xz") par.addExpression(cns.Parameters("blendweight"), "1 - " + self.pBlend.FullName) #ik cns = ref_loc.Kinematics.AddConstraint("Orientation", ik_ref[i], False) par.addExpression(cns.Parameters("blendweight"), self.pBlend.FullName) for s in "xyz": par.addExpression( ref_loc.Kinematics.Local.Parameters("rot" + s), 0) par.addExpression( self.ref_loc[1].Kinematics.Local.Parameters("posx"), self.n_sign + " (ctr_dist(%s.kine.global, %s.kine.global) * (1 - %s) + ctr_dist(%s.kine.global, %s.kine.global) * %s)" % (self.fk0_ctl.FullName, self.fk1_ctl.FullName, self.pBlend.FullName, self.ref_chn.bones[0].FullName, self.ref_chn.bones[1].FullName, self.pBlend.FullName)) par.addExpression( self.ref_loc[2].Kinematics.Local.Parameters("posx"), self.n_sign + " (ctr_dist(%s.kine.global, %s.kine.global) * (1 - %s) + ctr_dist(%s.kine.global, %s.kine.global) * %s)" % (self.fk1_ctl.FullName, self.fk2_ctl.FullName, self.pBlend.FullName, self.ref_chn.bones[1].FullName, self.end_chn.bones[0], self.pBlend.FullName)) par.addExpression( self.ref_loc[3].Kinematics.Local.Parameters("posx"), self.n_sign + " (ctr_dist(%s.kine.global, %s.kine.global) * (1 - %s) + ctr_dist(%s.kine.global, %s.kine.global) * %s)" % (self.fk2_ctl.FullName, self.fk3_ctl.FullName, self.pBlend.FullName, self.end_chn.bones[0].FullName, self.end_chn.eff, self.pBlend.FullName)) # Twist references --------------------------------- par.addExpression( self.pDriver, "ctr_dist(%s, %s) + ctr_dist(%s, %s) + ctr_dist(%s, %s)" % (self.tws0_loc.Kinematics.Global.FullName, self.tws1_loc.Kinematics.Global.FullName, self.tws1_loc.Kinematics.Global.FullName, self.tws2_loc.Kinematics.Global.FullName, self.tws2_loc.Kinematics.Global.FullName, self.tws3_loc.Kinematics.Global.FullName)) self.tws1_loc.Kinematics.AddConstraint("Position", self.mid0_ctl) self.tws1_loc.Kinematics.AddConstraint("Scaling", self.mid0_ctl) self.tws1_rot.Kinematics.AddConstraint("Orientation", self.mid0_ctl) par.addExpression(self.tws1_rot.Parameters("rotx"), 0) par.addExpression(self.tws1_rot.Parameters("roty"), 0) par.addExpression(self.tws1_rot.Parameters("rotz"), 0) self.tws2_loc.Kinematics.AddConstraint("Position", self.mid1_ctl) self.tws2_loc.Kinematics.AddConstraint("Scaling", self.mid1_ctl) self.tws2_rot.Kinematics.AddConstraint("Orientation", self.mid1_ctl) par.addExpression(self.tws2_rot.Parameters("rotx"), 0) par.addExpression(self.tws2_rot.Parameters("roty"), 0) par.addExpression(self.tws2_rot.Parameters("rotz"), 0) self.tws3_loc.Kinematics.AddConstraint("Position", self.ref_loc[-1]) #self.tws3_loc.Kinematics.AddConstraint("Scaling", self.eff_loc) aop.poseCns(self.tws3_rot, self.fk_ref, True, False, True, False) cns = aop.poseCns(self.tws3_rot, self.ik_ref, True, False, True, False) par.addExpression(cns.Parameters("blendweight"), self.pBlend.FullName) par.addExpression( self.tws3_rot.Parameters("rotx"), self.ik_ctl.Parameters("rotx").FullName + " * (1 - " + self.pBlend.FullName + ") + " + self.fk3_ctl.Parameters("rotx").FullName + " * " + self.pBlend.FullName) par.addExpression(self.tws3_rot.Parameters("roty"), 0) par.addExpression(self.tws3_rot.Parameters("rotz"), 0) self.tws0_rot.SclX = .001 par.addExpression(self.tws1_rot.SclX, self.pRoundness.FullName + " + .001") par.addExpression(self.tws2_rot.SclX, self.pRoundness.FullName + " + .001") self.tws3_rot.SclX = .001 # Divisions ---------------------------------------- # at 0 or 1 the division will follow exactly the rotation of the controler.. and we wont have this nice tangent + roll step = 1.0 / (self.divisions - 1.0) for i, div_cns in enumerate(self.div_cns): perc = max(.001, min(.999, i * step)) if self.negate: op = aop.sn_rollsplinekine_op(div_cns, [ self.tws3_rot, self.tws2_rot, self.tws1_rot, self.tws0_rot ], 1 - perc) else: op = aop.sn_rollsplinekine_op(div_cns, [ self.tws0_rot, self.tws1_rot, self.tws2_rot, self.tws3_rot ], perc) # Squash n Stretch op = aop.sn_squashstretch2_op(div_cns, self.root, self.pDriver.Value, "x") par.addExpression(op.Parameters("blend"), self.pVolume.FullName) par.addExpression(op.Parameters("driver"), self.pDriver.FullName) if self.options["mode"] == 1: # wip par.addExpression(op.Parameters("stretch"), self.pStretch[i]) par.addExpression(op.Parameters("squash"), self.pSquash[i]) else: op.Parameters("stretch").Value = self.st_value[i] op.Parameters("squash").Value = self.sq_value[i]
def addOperators(self): # Visibilities ------------------------------------- par.addExpression(self.fk0_ctl.Properties("visibility").Parameters("viewvis"), "1 - "+self.pBlend.FullName) par.addExpression(self.fk1_ctl.Properties("visibility").Parameters("viewvis"), "1 - "+self.pBlend.FullName) par.addExpression(self.fk2_ctl.Properties("visibility").Parameters("viewvis"), "1 - "+self.pBlend.FullName) par.addExpression(self.upv_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) par.addExpression(self.leash_crv.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) par.addExpression(self.ikcns_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName +" * "+ self.pIkCns.FullName) par.addExpression(self.ik_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) # Twist -------------------------------------------- for i, div_loc in enumerate(self.div0_loc): if i == 0: cns = aop.gear_dualUpVDirCns(div_loc, self.chain.root, self.chain.bones[1]) # cns = aop.dirCns(div_loc, self.chain.bones[1], None, False, "xy") # aop.gear_pointAtObjectAxis(cns, self.chain.root, [0,1,0]) elif i == self.settings["division0"]-1: continue else: d = i/(self.settings["division0"]-1.0) cns = aop.dirCns(div_loc, self.chain.bones[1], None, False, "xy") op = aop.spinePointAtOp(cns, self.div0_loc[0], self.chain.bones[0], d) for i, div_loc in enumerate(self.div_loc): d = i/(self.settings["division1"]-1.0) par.addExpression(div_loc.Parameters("rotx"), self.end_ref.Parameters("rotx").FullName+" * "+str(d)) # IK Solver----------------------------------------- # cns self.chain.eff.Kinematics.AddConstraint("Position", self.ik_ref, False) aop.chainUpvOp(self.chain, self.upv_ctl) for bone, fk_ctl, length, div in zip(self.chain.bones, [self.fk0_ctl, self.fk1_ctl], [self.length0, self.length1], self.div_loc): # for bone, fk in zip(self.chain.bones, [self.fk0_ctl, self.fk1_ctl]): # ik/fk orientation cns = bone.Kinematics.AddConstraint("Orientation", fk_ctl, False) par.addExpression(cns.Parameters("blendweight"), "1 - "+self.pBlend.FullName) # stretch fk_st = fk_ctl.Parameters("sclx").FullName + " * (1 - "+self.pBlend.FullName+")" root_eff_dist = "ctr_dist(%s.kine.global, %s.kine.global)"%(self.root.FullName, self.ik_ctl.FullName) ik_st = "cond("+root_eff_dist+" > "+str(self.chain.length)+", "+root_eff_dist+" / "+str(self.chain.length)+", 1) * "+self.pBlend.FullName parent_scl = bone.Parent3DObject.Parameters("sclx").FullName par.addExpression(bone.Parameters("sclx"), "("+fk_st+" + "+ik_st+")/"+parent_scl) # par.addExpression(div.Parameters("sclx"), bone.Parameters("length").FullName+"/"+str(length)) # blend / roll par.addExpression(self.chain.blend, self.pBlend) par.addExpression(self.chain.roll, self.pIkRoll) # ctr_loc self.ctrn_loc.Kinematics.AddConstraint("Position", self.chain.bones[1], False) for s in "xyz": par.addExpression(self.ctrn_loc.Kinematics.Local.Parameters("rot"+s), self.chain.bones[1].Kinematics.Local.Parameters("rot" + s).FullName + " * .5") # Stretch ----------------------------------------- # root_eff = "ctr_dist(%s.kine.global, %s.kine.global)"%(self.chain.root, self.ik_ref) # st_value = "(%s/%s)"%(root_eff,self.chain.length) # for bone in self.chain.bones: # par.addExpression(bone.Parameters("length"), # "cond(%s>%s,%s*%s,%s)*%s + %s*(1 - %s)"%(root_eff, # self.chain.length, # bone.Parameters("length").Value, # st_value, bone.Parameters("length").Value, # self.pBlend.FullName, # bone.Parameters("length").Value, # self.pBlend.FullName)) # Hook self.end_ref.Kinematics.AddConstraint("Position", self.chain.eff) self.end_ref.Kinematics.AddConstraint("Scaling", self.chain.eff) aop.poseCns(self.end_ref, self.fk2_ctl, True, False, True, False) cns = aop.poseCns(self.end_ref, self.ik_ref, True, False, True, False) par.addExpression(cns.Parameters("blendweight"), self.pBlend.fullName) par.addExpression(self.end_ref.Parameters("rotx"), 0) par.addExpression(self.end_ref.Parameters("roty"), 0) par.addExpression(self.end_ref.Parameters("rotz"), 0) par.setRotOrder(self.end_ref, "YZX") # Shape Reference --------------------------------- # shoulder aop.gear_rotationToPose(self.end_ref, self.chain.bones[1], self.ankle_outputs, "x", 0)
def addOperators(self): # Visibilities ------------------------------------- par.addExpression( self.fk0_ctl.Properties("visibility").Parameters("viewvis"), "1 - " + self.pBlend.FullName) par.addExpression( self.fk1_ctl.Properties("visibility").Parameters("viewvis"), "1 - " + self.pBlend.FullName) par.addExpression( self.fk2_ctl.Properties("visibility").Parameters("viewvis"), "1 - " + self.pBlend.FullName) par.addExpression( self.fk3_ctl.Properties("visibility").Parameters("viewvis"), "1 - " + self.pBlend.FullName) par.addExpression( self.upv_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) par.addExpression( self.ikcns_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName + " * " + self.pIkCns.FullName) par.addExpression( self.ik_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) if self.settings["roll"] == 0: par.addExpression( self.roll_ctl.Properties("visibility").Parameters("viewvis"), self.pBlend.FullName) # Leash -------------------------------------------- aop.clsCtrOp(self.upv_ctl, self.mid0_ctl, [0]) # IK Solver----------------------------------------- self.roll_ctl.Kinematics.AddConstraint("Position", self.ik_ref, False) self.ref_chn.eff.Kinematics.AddConstraint("Pose", self.roll_ctl, True) self.end_chn.eff.Kinematics.AddConstraint("Pose", self.roll_ctl, True) op = xsi.ApplyOp( "SkeletonUpVector", self.ref_chn.bones[0].FullName + ";" + self.upv_ctl.FullName)[0] par.addExpression(self.ref_chn.roll, self.pIkRoll.FullName + " + 180") op = xsi.ApplyOp( "SkeletonUpVector", self.end_chn.bones[0].FullName + ";" + self.upv_ctl.FullName)[0] par.addExpression(self.end_chn.roll, self.pIkRoll.FullName + " + 180") # ctrn for s in "xyz": par.addExpression( self.ctrn0_loc.Kinematics.Local.Parameters("rot" + s), self.ref_loc[1].Kinematics.Local.Parameters("rot" + s).FullName + " * .5") par.addExpression( self.ctrn0_loc.Kinematics.Global.Parameters("scl" + s), self.root.Kinematics.Global.Parameters("scl" + s).FullName) par.addExpression( self.ctrn1_loc.Kinematics.Local.Parameters("rot" + s), self.ref_loc[2].Kinematics.Local.Parameters("rot" + s).FullName + " * .5") par.addExpression( self.ctrn1_loc.Kinematics.Global.Parameters("scl" + s), self.root.Kinematics.Global.Parameters("scl" + s).FullName) self.ctrn0_loc.Kinematics.AddConstraint("Position", self.ref_loc[1], False) self.ctrn1_loc.Kinematics.AddConstraint("Position", self.ref_loc[2], False) # References Nulls --------------------------------- fk_ref = [self.fk0_ctl, self.fk1_ctl, self.fk2_ctl, self.fk_ref] ik_ref = [ self.ref_chn.bones[0], self.ref_chn.bones[1], self.end_chn.bones[0], self.ik_ref ] for i, ref_loc in enumerate(self.ref_loc): # fk cns = ref_loc.Kinematics.AddConstraint("Orientation", fk_ref[i], False) if i != len(self.ref_loc) - 1: cns = aop.dirCns(ref_loc, fk_ref[i + 1], None, False, self.n_sign + "xz") par.addExpression(cns.Parameters("blendweight"), "1 - " + self.pBlend.FullName) #ik cns = ref_loc.Kinematics.AddConstraint("Orientation", ik_ref[i], False) par.addExpression(cns.Parameters("blendweight"), self.pBlend.FullName) for s in "xyz": par.addExpression( ref_loc.Kinematics.Local.Parameters("rot" + s), 0) par.addExpression( self.ref_loc[1].Kinematics.Local.Parameters("posx"), self.n_sign + " (ctr_dist(%s.kine.global, %s.kine.global) * (1 - %s) + ctr_dist(%s.kine.global, %s.kine.global) * %s)" % (self.fk0_ctl.FullName, self.fk1_ctl.FullName, self.pBlend.FullName, self.ref_chn.bones[0].FullName, self.ref_chn.bones[1].FullName, self.pBlend.FullName)) par.addExpression( self.ref_loc[2].Kinematics.Local.Parameters("posx"), self.n_sign + " (ctr_dist(%s.kine.global, %s.kine.global) * (1 - %s) + ctr_dist(%s.kine.global, %s.kine.global) * %s)" % (self.fk1_ctl.FullName, self.fk2_ctl.FullName, self.pBlend.FullName, self.ref_chn.bones[1].FullName, self.end_chn.bones[0], self.pBlend.FullName)) par.addExpression( self.ref_loc[3].Kinematics.Local.Parameters("posx"), self.n_sign + " (ctr_dist(%s.kine.global, %s.kine.global) * (1 - %s) + ctr_dist(%s.kine.global, %s.kine.global) * %s)" % (self.fk2_ctl.FullName, self.fk3_ctl.FullName, self.pBlend.FullName, self.end_chn.bones[0].FullName, self.end_chn.eff, self.pBlend.FullName)) # Global Scale for s in "xyz": par.addExpression( self.ref_loc[0].Kinematics.Global.Parameters("scl%s" % s), 1) par.addExpression( self.end_ref.Kinematics.Global.Parameters("scl%s" % s), self.root.Kinematics.Global.Parameters("scl%s" % s)) # Twist references --------------------------------- par.addExpression( self.pDriver, "(ctr_dist(%s, %s) + ctr_dist(%s, %s) + ctr_dist(%s, %s)) / %s" % (self.tws0_loc.Kinematics.Global.FullName, self.tws1_loc.Kinematics.Global.FullName, self.tws1_loc.Kinematics.Global.FullName, self.tws2_loc.Kinematics.Global.FullName, self.tws2_loc.Kinematics.Global.FullName, self.tws3_loc.Kinematics.Global.FullName, self.root.Kinematics.Global.Parameters("sclx").FullName)) self.tws0_loc.Kinematics.AddConstraint("Pose", self.root, True) aop.dirCns(self.tws0_loc, self.mid0_ctl, None, False, self.n_sign + "xy") self.tws1_loc.Kinematics.AddConstraint("Position", self.mid0_ctl) self.tws1_loc.Kinematics.AddConstraint("Scaling", self.mid0_ctl) self.tws1_rot.Kinematics.AddConstraint("Orientation", self.mid0_ctl) par.addExpression(self.tws1_rot.Parameters("rotx"), 0) par.addExpression(self.tws1_rot.Parameters("roty"), 0) par.addExpression(self.tws1_rot.Parameters("rotz"), 0) self.tws2_loc.Kinematics.AddConstraint("Position", self.mid1_ctl) self.tws2_loc.Kinematics.AddConstraint("Scaling", self.mid1_ctl) self.tws2_rot.Kinematics.AddConstraint("Orientation", self.mid1_ctl) par.addExpression(self.tws2_rot.Parameters("rotx"), 0) par.addExpression(self.tws2_rot.Parameters("roty"), 0) par.addExpression(self.tws2_rot.Parameters("rotz"), 0) self.tws3_loc.Kinematics.AddConstraint("Position", self.ref_loc[-1]) #self.tws3_loc.Kinematics.AddConstraint("Scaling", self.eff_loc) aop.poseCns(self.tws3_rot, self.fk_ref, False, False, True, False) cns = aop.poseCns(self.tws3_rot, self.ik_ref, True, False, True, False) par.addExpression(cns.Parameters("blendweight"), self.pBlend.FullName) par.addExpression(self.tws3_rot.Parameters("rotx"), 0) par.addExpression(self.tws3_rot.Parameters("roty"), 0) par.addExpression(self.tws3_rot.Parameters("rotz"), 0) par.setRotOrder(self.tws3_rot, "YZX") self.tws0_rot.SclX = .001 par.addExpression(self.tws1_rot.SclX, self.pRoundness.FullName + " + .001") par.addExpression(self.tws2_rot.SclX, self.pRoundness.FullName + " + .001") self.tws3_rot.SclX = .001 # Divisions ---------------------------------------- # at 0 or 1 the division will follow exactly the rotation of the controler.. and we wont have this nice tangent + roll for i, div_cns in enumerate(self.div_cns): if i < (self.settings["div0"] + 1): perc = i / ((self.settings["div0"] + 1.0) * 3) elif i < (self.settings["div0"] + self.settings["div1"] + 2): perc = (1 / 3.0) + ((i - self.settings["div0"] - 1.0) / ((self.settings["div1"] + 1.0) * 3)) else: perc = (2 / 3.0) + ( (i - self.settings["div0"] - self.settings["div1"] - 2.0) / ((self.settings["div2"] + 1.0) * 3)) perc = max(.001, min(.999, perc)) if self.negate: op = aop.sn_rollsplinekine_op(div_cns, [ self.tws3_rot, self.tws2_rot, self.tws1_rot, self.tws0_rot ], 1 - perc) else: op = aop.sn_rollsplinekine_op(div_cns, [ self.tws0_rot, self.tws1_rot, self.tws2_rot, self.tws3_rot ], perc) # Squash n Stretch op = aop.sn_squashstretch2_op(div_cns, self.root, self.pDriver.Value, "x") par.addExpression(op.Parameters("blend"), self.pVolume.FullName) par.addExpression(op.Parameters("driver"), self.pDriver.FullName) if self.options["mode"] == 1: # wip par.addExpression(op.Parameters("stretch"), self.pStretch[i]) par.addExpression(op.Parameters("squash"), self.pSquash[i]) else: op.Parameters("stretch").Value = self.st_value[i] op.Parameters("squash").Value = self.sq_value[i]
def addOperators(self): #return i = 0 for x in self.oDirDrivenList: oTmpOp = aop.dirCns(x, self.oDirDriverList[i], self.upVec, False, "xz") xsi.ParentObj(x, self.oPointerLvlList[i]) i +=1 i =0 for oBlock in self.blockList: # Corners par.addExpression(self.oCornersList[i].Kinematics.Local.Parameters("posy"), \ "(cond(" + self.cornerA.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.cornerA.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][3].FullName + "," + \ self.cornerA.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][4].FullName + ") +" + \ "cond(" + self.cornerB.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.cornerB.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][11].FullName + "," + \ self.cornerB.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][12].FullName + "))" + \ "+ (cond(" + self.cornerA.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.cornerA.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][7].FullName + "," + \ self.cornerA.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][8].FullName + ") +" + \ "cond(" + self.cornerB.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.cornerB.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][15].FullName + "," + \ self.cornerB.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][16].FullName + "))") par.addExpression(self.oCornersList[i].Kinematics.Local.Parameters("posx"), \ "cond(" + self.cornerA.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.cornerA.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][1].FullName + "," + \ self.cornerA.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][2].FullName + ") +" + \ "cond(" + self.cornerB.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.cornerB.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][9].FullName + "," + \ self.cornerB.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][10].FullName + ")" + \ "+ (cond(" + self.cornerA.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.cornerA.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][5].FullName + "," + \ self.cornerA.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][6].FullName + ") +" + \ "cond(" + self.cornerB.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.cornerB.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][13].FullName + "," + \ self.cornerB.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][14].FullName + "))") #Control up down par.addExpression(self.oUpDownList[i].Kinematics.Local.Parameters("posy"), \ "cond(" + self.control.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.control.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][19].FullName + "," + \ self.control.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][20].FullName + ")") par.addExpression(self.oUpDownList[i].Kinematics.Local.Parameters("posx"), \ "cond(" + self.control.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.control.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][17].FullName + "," + \ self.control.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][18].FullName + ")") #Control sides par.addExpression(self.oSidesList[i].Kinematics.Local.Parameters("posy"), \ "cond(" + self.control.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.control.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][23].FullName + "," + \ self.control.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][24].FullName + ")") par.addExpression(self.oSidesList[i].Kinematics.Local.Parameters("posx"), \ "cond(" + self.control.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.control.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][21].FullName + "," + \ self.control.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][22].FullName + ")") i+=1
def addOperators(self): #return i = 0 for x in self.oDirDrivenList: oTmpOp = aop.dirCns(x, self.oDirDriverList[i], self.upVec, False, "xz") xsi.ParentObj(x, self.oPointerLvlList[i]) i += 1 i = 0 for oBlock in self.blockList: # Corners par.addExpression(self.oCornersList[i].Kinematics.Local.Parameters("posy"), \ "(cond(" + self.cornerA.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.cornerA.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][3].FullName + "," + \ self.cornerA.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][4].FullName + ") +" + \ "cond(" + self.cornerB.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.cornerB.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][11].FullName + "," + \ self.cornerB.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][12].FullName + "))" + \ "+ (cond(" + self.cornerA.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.cornerA.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][7].FullName + "," + \ self.cornerA.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][8].FullName + ") +" + \ "cond(" + self.cornerB.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.cornerB.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][15].FullName + "," + \ self.cornerB.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][16].FullName + "))") par.addExpression(self.oCornersList[i].Kinematics.Local.Parameters("posx"), \ "cond(" + self.cornerA.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.cornerA.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][1].FullName + "," + \ self.cornerA.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][2].FullName + ") +" + \ "cond(" + self.cornerB.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.cornerB.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][9].FullName + "," + \ self.cornerB.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][10].FullName + ")" + \ "+ (cond(" + self.cornerA.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.cornerA.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][5].FullName + "," + \ self.cornerA.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][6].FullName + ") +" + \ "cond(" + self.cornerB.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.cornerB.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][13].FullName + "," + \ self.cornerB.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][14].FullName + "))") #Control up down par.addExpression(self.oUpDownList[i].Kinematics.Local.Parameters("posy"), \ "cond(" + self.control.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.control.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][19].FullName + "," + \ self.control.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][20].FullName + ")") par.addExpression(self.oUpDownList[i].Kinematics.Local.Parameters("posx"), \ "cond(" + self.control.Kinematics.Local.Parameters("posy").FullName + " > 0," + \ self.control.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][17].FullName + "," + \ self.control.Kinematics.Local.Parameters("posy").FullName + " * " + self.blockList[i][18].FullName + ")") #Control sides par.addExpression(self.oSidesList[i].Kinematics.Local.Parameters("posy"), \ "cond(" + self.control.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.control.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][23].FullName + "," + \ self.control.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][24].FullName + ")") par.addExpression(self.oSidesList[i].Kinematics.Local.Parameters("posx"), \ "cond(" + self.control.Kinematics.Local.Parameters("posx").FullName + " > 0," + \ self.control.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][21].FullName + "," + \ self.control.Kinematics.Local.Parameters("posx").FullName + " * " + self.blockList[i][22].FullName + ")") i += 1