예제 #1
0
def gear_pathdriver_op(out, max, min, perc, driver):

    # -----------------------------------------------------
    # JSCRIPT
    paramDefs = []
    paramDefs.append(
        XSIFactory.CreateParamDef("max", c.siDouble, 0,
                                  c.siPersistable | c.siAnimatable, "", "",
                                  max, None, None, 0, 1))
    paramDefs.append(
        XSIFactory.CreateParamDef("min", c.siDouble, 0,
                                  c.siPersistable | c.siAnimatable, "", "",
                                  min, None, None, -1, 0))
    paramDefs.append(
        XSIFactory.CreateParamDef("percentage", c.siDouble, 0,
                                  c.siPersistable | c.siAnimatable, "", "",
                                  perc, 0, 100, 0, 100))
    paramDefs.append(
        XSIFactory.CreateParamDef("driver", c.siDouble, 0,
                                  c.siPersistable | c.siAnimatable, "", "", 0,
                                  None, None, -1, 1))

    outputPorts = [(out, "out")]
    inputPorts = []

    op = createJSOpFromFile("gear_pathdriver",
                            os.path.join(JSOPPATH, "gear_pathdriver_op.js"),
                            outputPorts, inputPorts, paramDefs)

    op.Connect()

    par.addExpression(op.Parameters("driver"), driver)

    return op
예제 #2
0
def gear_MatchGeometryOp_Define(ctxt):

    op = ctxt.Source

    pdef = XSIFactory.CreateParamDef("blend", c.siDouble, 0, c.siPersistable | c.siAnimatable, "", "",1,-100,100,0,1)
    op.AddParameter(pdef)
    pdef = XSIFactory.CreateParamDef("mode", c.siInt4, 0, c.siPersistable | c.siAnimatable, "", "",0,0,1,0,1)
    op.AddParameter(pdef)

    op.AlwaysEvaluate = False
    op.Debug = 0

    return True
예제 #3
0
def gear_SymmetrizePointsOp_Define(ctxt):

    op = ctxt.Source

    pdef = XSIFactory.CreateParamDef("axis", c.siInt4, 0, c.siPersistable|c.siAnimatable, "" , "" , 0, 0, 2, 0, 2)
    op.AddParameter(pdef)
    pdef = XSIFactory.CreateParamDef("mirror", c.siBool, 0, c.siPersistable|c.siAnimatable, "" , "" , False)
    op.AddParameter(pdef)

    op.AlwaysEvaluate = False
    op.Debug = 0

    return True
예제 #4
0
def gear_CopyWeightsOp_Define(ctxt):

    op = ctxt.Source
    op.AlwaysEvaluate = False
    op.Debug = 0

    pdef = XSIFactory.CreateParamDef("Blend", c.siDouble, 0,
                                     c.siPersistable | c.siAnimatable, "", "",
                                     1, 0, 1, 0, 1)
    op.AddParameter(pdef)
    pdef = XSIFactory.CreateParamDef("Index", c.siInt4, 0,
                                     c.siPersistable | c.siReadOnly, "", "")
    op.AddParameter(pdef)

    return True
예제 #5
0
def gear_resampler_op(out_crv, crv=None, start=0, end=1, parametric=0, mode=0):

    if crv is None:
        crv = out_crv

    # -----------------------------------------------------
    # JSCRIPT
    paramDefs = []
    paramDefs.append(
        XSIFactory.CreateParamDef("start", c.siDouble, 0,
                                  c.siPersistable | c.siAnimatable, "", "",
                                  start, 0, 1, 0, 1))
    paramDefs.append(
        XSIFactory.CreateParamDef("end", c.siDouble, 0,
                                  c.siPersistable | c.siAnimatable, "", "",
                                  end, 0, 1, 0, 1))
    paramDefs.append(
        XSIFactory.CreateParamDef("parametric", c.siInt4, 0,
                                  c.siPersistable | c.siAnimatable, "", "",
                                  parametric, 0, 1, 0, 1))
    paramDefs.append(
        XSIFactory.CreateParamDef("mode", c.siInt4, 0,
                                  c.siPersistable | c.siAnimatable, "", "",
                                  mode, 0, 1, 0, 1))

    outputPorts = [(out_crv.ActivePrimitive, "out")]
    inputPorts = [(out_crv.ActivePrimitive, "in_crv"),
                  (out_crv.Kinematics.Global, "in_crv_kine"),
                  (crv.ActivePrimitive, "ref_crv"),
                  (crv.Kinematics.Global, "ref_crv_kine")]

    op = createJSOpFromFile("gear_resampler",
                            os.path.join(JSOPPATH, "gear_resampler_op.js"),
                            outputPorts, inputPorts, paramDefs)

    op.Connect()

    layout = op.PPGLayout
    layout.Clear()

    layout.AddGroup("Percentage")
    layout.AddEnumControl("Parametric", ["Percentage", 0, "Parametric", 1])
    layout.AddEnumControl("Mode", ["Local", 0, "Global", 1])
    layout.AddItem("Start")
    layout.AddItem("End")
    layout.EndGroup()

    return op
