Пример #1
0
def fixEuler():
    print('fixEuler')
    animCurves = cmds.ls(type='animCurve')
    for each in animCurves:
        try:
            cmds.rotationInterpolation(each, c='none')
        except Exception:
            pass
Пример #2
0
def csl_quaternionSlerp():
    selectCtrls = mc.ls(sl=1, l=1)
    for selectCtrl in selectCtrls:
        selectCtrlAttrs = mc.keyframe(selectCtrl, query=True, name=True)
        if selectCtrlAttrs == None:
            mc.error(u'【所选物体无动画曲线】==' + selectCtrl)
        else:
            for selectCtrlAttr in selectCtrlAttrs:
                if "_rotate" in selectCtrlAttr:
                    mc.rotationInterpolation(selectCtrlAttr,
                                             convert='quaternionSlerp')
                    print(u'==【成功转为四元数】==' + selectCtrlAttr)
Пример #3
0
 def testInterpolation(curves):
     print '\nTESTING INTERPOLATION MODES\n'
     errors = 0
     for interp in [
             'none', 'euler', 'quaternion', 'quaternionSlerp',
             'quaternionSquad'
     ]:
         print "### Checking {} interpolation mode".format(
             string.upper(interp))
         for curve in curves:
             cmds.rotationInterpolation(curve, convert=interp)
             errors += verifyCurve(curve)
     return errors
Пример #4
0
def _quat_filter(transforms):
    """Unroll rotations by converting to quaternions and back to euler"""
    rotate_channels = []

    def is_keyed(plug):
        return plug.input(type="animCurveTA") is not None

    for transform in transforms:
        # Can only unroll transform with all axes keyed
        if not all(is_keyed(transform[ch]) for ch in ("rx", "ry", "rz")):
            continue

        rotate_channels += ["%s.rx" % transform]
        rotate_channels += ["%s.ry" % transform]
        rotate_channels += ["%s.rz" % transform]

    cmds.rotationInterpolation(rotate_channels, c="quaternionSlerp")
    cmds.rotationInterpolation(rotate_channels, c="none")
Пример #5
0
def rotationInterpolationMethod(curve):
    """Convert curve interpolation method to an enum value accepted by the library"""
    method = cmds.rotationInterpolation(curve, c=True, q=True)
    switcher = {
        "none": 0,
        "euler": 1,
        "quaternionSlerp": 2,
        "quaternion": 3,
        "quaternionSquad": 4
    }
    return switcher.get(method, 0)
Пример #6
0
def _quat_filter(transforms):
    """Unroll rotations by converting to quaternions and back to euler"""
    rotate_channels = []

    for transform in transforms:
        # Can only unroll transform with all axes keyed
        if not all(_is_keyed(transform[ch]) for ch in ("rx", "ry", "rz")):
            continue

        rotate_channels += ["%s.rx" % transform]
        rotate_channels += ["%s.ry" % transform]
        rotate_channels += ["%s.rz" % transform]

    try:
        cmds.rotationInterpolation(rotate_channels, c="quaternionSlerp")
        cmds.rotationInterpolation(rotate_channels, c="none")
    except Exception:
        log.info(traceback.format_exc())
        log.warning("Had trouble applying the Euler filter, "
                    "check the Script Editor for details.")
