Beispiel #1
0
    def addObjects(self):

        t = tra.getTransformLookingAt(self.guide.pos["root"], self.guide.pos["lookat"], self.y_axis, "zy")

        # Direction cns 
        self.dir_cns = pri.addNull(self.root, self.getName("dir_cns"), t, self.size*.1)
        self.addToGroup(self.dir_cns, "hidden")
        
        upv_pos = XSIMath.CreateVector3(0,1,0)
        upv_pos.MulByTransformationInPlace(t)
        self.upv_cns = pri.addNullFromPos(self.root, self.getName("upv_cns"), upv_pos, self.size*.1)
        self.addToGroup(self.upv_cns, "hidden")

        # IK Controler
        self.ik_cns = pri.addNull(self.root, "ik_cns", tra.getTransformFromPosition(self.guide.pos["lookat"]), self.size*.1)
        self.addToGroup(self.ik_cns, "hidden")
        self.ik_ctl = self.addCtl(self.ik_cns, "ik_ctl", tra.getTransformFromPosition(self.guide.pos["lookat"]), self.color_ik, "cross", h=self.size*.5)
        par.setKeyableParameters(self.ik_ctl, self.t_params)
        
        # FK Controler
        self.fk_ctl = self.addCtl(self.dir_cns, "fk_ctl", t, self.color_fk, "arrow", h=self.size*.5)
        xsi.SetNeutralPose(self.fk_ctl, c.siTrn)
        par.setKeyableParameters(self.fk_ctl, self.r_params)
        # par.addLocalParamToCollection(self.inv_params, self.fk_ctl, ["posx", "posy", "posz"])

        self.addShadow(self.fk_ctl, 0)        
Beispiel #2
0
def gear_AddNullChild_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    for sel in xsi.Selection:
        pri.addNull(sel, sel.Name + "_child", sel.Kinematics.Global.Transform)
Beispiel #3
0
def gear_AddNullChild_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    for sel in xsi.Selection:
        pri.addNull(sel, sel.Name+"_child", sel.Kinematics.Global.Transform)
Beispiel #4
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)
Beispiel #5
0
    def addLocMulti(self, name, parent):

        if "#" not in name:
            gear.log("You need to put a '#' in the name of multiple location.",
                     gear.sev_error)
            return False

        locs = []

        i = 0
        while True:
            localName = string.replaceSharpWithPadding(name, i)
            if localName not in self.tra.keys():
                break

            loc = pri.addNull(parent, self.getName(localName),
                              self.tra[localName])
            pri.setNullDisplay(loc, 1, .5, 2, 0, 0, 0, .5, .5, .5,
                               GUIDE_LOC_COLOR)
            par.addExpression(loc.size, self.root.size.FullName + " * .5")
            locs.append(loc)
            parent = loc

            i += 1

        return locs
Beispiel #6
0
    def addBlade(self, name, parentPos, parentDir):

        # Draw from UI
        dist = vec.getDistance2(parentPos, parentDir)

#        points = [0,0,0,1,0,dist*.5,0,1,dist*.25,0,0,1]
#        blade = cur.addCurve(parentPos, self.getName(name), points, True, 1, parentPos.Kinematics.Global.Transform, [.75, .75, 0])
        blade = pri.addNull(parentPos, self.getName(name), parentPos.Kinematics.Global.transform, dist * .5)
        pri.setNullDisplay(blade, 0, dist*.5, 9, .25, 0, 0, .5, 1, 0, GUIDE_BLADE_COLOR)
        for s in ["primary_icon", "shadow_icon", "shadow_offsetX", "shadow_offsetY", "shadow_offsetZ", "shadow_scaleX", "shadow_scaleY", "shadow_scaleZ"]:
            blade.ActivePrimitive.Parameters(s).AddExpression(blade.ActivePrimitive.Parameters(s).Value)
            blade.ActivePrimitive.Parameters(s).ReadOnly = True

        blade.Kinematics.Local.Parameters("rotorder").Value = 2
        blade.Kinematics.Local.Parameters("roty").Value = 90

        blade.Kinematics.AddConstraint("Position", parentPos, False)
        cns = blade.Kinematics.AddConstraint("Direction", parentDir, False)
        cns.Parameters("dirx").Value = 0
        cns.Parameters("diry").Value = 1
        cns.Parameters("dirz").Value = 0

        if name in self.blades.keys():
            blade.Kinematics.Global.Transform = self.blades[name].transform

        return blade
Beispiel #7
0
    def addBlade(self, name, parentPos, parentDir):

        # Draw from UI
        dist = vec.getDistance2(parentPos, parentDir)

        #        points = [0,0,0,1,0,dist*.5,0,1,dist*.25,0,0,1]
        #        blade = cur.addCurve(parentPos, self.getName(name), points, True, 1, parentPos.Kinematics.Global.Transform, [.75, .75, 0])
        blade = pri.addNull(parentPos, self.getName(name),
                            parentPos.Kinematics.Global.transform, dist * .5)
        pri.setNullDisplay(blade, 0, dist * .5, 9, .25, 0, 0, .5, 1, 0,
                           GUIDE_BLADE_COLOR)
        for s in [
                "primary_icon", "shadow_icon", "shadow_offsetX",
                "shadow_offsetY", "shadow_offsetZ", "shadow_scaleX",
                "shadow_scaleY", "shadow_scaleZ"
        ]:
            blade.ActivePrimitive.Parameters(s).AddExpression(
                blade.ActivePrimitive.Parameters(s).Value)
            blade.ActivePrimitive.Parameters(s).ReadOnly = True

        blade.Kinematics.Local.Parameters("rotorder").Value = 2
        blade.Kinematics.Local.Parameters("roty").Value = 90

        blade.Kinematics.AddConstraint("Position", parentPos, False)
        cns = blade.Kinematics.AddConstraint("Direction", parentDir, False)
        cns.Parameters("dirx").Value = 0
        cns.Parameters("diry").Value = 1
        cns.Parameters("dirz").Value = 0

        if name in self.blades.keys():
            blade.Kinematics.Global.Transform = self.blades[name].transform

        return blade
Beispiel #8
0
    def addObjects(self):

        if self.negate:
            transforms = [tra.getNegatedTransform(t) for t in self.guide.atra]
        else:
            transforms = self.guide.atra

        # Controlers ---------------------------------------
        self.end_ctl = self.addCtl(self.root, "end_ctl", transforms[-1], self.color_ik, "cube", w=self.size*.2, h=self.size*.2, d=self.size*.2)
        par.setKeyableParameters(self.end_ctl, ["posx", "posy", "posz", "rotx", "roty", "rotz", "rotorder"])
        xsi.SetNeutralPose(self.end_ctl)

        if self.settings["startctl"]:
            self.start_ctl = self.addCtl(self.root, "0_ctl", transforms[0], self.color_ik, "cube", w=self.size*.2, h=self.size*.2, d=self.size*.2)
            par.setKeyableParameters(self.start_ctl, ["posx", "posy", "posz", "rotx", "roty", "rotz", "rotorder"])
            xsi.SetNeutralPose(self.end_ctl)
        else:
            self.start_ctl = pri.addNull(self.root, self.getName("0_loc"), transforms[0], self.size*.2)
            self.addToGroup(self.start_ctl, "hidden")

        # Locations ----------------------------------------
        self.loc = []
        for i, t in enumerate(transforms[1:-1]):
            loc = pri.addNull(self.root, self.getName("%s_loc"%(i+1)), t, self.size*.2)
            self.addToGroup(loc, "hidden")
            self.loc.append(loc)

        # Intermediate controlers --------------------------
        if self.settings["interctl"]:
            self.inter_ctl = []
            for i, loc in enumerate(self.loc):
                ctl = self.addCtl(loc, "%s_ctl"%(i+1), loc.Kinematics.Global.Transform, self.color_fk, "cube", w=self.size*.2, h=self.size*.2, d=self.size*.2)
                par.setKeyableParameters(ctl, ["posx", "posy", "posz", "rotx", "roty", "rotz", "rotorder"])
                xsi.SetNeutralPose(ctl)
                self.inter_ctl.append(ctl)

        # Deformers (Shadow) -------------------------------
        self.addShadow(self.start_ctl, 0)

        if self.settings["interctl"]:
            for i, ctl in enumerate(self.inter_ctl):
                self.addShadow(ctl, i+1)
        else:
            for i, loc in enumerate(self.loc):
                self.addShadow(loc, i+1)

        self.addShadow(self.end_ctl, "end")
Beispiel #9
0
    def addRoot(self):

        self.root = pri.addNull(self.parent, self.getName("root"), self.tra["root"])
        pri.setNullDisplay(self.root, 1, 1, 4, 0, 0, 0, .75, .75, .75, GUIDE_ROOT_COLOR)

        # Settings
        self.settings = self.addProperty(self.root, "settings")

        return self.root
Beispiel #10
0
def gear_AddNullParent_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    for sel in xsi.Selection:
        null = pri.addNull(sel.Parent3DObject, sel.Name+"_parent", sel.Kinematics.Global.Transform)
        null.AddChild(sel)
Beispiel #11
0
def gear_AddNullParent_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    for sel in xsi.Selection:
        null = pri.addNull(sel.Parent3DObject, sel.Name+"_parent", sel.Kinematics.Global.Transform)
        null.AddChild(sel)
Beispiel #12
0
    def addObjects(self):

        t = tra.getTransformLookingAt(self.guide.pos["root"],
                                      self.guide.pos["lookat"], self.y_axis,
                                      "zy")

        # Direction cns
        self.dir_cns = pri.addNull(self.root, self.getName("dir_cns"), t,
                                   self.size * .1)
        self.addToGroup(self.dir_cns, "hidden")

        upv_pos = XSIMath.CreateVector3(0, 1, 0)
        upv_pos.MulByTransformationInPlace(t)
        self.upv_cns = pri.addNullFromPos(self.root, self.getName("upv_cns"),
                                          upv_pos, self.size * .1)
        self.addToGroup(self.upv_cns, "hidden")

        # IK Controler
        self.ik_cns = pri.addNull(
            self.root, "ik_cns",
            tra.getTransformFromPosition(self.guide.pos["lookat"]),
            self.size * .1)
        self.addToGroup(self.ik_cns, "hidden")
        self.ik_ctl = self.addCtl(self.ik_cns,
                                  "ik_ctl",
                                  tra.getTransformFromPosition(
                                      self.guide.pos["lookat"]),
                                  self.color_ik,
                                  "cross",
                                  h=self.size * .5)
        par.setKeyableParameters(self.ik_ctl, self.t_params)

        # FK Controler
        self.fk_ctl = self.addCtl(self.dir_cns,
                                  "fk_ctl",
                                  t,
                                  self.color_fk,
                                  "arrow",
                                  h=self.size * .5)
        xsi.SetNeutralPose(self.fk_ctl, c.siTrn)
        par.setKeyableParameters(self.fk_ctl, self.r_params)
        # par.addLocalParamToCollection(self.inv_params, self.fk_ctl, ["posx", "posy", "posz"])

        self.addShadow(self.fk_ctl, 0)
