コード例 #1
0
ファイル: __init__.py プロジェクト: satishgoda/EHM_tools
    def addOperators(self):

        # Visibilities -------------------------------------
        par.addExpression(self.ik0_ctl.Properties("visibility").Parameters("viewvis"), self.pShowIk.FullName)
        par.addExpression(self.ik1_ctl.Properties("visibility").Parameters("viewvis"), self.pShowIk.FullName)
        par.addExpression(self.tan0_ctl.Properties("visibility").Parameters("viewvis"), self.pShowIk.FullName)
        par.addExpression(self.tan1_ctl.Properties("visibility").Parameters("viewvis"), self.pShowIk.FullName)
        for fk_ctl in self.fk_ctl[1:-1]:
            par.addExpression(fk_ctl.Properties("visibility").Parameters("viewvis"), self.pShowFk.FullName)

        # Tangent position ---------------------------------
        d = vec.getDistance(self.guide.apos[0], self.guide.apos[1])

        exp = self.pTan0.FullName + " * " + str(self.tan0_ctl.Parameters("nposy").Value)+" * (ctr_dist("+self.ik0_ctl.FullName+","+self.ik1_ctl.FullName+") / "+str(d)+")"
        par.addExpression(self.tan0_ctl.Parameters("nposy"), exp)

        exp = self.pTan1.FullName + " * " + str(self.tan1_ctl.Parameters("nposy").Value)+" * (ctr_dist("+self.ik0_ctl.FullName+","+self.ik1_ctl.FullName+") / "+str(d)+")"
        par.addExpression(self.tan1_ctl.Parameters("nposy"), exp)

        # Curves -------------------------------------------
        op = aop.sn_curveslide2_op(self.slv_crv, self.mst_crv, 0, 1.5, .5, .5)

        par.addExpression(op.Parameters("position"), self.pPosition.FullName)
        par.addExpression(op.Parameters("maxstretch"), self.pMaxStretch.FullName)
        par.addExpression(op.Parameters("maxsquash"), self.pMaxSquash.FullName)
        par.addExpression(op.Parameters("softness"), self.pSoftness.FullName)

        # Division -----------------------------------------
        for i in range(self.settings["division"]):

            # References
            u = i / (self.settings["division"] - 1.0)
            div_cns = self.div_cns[i]

            cns = aop.pathCns(div_cns, self.slv_crv, 0, u*100, True, None, False)

            cns.Parameters("dirx").Value = 0
            cns.Parameters("diry").Value = 1
            cns.Parameters("dirz").Value = 0

            cns.Parameters("upx").Value = 0
            cns.Parameters("upy").Value = 0
            cns.Parameters("upz").Value = -1

            # Roll
            aop.spinePointAtOp(cns, self.ik0_ctl, self.ik1_ctl, u)

            # Squash n Stretch
            op = aop.sn_squashstretch2_op(div_cns, self.slv_crv, self.slv_crv.ActivePrimitive.Geometry.Curves(0).Length, "y")
            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]

            # Controlers
            fk_ctl = self.fk_ctl[i]

            for s in "xyz":
                par.addExpression(fk_ctl.Parameters("npos"+s), div_cns.Parameters("pos"+s).FullName)
                par.addExpression(fk_ctl.Parameters("nrot"+s), div_cns.Parameters("rot"+s).FullName)
                par.addExpression(fk_ctl.Kinematics.Global.Parameters("scl"+s), div_cns.Kinematics.Global.Parameters("scl"+s).FullName)

        # Orientation Lock
        cns = self.div_cns[0].Kinematics.AddConstraint("Orientation", self.ik0_ctl, False)
        par.addExpression(cns.Parameters("blendweight"), self.pLockOri0.FullName)
        cns = self.div_cns[-1].Kinematics.AddConstraint("Orientation", self.ik1_ctl, False)
        par.addExpression(cns.Parameters("blendweight"), self.pLockOri1.FullName)

        # Volume -------------------------------------------
        op = aop.sn_curvelength_op(self.pDriver, self.slv_crv)

        # Connections (Hooks) ------------------------------
        self.cnx0.Kinematics.AddConstraint("Position", self.div_cns[0], False)
        self.cnx0.Kinematics.AddConstraint("Orientation", self.div_cns[0], False)
        self.cnx1.Kinematics.AddConstraint("Position", self.fk_ctl[-1], False)
        self.cnx1.Kinematics.AddConstraint("Orientation", self.fk_ctl[-1], False)