예제 #6
0
def gear_pointAtObjectAxis(cns, ref, axis=[0, 1, 0]):

    if cns.Parameters("tangent"):
        cns.Parameters("tangent").Value = True

    cns.Parameters("upvct_active").Value = True

    # -----------------------------------------------------
    # JSCRIPT
    paramDefs = [
        XSIFactory.CreateParamDef(s, c.siDouble, 0,
                                  c.siPersistable | c.siAnimatable, "", "", d,
                                  -1, 1, -1, 1) for d, s in zip(axis, "xyz")
    ]

    outputPorts = [(cns.Parameters("pointat%s" % s), "out_%s" % s)
                   for s in "xyz"]
    inputPorts = [(ref.Kinematics.Global, "kine")]

    op = createJSOpFromFile(
        "gear_pointAtObjectAxis",
        os.path.join(JSOPPATH, "gear_pointAtObjectAxis_op.js"), outputPorts,
        inputPorts, paramDefs)

    # Connect
    op.Connect()

    return op
예제 #7
0
def gear_SmoothShapeOp_Define(ctxt):

    op = ctxt.Source
    op.AlwaysEvaluate = False
    op.Debug = 0

    pdef = XSIFactory.CreateParamDef("NeighbourDepth", c.siInt4, 0,
                                     c.siPersistable | c.siAnimatable, "", "",
                                     1, 1, 10, 1, 10)
    op.AddParameter(pdef)
    pdef = XSIFactory.CreateParamDef("Blend", c.siDouble, 0,
                                     c.siPersistable | c.siAnimatable, "", "",
                                     1, 0, 1, 0, 1)
    op.AddParameter(pdef)

    return True
예제 #8
0
def gear_ScaleShapeOp_Define(ctxt):

    op = ctxt.Source
    op.AlwaysEvaluate = False
    op.Debug = 0

    pdef = XSIFactory.CreateParamDef("Scale", c.siDouble, 0,
                                     c.siPersistable | c.siAnimatable, "", "",
                                     .5, -100, 100, 0, 1)
    op.AddParameter(pdef)

    return True
예제 #9
0
def sn_pointAt_op(out_obj, target, upv):

    # -----------------------------------------------------
    # JSCRIPT
    paramDefs = []
    paramDefs.append(
        XSIFactory.CreateParamDef("offset", c.siDouble, 0,
                                  c.siPersistable | c.siAnimatable, "", "", 0,
                                  -180, 180, -90, 90))

    outputPorts = [(out_obj.Kinematics.Global, "out")]
    inputPorts = [(out_obj.Kinematics.Global, "out"),
                  (target.Kinematics.Global, "in_target"),
                  (upv.Kinematics.Global, "in_upv")]

    op = createJSOpFromFile("sn_pointAt_op",
                            os.path.join(JSOPPATH, "sn_pointAt_op.js"),
                            outputPorts, inputPorts, paramDefs)

    op.Connect()

    return op
예제 #10
0
def gear_slerp_op(out, refA, refB, blend=.5):

    # -----------------------------------------------------
    # JSCRIPT
    paramDefs = []
    paramDefs.append(
        XSIFactory.CreateParamDef("blend", c.siDouble, 0,
                                  c.siPersistable | c.siAnimatable, "", "",
                                  blend, 0, 1, 0, 1))

    outputPorts = [(out.Kinematics.Global, "out")]
    inputPorts = [(out.Kinematics.Global, "in_obj"),
                  (refA.Kinematics.Global, "refA"),
                  (refB.Kinematics.Global, "refB")]

    op = createJSOpFromFile("gear_slerp",
                            os.path.join(JSOPPATH, "gear_slerp_op.js"),
                            outputPorts, inputPorts, paramDefs)

    op.Connect()

    return op
예제 #11
0
def gear_dualUpVDirCns(cns, ref, target, negate=False):

    # -----------------------------------------------------
    # JSCRIPT
    paramDefs = []
    paramDefs.append(
        XSIFactory.CreateParamDef("negate", c.siBool, 0,
                                  c.siPersistable | c.siAnimatable, "", "",
                                  negate))

    outputPorts = [(cns.Kinematics.Global, "out")]
    inputPorts = [(cns.Kinematics.Global, "kcns"),
                  (ref.Kinematics.Global, "kref"),
                  (target.Kinematics.Global, "ktar")]

    op = createJSOpFromFile("gear_dualUpVDirCns",
                            os.path.join(JSOPPATH, "gear_dualUpVDirCns_op.js"),
                            outputPorts, inputPorts, paramDefs)

    # Connect
    op.Connect()

    return op