Beispiel #13
0
    def initialHierarchy(self):

        # Root ---------------------------------------------
        # For this component we need the root to be correctly oriented
        t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[1], self.guide.blades["blade"].z, "yx", self.negate)
        self.root = pri.addNull(self.model, self.getName("root"), t, self.size *.2)
        self.addToGroup(self.root, "hidden")

        # Shd ----------------------------------------------
        if self.options["shadowRig"]:
            self.shd_org = self.rig.shd_org.AddNull(self.getName("shd_org"))
            self.addToGroup(self.shd_org, "hidden")
Beispiel #14
0
    def initialHierarchy(self):

        # Root ---------------------------------------------
        # For this component we need the root to be correctly oriented
        t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[1], self.guide.blades["blade"].z, "yx", self.negate)
        self.root = pri.addNull(self.model, self.getName("root"), t, self.size *.2)
        self.addToGroup(self.root, "hidden")

        # Shd ----------------------------------------------
        if self.options["shadowRig"]:
            self.shd_org = self.rig.shd_org.AddNull(self.getName("shd_org"))
            self.addToGroup(self.shd_org, "hidden")
Beispiel #15
0
def gear_CreateRollSplineKine_Execute():

    if xsi.Selection.Count < 2:
        gear.log("Select at least two objects", gear.sev_error)
        return

    controlers = [
        pri.addNull(obj, obj.Name + "_rot", obj.Kinematics.Global.Transform)
        for obj in xsi.Selection
    ]
    for ctl in controlers:
        pri.setNullDisplay(ctl, 2)

    # -----------------------------------------------------
    # UI
    prop = xsi.ActiveSceneRoot.AddProperty("CustomProperty", False,
                                           "SplineKineOptions")
    pDivision = prop.AddParameter3("division", c.siInt4, 10, 1, None, False,
                                   False)

    rtn = xsi.InspectObj(prop, "", "Spline Kine Options", c.siModal, False)

    div_count = pDivision.Value

    xsi.DeleteObj(prop)

    if rtn:
        return

    # -----------------------------------------------------
    # Create Parent property to connect the multiple operators parameters
    prop = controlers[0].Properties("gear_splinekine_options")
    if not prop:
        prop = controlers[0].AddProperty("CustomProperty", False,
                                         "gear_splinekine_options")
        prop.AddParameter3("resample", c.siBool, True, None, None, True, False)
        prop.AddParameter3("subdiv", c.siInt4, 10, 3, 50, True, False)
        prop.AddParameter3("absolute", c.siBool, False, None, None, True,
                           False)

    # -----------------------------------------------------
    for i in range(div_count):

        div = controlers[0].AddNull("div_%s" % i)
        pri.setNullDisplay(div, 4, .5)
        op = aop.sn_rollsplinekine_op(div, controlers, i / (div_count - 1.0))

        for s in ["resample", "subdiv", "absolute"]:
            op.Parameters(s).AddExpression(prop.Parameters(s))

    xsi.InspectObj(prop)
Beispiel #16
0
    def addLoc(self, name, parent, position=None):

        if name not in self.tra.keys():
            self.tra[name] = tra.getTransformFromPosition(position)

        if name in self.prim.keys():
            loc = self.prim[name].create(parent, self.getName(name), self.tra[name], GUIDE_LOC_COLOR)
        else:
            loc = pri.addNull(parent, self.getName(name), self.tra[name])
            pri.setNullDisplay(loc, 1, .5, 2, 0, 0, 0, .5, .5, .5, GUIDE_LOC_COLOR)

        if loc.Type == "null":
            par.addExpression(loc.size, self.root.size.FullName+" * .5")

        return loc
Beispiel #17
0
def gear_CreateRollSplineKine_Execute():

    if xsi.Selection.Count < 2:
        gear.log("Select at least two objects", gear.sev_error)
        return

    controlers = [pri.addNull(obj, obj.Name+"_rot", obj.Kinematics.Global.Transform) for obj in xsi.Selection]
    for ctl in controlers:
        pri.setNullDisplay(ctl, 2)

    # -----------------------------------------------------
    # UI
    prop = xsi.ActiveSceneRoot.AddProperty("CustomProperty", False, "SplineKineOptions")
    pDivision = prop.AddParameter3("division", c.siInt4, 1, 1, 20, False, False)

    rtn = xsi.InspectObj(prop, "", "Spline Kine Options", c.siModal, False)

    div_count = pDivision.Value

    xsi.DeleteObj(prop)

    if rtn:
        return

    # -----------------------------------------------------
    # Create Parent property to connect the multiple operators parameters
    prop = controlers[0].Properties("gear_splinekine_options")
    if not prop:
        prop = controlers[0].AddProperty("CustomProperty", False, "gear_splinekine_options")
        prop.AddParameter3("resample", c.siBool, True, None, None, True, False)
        prop.AddParameter3("subdiv", c.siInt4, 10, 3, 50, True, False)
        prop.AddParameter3("absolute", c.siBool, False, None, None, True, False)

    # -----------------------------------------------------
    for i in range(div_count):

        div = controlers[0].AddNull("div_%s"%i)
        pri.setNullDisplay(div, 4, .5)
        op = aop.gear_rollsplinekine_op(div, controlers, i/(div_count-1.0))

        for s in ["resample", "subdiv", "absolute"]:
            op.Parameters(s).AddExpression(prop.Parameters(s))

    xsi.InspectObj(prop)
Beispiel #18
0
    def addObjects(self):

        self.normal = self.guide.blades["blade"].z
        self.binormal = self.guide.blades["blade"].x

        self.division = len(self.guide.apos)-1

        # FK controlers ------------------------------------
        self.fk_ctl = []
        parent = self.root
        for i, t in enumerate(tra.getChainTransform(self.guide.apos, self.normal, self.negate)):
            dist = vec.getDistance(self.guide.apos[i], self.guide.apos[i+1])
            fk_ctl = self.addCtl(parent, "fk%s_ctl"%i, t, self.color_fk, "cube", w=dist, h=self.size*.25, d=self.size*.25, po=XSIMath.CreateVector3(dist*.5*self.n_factor,0,0))
            xsi.SetNeutralPose(fk_ctl, c.siTrn)
            par.setKeyableParameters(fk_ctl)
            par.addLocalParamToCollection(self.inv_params, fk_ctl, ["posx", "posy", "posz"])

            parent = fk_ctl
            self.fk_ctl.append(fk_ctl)

        xsi.SetNeutralPose(self.fk_ctl[0])

        # Chain -------------------------------------------
        parent = self.fk_ctl[0]
        self.chain = []
        for i in range(self.division):
            pos = [self.guide.apos[i], self.guide.apos[i+1]]
            chain = pri.add2DChain(parent, self.getName("spring%s"%i), pos, self.normal, self.negate, self.size*.25, True)
            self.addToGroup(chain.all, "hidden")

            eff_ref = pri.addNull(chain.root, self.getName("eff%s_ref"%i), chain.eff.Kinematics.Global.Transform, self.size*.1)
            eff_ref.AddChild(chain.eff)
            self.addToGroup(eff_ref, "hidden")

            self.addShadow(chain.bones[0], i)

            self.chain.append(chain)
            parent = chain.bones[0]

        # Plot Reference ----------------------------------
        self.ref = pri.addNullChain(self.root, self.getName("#_ref"), self.guide.apos, self.normal, self.negate, self.size * .1)
        self.addToGroup(self.ref, "hidden")
        xsi.SetNeutralPose(self.ref[0])
Beispiel #19
0
    def addLocMulti(self, name, parent):

        if "#" not in name:
            gear.log("You need to put a '#' in the name of multiple location.", gear.sev_error)
            return False

        locs = []

        i = 0
        while True:
            localName = string.replaceSharpWithPadding(name, i)
            if localName not in self.tra.keys():
                break

            loc = pri.addNull(parent, self.getName(localName), self.tra[localName])
            pri.setNullDisplay(loc, 1, .5, 2, 0, 0, 0, .5, .5, .5, GUIDE_LOC_COLOR)
            par.addExpression(loc.size, self.root.size.FullName+" * .5")
            locs.append(loc)
            parent = loc

            i += 1

        return locs
Beispiel #20
0
    def addObjects(self):

        self.div_count = len(self.guide.apos) - 5

        plane = [self.guide.apos[0], self.guide.apos[-4], self.guide.apos[-3]]
        self.normal = self.getNormalFromPos(plane)
        self.binormal = self.getBiNormalFromPos(plane)

        # Heel ---------------------------------------------
        t = tra.getTransformLookingAt(self.guide.pos["heel"], self.guide.apos[-4], self.normal, "xz", self.negate)

        self.heel_loc = pri.addNull(self.root, self.getName("heel_loc"), t, self.size*.15)
        xsi.SetNeutralPose(self.heel_loc)
        self.addToGroup(self.heel_loc, "hidden")

        self.heel_ctl = self.addCtl(self.heel_loc, "heel_ctl", t, self.color_ik, "sphere", w=self.size*.1)
        xsi.SetNeutralPose(self.heel_ctl)
        par.setKeyableParameters(self.heel_ctl, self.r_params)

        # Tip ----------------------------------------------
        v = XSIMath.CreateVector3(self.guide.apos[-5].X,self.guide.apos[-1].Y,self.guide.apos[-5].Z)
        t.SetTranslation(v)
        self.tip_ctl = self.addCtl(self.heel_ctl, "tip_ctl", t, self.color_ik, "circle", w=self.size*.5)
        xsi.SetNeutralPose(self.tip_ctl)
        par.setKeyableParameters(self.heel_ctl, self.r_params)

        # Roll ---------------------------------------------
        if self.settings["roll"] == 0:
            t = tra.getTransformFromPosition(self.guide.pos["root"])
            t.SetRotation(tra.getRotationFromAxis(self.y_axis, self.normal, "yz", self.negate))
            self.roll_ctl = self.addCtl(self.root, "roll_ctl", t, self.color_ik, "cylinder", w=self.size*.5, h=self.size*.5, ro=XSIMath.CreateRotation(3.1415*.5,0,0))
            xsi.SetNeutralPose(self.roll_ctl)
            par.setKeyableParameters(self.roll_ctl, ["rotx", "rotz"])

        # Backward Controlers ------------------------------
        bk_pos = self.guide.apos[1:-3]
        bk_pos.reverse()
        parent = self.tip_ctl
        self.bk_ctl = []
        for i, pos in enumerate(bk_pos):

            if i == 0:
                t = self.heel_loc.Kinematics.Global.Transform
                t.SetTranslation(pos)
            else:
                dir = bk_pos[i-1]
                t = tra.getTransformLookingAt(pos, dir, self.normal, "xz", self.negate)

            bk_ctl = self.addCtl(parent, "bk%s_ctl"%i, t, self.color_ik, "sphere", w=self.size*.15)
            xsi.SetNeutralPose(bk_ctl)
            par.setKeyableParameters(bk_ctl, self.r_params)

            self.bk_ctl.append(bk_ctl)
            parent = bk_ctl

        # Forward Controlers ------------------------------
        self.fk_ref = pri.addNullFromPos(self.bk_ctl[-1], self.getName("fk_ref"), self.guide.apos[0], self.size*.5)
        self.addToGroup(self.fk_ref, "hidden")

        self.fk_ctl = []
        parent = self.fk_ref
        for i, bk_ctl in enumerate(reversed(self.bk_ctl[1:])):
            t = bk_ctl.Kinematics.Global.Transform
            dist = vec.getDistance(self.guide.apos[i+1], self.guide.apos[i+2])
            fk_ctl = self.addCtl(parent, "fk%s_ctl"%i, t, self.color_fk, "cube", w=dist, h=self.size*.5, d=self.size*.5, po=XSIMath.CreateVector3(dist*.5*self.n_factor,0,0))
            xsi.SetNeutralPose(fk_ctl)
            par.setKeyableParameters(fk_ctl)
            self.addShadow(fk_ctl, i)

            parent = fk_ctl
            self.fk_ctl.append(fk_ctl)