コード例 #2
0
ファイル: __init__.py プロジェクト: EricTRocks/GEAR_mc
    def addOperators(self):

        # Controlers Limits -------------------------------
        # pos_0 = self.crv[0].ActivePrimitive.Geometry.Curves(0).EvaluatePosition(0)[0]
        # pos_1 = self.crv[0].ActivePrimitive.Geometry.Curves(0).EvaluatePosition(4)[0]
        # pos_0 = XSIMath.MapObjectPositionToWorldSpace(self.crv[0].Kinematics.Global.Transform, pos_0)
        # pos_1 = XSIMath.MapObjectPositionToWorldSpace(self.crv[0].Kinematics.Global.Transform, pos_1)

        # lim_min = pos_0.Y - self.ctl[0].Kinematics.Global.Transform.Translation.Y
        # lim_max = pos_1.Y - self.ctl[0].Kinematics.Global.Transform.Translation.Y

        for ctl, crv, upv, centers, off, perc in zip(self.ctl, self.crv, self.upv, self.ctr, self.off, self.percentages):

            # crv_geo = crv.ActivePrimitive.Geometry
            # crv_0 = crv_geo.Curves(0)
            # crv_tra = crv.Kinematics.Global.Transform

            # Set Limits ----------------------------------
            par.setLimit(ctl, ["posy"], -1, 1)
            # ctl.Kinematics.Local.Parameters("posyminactive").Value = True
            # ctl.Kinematics.Local.Parameters("posymaxactive").Value = True
            # ctl.Kinematics.Local.Parameters("posyminlimit").Value = lim_min
            # ctl.Kinematics.Local.Parameters("posymaxlimit").Value = lim_max

            # Path Constraint -----------------------------
            constraints = []
            for ctr in centers:
                cns = aop.pathCns(ctr, crv, 0, perc, True, upv, False)
                ope.setConstraintTangency(cns, [0,1,0], [0,0,-1])
                constraints.append(cns)

            pos_min = "max(0,-%s)*%s"%(ctl.Kinematics.Local.Parameters("posy").FullName,perc)
            pos_max = "max(0,%s)*%s"%(ctl.Kinematics.Local.Parameters("posy").FullName,100-perc)
            par.addExpression(constraints[1].Parameters("perc"), "%s - %s + %s"%(perc,pos_min,pos_max))

            cns_perc = constraints[1].Parameters("perc").FullName
            par.addExpression(constraints[0].Parameters("perc"), cns_perc + " * .5 ")
            par.addExpression(constraints[2].Parameters("perc"), cns_perc + " + (100 - "+cns_perc+" ) * .5 ")

            # Connect Offset to Controler
            for s in "xz":
                par.addExpression(off.Kinematics.Local.Parameters("pos%s"%s), ctl.Kinematics.Local.Parameters("pos%s"%s).FullName+" * "+str(self.scale))
            for s in "yz":
                par.addExpression(off.Kinematics.Local.Parameters("rot%s"%s), ctl.Kinematics.Local.Parameters("rot%s"%s).FullName)
            for s in "x":
                par.addExpression(off.Kinematics.Local.Parameters("scl%s"%s), ctl.Kinematics.Local.Parameters("scl%s"%s).FullName)

        # Constrained Curve -------------------------------
        for i in range(self.crv_count):

            if i == self.inter_crv:
                centers = self.off
            else:
                centers = [ctr[i] for ctr in self.ctr]

            for ctr, pnts in zip(centers, [[0,1],[2],[3,4]]):
                aop.clsCtrOp(self.cns_crv[i], ctr, pnts)

        # Shadows -----------------------------------------
        constraints = []
        for i in range(self.shd_count):

            u = i/4.0
            for j in range(self.crv_count):

                if j == self.inter_crv:
                    cns = aop.pathCns(self.loc[j*self.shd_count+i], self.cns_crv[j], 1, u, True, None, False)
                    constraints.append(cns)
                else:
                    cns = aop.pathCns(self.loc[j*self.shd_count+i], self.cns_crv[j], 1, u, True, self.upv[0], False)



        # Connect Roll
        aop.gear_pointAtObjectAxis(constraints[0], self.ctl[0], [0,0,1])
        aop.spinePointAtOp(constraints[1], self.ctl[0], self.ctl[1], .5)
        aop.gear_pointAtObjectAxis(constraints[2], self.ctl[1], [0,0,1])
        aop.spinePointAtOp(constraints[3], self.ctl[1], self.ctl[2], .5)
        aop.gear_pointAtObjectAxis(constraints[4], self.ctl[2], [0,0,1])