Пример #7
0
def testCurves():
    """ Testing suite function that will generate a random animation for a cube and run
    checks whether the values evaluated by the animation library match Maya's. The test
    will iterate over all infinity and tangent types as well as interpolation methods
    for rotation curves"""

    cmds.file(f=True, new=True)
    name = 'cube'

    # generate random animation for the cube
    cmds.polyCube(name=name)

    cmds.currentTime(-10)
    cmds.move(rand.uniform(-100.0, 100.0),
              rand.uniform(-100.0, 100.0),
              rand.uniform(-100.0, 100.0),
              name,
              a=True)
    cmds.rotate(rand.uniform(-360.0, 360.0),
                rand.uniform(-360.0, 360.0),
                rand.uniform(-360.0, 360.0),
                name,
                a=True)
    cmds.setKeyframe(name)

    cmds.currentTime(0)
    cmds.move(rand.uniform(-100.0, 100.0),
              rand.uniform(-100.0, 100.0),
              rand.uniform(-100.0, 100.0),
              name,
              a=True)
    cmds.rotate(rand.uniform(-360.0, 360.0),
                rand.uniform(-360.0, 360.0),
                rand.uniform(-360.0, 360.0),
                name,
                a=True)
    cmds.setKeyframe(name)

    cmds.currentTime(10)
    cmds.move(rand.uniform(-100.0, 100.0),
              rand.uniform(-100.0, 100.0),
              rand.uniform(-100.0, 100.0),
              name,
              a=True)
    cmds.rotate(rand.uniform(-360.0, 360.0),
                rand.uniform(-360.0, 360.0),
                rand.uniform(-360.0, 360.0),
                name,
                a=True)
    cmds.setKeyframe(name)

    cmds.currentTime(20)
    cmds.move(rand.uniform(-100.0, 100.0),
              rand.uniform(-100.0, 100.0),
              rand.uniform(-100.0, 100.0),
              name,
              a=True)
    cmds.rotate(rand.uniform(-360.0, 360.0),
                rand.uniform(-360.0, 360.0),
                rand.uniform(-360.0, 360.0),
                name,
                a=True)
    cmds.setKeyframe(name)

    cmds.currentTime(30)
    cmds.move(rand.uniform(-100.0, 100.0),
              rand.uniform(-100.0, 100.0),
              rand.uniform(-100.0, 100.0),
              name,
              a=True)
    cmds.rotate(rand.uniform(-360.0, 360.0),
                rand.uniform(-360.0, 360.0),
                rand.uniform(-360.0, 360.0),
                name,
                a=True)
    cmds.setKeyframe(name)

    curves = [
        name + '_translateX', name + '_rotateX', name + '_rotateY',
        name + '_rotateZ', name + '_visibility'
    ]

    rotCurves = [
        name + '_rotateX',
        name + '_rotateY',
        name + '_rotateZ',
    ]

    infinities = ['constant', 'linear', 'cycle', 'cycleRelative', 'oscillate']

    tangents = [
        'linear', 'fast', 'slow', 'flat', 'step', 'stepnext', 'fixed',
        'clamped', 'plateau', 'spline'
    ]

    interpolation = [
        'none', 'euler', 'quaternion', 'quaternionSlerp', 'quaternionSquad'
    ]

    errors = 0

    print '\nTESTING INFINITY MODES\n'

    for inf in infinities:
        print "### Checking infinity mode: {}".format(inf)
        for curve in curves:
            cmds.setInfinity(curve, pri=inf, poi=inf)
            errors += verifyCurve(curve)

    print '\nTESTING TANGENT TYPES\n'

    for tan in tangents:
        print "### Checking tangent: {}".format(tan)
        cmds.keyTangent(curves, edit=True, time=(':', ), itt=tan, ott=tan)
        for curve in curves:
            errors += verifyCurve(curve)

    print '\nTESTING INTERPOLATION MODES\n'

    for int in interpolation:
        print "### Checking interpolation mode: {}".format(int)
        for curve in rotCurves:
            cmds.rotationInterpolation(curve, convert=int)

        if int == "none" or int == "euler":
            for curve in rotCurves:
                errors += verifyCurve(curve)
        else:
            errors += verifyCurveQuaternion(rotCurves[0], rotCurves[1],
                                            rotCurves[2])

    print "\nTotal errors: {}".format(errors)
Пример #8
0
def utilityGetCurveInterpolation(curvePath):
    try:
        cmds.rotationInterpolation(curvePath, q=True)
    except RuntimeError:
        return "none"
Пример #9
0
def utilitySetCurveInterpolation(curvePath, mode="none"):
    try:
        cmds.rotationInterpolation(curvePath, convert=mode)
    except RuntimeError:
        pass
Пример #10
0
for each in cmds.ls(sl=1):
    cmds.setAttr(each+'.template', 1)
    
cmds.addAttr("bs_lid_r.crv_open_out_up_lid_r",min=0,max=1)
###connect scale###
for each in cmds.ls(sl=1):
    cmds.connectAttr('ctrl_root.GlobalScale', each+'.scaleX')
    cmds.connectAttr('ctrl_root.GlobalScale', each+'.scaleY')
    cmds.connectAttr('ctrl_root.GlobalScale', each+'.scaleZ')
    
###Fix Synchronized euler on all####
import maya.cmds as cmds
animCurves=cmds.ls(type='animCurve')    
for each in animCurves:
    try:
        cmds.rotationInterpolation(each,c='none')
    except Exception:
        pass
#####
    
for each in cmds.ls(sl=1):
 to jnt_LeftThumb1.

for each in cmds.ls(sl=1):
    cmds.connectAttr ('ctrl_root.visibilityleftarm', each+'.scale.scaleX',f=1)
    cmds.connectAttr ('ctrl_root.visibilityleftarm', each+'.scale.scaleY',f=1)
    cmds.connectAttr ('ctrl_root.visibilityleftarm', each+'.scale.scaleZ',f=1)
    
for each in cmds.ls(sl=1):   
    cmds.setAttr(each+".inputAttractMethod",1)
    cmds.setAttr(each+".inputAttractMapType",1)