Beispiel #21
0
    def addObjects(self):

        self.normal = self.getNormalFromPos(self.guide.apos[1:])

        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])
        self.length3 = vec.getDistance(self.guide.apos[3], self.guide.apos[4])

        # 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",
                                   w=1,
                                   h=self.size * .1,
                                   d=self.size * .1,
                                   po=XSIMath.CreateVector3(
                                       .5 * self.n_factor, 0, 0))
        self.fk0_ctl.Kinematics.Global.Parameters("SclX").Value = self.length0
        xsi.SetNeutralPose(self.fk0_ctl)
        xsi.SetNeutralPose(self.fk0_ctl, c.siST)
        par.setKeyableParameters(self.fk0_ctl)

        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",
                                   w=1,
                                   h=self.size * .1,
                                   d=self.size * .1,
                                   po=XSIMath.CreateVector3(
                                       .5 * self.n_factor, 0, 0))
        self.fk1_ctl.Kinematics.Global.Parameters("SclX").Value = self.length1
        xsi.SetNeutralPose(self.fk1_ctl, c.siST)
        par.setKeyableParameters(self.fk1_ctl)

        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",
                                   w=1,
                                   h=self.size * .1,
                                   d=self.size * .1,
                                   po=XSIMath.CreateVector3(
                                       .5 * self.n_factor, 0, 0))
        self.fk2_ctl.Kinematics.Global.Parameters("SclX").Value = self.length2
        xsi.SetNeutralPose(self.fk2_ctl, c.siST)
        par.setKeyableParameters(self.fk2_ctl)

        t = tra.getTransformLookingAt(self.guide.apos[3], self.guide.apos[4],
                                      self.normal, "xz", self.negate)
        self.fk3_ctl = self.addCtl(self.fk2_ctl,
                                   "fk3_ctl",
                                   t,
                                   self.color_fk,
                                   "cube",
                                   w=self.length3,
                                   h=self.size * .1,
                                   d=self.size * .1,
                                   po=XSIMath.CreateVector3(
                                       self.length3 * .5 * self.n_factor, 0,
                                       0))
        xsi.SetNeutralPose(self.fk3_ctl, c.siST)
        par.setKeyableParameters(self.fk3_ctl)

        # IK Controlers ------------------------------------
        self.ik_cns = pri.addNullFromPos(self.root, self.getName("ik_cns"),
                                         self.guide.apos[3], 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)
        self.addToCtlGroup(self.ikcns_ctl)
        par.setKeyableParameters(self.ikcns_ctl)

        t = tra.getTransformLookingAt(self.guide.apos[3], self.guide.apos[4],
                                      self.x_axis, "zx", False)
        self.ik_ctl = self.addCtl(self.ikcns_ctl,
                                  "ik_ctl",
                                  t,
                                  self.color_ik,
                                  "cube",
                                  h=self.size * .12,
                                  w=self.size * .12,
                                  d=self.length2,
                                  po=XSIMath.CreateVector3(
                                      0, 0, self.length2 * .5))
        par.setKeyableParameters(self.ik_ctl)

        # Upv
        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)

        # References ---------------------------------------
        # Ik ref
        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")

        # Fk ref
        self.fk_ref = pri.addNull(self.fk2_ctl, self.getName("fk_ref"),
                                  self.ik_ref.Kinematics.Global.Transform,
                                  self.size * .1)
        self.addToGroup(self.fk_ref, "hidden")

        # Roll Controler -----------------------------------
        if self.settings["roll"] == 0:  # Roll with a controler
            self.roll_ctl = self.addCtl(
                self.ik_ref,
                "roll_ctl",
                self.ik_ref.Kinematics.Global.Transform,
                self.color_ik,
                "bendedarrow2",
                w=self.length2 * .5 * self.n_factor,
                po=XSIMath.CreateVector3(0, self.length2 * .5 * self.n_factor,
                                         0))
            if self.negate:
                self.roll_ctl.Kinematics.Local.Parameters("rotx").Value = 180
                xsi.SetNeutralPose(self.roll_ctl)
            par.setKeyableParameters(self.roll_ctl, self.r_params)

        # Chain --------------------------------------------
        self.ref_chn = pri.add2DChain(self.root, self.getName("ref"),
                                      self.guide.apos[:3], self.normal,
                                      self.negate, self.size * .1, True)
        self.addToGroup(self.ref_chn.all, "hidden")

        self.end_chn = pri.add2DChain(self.ref_chn.bones[-1],
                                      self.getName("end"),
                                      self.guide.apos[2:4], self.normal,
                                      self.negate, self.size * .1, True)
        self.addToGroup(self.end_chn.all, "hidden")

        # Reference Nulls ---------------------------------
        self.ref_loc = []
        parent = self.root
        for i, ref in enumerate(
            [self.fk0_ctl, self.fk1_ctl, self.fk2_ctl, self.fk_ref]):
            t = tra.getFilteredTransform(ref.Kinematics.Global.Transform, True,
                                         True, False)
            ref_loc = pri.addNull(parent, self.getName("ref%s_loc" % i), t,
                                  self.size * .1)
            self.addToGroup(ref_loc, "hidden")
            self.ref_loc.append(ref_loc)

            parent = ref_loc

        # Mid Controler ------------------------------------
        self.ctrn0_loc = pri.addNullFromPos(self.ref_loc[0],
                                            self.getName("ctrn0_loc"),
                                            self.guide.apos[1],
                                            self.size * .05)
        self.ctrn1_loc = pri.addNullFromPos(self.ref_loc[1],
                                            self.getName("ctrn1_loc"),
                                            self.guide.apos[2],
                                            self.size * .05)

        self.addToGroup([self.ctrn0_loc, self.ctrn1_loc], "hidden")

        self.mid0_ctl = self.addCtl(self.ctrn0_loc,
                                    "mid0_ctl",
                                    self.ctrn0_loc.Kinematics.Global.Transform,
                                    self.color_ik,
                                    "sphere",
                                    h=self.size * .1)
        self.mid1_ctl = self.addCtl(self.ctrn1_loc,
                                    "mid1_ctl",
                                    self.ctrn1_loc.Kinematics.Global.Transform,
                                    self.color_ik,
                                    "sphere",
                                    h=self.size * .1)

        # Twist references ---------------------------------
        t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[1],
                                      self.normal, "xz", self.negate)
        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.ctrn0_loc, self.getName("tws1_loc"),
                                    self.ctrn0_loc.Kinematics.Global.Transform,
                                    self.size * .05)
        self.tws1_rot = pri.addNull(self.tws1_loc, self.getName("tws1_rot"),
                                    self.ctrn0_loc.Kinematics.Global.Transform)
        pri.setNullDisplay(self.tws1_rot, 0, self.size * .05, 2, 0, 0, 0,
                           self.size * .01)

        self.tws2_loc = pri.addNull(self.ctrn1_loc, self.getName("tws2_loc"),
                                    self.ctrn1_loc.Kinematics.Global.Transform,
                                    self.size * .05)
        self.tws2_rot = pri.addNull(self.tws2_loc, self.getName("tws2_rot"),
                                    self.ctrn1_loc.Kinematics.Global.Transform)
        pri.setNullDisplay(self.tws2_rot, 0, self.size * .05, 2, 0, 0, 0,
                           self.size * .01)

        t = tra.getFilteredTransform(
            self.ref_loc[-2].Kinematics.Global.Transform, True, True, False)
        t.SetTranslation(self.guide.apos[3])
        self.tws3_loc = pri.addNull(self.ref_loc[-1], self.getName("tws3_loc"),
                                    t, self.size * .05)
        self.tws3_rot = pri.addNull(self.tws3_loc, self.getName("tws3_rot"), t)
        pri.setNullDisplay(self.tws3_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, self.tws3_loc, self.tws3_rot
        ], "hidden")

        # 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"] + self.settings["div2"] + 4

        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)