コード例 #3
0
ファイル: __init__.py プロジェクト: jeanim/gear
    def addOperators(self):

        # Visibilities -------------------------------------
        par.addExpression(
            self.ik_ctl.Properties("visibility").Parameters("viewvis"),
            self.pShowIk.FullName)
        for fk_ctl in self.fk_ctl:
            par.addExpression(
                fk_ctl.Properties("visibility").Parameters("viewvis"),
                self.pShowFk.FullName)

        # Tangent position ---------------------------------
        d = vec.getDistance(self.guide.pos["root"], self.guide.pos["neck"])

        exp = self.pTan0.FullName + " * " + str(
            self.tan0_loc.Parameters("nposy").Value
        ) + " * (ctr_dist(" + self.root.FullName + "," + self.ik_ctl.FullName + ") / " + str(
            d) + ")"
        par.addExpression(self.tan0_loc.Parameters("nposy"), exp)

        exp = self.pTan1.FullName + " * " + str(
            self.tan1_loc.Parameters("nposy").Value
        ) + " * (ctr_dist(" + self.root.FullName + "," + self.ik_ctl.FullName + ") / " + str(
            d) + ")"
        par.addExpression(self.tan1_loc.Parameters("nposy"), exp)

        # Curves -------------------------------------------
        op = aop.sn_curveslide2_op(self.slv_crv, self.mst_crv, 0, 1.5, .5, .5)

        par.addExpression(op.Parameters("position"), 0)
        par.addExpression(op.Parameters("maxstretch"),
                          self.pMaxStretch.FullName)
        par.addExpression(op.Parameters("maxsquash"), self.pMaxSquash.FullName)
        par.addExpression(op.Parameters("softness"), self.pSoftness.FullName)

        # Division -----------------------------------------
        for i in range(self.settings["division"]):

            # References
            u = i / (self.settings["division"] - 1.0)
            div_cns = self.div_cns[i]

            cns = aop.pathCns(div_cns, self.slv_crv, 0, u * 100, True, None,
                              False)

            cns.Parameters("dirx").Value = 0
            cns.Parameters("diry").Value = 1
            cns.Parameters("dirz").Value = 0

            cns.Parameters("upx").Value = 0
            cns.Parameters("upy").Value = 0
            cns.Parameters("upz").Value = -1

            # Roll
            aop.spinePointAtOp(cns, self.root, self.ik_ctl, u)

            # Squash n Stretch
            op = aop.sn_squashstretch2_op(
                div_cns, self.slv_crv,
                self.slv_crv.ActivePrimitive.Geometry.Curves(0).Length, "y")
            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:
                import gear
                op.Parameters("stretch").Value = self.st_value[i]
                op.Parameters("squash").Value = self.sq_value[i]

            # Controlers
            fk_ctl = self.fk_ctl[i]

            for s in "xyz":
                par.addExpression(fk_ctl.Parameters("npos" + s),
                                  div_cns.Parameters("pos" + s).FullName)
                par.addExpression(fk_ctl.Parameters("nrot" + s),
                                  div_cns.Parameters("rot" + s).FullName)
                par.addExpression(
                    fk_ctl.Kinematics.Global.Parameters("scl" + s),
                    div_cns.Kinematics.Global.Parameters("scl" + s).FullName)

        # Orientation Lock
        cns = self.div_cns[-1].Kinematics.AddConstraint(
            "Orientation", self.ik_ctl, False)
        par.addExpression(cns.Parameters("blendweight"),
                          self.pLockOri.FullName)

        # Volume -------------------------------------------
        op = aop.sn_curvelength_op(self.pDriver, self.slv_crv)

        # Head ---------------------------------------------
        self.fk_ctl[-1].AddChild(self.head_cns)
        if self.headref_count > 0:
            cns = self.head_cns.Kinematics.AddConstraint(
                "Orientation", self.fk_ctl[-1], True)
            par.addExpression(cns.Parameters("active"),
                              self.pHeadRef.FullName + " == 0")