예제 #12
0
def sn_ikfk2bone_op(out=[],
                    root=None,
                    eff=None,
                    upv=None,
                    fk0=None,
                    fk1=None,
                    fk2=None,
                    lengthA=5,
                    lengthB=3,
                    negate=False,
                    blend=0,
                    lang=CPP):

    # -----------------------------------------------------
    if lang == CPP:
        # Create Operator
        op = XSIFactory.CreateObject("sn_ikfk2bone_op")

        # Outputs
        for i, s in enumerate(["OutBoneA", "OutBoneB", "OutCenterN",
                               "OutEff"]):
            if len(out) > i and out[i] is not None:
                op.AddOutputPort(out[i].Kinematics.Global, s)

        # Inputs
        op.AddInputPort(root.Kinematics.Global)
        op.AddInputPort(eff.Kinematics.Global)
        op.AddInputPort(upv.Kinematics.Global)
        op.AddInputPort(fk0.Kinematics.Global)
        op.AddInputPort(fk1.Kinematics.Global)
        op.AddInputPort(fk2.Kinematics.Global)

    # -----------------------------------------------------
    elif lang == JSCRIPT:

        paramDefs = []
        paramDefs.append(
            XSIFactory.CreateParamDef("lengthA", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      3, 0, None, 0, 10))
        paramDefs.append(
            XSIFactory.CreateParamDef("lengthB", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      5, 0, None, 0, 10))
        paramDefs.append(
            XSIFactory.CreateParamDef("negate", c.siBool, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      False))
        paramDefs.append(
            XSIFactory.CreateParamDef("blend", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      0, 0, 1, 0, 1))
        paramDefs.append(
            XSIFactory.CreateParamDef("roll", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      0, -360, 360, -360, 360))
        paramDefs.append(
            XSIFactory.CreateParamDef("scaleA", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      1, 0, None, 0, 2))
        paramDefs.append(
            XSIFactory.CreateParamDef("scaleB", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      1, 0, None, 0, 2))
        paramDefs.append(
            XSIFactory.CreateParamDef("maxstretch", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      1, 1, None, 1, 2))
        paramDefs.append(
            XSIFactory.CreateParamDef("softness", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      0, 0, None, 0, 1))
        paramDefs.append(
            XSIFactory.CreateParamDef("slide", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      0.5, 0, 1, 0, 1))
        paramDefs.append(
            XSIFactory.CreateParamDef("reverse", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      0, 0, 1, 0, 1))

        outputPorts = [(out[i].Kinematics.Global, name)
                       for i, name in enumerate(
                           ["OutBoneA", "OutBoneB", "OutCenterN", "OutEff"])
                       if (len(out) > i and out[i] is not None)]
        inputPorts = [(obj.Kinematics.Global, "input_%s" % i)
                      for i, obj in enumerate([root, eff, upv, fk0, fk1, fk2])]

        op = createJSOpFromFile("sn_ikfk2bone_op",
                                os.path.join(JSOPPATH, "sn_ikfk2bone_op.js"),
                                outputPorts, inputPorts, paramDefs)

    # -----------------------------------------------------
    # Set default values
    op.Parameters("negate").Value = negate
    op.Parameters("lengthA").Value = lengthA
    op.Parameters("lengthB").Value = lengthB
    op.Parameters("blend").Value = blend

    # Connect
    op.Connect()

    return op