Beispiel #22
0
    def addObjects(self):

        self.div_count = len(self.guide.apos) - 5

        plane = [self.guide.apos[0], self.guide.apos[-4], self.guide.apos[-3]]
        self.normal = self.getNormalFromPos(plane)
        self.binormal = self.getBiNormalFromPos(plane)

        # Heel ---------------------------------------------
        t = tra.getTransformLookingAt(self.guide.pos["heel"],
                                      self.guide.apos[-4], self.normal, "xz",
                                      self.negate)

        self.heel_loc = pri.addNull(self.root, self.getName("heel_loc"), t,
                                    self.size * .15)
        xsi.SetNeutralPose(self.heel_loc)
        self.addToGroup(self.heel_loc, "hidden")

        self.heel_ctl = self.addCtl(self.heel_loc,
                                    "heel_ctl",
                                    t,
                                    self.color_ik,
                                    "sphere",
                                    w=self.size * .1)
        xsi.SetNeutralPose(self.heel_ctl)
        par.setKeyableParameters(self.heel_ctl, self.r_params)

        # Tip ----------------------------------------------
        v = XSIMath.CreateVector3(self.guide.apos[-5].X, self.guide.apos[-1].Y,
                                  self.guide.apos[-5].Z)
        t.SetTranslation(v)
        self.tip_ctl = self.addCtl(self.heel_ctl,
                                   "tip_ctl",
                                   t,
                                   self.color_ik,
                                   "circle",
                                   w=self.size * .5)
        xsi.SetNeutralPose(self.tip_ctl)
        par.setKeyableParameters(self.heel_ctl, self.r_params)

        # Roll ---------------------------------------------
        if self.settings["roll"] == 0:
            t = tra.getTransformFromPosition(self.guide.pos["root"])
            t.SetRotation(
                tra.getRotationFromAxis(self.y_axis, self.normal, "yz",
                                        self.negate))
            self.roll_ctl = self.addCtl(self.root,
                                        "roll_ctl",
                                        t,
                                        self.color_ik,
                                        "cylinder",
                                        w=self.size * .5,
                                        h=self.size * .5,
                                        ro=XSIMath.CreateRotation(
                                            3.1415 * .5, 0, 0))
            xsi.SetNeutralPose(self.roll_ctl)
            par.setKeyableParameters(self.roll_ctl, ["rotx", "rotz"])

        # Backward Controlers ------------------------------
        bk_pos = self.guide.apos[1:-3]
        bk_pos.reverse()
        parent = self.tip_ctl
        self.bk_ctl = []
        for i, pos in enumerate(bk_pos):

            if i == 0:
                t = self.heel_loc.Kinematics.Global.Transform
                t.SetTranslation(pos)
            else:
                dir = bk_pos[i - 1]
                t = tra.getTransformLookingAt(pos, dir, self.normal, "xz",
                                              self.negate)

            bk_ctl = self.addCtl(parent,
                                 "bk%s_ctl" % i,
                                 t,
                                 self.color_ik,
                                 "sphere",
                                 w=self.size * .15)
            xsi.SetNeutralPose(bk_ctl)
            par.setKeyableParameters(bk_ctl, self.r_params)

            self.bk_ctl.append(bk_ctl)
            parent = bk_ctl

        # Forward Controlers ------------------------------
        self.fk_ref = pri.addNullFromPos(self.bk_ctl[-1],
                                         self.getName("fk_ref"),
                                         self.guide.apos[0], self.size * .5)
        self.addToGroup(self.fk_ref, "hidden")

        self.fk_ctl = []
        parent = self.fk_ref
        for i, bk_ctl in enumerate(reversed(self.bk_ctl[1:])):
            t = bk_ctl.Kinematics.Global.Transform
            dist = vec.getDistance(self.guide.apos[i + 1],
                                   self.guide.apos[i + 2])
            fk_ctl = self.addCtl(parent,
                                 "fk%s_ctl" % i,
                                 t,
                                 self.color_fk,
                                 "cube",
                                 w=dist,
                                 h=self.size * .5,
                                 d=self.size * .5,
                                 po=XSIMath.CreateVector3(
                                     dist * .5 * self.n_factor, 0, 0))
            xsi.SetNeutralPose(fk_ctl)
            par.setKeyableParameters(fk_ctl)
            self.addShadow(fk_ctl, i)

            parent = fk_ctl
            self.fk_ctl.append(fk_ctl)
Beispiel #23
0
    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")
Beispiel #24
0
    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")
Beispiel #25
0
    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)