コード例 #4
0
    def addOperators(self):

        # Controlers Limits -------------------------------
        # pos_0 = self.crv[0].ActivePrimitive.Geometry.Curves(0).EvaluatePosition(0)[0]
        # pos_1 = self.crv[0].ActivePrimitive.Geometry.Curves(0).EvaluatePosition(4)[0]
        # pos_0 = XSIMath.MapObjectPositionToWorldSpace(self.crv[0].Kinematics.Global.Transform, pos_0)
        # pos_1 = XSIMath.MapObjectPositionToWorldSpace(self.crv[0].Kinematics.Global.Transform, pos_1)

        # lim_min = pos_0.Y - self.ctl[0].Kinematics.Global.Transform.Translation.Y
        # lim_max = pos_1.Y - self.ctl[0].Kinematics.Global.Transform.Translation.Y

        for ctl, crv, upv, centers, off, perc in zip(self.ctl, self.crv,
                                                     self.upv, self.ctr,
                                                     self.off,
                                                     self.percentages):

            # crv_geo = crv.ActivePrimitive.Geometry
            # crv_0 = crv_geo.Curves(0)
            # crv_tra = crv.Kinematics.Global.Transform

            # Set Limits ----------------------------------
            par.setLimit(ctl, ["posy"], -1, 1)
            # ctl.Kinematics.Local.Parameters("posyminactive").Value = True
            # ctl.Kinematics.Local.Parameters("posymaxactive").Value = True
            # ctl.Kinematics.Local.Parameters("posyminlimit").Value = lim_min
            # ctl.Kinematics.Local.Parameters("posymaxlimit").Value = lim_max

            # Path Constraint -----------------------------
            constraints = []
            for ctr in centers:
                cns = aop.pathCns(ctr, crv, 0, perc, True, upv, False)
                ope.setConstraintTangency(cns, [0, 1, 0], [0, 0, -1])
                constraints.append(cns)

            pos_min = "max(0,-%s)*%s" % (
                ctl.Kinematics.Local.Parameters("posy").FullName, perc)
            pos_max = "max(0,%s)*%s" % (
                ctl.Kinematics.Local.Parameters("posy").FullName, 100 - perc)
            par.addExpression(constraints[1].Parameters("perc"),
                              "%s - %s + %s" % (perc, pos_min, pos_max))

            cns_perc = constraints[1].Parameters("perc").FullName
            par.addExpression(constraints[0].Parameters("perc"),
                              cns_perc + " * .5 ")
            par.addExpression(constraints[2].Parameters("perc"),
                              cns_perc + " + (100 - " + cns_perc + " ) * .5 ")

            # Connect Offset to Controler
            for s in "xz":
                par.addExpression(
                    off.Kinematics.Local.Parameters("pos%s" % s),
                    ctl.Kinematics.Local.Parameters("pos%s" % s).FullName +
                    " * " + str(self.scale))
            for s in "yz":
                par.addExpression(
                    off.Kinematics.Local.Parameters("rot%s" % s),
                    ctl.Kinematics.Local.Parameters("rot%s" % s).FullName)
            for s in "x":
                par.addExpression(
                    off.Kinematics.Local.Parameters("scl%s" % s),
                    ctl.Kinematics.Local.Parameters("scl%s" % s).FullName)

        # Constrained Curve -------------------------------
        for i in range(self.crv_count):

            if i == self.inter_crv:
                centers = self.off
            else:
                centers = [ctr[i] for ctr in self.ctr]

            for ctr, pnts in zip(centers, [[0, 1], [2], [3, 4]]):
                aop.clsCtrOp(self.cns_crv[i], ctr, pnts)

        # Shadows -----------------------------------------
        constraints = []
        for i in range(self.shd_count):

            u = i / 4.0
            for j in range(self.crv_count):

                if j == self.inter_crv:
                    cns = aop.pathCns(self.loc[j * self.shd_count + i],
                                      self.cns_crv[j], 1, u, True, None, False)
                    constraints.append(cns)
                else:
                    cns = aop.pathCns(self.loc[j * self.shd_count + i],
                                      self.cns_crv[j], 1, u, True, self.upv[0],
                                      False)

        # Connect Roll
        aop.gear_pointAtObjectAxis(constraints[0], self.ctl[0], [0, 0, 1])
        aop.spinePointAtOp(constraints[1], self.ctl[0], self.ctl[1], .5)
        aop.gear_pointAtObjectAxis(constraints[2], self.ctl[1], [0, 0, 1])
        aop.spinePointAtOp(constraints[3], self.ctl[1], self.ctl[2], .5)
        aop.gear_pointAtObjectAxis(constraints[4], self.ctl[2], [0, 0, 1])