예제 #13
0
def sn_curveslide2_op(outcrv,
                      incrv,
                      position=0,
                      maxstretch=1,
                      maxsquash=1,
                      softness=0,
                      lang=CPP):

    inlength = incrv.ActivePrimitive.Geometry.Length

    # CPP -----------------------------------------------
    if lang == CPP:
        # Create Operator
        op = XSIFactory.CreateObject("sn_curveslide2_op")

        # IO
        op.AddIOPort(outcrv.ActivePrimitive)
        op.AddInputPort(incrv.ActivePrimitive)

        # Set default values
        op.Parameters("mstlength").Value = inlength
        op.Parameters("slvlength").Value = inlength
        op.Parameters("position").Value = position
        op.Parameters("maxstretch").Value = maxstretch
        op.Parameters("maxsquash").Value = maxsquash
        op.Parameters("softness").Value = softness

        # Connect
        op.Connect()

    # JSCRIPT -------------------------------------------
    elif lang == JSCRIPT:

        paramDefs = []
        paramDefs.append(
            XSIFactory.CreateParamDef("mstlength", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      inlength, 0, None, inlength * .5,
                                      inlength * 2))
        paramDefs.append(
            XSIFactory.CreateParamDef("slvlength", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      inlength, 0, None, inlength * .5,
                                      inlength * 2))
        paramDefs.append(
            XSIFactory.CreateParamDef("position", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      position, 0, 1, 0, 1))
        paramDefs.append(
            XSIFactory.CreateParamDef("maxstretch", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      maxstretch, 0, None, 0, 3))
        paramDefs.append(
            XSIFactory.CreateParamDef("maxsquash", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      maxsquash, 0, 1, 0, 1))
        paramDefs.append(
            XSIFactory.CreateParamDef("softness", c.siDouble, 0,
                                      c.siPersistable | c.siAnimatable, "", "",
                                      softness, 0, 1, 0, 1))

        outputPorts = [(outcrv.ActivePrimitive, "out")]
        inputPorts = [(outcrv.ActivePrimitive, "in_crv"),
                      (incrv.ActivePrimitive, "ref_crv")]

        op = createJSOpFromFile(
            "gear_curveslide2", os.path.join(JSOPPATH,
                                             "gear_curveslide2_op.js"),
            outputPorts, inputPorts, paramDefs)

        op.Connect()

        layout = op.PPGLayout
        layout.Clear()

        layout.AddGroup("Default")
        layout.AddItem("slvlength", "Slave Length")
        layout.AddItem("mstlength", "Master Length")
        layout.EndGroup()
        layout.AddGroup("Animate")
        layout.AddItem("position", "Position")
        layout.AddItem("maxstretch", "Max Stretch")
        layout.AddItem("maxsquash", "Max Squash")
        layout.AddItem("softness", "Softness")
        layout.EndGroup()

    return op
예제 #14
0
def gear_zipper_op(crv0, crv1):

    # -----------------------------------------------------
    # JSCRIPT
    paramDefs = []
    paramDefs.append(
        XSIFactory.CreateParamDef("zip", c.siDouble, 0,
                                  c.siPersistable | c.siAnimatable, "", "", 0,
                                  0, 1, 0, 1))
    paramDefs.append(
        XSIFactory.CreateParamDef("bias", c.siDouble, 0,
                                  c.siPersistable | c.siAnimatable, "", "", .5,
                                  0, 1, 0, 1))
    paramDefs.append(XSIFactory.CreateFCurveParamDef("start_fcv"))
    paramDefs.append(XSIFactory.CreateFCurveParamDef("speed_fcv"))

    outputPorts = [(crv0.ActivePrimitive, "out_0"),
                   (crv1.ActivePrimitive, "out_1")]
    inputPorts = [(crv0.ActivePrimitive, "crv0"),
                  (crv1.ActivePrimitive, "crv1")]

    op = createJSOpFromFile("gear_zipper",
                            os.path.join(JSOPPATH, "gear_zipper_op.js"),
                            outputPorts, inputPorts, paramDefs)

    op.Connect()

    # FCurve profile
    fcv.drawFCurve(
        op.Parameters("start_fcv").Value, [[0, 0], [1, 1]],
        c.siLinearKeyInterpolation)
    fcv.drawFCurve(
        op.Parameters("speed_fcv").Value, [[0, 0], [1, 1]],
        c.siLinearKeyInterpolation)

    # Layout
    layout = op.PPGLayout
    layout.Clear()

    layout.AddGroup("Zipper")
    layout.AddItem("Mute", "Mute")
    layout.AddItem("zip", "Zip")
    layout.AddItem("bias", "Bias")
    layout.EndGroup()

    layout.AddGroup("Profile")
    item = layout.AddFCurve("start_fcv")
    item.SetAttribute(c.siUIFCurveLabelX, "Points")
    item.SetAttribute(c.siUIFCurveLabelY, "Start")
    item.SetAttribute(c.siUIFCurveViewMinX, -.1)
    item.SetAttribute(c.siUIFCurveViewMaxX, 1.1)
    item.SetAttribute(c.siUIFCurveViewMinY, -.1)
    item.SetAttribute(c.siUIFCurveViewMaxY, 1.1)
    item.SetAttribute(c.siUIFCurveGridSpaceX, .1)
    item.SetAttribute(c.siUIFCurveGridSpaceY, .1)
    layout.EndGroup()

    layout.AddGroup("Speed")
    item = layout.AddFCurve("speed_fcv")
    item.SetAttribute(c.siUIFCurveLabelX, "Points")
    item.SetAttribute(c.siUIFCurveLabelY, "Speed")
    item.SetAttribute(c.siUIFCurveViewMinX, -.1)
    item.SetAttribute(c.siUIFCurveViewMaxX, 2.1)
    item.SetAttribute(c.siUIFCurveViewMinY, -.1)
    item.SetAttribute(c.siUIFCurveViewMaxY, 1.1)
    item.SetAttribute(c.siUIFCurveGridSpaceX, .1)
    item.SetAttribute(c.siUIFCurveGridSpaceY, .1)
    layout.EndGroup()

    return op