Beispiel #26
0
    def addObjects(self):
        self.normal = self.guide.blades["blade"].z
        t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[2], self.normal, "zx", False)
        offsetRotation = XSIMath.CreateRotation()
        t.GetRotation(offsetRotation)
        self.tracking_lvl = pri.addNullFromPos(self.root, self.getName("tracking_lvl"), self.guide.apos[0 ],   self.size*.15)
        self.addToGroup(self.tracking_lvl, "hidden")
        self.loc = pri.addNullsFromPositions(self.tracking_lvl, self.getName("#_loc"), self.guide.apos[3:],  offsetRotation, self.size*.15)
        self.addToGroup(self.loc, "hidden")
        i = 0
        self.oDirDriverList = []
        self.oDirDrivenList = []
        self.oPointerLvlList = []
        self.oCornersList = []
        self.oUpDownList = []
        self.oSidesList = []
       
        for x in self.loc:
            t = x.Kinematics.Global.Transform
            self.coners_lvl = pri.addNull(x, self.getName("coners%s_lvl"%i), t, self.size*.15)
            self.upDown_lvl = pri.addNull(self.coners_lvl, self.getName("upDown%s_lvl"%i), t, self.size*.15)
            self.sides_lvl = pri.addNull(self.upDown_lvl, self.getName("sides%s_lvl"%i), t, self.size*.15)
            self.tweak_lvl = pri.addNull(self.sides_lvl, self.getName("tweak%s_lvl"%i), t, self.size*.15)
            t2 = tra.getTransformLookingAt(self.guide.apos[0], x.Kinematics.Global.Transform.Translation, self.normal, "xy", False)
            self.oPointer= pri.addNull(self.root, self.getName("pointer%s_loc"%i), t2, self.size*.15)
            self.oPointerLvl= pri.addNull(self.root, self.getName("pointer%s_lvl"%i), t, self.size*.15)
            self.shadow = self.addShadow(self.oPointerLvl, "%s"%i)
            self.oHiddenList = [self.coners_lvl,  self.upDown_lvl, self.sides_lvl, self.oPointer, self.oPointerLvl, self.tweak_lvl ]
            self.addToGroup(self.oHiddenList, "hidden")
            self.oDirDriverList.append(self.tweak_lvl)
            self.oDirDrivenList.append(self.oPointer)
            self.oPointerLvlList.append(self.oPointerLvl)
            self.oCornersList.append(self.coners_lvl)
            self.oUpDownList.append(self.upDown_lvl)
            self.oSidesList.append(self.sides_lvl)

            i +=1
            
        self.cornerA_lvl = pri.addNullFromPos(self.root, self.getName("cornerA_lvl"), self.guide.apos[3],   self.size*.15)
        self.cornerA = pri.addNullFromPos(self.cornerA_lvl, self.getName("cornerA"), self.guide.apos[3],  self.size*.15)
        self.addToGroup(self.cornerA_lvl, "hidden")
        self.addToGroup(self.cornerA, "hidden")

        self.cornerB_lvl = pri.addNullFromPos(self.root, self.getName("cornerB_lvl"), self.guide.apos[-1],   self.size*.15)
        self.cornerB = pri.addNullFromPos(self.cornerB_lvl, self.getName("cornerB"), self.guide.apos[-1],   self.size*.15)
        self.addToGroup(self.cornerB_lvl, "hidden")
        self.addToGroup(self.cornerB, "hidden")
        
        self.upVec = pri.addNullFromPos(self.root, self.getName("upVec_loc"), self.guide.apos[1], self.size*.15)
        self.addToGroup(self.upVec, "hidden")

        self.mediumPosition = self.guide.apos[((len(self.guide.apos) -3 )//2) + 3]
        self.oTempPosY =  XSIMath.CreateVector3()
        self.oTempPosY.X =  self.mediumPosition.X
        self.oTempPosY.Y =  self.mediumPosition.Y + 3
        self.oTempPosY.Z =  self.mediumPosition.Z
        
        self.oTempPosZ = XSIMath.CreateVector3()
        self.oTempPosZ.X =  self.mediumPosition.X
        self.oTempPosZ.Y =  self.mediumPosition.Y
        self.oTempPosZ.Z =  self.mediumPosition.Z +3

        
        t = tra.getTransformLookingAt( self.mediumPosition, self.oTempPosZ, self.oTempPosY, "zy", self.negate)
        t.RotZ = 0.0

        self.control_lvl = pri.addNull(self.root, self.getName("eyelidCtl_lvl"), t, self.size*.15)
        self.addToGroup(self.control_lvl, "hidden")
        self.control = self.addCtl(self.control_lvl, "eyelid_ctl", t, self.color_ik,  "square", w=self.size*.2)
Beispiel #27
0
    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")
Beispiel #28
0
    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")
Beispiel #29
0
 def drawRef(self, t):
     ref = pri.addNull(xsi.ActiveSceneRoot, self.getName("ref"), t, .3)
     pri.setNullDisplay(ref, 1, .3, 2, 0, 0, 0, .5, .5, .5, [.5,.875,.5])
     return ref
Beispiel #30
0
 def drawRef(self, t):
     ref = pri.addNull(xsi.ActiveSceneRoot, self.getName("ref"), t, .3)
     pri.setNullDisplay(ref, 1, .3, 2, 0, 0, 0, .5, .5, .5, [.5, .875, .5])
     return ref
Beispiel #31
0
    def addObjects(self):

        if self.negate:
            transforms = [
                tra.getNegatedTransform(
                    tra.getFilteredTransform(t, True, True, False))
                for t in self.guide.atra
            ]
        else:
            transforms = [
                tra.getFilteredTransform(t, True, True, False)
                for t in self.guide.atra
            ]

        # Controlers ---------------------------------------
        self.end_ctl = self.addCtl(self.root,
                                   "end_ctl",
                                   transforms[-1],
                                   self.color_ik,
                                   "cube",
                                   w=self.size * .2,
                                   h=self.size * .2,
                                   d=self.size * .2)
        par.setKeyableParameters(
            self.end_ctl,
            ["posx", "posy", "posz", "rotx", "roty", "rotz", "rotorder"])
        xsi.SetNeutralPose(self.end_ctl)

        if self.settings["startctl"]:
            self.start_ctl = self.addCtl(self.root,
                                         "0_ctl",
                                         transforms[0],
                                         self.color_ik,
                                         "cube",
                                         w=self.size * .2,
                                         h=self.size * .2,
                                         d=self.size * .2)
            par.setKeyableParameters(
                self.start_ctl,
                ["posx", "posy", "posz", "rotx", "roty", "rotz", "rotorder"])
            xsi.SetNeutralPose(self.end_ctl)
        else:
            self.start_ctl = pri.addNull(self.root, self.getName("0_loc"),
                                         transforms[0], self.size * .2)
            self.addToGroup(self.start_ctl, "hidden")

        # Locations ----------------------------------------
        self.loc = []
        for i, t in enumerate(transforms[1:-1]):
            loc = pri.addNull(self.root, self.getName("%s_loc" % (i + 1)), t,
                              self.size * .2)
            self.addToGroup(loc, "hidden")
            self.loc.append(loc)

        # Intermediate controlers --------------------------
        if self.settings["interctl"]:
            self.inter_ctl = []
            for i, loc in enumerate(self.loc):
                ctl = self.addCtl(loc,
                                  "%s_ctl" % (i + 1),
                                  loc.Kinematics.Global.Transform,
                                  self.color_fk,
                                  "cube",
                                  w=self.size * .2,
                                  h=self.size * .2,
                                  d=self.size * .2)
                par.setKeyableParameters(ctl, [
                    "posx", "posy", "posz", "rotx", "roty", "rotz", "rotorder"
                ])
                xsi.SetNeutralPose(ctl)
                self.inter_ctl.append(ctl)

        # Deformers (Shadow) -------------------------------
        self.addShadow(self.start_ctl, 0)

        if self.settings["interctl"]:
            for i, ctl in enumerate(self.inter_ctl):
                self.addShadow(ctl, i + 1)
        else:
            for i, loc in enumerate(self.loc):
                self.addShadow(loc, i + 1)

        self.addShadow(self.end_ctl, "end")
Beispiel #32
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)
Beispiel #33
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)
Beispiel #34
0
 def addObjects(self):
 
     # Jaw objects
     self.jawRotCenter = pri.addNullFromPos(self.root, self.getName("jaw_rot_center"), self.guide.apos[2], self.size*.02)
     self.jawTrans = pri.addNullFromPos(self.jawRotCenter, self.getName("jaw_translation"), self.guide.apos[0], self.size*.02)
     self.jawRotBase = pri.addNullFromPos(self.jawTrans, self.getName("jaw_rot_base"), self.guide.apos[0], self.size*.02)
     
     self.addToGroup(self.jawRotCenter, "hidden")
     self.addToGroup(self.jawTrans, "hidden")
     self.addToGroup(self.jawRotBase, "hidden")
     
     self.addShadow(self.jawRotBase, "jaw")
     
     plane = [self.guide.apos[0], self.guide.apos[1], self.guide.apos[2]]
     self.normal = self.getNormalFromPos(plane)
     
     
     
     self.jawContLvl = pri.addNullFromPos(self.root, self.getName("jaw_ctl_Level"), self.guide.apos[1], self.size*.02)
     t = self.jawContLvl.Kinematics.Global.Transform
     self.oAngle = XSIMath.DegreesToRadians( 90)
     self.tmpRot = XSIMath.CreateRotation(self.oAngle, 0.0, 0.0)    
     self.jawControl = self.addCtl(self.jawContLvl, "jaw_ctl", t, self.color_fk,  "circle", w=self.size*.5, ro = self.tmpRot)
     
     self.addToGroup(self.jawContLvl, "hidden")
     
     #Neutral posing
     
     xsi.SetNeutralPose(self.jawRotCenter, c.siSRT)
     xsi.SetNeutralPose(self.jawTrans, c.siSRT)
     
     
     #teeth Objects
     
     plane = [self.guide.pos["root"], self.guide.pos["lip01"], self.guide.pos["tongueB"]]
     self.normal = self.getNormalFromPos(plane)
     self.binormal = self.getBiNormalFromPos(plane)
     
     
     t = tra.getTransformLookingAt(self.guide.pos["teethT"], self.guide.pos["teethB"], self.normal, "zx", 1)        
     self.teeth_lvl = pri.addNull(self.root, self.getName("teeth_lvl"), t)
     self.teeth_lvl.Parameters("primary_icon").Value = 1
     self.teethHead = pri.addNull(self.root, self.getName("teethHead"), t)
     self.teethJaw = pri.addNull(self.jawRotBase, self.getName("teethJaw"), t)
     self.upTeethControl = self.addCtl(self.teeth_lvl, "upTeeth_ctl", t, self.color_fk,  "circle", w=self.size*.2)
     self.downTeethControl = self.addCtl(self.teethJaw, "downTeeth_ctl", t, self.color_fk,  "circle", w=self.size*.2)
     
     self.addToGroup(self.teeth_lvl, "hidden")
     self.addToGroup(self.teethHead, "hidden")
     self.addToGroup(self.teethJaw, "hidden")
     self.addShadow(self.upTeethControl, "upTeeth")
     self.addShadow(self.downTeethControl, "lowTeeth")
     
     
     
     #Lips Objects
     t = tra.getTransformLookingAt(self.guide.pos["teethT"], self.guide.pos["teethB"], self.normal, "zx", 1)        
     self.upLips_lvl = pri.addNull(self.root, self.getName("upLips_lvl"), t)
     self.upLips_lvl.Parameters("primary_icon").Value = 4
     self.upLips_loc = pri.addNull(self.upLips_lvl, self.getName("upLips_loc"), t)
     self.upLipsHead = pri.addNull(self.root, self.getName("upLipsHead"), t)
     self.upLipsJaw = pri.addNull(self.jawRotBase, self.getName("upLipsJaw"), t)
     self.lowLipsJaw_lvl = pri.addNull(self.jawRotBase, self.getName("lowLipsJaw_lvl"), t)
     self.lowLipsJaw = pri.addNull(self.lowLipsJaw_lvl, self.getName("lowLipsJaw"), t)
     
     self.addToGroup(self.upLips_lvl, "hidden")
     self.addToGroup(self.upLipsHead, "hidden")
     self.addToGroup(self.upLipsJaw, "hidden")
     self.addToGroup(self.lowLipsJaw_lvl, "hidden")
     self.addToGroup(self.lowLipsJaw, "hidden")
     self.addToGroup(self.upLips_loc, "hidden")
     
     
     #upper lips
     t = tra.getTransformFromPosition(self.guide.pos["lip01"])
     self.uLip01Upper_ref = pri.addNull(self.upLips_loc, self.getName("uLip01Upper_loc"), t, self.size * .01)
     self.uLip01Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("uLip01Lower_loc"), t, self.size * .01)
     self.uLip01_lvl = pri.addNull(self.root, self.getName("uLip01_lvl"), t, self.size * .01)
     self.uLip01_ctl = self.addCtl(self.uLip01_lvl, "uLip01_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.uLip01_lvl, "hidden")
     self.addToGroup(self.uLip01Upper_ref, "hidden")
     self.addToGroup(self.uLip01Lower_ref, "hidden")
     self.addShadow(self.uLip01_ctl, "uLip01")
     
     
     t = tra.getTransformFromPosition(self.guide.pos["lip02"])
     self.uLip02Upper_ref = pri.addNull(self.upLips_loc, self.getName("uLip02Upper_loc"), t, self.size * .01)
     self.uLip02Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("uLip02Lower_loc"), t, self.size * .01)
     self.uLip02_lvl = pri.addNull(self.root, self.getName("uLip02_lvl"), t, self.size * .01)
     self.uLip02_ctl = self.addCtl(self.uLip02_lvl, "uLip02_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.uLip02_lvl, "hidden")
     self.addToGroup(self.uLip02Upper_ref, "hidden")
     self.addToGroup(self.uLip02Lower_ref, "hidden")
     self.addShadow(self.uLip02_ctl, "uLip02")
     
     t = tra.getTransformFromPosition(self.guide.pos["lip03"])
     self.uLip03Upper_ref = pri.addNull(self.upLips_loc, self.getName("uLip03Upper_loc"), t, self.size * .01)
     self.uLip03Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("uLip03Lower_loc"), t, self.size * .01)
     self.uLip03_lvl = pri.addNull(self.root, self.getName("uLip03_lvl"), t, self.size * .01)
     self.uLip03_ctl = self.addCtl(self.uLip03_lvl, "uLip03_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.uLip03_lvl, "hidden")
     self.addToGroup(self.uLip03Upper_ref, "hidden")
     self.addToGroup(self.uLip03Lower_ref, "hidden")
     self.addShadow(self.uLip03_ctl, "uLip03")
     
     t = tra.getTransformFromPosition(self.guide.pos["lip11"])
     self.uLip11Upper_ref = pri.addNull(self.upLips_loc, self.getName("uLip11Upper_loc"), t, self.size * .01)
     self.uLip11Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("uLip11Lower_loc"), t, self.size * .01)
     self.uLip11_lvl = pri.addNull(self.root, self.getName("uLip11_lvl"), t, self.size * .01)
     self.uLip11_ctl = self.addCtl(self.uLip11_lvl, "uLip11_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.uLip11_lvl, "hidden")
     self.addToGroup(self.uLip11Upper_ref, "hidden")
     self.addToGroup(self.uLip11Lower_ref, "hidden")
     self.addShadow(self.uLip11_ctl, "uLip11")
     
     t = tra.getTransformFromPosition(self.guide.pos["lip12"])
     self.uLip12Upper_ref = pri.addNull(self.upLips_loc, self.getName("uLip12Upper_loc"), t, self.size * .01)
     self.uLip12Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("uLip12Lower_loc"), t, self.size * .01)
     self.uLip12_lvl = pri.addNull(self.root, self.getName("uLip12_lvl"), t, self.size * .01)
     self.uLip12_ctl = self.addCtl(self.uLip12_lvl, "uLip12_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.uLip12_lvl, "hidden")
     self.addToGroup(self.uLip12Upper_ref, "hidden")
     self.addToGroup(self.uLip12Lower_ref, "hidden")
     self.addShadow(self.uLip12_ctl, "uLip12")
     
     
     
     
     #lower Lips
     
     t = tra.getTransformFromPosition(self.guide.pos["lip05"])
     self.lLip05Upper_ref = pri.addNull(self.upLips_loc, self.getName("lLip05Upper_loc"), t, self.size * .01)
     self.lLip05Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("lLip05Lower_loc"), t, self.size * .01)
     self.lLip05_lvl = pri.addNull(self.root, self.getName("lLip05_lvl"), t, self.size * .01)
     self.lLip05_ctl = self.addCtl(self.lLip05_lvl, "lLip05_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.lLip05_lvl, "hidden")
     self.addToGroup(self.lLip05Upper_ref, "hidden")
     self.addToGroup(self.lLip05Lower_ref, "hidden")
     self.addShadow(self.lLip05_ctl, "lLip05")
     
     t = tra.getTransformFromPosition(self.guide.pos["lip06"])
     self.lLip06Upper_ref = pri.addNull(self.upLips_loc, self.getName("lLip06Upper_loc"), t, self.size * .01)
     self.lLip06Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("lLip06Lower_loc"), t, self.size * .01)
     self.lLip06_lvl = pri.addNull(self.root, self.getName("lLip06_lvl"), t, self.size * .01)
     self.lLip06_ctl = self.addCtl(self.lLip06_lvl, "lLip06_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.lLip06_lvl, "hidden")
     self.addToGroup(self.lLip06Upper_ref, "hidden")
     self.addToGroup(self.lLip06Lower_ref, "hidden")
     self.addShadow(self.lLip06_ctl, "lLip06")
     
     t = tra.getTransformFromPosition(self.guide.pos["lip07"])
     self.lLip07Upper_ref = pri.addNull(self.upLips_loc, self.getName("lLip07Upper_loc"), t, self.size * .01)
     self.lLip07Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("lLip07Lower_loc"), t, self.size * .01)
     self.lLip07_lvl = pri.addNull(self.root, self.getName("lLip07_lvl"), t, self.size * .01)
     self.lLip07_ctl = self.addCtl(self.lLip07_lvl, "lLip07_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.lLip07_lvl, "hidden")
     self.addToGroup(self.lLip07Upper_ref, "hidden")
     self.addToGroup(self.lLip07Lower_ref, "hidden")
     self.addShadow(self.lLip07_ctl, "lLip07")
     
     t = tra.getTransformFromPosition(self.guide.pos["lip08"])
     self.lLip08Upper_ref = pri.addNull(self.upLips_loc, self.getName("lLip08Upper_loc"), t, self.size * .01)
     self.lLip08Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("lLip08Lower_loc"), t, self.size * .01)
     self.lLip08_lvl = pri.addNull(self.root, self.getName("lLip08_lvl"), t, self.size * .01)
     self.lLip08_ctl = self.addCtl(self.lLip08_lvl, "lLip08_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.lLip08_lvl, "hidden")
     self.addToGroup(self.lLip08Upper_ref, "hidden")
     self.addToGroup(self.lLip08Lower_ref, "hidden")
     self.addShadow(self.lLip08_ctl, "lLip08")
     
     t = tra.getTransformFromPosition(self.guide.pos["lip09"])
     self.lLip09Upper_ref = pri.addNull(self.upLips_loc, self.getName("lLip09Upper_loc"), t, self.size * .01)
     self.lLip09Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("lLip09Lower_loc"), t, self.size * .01)
     self.lLip09_lvl = pri.addNull(self.root, self.getName("lLip09_lvl"), t, self.size * .01)
     self.lLip09_ctl = self.addCtl(self.lLip09_lvl, "lLip09_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.lLip09_lvl, "hidden")
     self.addToGroup(self.lLip09Upper_ref, "hidden")
     self.addToGroup(self.lLip09Lower_ref, "hidden")
     self.addShadow(self.lLip09_ctl, "lLip09")
    
     
     
     #Corner lips
     
     t = tra.getTransformLookingAt(self.guide.pos["lip04"], self.guide.pos["lipL"], self.normal, "zx", 1)
     self.lLip04Upper_ref = pri.addNull(self.upLips_loc, self.getName("LLip04Upper_loc"), t, self.size * .01)
     self.lLip04Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("LLip04Lower_loc"), t, self.size * .01)
     self.cLip04_lvl = pri.addNull(self.root, self.getName("cLip04_lvl"), t, self.size * .05)
     self.cLip04_ctl = self.addCtl(self.cLip04_lvl, "LLip04_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.cLip04_lvl, "hidden")
     self.addToGroup(self.lLip04Upper_ref, "hidden")
     self.addToGroup(self.lLip04Lower_ref, "hidden")
     self.addShadow(self.cLip04_ctl, "cLip04")
     
     
     t = tra.getTransformLookingAt(self.guide.pos["lip10"], self.guide.pos["lipR"], self.normal, "zx", 1) 
     self.lLip10Upper_ref = pri.addNull(self.upLips_loc, self.getName("RLip10Upper_loc"), t, self.size * .01)
     self.lLip10Lower_ref = pri.addNull(self.lowLipsJaw, self.getName("RLip10Lower_loc"), t, self.size * .01)
     self.cLip10_lvl = pri.addNull(self.root, self.getName("cLip10_lvl"), t, self.size * .05)
     self.cLip10_ctl = self.addCtl(self.cLip10_lvl, "RLip10_ctl", t, self.color_fk,  "cube", w=self.size*.02, h = self.size*.02, d = self.size*.02 )
     self.addToGroup(self.cLip10_lvl, "hidden")
     self.addToGroup(self.lLip10Upper_ref, "hidden")
     self.addToGroup(self.lLip10Lower_ref, "hidden")
     self.addShadow(self.cLip10_ctl, "cLip10")
     
     
     #Tongue
     
     self.oAngle = XSIMath.DegreesToRadians( 90)
     self.tmpRot = XSIMath.CreateRotation(0.0, 0.0, self.oAngle)    
     
     t = tra.getTransformLookingAt(self.guide.pos["tongueB"], self.guide.pos["tongueBM"], self.normal, "zx", 0) 
     self.tongue01_ctl = self.addCtl(self.teethJaw, "tongue01_ctl", t, self.color_fk,  "square", w=self.size*.1, d=self.size*.01, ro=self.tmpRot)
     self.tongue01 = pri.addNull(self.tongue01_ctl, self.getName("tongue01"), t, self.size * .05) 
     self.addShadow(self.tongue01_ctl, "tongue01")
     xsi.SetNeutralPose(self.tongue01_ctl, c.siSRT)
     self.addToGroup(self.tongue01, "hidden")
       
     t = tra.getTransformLookingAt(self.guide.pos["tongueBM"], self.guide.pos["tongueC"], self.normal, "zx", 0)
     self.tongue02_ctl = self.addCtl(self.tongue01, "tongue02_ctl", t, self.color_fk,  "square", w=self.size*.1, d=self.size*.01, ro=self.tmpRot)        
     self.tongue02 = pri.addNull(self.tongue02_ctl, self.getName("tongue02"), t, self.size * .05)
     self.addShadow(self.tongue02_ctl, "tongue02")
     xsi.SetNeutralPose(self.tongue02_ctl, c.siSRT)
     self.addToGroup(self.tongue02, "hidden")
     
     t = tra.getTransformLookingAt(self.guide.pos["tongueC"], self.guide.pos["tongueTM"], self.normal, "zx", 0)
     self.tongue03_ctl = self.addCtl(self.tongue02, "tongue03_ctl", t, self.color_fk,  "square", w=self.size*.1, d=self.size*.01, ro=self.tmpRot)
     self.tongue03 = pri.addNull(self.tongue03_ctl, self.getName("tongue03"), t, self.size * .05)
     self.addShadow(self.tongue03_ctl, "tongue03")
     xsi.SetNeutralPose(self.tongue03_ctl, c.siSRT)
     self.addToGroup(self.tongue03, "hidden")
     
     t = tra.getTransformLookingAt(self.guide.pos["tongueTM"], self.guide.pos["tongueT"], self.normal, "zx", 0) 
     self.tongue04_ctl = self.addCtl(self.tongue03, "tongue04_ctl", t, self.color_fk,  "square", w=self.size*.1, d=self.size*.01, ro=self.tmpRot)
     self.tongue04 = pri.addNull(self.tongue04_ctl, self.getName("tongue04"), t, self.size * .05)
     self.addShadow(self.tongue04_ctl, "tongue04")
     xsi.SetNeutralPose(self.tongue04_ctl, c.siSRT)
     self.addToGroup(self.tongue04, "hidden")
     
     t = tra.getTransformLookingAt(self.guide.pos["tongueT"], self.guide.pos["tongueTM"], self.normal, "zx", 1) 
     self.tongue05_ctl = self.addCtl(self.tongue04, "tongue05_ctl", t, self.color_fk,  "square", w=self.size*.1, d=self.size*.01, ro=self.tmpRot)
     self.tongue05 = pri.addNull(self.tongue05_ctl, self.getName("tongue05"), t, self.size * .05)
     self.addShadow(self.tongue05_ctl, "tongue05")
     xsi.SetNeutralPose(self.tongue05_ctl, c.siSRT)
     self.addToGroup(self.tongue05, "hidden")
Beispiel #35
0
    def addObjects(self):

        self.inter_shd = 1
        self.shd_count = self.inter_shd * 2 + 3
        self.inter_crv = 1
        self.crv_count = self.inter_crv * 2 + 1

        self.npo = []
        self.ctl = []

        self.crv = []
        self.upv = []
        self.ctr = []
        self.off = []
        self.cns_crv = []
        self.loc = []

        self.percentages = []

        for i, name, blade in zip(range(3), ["root", "mid_loc", "end_loc"],
                                  ["blade", "mid_blade", "end_blade"]):

            # Path ----------------------------------------
            crv = self.guide.prim["%s_crv" % i].create(
                self.root, self.getName("%s_crv" % i), None)
            xsi.SetNeutralPose(crv)

            self.crv.append(crv)
            self.addToGroup(crv, "hidden")

            if i == 0:
                y0 = cur.getGlobalPointPosition(0, crv).Y
                y1 = cur.getGlobalPointPosition(
                    crv.ActivePrimitive.Geometry.Points.Count - 1, crv).Y

                self.scale = (y1 - y0) * .5

            # Controlers ----------------------------------
            lookat = XSIMath.CreateVector3()
            lookat.Add(self.guide.pos[name], self.guide.blades[blade].x)
            if blade == "end_blade":
                axisPlane = "zx"
                axisNegate = True
            else:
                axisPlane = "zx"
                axisNegate = False
            t = tra.getTransformLookingAt(self.guide.pos[name], lookat,
                                          self.guide.blades[blade].y,
                                          axisPlane, axisNegate)
            t.SetScaling(
                XSIMath.CreateVector3(self.scale, self.scale, self.scale))

            npo = pri.addNull(self.root, self.getName("%s_npo" % i), t, 1)
            pri.setNullDisplay(npo, 0, 1, 4, 0, 0, 0, .15, 2, 0)
            self.addToGroup(npo, "unselectable")

            ctl = self.addCtl(npo,
                              "%s_ctl" % i,
                              t,
                              self.color_ik,
                              "sphere",
                              w=.2)
            xsi.SetNeutralPose(ctl)
            par.setKeyableParameters(ctl, [
                "posx", "posy", "posz", "rotx", "roty", "rotz", "rotorder",
                "sclx"
            ])
            # par.addLocalParamToCollection(self.inv_params, ctl, ["posx", "roty", "rotz"]) # to be defined
            # par.setRotOrder(ctl, "XZY") # to be defined

            self.ctl.append(ctl)

            # Up Vector, Center, Offset -------------------
            v = XSIMath.CreateVector3(self.guide.blades[blade].x.X,
                                      self.guide.blades[blade].x.Y,
                                      self.guide.blades[blade].x.Z)
            v.ScaleInPlace(-self.size)
            v.AddInPlace(self.guide.pos[name])
            upv = pri.addNullFromPos(crv,
                                     self.getName("%s_upv") % i, v,
                                     self.size * .025)
            ctr = [
                pri.addNullFromPos(crv, self.getName("%s_%s_ctr" % (i, j)),
                                   self.guide.apos[i], self.size * .025)
                for j in range(3)
            ]
            off = pri.addNullFromPos(ctr[1],
                                     self.getName("%s_off") % i,
                                     self.guide.apos[i], self.size * .05)

            self.upv.append(upv)
            self.ctr.append(ctr)
            self.off.append(off)
            self.addToGroup(upv, "hidden")
            self.addToGroup(ctr, "hidden")
            self.addToGroup(off, "hidden")

            # Collecting Percentage to evaluate the curve
            v = XSIMath.MapWorldPositionToObjectSpace(
                crv.Kinematics.Global.Transform, self.guide.pos[name])
            a = crv.ActivePrimitive.Geometry.GetClosestCurvePosition2(v)
            perc = crv.ActivePrimitive.Geometry.Curves(0).GetPercentageFromU(
                a[2])
            self.percentages.append(perc)

        # Constrained Curve -------------------------------
        self.cns_crv = []
        self.loc = []
        for i in range(self.crv_count):
            positions = []
            for crv, perc in zip(self.crv, self.percentages):

                if i < self.inter_crv:
                    perc = (i + 1.0) / (self.inter_crv + 1.0) * perc
                elif i > self.inter_crv:
                    perc = perc + (i - self.inter_crv) / (self.inter_crv +
                                                          1.0) * perc

                pos = crv.ActivePrimitive.Geometry.Curves(
                    0).EvaluatePositionFromPercentage(perc)[0]
                pos = XSIMath.MapObjectPositionToWorldSpace(
                    crv.Kinematics.Global.Transform, pos)
                positions.append(pos)

            positions.insert(
                1, vec.linearlyInterpolate(positions[0], positions[1], .1))
            positions.insert(
                -1, vec.linearlyInterpolate(positions[-2], positions[-1], .9))
            cns_crv = cur.addCurveFromPos(self.root,
                                          self.getName("cns%s_crv" % i),
                                          positions, False, 3)

            self.cns_crv.append(cns_crv)
            self.addToGroup(cns_crv, "hidden")

            # Shadows
            for j in range(self.shd_count):

                if i < self.inter_crv:
                    name = "%s_low%s" % (j, i)
                elif i == self.inter_crv:
                    name = str(j)
                elif i > self.inter_crv:
                    name = "%s_upp%s" % (j, i - self.inter_crv - 1)

                loc = pri.addNullFromPos(cns_crv, self.getName(name + "_loc"),
                                         XSIMath.CreateVector3(),
                                         self.size * .05)
                self.addShadow(loc, name)

                self.loc.append(loc)
                self.addToGroup(loc, "hidden")
Beispiel #36
0
    def addObjects(self):
        self.normal = self.guide.blades["blade"].z
        t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[2],
                                      self.normal, "zx", False)
        offsetRotation = XSIMath.CreateRotation()
        t.GetRotation(offsetRotation)
        self.tracking_lvl = pri.addNullFromPos(self.root,
                                               self.getName("tracking_lvl"),
                                               self.guide.apos[0],
                                               self.size * .15)
        self.addToGroup(self.tracking_lvl, "hidden")
        self.loc = pri.addNullsFromPositions(self.tracking_lvl,
                                             self.getName("#_loc"),
                                             self.guide.apos[3:],
                                             offsetRotation, self.size * .15)
        self.addToGroup(self.loc, "hidden")
        i = 0
        self.oDirDriverList = []
        self.oDirDrivenList = []
        self.oPointerLvlList = []
        self.oCornersList = []
        self.oUpDownList = []
        self.oSidesList = []

        for x in self.loc:
            t = x.Kinematics.Global.Transform
            self.coners_lvl = pri.addNull(x, self.getName("coners%s_lvl" % i),
                                          t, self.size * .15)
            self.upDown_lvl = pri.addNull(self.coners_lvl,
                                          self.getName("upDown%s_lvl" % i), t,
                                          self.size * .15)
            self.sides_lvl = pri.addNull(self.upDown_lvl,
                                         self.getName("sides%s_lvl" % i), t,
                                         self.size * .15)
            self.tweak_lvl = pri.addNull(self.sides_lvl,
                                         self.getName("tweak%s_lvl" % i), t,
                                         self.size * .15)
            t2 = tra.getTransformLookingAt(
                self.guide.apos[0], x.Kinematics.Global.Transform.Translation,
                self.normal, "xy", False)
            self.oPointer = pri.addNull(self.root,
                                        self.getName("pointer%s_loc" % i), t2,
                                        self.size * .15)
            self.oPointerLvl = pri.addNull(self.root,
                                           self.getName("pointer%s_lvl" % i),
                                           t, self.size * .15)
            self.shadow = self.addShadow(self.oPointerLvl, "%s" % i)
            self.oHiddenList = [
                self.coners_lvl, self.upDown_lvl, self.sides_lvl,
                self.oPointer, self.oPointerLvl, self.tweak_lvl
            ]
            self.addToGroup(self.oHiddenList, "hidden")
            self.oDirDriverList.append(self.tweak_lvl)
            self.oDirDrivenList.append(self.oPointer)
            self.oPointerLvlList.append(self.oPointerLvl)
            self.oCornersList.append(self.coners_lvl)
            self.oUpDownList.append(self.upDown_lvl)
            self.oSidesList.append(self.sides_lvl)

            i += 1

        self.cornerA_lvl = pri.addNullFromPos(self.root,
                                              self.getName("cornerA_lvl"),
                                              self.guide.apos[3],
                                              self.size * .15)
        self.cornerA = pri.addNullFromPos(self.cornerA_lvl,
                                          self.getName("cornerA"),
                                          self.guide.apos[3], self.size * .15)
        self.addToGroup(self.cornerA_lvl, "hidden")
        self.addToGroup(self.cornerA, "hidden")

        self.cornerB_lvl = pri.addNullFromPos(self.root,
                                              self.getName("cornerB_lvl"),
                                              self.guide.apos[-1],
                                              self.size * .15)
        self.cornerB = pri.addNullFromPos(self.cornerB_lvl,
                                          self.getName("cornerB"),
                                          self.guide.apos[-1], self.size * .15)
        self.addToGroup(self.cornerB_lvl, "hidden")
        self.addToGroup(self.cornerB, "hidden")

        self.upVec = pri.addNullFromPos(self.root, self.getName("upVec_loc"),
                                        self.guide.apos[1], self.size * .15)
        self.addToGroup(self.upVec, "hidden")

        self.mediumPosition = self.guide.apos[(
            (len(self.guide.apos) - 3) // 2) + 3]
        self.oTempPosY = XSIMath.CreateVector3()
        self.oTempPosY.X = self.mediumPosition.X
        self.oTempPosY.Y = self.mediumPosition.Y + 3
        self.oTempPosY.Z = self.mediumPosition.Z

        self.oTempPosZ = XSIMath.CreateVector3()
        self.oTempPosZ.X = self.mediumPosition.X
        self.oTempPosZ.Y = self.mediumPosition.Y
        self.oTempPosZ.Z = self.mediumPosition.Z + 3

        t = tra.getTransformLookingAt(self.mediumPosition, self.oTempPosZ,
                                      self.oTempPosY, "zy", self.negate)
        t.RotZ = 0.0

        self.control_lvl = pri.addNull(self.root,
                                       self.getName("eyelidCtl_lvl"), t,
                                       self.size * .15)
        self.addToGroup(self.control_lvl, "hidden")
        self.control = self.addCtl(self.control_lvl,
                                   "eyelid_ctl",
                                   t,
                                   self.color_ik,
                                   "square",
                                   w=self.size * .2)
Beispiel #37
0
    def addObjects(self):

        self.inter_shd = 1
        self.shd_count = self.inter_shd * 2 + 3
        self.inter_crv = 1
        self.crv_count = self.inter_crv * 2 + 1

        self.npo = []
        self.ctl = []

        self.crv = []
        self.upv = []
        self.ctr = []
        self.off = []
        self.cns_crv = []
        self.loc = []

        self.percentages = []

        for i, name, blade in zip(range(3), ["root", "mid_loc", "end_loc"], ["blade", "mid_blade", "end_blade"]):

            # Path ----------------------------------------
            crv = self.guide.prim["%s_crv"%i].create(self.root, self.getName("%s_crv"%i), None)
            xsi.SetNeutralPose(crv)

            self.crv.append(crv)
            self.addToGroup(crv, "hidden")

            if i == 0:
                y0 = cur.getGlobalPointPosition(0, crv).Y
                y1 = cur.getGlobalPointPosition(crv.ActivePrimitive.Geometry.Points.Count-1, crv).Y

                self.scale = (y1 - y0) * .5

            # Controlers ----------------------------------
            lookat = XSIMath.CreateVector3()
            lookat.Add(self.guide.pos[name], self.guide.blades[blade].x)
            if blade == "end_blade":
                axisPlane = "zx"
                axisNegate =  True
            else:
                axisPlane = "zx"
                axisNegate = False
            t = tra.getTransformLookingAt(self.guide.pos[name], lookat, self.guide.blades[blade].y, axisPlane, axisNegate)
            t.SetScaling(XSIMath.CreateVector3(self.scale, self.scale, self.scale))

            npo = pri.addNull(self.root, self.getName("%s_npo"%i), t, 1)
            pri.setNullDisplay(npo, 0, 1, 4, 0, 0, 0, .15, 2, 0)
            self.addToGroup(npo, "unselectable")

            ctl = self.addCtl(npo, "%s_ctl"%i, t, self.color_ik, "sphere", w=.2)
            xsi.SetNeutralPose(ctl)
            par.setKeyableParameters(ctl, ["posx", "posy", "posz", "rotx", "roty", "rotz", "rotorder", "sclx"])
            # par.addLocalParamToCollection(self.inv_params, ctl, ["posx", "roty", "rotz"]) # to be defined
            # par.setRotOrder(ctl, "XZY") # to be defined

            self.ctl.append(ctl)


            # Up Vector, Center, Offset -------------------
            v = XSIMath.CreateVector3(self.guide.blades[blade].x.X, self.guide.blades[blade].x.Y, self.guide.blades[blade].x.Z)
            v.ScaleInPlace(-self.size)
            v.AddInPlace(self.guide.pos[name])
            upv = pri.addNullFromPos(crv, self.getName("%s_upv")%i, v, self.size*.025)
            ctr = [pri.addNullFromPos(crv, self.getName("%s_%s_ctr"%(i,j)), self.guide.apos[i], self.size*.025) for j in range(3)]
            off = pri.addNullFromPos(ctr[1], self.getName("%s_off")%i, self.guide.apos[i], self.size*.05)

            self.upv.append(upv)
            self.ctr.append(ctr)
            self.off.append(off)
            self.addToGroup(upv, "hidden")
            self.addToGroup(ctr, "hidden")
            self.addToGroup(off, "hidden")

            # Collecting Percentage to evaluate the curve
            v = XSIMath.MapWorldPositionToObjectSpace(crv.Kinematics.Global.Transform, self.guide.pos[name])
            a = crv.ActivePrimitive.Geometry.GetClosestCurvePosition2(v)
            perc = crv.ActivePrimitive.Geometry.Curves(0).GetPercentageFromU(a[2])
            self.percentages.append(perc)

        # Constrained Curve -------------------------------
        self.cns_crv = []
        self.loc = []
        for i in range(self.crv_count):
            positions = []
            for crv, perc in zip(self.crv, self.percentages):

                if i < self.inter_crv:
                    perc = (i+1.0)/(self.inter_crv+1.0) * perc
                elif i > self.inter_crv:
                    perc = perc + (i-self.inter_crv)/(self.inter_crv+1.0) * perc

                pos = crv.ActivePrimitive.Geometry.Curves(0).EvaluatePositionFromPercentage(perc)[0]
                pos = XSIMath.MapObjectPositionToWorldSpace(crv.Kinematics.Global.Transform, pos)
                positions.append(pos)

            positions.insert(1, vec.linearlyInterpolate(positions[0], positions[1], .1))
            positions.insert(-1, vec.linearlyInterpolate(positions[-2], positions[-1], .9))
            cns_crv = cur.addCurveFromPos(self.root, self.getName("cns%s_crv"%i), positions, False, 3)

            self.cns_crv.append(cns_crv)
            self.addToGroup(cns_crv, "hidden")

            # Shadows
            for j in range(self.shd_count):

                if i < self.inter_crv:
                    name = "%s_low%s"%(j,i)
                elif i == self.inter_crv:
                    name = str(j)
                elif i > self.inter_crv:
                    name = "%s_upp%s"%(j,i-self.inter_crv-1)

                loc = pri.addNullFromPos(cns_crv, self.getName(name+"_loc"), XSIMath.CreateVector3(), self.size*.05)
                self.addShadow(loc, name)

                self.loc.append(loc)
                self.addToGroup(loc, "hidden")
Beispiel #38
0
    def addObjects(self):

        self.normal = self.getNormalFromPos(self.guide.apos[1:])

        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])
        self.length3 = vec.getDistance(self.guide.apos[3], self.guide.apos[4])

        # 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", w=1, h=self.size*.1, d=self.size*.1, po=XSIMath.CreateVector3(.5*self.n_factor,0,0))
        self.fk0_ctl.Kinematics.Global.Parameters("SclX").Value = self.length0
        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, "cube", w=1, h=self.size*.1, d=self.size*.1, po=XSIMath.CreateVector3(.5*self.n_factor,0,0))
        self.fk1_ctl.Kinematics.Global.Parameters("SclX").Value = self.length1
        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", w=1, h=self.size*.1, d=self.size*.1, po=XSIMath.CreateVector3(.5*self.n_factor,0,0))
        self.fk2_ctl.Kinematics.Global.Parameters("SclX").Value = self.length2
        xsi.SetNeutralPose(self.fk2_ctl, c.siST)
        par.setKeyableParameters(self.fk2_ctl)
        par.addLocalParamToCollection(self.inv_params, self.fk2_ctl, ["posx", "posy", "posz"])

        t = tra.getTransformLookingAt(self.guide.apos[3], self.guide.apos[4], self.normal, "xz", self.negate)
        self.fk3_ctl = self.addCtl(self.fk2_ctl, "fk3_ctl", t, self.color_fk, "cube", w=self.length3, h=self.size*.1, d=self.size*.1, po=XSIMath.CreateVector3(self.length3*.5*self.n_factor,0,0))
        xsi.SetNeutralPose(self.fk3_ctl, c.siST)
        par.setKeyableParameters(self.fk3_ctl)
        par.addLocalParamToCollection(self.inv_params, self.fk3_ctl, ["posx", "posy", "posz"])

        # IK Controlers ------------------------------------
        self.ik_cns = pri.addNullFromPos(self.root, self.getName("ik_cns"), self.guide.apos[3], 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)
        self.addToCtlGroup(self.ikcns_ctl)
        par.setKeyableParameters(self.ikcns_ctl)
        par.addLocalParamToCollection(self.inv_params, self.ikcns_ctl, ["posx", "rotx", "rotz"])

        t = tra.getTransformLookingAt(self.guide.apos[3], self.guide.apos[4], self.x_axis, "zx", False)
        self.ik_ctl = self.addCtl(self.ikcns_ctl, "ik_ctl", t, self.color_ik, "cube", h=self.size*.12, w=self.size*.12, d=self.length2, po=XSIMath.CreateVector3(0,0,self.length2*.5))
        par.setKeyableParameters(self.ik_ctl)
        par.addLocalParamToCollection(self.inv_params, self.ik_ctl, ["posx"])

        # Upv
        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"])

        # References ---------------------------------------
        # Ik ref
        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")

        # Fk ref
        self.fk_ref = pri.addNull(self.fk3_ctl, self.getName("fk_ref"), self.ik_ref.Kinematics.Global.Transform, self.size * .1)
        self.addToGroup(self.fk_ref, "hidden")

        # Roll Controler -----------------------------------
        if self.settings["roll"] == 0: # Roll with a controler
            self.roll_ctl = self.addCtl(self.root, "roll_ctl", self.ik_ctl.Kinematics.Global.Transform, self.color_ik, "bendedarrow2", w=self.length2*.5*self.n_factor, po=XSIMath.CreateVector3(0,self.length2*.5*self.n_factor,0))
            if self.negate:
                self.roll_ctl.Kinematics.Local.Parameters("rotx").Value = 180
                xsi.SetNeutralPose(self.roll_ctl)
            par.setKeyableParameters(self.roll_ctl, self.r_params)

        # Chain --------------------------------------------
        self.ref_chn = pri.add2DChain(self.root, self.getName("ref"), self.guide.apos[:3], self.normal, self.negate, self.size*.1, True)
        self.addToGroup(self.ref_chn.all, "hidden")

        self.end_chn = pri.add2DChain(self.ref_chn.bones[-1], self.getName("end"), self.guide.apos[2:4], self.normal, self.negate, self.size*.1, True)
        self.addToGroup(self.end_chn.all, "hidden")

        # Reference Nulls ---------------------------------
        self.ref_loc = []
        parent = self.root
        for i, ref in enumerate([self.fk0_ctl, self.fk1_ctl, self.fk2_ctl, self.fk_ref]):
            t = tra.getFilteredTransform(ref.Kinematics.Global.Transform, True, True, False)
            ref_loc = pri.addNull(parent, self.getName("ref%s_loc"%i), t, self.size*.1)
            self.addToGroup(ref_loc, "hidden")
            self.ref_loc.append(ref_loc)

            parent = ref_loc

        # Mid Controler ------------------------------------
        self.ctrn0_loc = pri.addNullFromPos(self.ref_loc[0], self.getName("ctrn0_loc"), self.guide.apos[1], self.size*.05)
        self.ctrn1_loc = pri.addNullFromPos(self.ref_loc[1], self.getName("ctrn1_loc"), self.guide.apos[2], self.size*.05)

        self.addToGroup([self.ctrn0_loc, self.ctrn1_loc], "hidden")

        self.mid0_ctl = self.addCtl(self.ctrn0_loc, "mid0_ctl", self.ctrn0_loc.Kinematics.Global.Transform, self.color_ik, "sphere", h=self.size*.1)
        par.addLocalParamToCollection(self.inv_params, self.mid0_ctl, ["posx", "posy", "posz"])
        self.mid1_ctl = self.addCtl(self.ctrn1_loc, "mid1_ctl", self.ctrn1_loc.Kinematics.Global.Transform, self.color_ik, "sphere", h=self.size*.1)
        par.addLocalParamToCollection(self.inv_params, self.mid1_ctl, ["posx", "posy", "posz"])

        # Twist references ---------------------------------
        t = tra.getTransformLookingAt(self.guide.apos[0], self.guide.apos[1], self.normal, "xz", self.negate)
        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.ctrn0_loc, self.getName("tws1_loc"), self.ctrn0_loc.Kinematics.Global.Transform, self.size*.05)
        self.tws1_rot = pri.addNull(self.tws1_loc, self.getName("tws1_rot"), self.ctrn0_loc.Kinematics.Global.Transform)
        pri.setNullDisplay(self.tws1_rot, 0, self.size*.05, 2, 0, 0, 0, self.size*.01)

        self.tws2_loc = pri.addNull(self.ctrn1_loc, self.getName("tws2_loc"), self.ctrn1_loc.Kinematics.Global.Transform, self.size*.05)
        self.tws2_rot = pri.addNull(self.tws2_loc, self.getName("tws2_rot"), self.ctrn1_loc.Kinematics.Global.Transform)
        pri.setNullDisplay(self.tws2_rot, 0, self.size*.05, 2, 0, 0, 0, self.size*.01)

        t = tra.getFilteredTransform(self.ref_loc[-2].Kinematics.Global.Transform, True, True, False)
        t.SetTranslation(self.guide.apos[3])
        self.tws3_loc = pri.addNull(self.ref_loc[-1], self.getName("tws3_loc"), t, self.size*.05)
        self.tws3_rot = pri.addNull(self.tws3_loc, self.getName("tws3_rot"),t)
        self.tws3_rot.Kinematics.Global.Parameters("SclX").Value = .001
        pri.setNullDisplay(self.tws3_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, self.tws3_loc, self.tws3_rot], "hidden")

        # End reference ------------------------------------
        t = tra.getFilteredTransform(self.tws3_rot.Kinematics.Global.Transform, True, True, False)
        self.end_ref = pri.addNull(self.tws3_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"] + self.settings["div2"] + 4

        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)
Beispiel #39
0
    def addObjects(self):

        self.normal = self.guide.blades["blade"].z
        self.binormal = self.guide.blades["blade"].x

        self.division = len(self.guide.apos) - 1

        # FK controlers ------------------------------------
        self.fk_ctl = []
        parent = self.root
        for i, t in enumerate(
                tra.getChainTransform(self.guide.apos, self.normal,
                                      self.negate)):
            dist = vec.getDistance(self.guide.apos[i], self.guide.apos[i + 1])
            fk_ctl = self.addCtl(parent,
                                 "fk%s_ctl" % i,
                                 t,
                                 self.color_fk,
                                 "cube",
                                 w=dist,
                                 h=self.size * .25,
                                 d=self.size * .25,
                                 po=XSIMath.CreateVector3(
                                     dist * .5 * self.n_factor, 0, 0))
            xsi.SetNeutralPose(fk_ctl, c.siTrn)
            par.setKeyableParameters(fk_ctl)
            par.addLocalParamToCollection(self.inv_params, fk_ctl,
                                          ["posx", "posy", "posz"])

            parent = fk_ctl
            self.fk_ctl.append(fk_ctl)

        xsi.SetNeutralPose(self.fk_ctl[0])

        # Chain -------------------------------------------
        parent = self.fk_ctl[0]
        self.chain = []
        for i in range(self.division):
            pos = [self.guide.apos[i], self.guide.apos[i + 1]]
            chain = pri.add2DChain(parent, self.getName("spring%s" % i), pos,
                                   self.normal, self.negate, self.size * .25,
                                   True)
            self.addToGroup(chain.all, "hidden")

            eff_ref = pri.addNull(chain.root, self.getName("eff%s_ref" % i),
                                  chain.eff.Kinematics.Global.Transform,
                                  self.size * .1)
            eff_ref.AddChild(chain.eff)
            self.addToGroup(eff_ref, "hidden")

            self.addShadow(chain.bones[0], i)

            self.chain.append(chain)
            parent = chain.bones[0]

        # Plot Reference ----------------------------------
        self.ref = pri.addNullChain(self.root, self.getName("#_ref"),
                                    self.guide.apos, self.normal, self.negate,
                                    self.size * .1)
        self.addToGroup(self.ref, "hidden")
        xsi.SetNeutralPose(self.ref[0])
Beispiel #40
0
    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")
Beispiel #41
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)