Esempio n. 1
0
    def parseMatrixAttribute(self, name, shortName, attrInfo):
        """
		Given a JSON subsection describing a matrix attribute create the
		attribute and set all of the provided flags/members for it.
			name = Attribute long name
			shortName = Attribute short name
			attrInfo = JSON object containing the main attribute information
		"""
        jsonDebug('parseMatrixAttribute(%s)' % name)

        matrixType = JsonKeys.kTypeMatrixTypes[attrInfo[JsonKeys.kKeyAttrType]]
        if JsonKeys.kKeyDefault in attrInfo:
            jsonDebug('Setting the matrix default to "%s"' %
                      attrInfo[JsonKeys.kKeyDefault])
            mDefault = omAPI.MFnMatrixData()
            defaultValue = mDefault.create(
                omAPI.MMatrix(attrInfo[JsonKeys.kKeyDefault]))
            mAttr = omAPI.MFnMatrixAttribute(defaultValue)
            attr = mAttr.create(name, shortName, matrixType)
        else:
            jsonDebug('Creating matrix attribute with no default')
            mAttr = omAPI.MFnMatrixAttribute()
            attr = mAttr.create(name, shortName, matrixType)

        return attr
    def initialize():
        nAttr = om.MFnMatrixAttribute()
        distanceTerrainNode.terrainMatrix = nAttr.create(
            'terrainMatrix', 'terrainMtrx')
        nAttr.storable = True

        nAttr = om.MFnTypedAttribute()
        distanceTerrainNode.terrain = nAttr.create('terrain', 'terrain',
                                                   om.MFnData.kMesh)
        nAttr.storable = True
        nAttr.writable = True

        nAttr = om.MFnNumericAttribute()
        distanceTerrainNode.jointPos = nAttr.create('jointPosition',
                                                    'jointPos',
                                                    om.MFnNumericData.k3Float,
                                                    0)
        nAttr.storable = True
        nAttr.writable = True
        nAttr = om.MFnNumericAttribute()
        distanceTerrainNode.distance = nAttr.create('distance', 'distance',
                                                    om.MFnNumericData.kFloat,
                                                    0)

        distanceTerrainNode.addAttribute(distanceTerrainNode.terrainMatrix)
        distanceTerrainNode.addAttribute(distanceTerrainNode.terrain)
        distanceTerrainNode.addAttribute(distanceTerrainNode.jointPos)
        distanceTerrainNode.addAttribute(distanceTerrainNode.distance)
        distanceTerrainNode.attributeAffects(distanceTerrainNode.terrainMatrix,
                                             distanceTerrainNode.distance)
        distanceTerrainNode.attributeAffects(distanceTerrainNode.terrain,
                                             distanceTerrainNode.distance)
        distanceTerrainNode.attributeAffects(distanceTerrainNode.jointPos,
                                             distanceTerrainNode.distance)
Esempio n. 3
0
    def initialize():
        typedAttr = om.MFnTypedAttribute()
        matrixAttr = om.MFnMatrixAttribute()
        numericAttr = om.MFnNumericAttribute()

        # OUTPUT
        prCurveFrame.outputMatrix = matrixAttr.create("outputMatrix", "outputMatrix", matrixAttr.kDouble)
        matrixAttr.array = True
        matrixAttr.usesArrayDataBuilder = True
        matrixAttr.readable = True
        matrixAttr.writable = False
        prCurveFrame.addAttribute(prCurveFrame.outputMatrix)

        # INPUT
        prCurveFrame.inputCurve = typedAttr.create('inputCurve', 'inputCurve', om.MFnNurbsCurveData.kNurbsCurve)
        prCurveFrame.addAttribute(prCurveFrame.inputCurve)
        prCurveFrame.attributeAffects(prCurveFrame.inputCurve, prCurveFrame.outputMatrix)

        prCurveFrame.worldUpMatrix = matrixAttr.create("worldUpMatrix", "worldUpMatrix", matrixAttr.kDouble)
        prCurveFrame.addAttribute(prCurveFrame.worldUpMatrix)
        prCurveFrame.attributeAffects(prCurveFrame.worldUpMatrix, prCurveFrame.outputMatrix)

        prCurveFrame.points = numericAttr.create("points", "points", om.MFnNumericData.kInt, 5)
        numericAttr.keyable = True
        prCurveFrame.addAttribute(prCurveFrame.points)
        prCurveFrame.attributeAffects(prCurveFrame.points, prCurveFrame.outputMatrix)
Esempio n. 4
0
    def initialize():
        mtxMFnAttr = om2.MFnMatrixAttribute()

        Matrix2Vectors.mtxIn = mtxMFnAttr.create('matrixIn', 'mtxIn')
        mtxMFnAttr.readable = True
        mtxMFnAttr.writable = True
        mtxMFnAttr.storable = True
        Matrix2Vectors.addAttribute(Matrix2Vectors.mtxIn)

        Matrix2Vectors.row0 = mtxMFnAttr.create('row0Mtx', 'row0Mtx')
        mtxMFnAttr.readable = True
        Matrix2Vectors.addAttribute(Matrix2Vectors.row0)

        Matrix2Vectors.row1 = mtxMFnAttr.create('row1Mtx', 'row1Mtx')
        mtxMFnAttr.readable = True
        Matrix2Vectors.addAttribute(Matrix2Vectors.row1)

        Matrix2Vectors.row2 = mtxMFnAttr.create('row2Mtx', 'row2Mtx')
        mtxMFnAttr.readable = True
        Matrix2Vectors.addAttribute(Matrix2Vectors.row2)

        Matrix2Vectors.attributeAffects(Matrix2Vectors.mtxIn,
                                        Matrix2Vectors.row0)
        Matrix2Vectors.attributeAffects(Matrix2Vectors.mtxIn,
                                        Matrix2Vectors.row1)
        Matrix2Vectors.attributeAffects(Matrix2Vectors.mtxIn,
                                        Matrix2Vectors.row2)
Esempio n. 5
0
def create_skeleton_compound(classtype, name):
    mComp = OpenMaya.MFnCompoundAttribute()
    compound = mComp.create(name, name)
    setattr(classtype, name, compound)
    mComp.array = True
    mComp.storable = True
    mComp.writable = True

    mAttr = OpenMaya.MFnMatrixAttribute()
    srcMatrix = mAttr.create(name + "SrcMatrix", name + "SrcMatrix")
    setattr(classtype, name + "SrcMatrix", srcMatrix)
    mAttr.array = False
    mAttr.storable = True
    mAttr.writable = True

    nAttr = OpenMaya.MFnNumericAttribute()
    boneParent = nAttr.create(name + "BoneParent", name + "BoneParent",
                              OpenMaya.MFnNumericData.kInt, -1)
    setattr(classtype, name + "BoneParent", boneParent)
    nAttr.array = False
    nAttr.storable = True
    nAttr.writable = True

    nAttr = OpenMaya.MFnNumericAttribute()
    translateScale = nAttr.create(name + "TranslateScale",
                                  name + "TranslateScale",
                                  OpenMaya.MFnNumericData.kFloat, 0)
    setattr(classtype, name + "TranslateScale", translateScale)
    nAttr.array = False
    nAttr.storable = True
    nAttr.writable = True

    nAttr = OpenMaya.MFnNumericAttribute()
    targetTranslate = nAttr.create(name + "TargetTranslate",
                                   name + "TargetTranslate",
                                   OpenMaya.MFnNumericData.k3Float)
    setattr(classtype, name + "TargetTranslate", targetTranslate)
    nAttr.array = False
    nAttr.storable = True
    nAttr.writable = True
    nAttr.keyable = True

    classtype.addAttribute(srcMatrix)
    classtype.addAttribute(boneParent)
    classtype.addAttribute(translateScale)
    classtype.addAttribute(targetTranslate)

    mComp.addChild(srcMatrix)
    mComp.addChild(boneParent)
    mComp.addChild(translateScale)
    mComp.addChild(targetTranslate)

    classtype.addAttribute(compound)

    return compound
Esempio n. 6
0
    def initialize():
        tAttr = om.MFnTypedAttribute()
        mAttr = om.MFnMatrixAttribute()

        Node.aMatrices = mAttr.create(
            'matrices', 'ms', om.MFnMatrixAttribute.kDouble)
        mAttr.readable = False
        mAttr.array = True
        Node.addAttribute(Node.aMatrices)

        Node.aOutCurve = tAttr.create(
            'outCurve', 'oc', om.MFnNurbsCurveData.kNurbsCurve)
        tAttr.writable = False
        Node.addAttribute(Node.aOutCurve)

        Node.attributeAffects(Node.aMatrices, Node.aOutCurve)
def nodeInitializer():

    classname = SkeletonSolverNode

    #input
    skel = create_skeleton_compound(classname, 'skeleton')

    # output
    mAttr = OpenMaya.MFnMatrixAttribute()
    classname.outputs = mAttr.create("outputs", "outputs")
    mAttr.array = True
    mAttr.storable = True
    mAttr.writable = True

    classname.addAttribute(classname.outputs)

    classname.attributeAffects(skel, classname.outputs)
Esempio n. 8
0
def create_capsule_compound(classtype, name):
    mComp = OpenMaya.MFnCompoundAttribute()
    compound = mComp.create(name, name)
    setattr(classtype, name, compound)
    mComp.array = False
    mComp.storable = True
    mComp.writable = True

    mAttr = OpenMaya.MFnMatrixAttribute()
    matrix = mAttr.create(name + "Matrix", name + "Matrix")
    setattr(classtype, name + "Matrix", matrix)
    mAttr.array = False
    mAttr.storable = True
    mAttr.writable = True

    nAttr = OpenMaya.MFnNumericAttribute()
    radius = nAttr.create(name + "Radius", name + "Radius",
                          OpenMaya.MFnNumericData.kDouble, 0.5)
    setattr(classtype, name + "Radius", radius)
    nAttr.array = False
    nAttr.storable = True
    nAttr.writable = True

    nAttr = OpenMaya.MFnNumericAttribute()
    height = nAttr.create(name + "Height", name + "Height",
                          OpenMaya.MFnNumericData.kDouble, 1.0)
    setattr(classtype, name + "Height", height)
    nAttr.array = False
    nAttr.storable = True
    nAttr.writable = True

    classtype.addAttribute(matrix)
    classtype.addAttribute(radius)
    classtype.addAttribute(height)

    mComp.addChild(matrix)
    mComp.addChild(radius)
    mComp.addChild(height)

    classtype.addAttribute(compound)

    return compound
Esempio n. 9
0
    def initialize():
        num_attr = om2.MFnNumericAttribute()
        mtx_attr = om2.MFnMatrixAttribute()

        SimpleNode.a_arg = mtx_attr.create('matrixIn', 'mtxIn', om2.MFnNumericData.kFloat)
        mtx_attr.writable = True
        mtx_attr.storable = True
        om2.MPxNode.addAttribute(SimpleNode.a_arg)

        SimpleNode.a_amp = num_attr.create('amp', 'amp', om2.MFnNumericData.kFloat, 1.0)
        num_attr.storable = True
        om2.MPxNode.addAttribute(SimpleNode.a_amp)

        SimpleNode.a_val = num_attr.create('val', 'val', om2.MFnNumericData.kFloat, 0.0)
        num_attr.storable = True
        num_attr.writable = True
        om2.MPxNode.addAttribute(SimpleNode.a_val)

        om2.MPxNode.attributeAffects(SimpleNode.a_arg, SimpleNode.a_val)
        om2.MPxNode.attributeAffects(SimpleNode.a_amp, SimpleNode.a_val)
Esempio n. 10
0
def setPlugDefault(plug, default):
    obj = plug.attribute()
    if obj.hasFn(om2.MFn.kNumericAttribute):
        attr = om2.MFnNumericAttribute(obj)
        Type = attr.numericType()
        attr.default = tuple(default) if Type in (
            om2.MFnNumericData.k2Double, om2.MFnNumericData.k3Double,
            om2.MFnNumericData.k4Double) else default
        return True
    elif obj.hasFn(om2.MFn.kTypedAttribute):
        if not isinstance(default, om2.MObject):
            raise ValueError(
                "Wrong type passed to MFnTypeAttribute must be on type MObject, received : {}"
                .format(type(default)))
        attr = om2.MFnTypedAttribute(obj)
        attr.default = default
        return True
    elif obj.hasFn(om2.MFn.kUnitAttribute):
        if not isinstance(default, (om2.MAngle, om2.MDistance, om2.MTime)):
            raise ValueError(
                "Wrong type passed to MFnUnitAttribute must be on type MAngle,MDistance or MTime, received : {}"
                .format(type(default)))
        attr = om2.MFnUnitAttribute(obj)
        attr.default = default
        return True
    elif obj.hasFn(om2.MFn.kMatrixAttribute):
        attr = om2.MFnMatrixAttribute(obj)
        attr.default = default
        return True
    elif obj.hasFn(om2.MFn.kEnumAttribute):
        if not isinstance(default, (int, str)):
            raise ValueError(
                "Wrong type passed to MFnEnumAttribute must be on type int or float, received : {}"
                .format(type(default)))
        attr = om2.MFnEnumAttribute(obj)
        if isinstance(default, int):
            attr.default = default
        else:
            attr.setDefaultByName(default)
        return True
    return False
Esempio n. 11
0
def nodeInitializer():

    classname = ConstraintSolverNode

    #input
    skel = create_skeleton_compound(classname, 'skeleton')
    primitivesS = create_primitives_compound(classname, 'primitiveSource')
    primitivesD = create_primitives_compound(classname, 'primitiveDestination')
    link = create_primitive_links_compound(classname, 'link')

    # output
    mAttr = OpenMaya.MFnMatrixAttribute()
    classname.outputs = mAttr.create("outputs", "outputs")
    mAttr.array = True
    mAttr.storable = True
    mAttr.writable = True

    classname.addAttribute(classname.outputs)

    classname.attributeAffects(skel, classname.outputs)
    classname.attributeAffects(primitivesS, classname.outputs)
    classname.attributeAffects(primitivesD, classname.outputs)
    classname.attributeAffects(link, classname.outputs)
Esempio n. 12
0
def plugDefault(plug):
    obj = plug.attribute()
    if obj.hasFn(om2.MFn.kNumericAttribute):
        attr = om2.MFnNumericAttribute(obj)
        return attr.default
    elif obj.hasFn(om2.MFn.kTypedAttribute):
        attr = om2.MFnTypedAttribute(obj)
        default = attr.default
        if default.apiType() == om2.MFn.kInvalid:
            return None
        elif default.apiType() == om2.MFn.kStringData:
            return om2.MFnStringData(default).string()
        return default
    elif obj.hasFn(om2.MFn.kUnitAttribute):
        attr = om2.MFnUnitAttribute(obj)
        return attr.default
    elif obj.hasFn(om2.MFn.kMatrixAttribute):
        attr = om2.MFnMatrixAttribute(obj)
        return attr.default
    elif obj.hasFn(om2.MFn.kEnumAttribute):
        attr = om2.MFnEnumAttribute(obj)
        return attr.default
    return None
Esempio n. 13
0
def nodeInitializer():
    '''
    Defines the input and output attributes as static variables in our plug-in class.
    '''
    
    # The following function set will allow us to create our attributes.
    numericAttributeFn = OpenMaya.MFnNumericAttribute()
    angleAttributeFn = OpenMaya.MFnUnitAttribute()
    matrixAttributeFn = OpenMaya.MFnMatrixAttribute()
    compoundAttributeFn = OpenMaya.MFnCompoundAttribute()

    #==================================#
    #      INPUT NODE ATTRIBUTE(S)     #
    #==================================#

    #--------------------#
    #  Robot Definition  #
    #--------------------#
    
    # Robot Definition Parent Attr
    robotIKS.robotDef = compoundAttributeFn.create('robotDefinition', 'robotDef')
    
    # a1 # 
    robotIKS.a1_attr = numericAttributeFn.create('a1', 'a1', OpenMaya.MFnNumericData.kFloat, 32.0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.a1_attr) 

    # a2 # 
    robotIKS.a2_attr = numericAttributeFn.create('a2', 'a2', OpenMaya.MFnNumericData.kFloat, 20.0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.a2_attr)     

    # b # 
    robotIKS.b_attr = numericAttributeFn.create('b', 'b', OpenMaya.MFnNumericData.kFloat, 0.0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.b_attr)     

    # c1 # 
    robotIKS.c1_attr = numericAttributeFn.create('c1', 'c1', OpenMaya.MFnNumericData.kFloat, 78.0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.c1_attr) 
  
    # c2 # 
    robotIKS.c2_attr = numericAttributeFn.create('c2', 'c2', OpenMaya.MFnNumericData.kFloat, 128.0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.c2_attr) 

    # c3 # 
    robotIKS.c3_attr = numericAttributeFn.create('c3', 'c3', OpenMaya.MFnNumericData.kFloat, 118.25)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.c3_attr) 

    # c4 # 
    robotIKS.c4_attr = numericAttributeFn.create('c4', 'c4', OpenMaya.MFnNumericData.kFloat, 20.0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.c4_attr) 
    
    robotIKS.addAttribute(robotIKS.robotDef)  # Add Parent Attr 


    #----------------#
    #  Axis Offsets  #
    #----------------#
    robotIKS.axisOffsets = compoundAttributeFn.create('axisOffsets', 'aOffsets')

    # Axis 1 Offset #
    robotIKS.axis1_offset_attr = numericAttributeFn.create('axis1Offset', 'a1Offset', OpenMaya.MFnNumericData.kFloat, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.axis1_offset_attr) 
    
    # Axis 2 Offset #
    robotIKS.axis2_offset_attr = numericAttributeFn.create('axis2Offset', 'a2Offset', OpenMaya.MFnNumericData.kFloat, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.axis2_offset_attr) 
    
    # Axis 3 Offset #
    robotIKS.axis3_offset_attr = numericAttributeFn.create('axis3Offset', 'a3Offset', OpenMaya.MFnNumericData.kFloat, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.axis3_offset_attr)  

    # Axis 4 Offset #
    robotIKS.axis4_offset_attr = numericAttributeFn.create('axis4Offset', 'a4Offset', OpenMaya.MFnNumericData.kFloat, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.axis4_offset_attr)  

    # Axis 5 Offset #
    robotIKS.axis5_offset_attr = numericAttributeFn.create('axis5Offset', 'a5Offset', OpenMaya.MFnNumericData.kFloat, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.axis5_offset_attr)

    # Axis 6 Offset #
    robotIKS.axis6_offset_attr = numericAttributeFn.create('axis6Offset', 'a6Offset', OpenMaya.MFnNumericData.kFloat, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.axis6_offset_attr)  

    robotIKS.addAttribute(robotIKS.axisOffsets)  # Add Parent Attr 
  

    #------------------------#
    #  Flip Axis Directions  # 
    #------------------------#
    robotIKS.axisDirections = compoundAttributeFn.create('axisDirections', 'axisDirs')
    
    # Flip Axis 1 Direction #
    robotIKS.flip_a1_attr = numericAttributeFn.create('flipA1', 'flipA1', OpenMaya.MFnNumericData.kBoolean, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.flip_a1_attr) 

    # Flip Axis 2 Direction #
    robotIKS.flip_a2_attr = numericAttributeFn.create('flipA2', 'flipA2', OpenMaya.MFnNumericData.kBoolean, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.flip_a2_attr) 

    # Flip Axis 3 Direction #
    robotIKS.flip_a3_attr = numericAttributeFn.create('flipA3', 'flipA3', OpenMaya.MFnNumericData.kBoolean, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.flip_a3_attr) 

    # Flip Axis 4 Direction #
    robotIKS.flip_a4_attr = numericAttributeFn.create('flipA4', 'flipA4', OpenMaya.MFnNumericData.kBoolean, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.flip_a4_attr) 

    # Flip Axis 5 Direction #
    robotIKS.flip_a5_attr = numericAttributeFn.create('flipA5', 'flipA5', OpenMaya.MFnNumericData.kBoolean, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.flip_a5_attr) 

    # Flip Axis 6 Direction #
    robotIKS.flip_a6_attr = numericAttributeFn.create('flipA6', 'flipA6', OpenMaya.MFnNumericData.kBoolean, 0)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.flip_a6_attr) 

    robotIKS.addAttribute(robotIKS.axisDirections)  # Add Parent Attr 


    #----------------------#
    #  Joint Config Bools  # 
    #----------------------#
    
    # Robot Definition Parent Attr
    robotIKS.jointConfig = compoundAttributeFn.create('jointConfiguration', 'config')
    
    # soln1 # 
    robotIKS.sol_1_attr = numericAttributeFn.create('soln1', 'soln1', OpenMaya.MFnNumericData.kBoolean, 1)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.sol_1_attr) 

    # soln2 # 
    robotIKS.sol_2_attr = numericAttributeFn.create('soln2', 'soln2', OpenMaya.MFnNumericData.kBoolean, 1)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.sol_2_attr)     

    # soln3 # 
    robotIKS.sol_3_attr = numericAttributeFn.create('soln3', 'soln3', OpenMaya.MFnNumericData.kBoolean, 1)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.sol_3_attr)     

    # ik #
    robotIKS.ik_attr = numericAttributeFn.create('ik', 'ik', OpenMaya.MFnNumericData.kBoolean, 1)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.ik_attr)     
    
    robotIKS.addAttribute(robotIKS.jointConfig)  # Add Parent Attr 

    #-------------------#
    #    FK Controls    # 
    #-------------------#  
    robotIKS.fkControls = compoundAttributeFn.create('fkControls', 'fkCtrls')
    
    # J1 FK #  
    robotIKS.a1_fk_attr = angleAttributeFn.create('j1_FK', 'j1_FK', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = True 
    angleAttributeFn.writable = True
    angleAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.a1_fk_attr)     

    # J2 FK #  
    robotIKS.a2_fk_attr = angleAttributeFn.create('j2_FK', 'j2_FK', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = True 
    angleAttributeFn.writable = True
    angleAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.a2_fk_attr)     

    # J3 FK #  
    robotIKS.a3_fk_attr = angleAttributeFn.create('j3_FK', 'j3_FK', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = True 
    angleAttributeFn.writable = True
    angleAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.a3_fk_attr)     

    # J4 FK #  
    robotIKS.a4_fk_attr = angleAttributeFn.create('j4_FK', 'j4_FK', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = True 
    angleAttributeFn.writable = True
    angleAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.a4_fk_attr)     

    # J5 FK #  
    robotIKS.a5_fk_attr = angleAttributeFn.create('j5_FK', 'j5_FK', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = True 
    angleAttributeFn.writable = True
    angleAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.a5_fk_attr)     

    # J6 FK #  
    robotIKS.a6_fk_attr = angleAttributeFn.create('j6_FK', 'j6_FK', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = True 
    angleAttributeFn.writable = True
    angleAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.a6_fk_attr)     


    robotIKS.addAttribute(robotIKS.fkControls) 
    
                    
    #---------------------------------#
    #  TCP Translation - Local Space  #
    #---------------------------------#
    
    # TCP Parent Attr
    robotIKS.tcp = compoundAttributeFn.create('tcpFrame', 'tcp') 
    
    # tcpX #
    robotIKS.tcp_x_attr = numericAttributeFn.create('tcpX', 'tcpX', OpenMaya.MFnNumericData.kFloat)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.tcp_x_attr) 

    # tcpY #
    robotIKS.tcp_y_attr = numericAttributeFn.create('tcpY', 'tcpY', OpenMaya.MFnNumericData.kFloat)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False 
    compoundAttributeFn.addChild(robotIKS.tcp_y_attr)

    # tcpZ #
    robotIKS.tcp_z_attr = numericAttributeFn.create('tcpZ', 'tcpZ', OpenMaya.MFnNumericData.kFloat)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False
    compoundAttributeFn.addChild(robotIKS.tcp_z_attr)  
    
    # TCP Matrix - Local Space ##
    robotIKS.tcp_mat_attr = matrixAttributeFn.create('tcpMatrix', 'tcpMat', OpenMaya.MFnMatrixAttribute.kDouble)
    matrixAttributeFn.writable = True 
    matrixAttributeFn.storable = True 
    matrixAttributeFn.hidden = False 
    compoundAttributeFn.addChild(robotIKS.tcp_mat_attr) 
    
    robotIKS.addAttribute(robotIKS.tcp)  # Add parent Attr
    
   

    #---------------------------------#
    #  LCS Translation - Local Space  #
    #---------------------------------#
    
    # LCS Parent Attr
    robotIKS.lcs = compoundAttributeFn.create('localFrame', 'lcs') 
    
    # lcsX #
    robotIKS.lcs_x_attr = numericAttributeFn.create('lcsX', 'lcsX', OpenMaya.MFnNumericData.kFloat)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False 
    compoundAttributeFn.addChild(robotIKS.lcs_x_attr) 

    # lcsY #
    robotIKS.lcs_y_attr = numericAttributeFn.create('lcsY', 'lcsY', OpenMaya.MFnNumericData.kFloat)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False 
    compoundAttributeFn.addChild(robotIKS.lcs_y_attr) 

    # lcsZ #
    robotIKS.lcs_z_attr = numericAttributeFn.create('lcsZ', 'lcsZ', OpenMaya.MFnNumericData.kFloat)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False 
    compoundAttributeFn.addChild(robotIKS.lcs_z_attr) 

    ## LCS Matrix - Local Space ##
    robotIKS.lcs_mat_attr = matrixAttributeFn.create('lcsMatrix', 'lcsMat', OpenMaya.MFnMatrixAttribute.kDouble)
    matrixAttributeFn.writable = True 
    matrixAttributeFn.storable = True 
    matrixAttributeFn.hidden = False 
    compoundAttributeFn.addChild(robotIKS.lcs_mat_attr)  

    robotIKS.addAttribute(robotIKS.lcs)  # Add parent Attr
    
    
    #-----------------------------------------#      
    #  Target Translation - Maya World Space  #
    #-----------------------------------------#      
    
    # Target Parent Attr
    robotIKS.target = compoundAttributeFn.create('targetFrame', 'target') 
    
    # targetX #
    robotIKS.target_x_attr = numericAttributeFn.create('targetX', 'targetX', OpenMaya.MFnNumericData.kFloat)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False 
    compoundAttributeFn.addChild(robotIKS.target_x_attr) 

    # targetY #
    robotIKS.target_y_attr = numericAttributeFn.create('targetY', 'targetY', OpenMaya.MFnNumericData.kFloat)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False 
    compoundAttributeFn.addChild(robotIKS.target_y_attr) 

    # targetZ #
    robotIKS.target_z_attr = numericAttributeFn.create('targetZ', 'targetZ', OpenMaya.MFnNumericData.kFloat)
    numericAttributeFn.writable = True 
    numericAttributeFn.storable = True 
    numericAttributeFn.hidden = False 
    compoundAttributeFn.addChild(robotIKS.target_z_attr)
    
    ## Target Matrix - World Space ##
    robotIKS.target_mat_attr = matrixAttributeFn.create('targetMatrix', 'targetMat', OpenMaya.MFnMatrixAttribute.kDouble)
    matrixAttributeFn.writable = True 
    matrixAttributeFn.storable = True 
    matrixAttributeFn.hidden = False 
    compoundAttributeFn.addChild(robotIKS.target_mat_attr)    

    robotIKS.addAttribute(robotIKS.target)  # Add parent Attr

    #-----------------------------------------#      
    #                Solver Type              #
    #-----------------------------------------#  
    robotIKS.solver_type_attr= numericAttributeFn.create('solverType', 'solverType', OpenMaya.MFnNumericData.kInt, 0)
    numericAttributeFn.storable = True 
    numericAttributeFn.writable = True
    numericAttributeFn.hidden = False
    robotIKS.addAttribute(robotIKS.solver_type_attr)     
    
    #==================================#
    #     OUTPUT NODE ATTRIBUTE(S)     #
    #==================================#
    
    # Final Joint Values Parent Attr
    robotIKS.theta = compoundAttributeFn.create('JointVals', 'theta') 

    robotIKS.theta1_attr = angleAttributeFn.create('theta1', 'J1', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = False 
    angleAttributeFn.writable = False
    angleAttributeFn.readable = True 
    angleAttributeFn.hidden = False
    #robotIKS.addAttribute(robotIKS.theta1_attr) 
    compoundAttributeFn.addChild(robotIKS.theta1_attr)

    robotIKS.theta2_attr = angleAttributeFn.create('theta2', 'J2', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = False 
    angleAttributeFn.writable = False
    angleAttributeFn.readable = True 
    angleAttributeFn.hidden = False 
    #robotIKS.addAttribute(robotIKS.theta2_attr) 
    compoundAttributeFn.addChild(robotIKS.theta2_attr)

    robotIKS.theta3_attr = angleAttributeFn.create('theta3', 'J3', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = False 
    angleAttributeFn.writable = False
    angleAttributeFn.readable = True 
    angleAttributeFn.hidden = False
    #robotIKS.addAttribute(robotIKS.theta3_attr)  
    compoundAttributeFn.addChild(robotIKS.theta3_attr)

    robotIKS.theta4_attr = angleAttributeFn.create('theta4', 'J4', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = False 
    angleAttributeFn.writable = False
    angleAttributeFn.readable = True 
    angleAttributeFn.hidden = False
    #robotIKS.addAttribute(robotIKS.theta4_attr)  
    compoundAttributeFn.addChild(robotIKS.theta4_attr)

    robotIKS.theta5_attr = angleAttributeFn.create('theta5', 'J5', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = False 
    angleAttributeFn.writable = False
    angleAttributeFn.readable = True 
    angleAttributeFn.hidden = False
    #robotIKS.addAttribute(robotIKS.theta5_attr)  
    compoundAttributeFn.addChild(robotIKS.theta5_attr)

    robotIKS.theta6_attr = angleAttributeFn.create('theta6', 'J6', OpenMaya.MFnUnitAttribute.kAngle)
    angleAttributeFn.storable = False 
    angleAttributeFn.writable = False
    angleAttributeFn.readable = True 
    angleAttributeFn.hidden = False
    #robotIKS.addAttribute(robotIKS.theta6_attr)  
    compoundAttributeFn.addChild(robotIKS.theta6_attr)
    
    robotIKS.addAttribute(robotIKS.theta)  # Add parent Attr


    #===================================#
    #    NODE ATTRIBUTE DEPENDENCIES    #
    #===================================#

    input_attrs = [robotIKS.a1_attr,
                   robotIKS.a2_attr,
                   robotIKS.b_attr,
                   robotIKS.c1_attr,
                   robotIKS.c2_attr,
                   robotIKS.c3_attr,
                   robotIKS.c4_attr,
                   robotIKS.axis1_offset_attr,
                   robotIKS.axis2_offset_attr,
                   robotIKS.axis3_offset_attr,
                   robotIKS.axis4_offset_attr,
                   robotIKS.axis5_offset_attr,
                   robotIKS.axis6_offset_attr,
                   robotIKS.flip_a1_attr,
                   robotIKS.flip_a2_attr,
                   robotIKS.flip_a3_attr,
                   robotIKS.flip_a4_attr,
                   robotIKS.flip_a5_attr,
                   robotIKS.flip_a6_attr,
                   robotIKS.sol_1_attr,
                   robotIKS.sol_2_attr,
                   robotIKS.sol_3_attr,
                   robotIKS.ik_attr,
                   robotIKS.a1_fk_attr,
                   robotIKS.a2_fk_attr,
                   robotIKS.a3_fk_attr,
                   robotIKS.a4_fk_attr,
                   robotIKS.a5_fk_attr,
                   robotIKS.a6_fk_attr,
                   robotIKS.tcp_x_attr,
                   robotIKS.tcp_y_attr,
                   robotIKS.tcp_z_attr,
                   robotIKS.tcp_mat_attr,
                   robotIKS.lcs_x_attr,
                   robotIKS.lcs_y_attr,
                   robotIKS.lcs_z_attr,
                   robotIKS.lcs_mat_attr,
                   robotIKS.target_x_attr,
                   robotIKS.target_y_attr,
                   robotIKS.target_z_attr,
                   robotIKS.target_mat_attr,
                   robotIKS.solver_type_attr
                  ]

    output_attrs = [robotIKS.theta1_attr,
                   robotIKS.theta2_attr,
                   robotIKS.theta3_attr,
                   robotIKS.theta4_attr,
                   robotIKS.theta5_attr,
                   robotIKS.theta6_attr,
                   robotIKS.theta]

    for input_attr in input_attrs:
        for output_attr in output_attrs:
            robotIKS.attributeAffects(input_attr, output_attr)
Esempio n. 14
0
    def initialize():
        nAttr0 = om.MFnMatrixAttribute()
        MatrixCombine.inInitialMatrix = nAttr0.create('initialMatrix', 'im')
        nAttr0.keyable = False

        nAttrAllWeightList = om.MFnCompoundAttribute()
        MatrixCombine.inAllPoseInfoList = nAttrAllWeightList.create(
            'allPoseInfoList', 'pil')
        nAttrAllWeightList.keyable = True
        nAttrAllWeightList.array = True
        nAttrAllWeightList.storable = True
        nAttrAllWeightList.indexMatters = False

        nAttrPoseName = om.MFnTypedAttribute()
        MatrixCombine.inPoseName = nAttrPoseName.create(
            'poseName', 'pl', om.MFnData.kString)
        nAttrPoseName.keyable = True

        nAttrMatList = om.MFnMatrixAttribute()
        MatrixCombine.inPoseMatrix = nAttrMatList.create("poseMatrix", 'pm')
        nAttrMatList.keyable = True

        nAttrWeightInPose = om.MFnNumericAttribute()
        MatrixCombine.inPoseWeights = nAttrWeightInPose.create(
            'poseWeightList', 'pwl', om.MFnNumericData.kFloat, 0.0)
        nAttrWeightInPose.keyable = True
        nAttrWeightInPose.array = True
        nAttrWeightInPose.storable = True
        nAttrWeightInPose.indexMatters = False

        nAttrAllWeightList.addChild(MatrixCombine.inPoseName)
        nAttrAllWeightList.addChild(MatrixCombine.inPoseMatrix)
        nAttrAllWeightList.addChild(MatrixCombine.inPoseWeights)

        nAttrNum = om.MFnNumericAttribute()
        MatrixCombine.inEditMode = nAttrNum.create("editMode", "emd",
                                                   om.MFnNumericData.kFloat,
                                                   0.0)
        nAttrNum.keyable = False

        nAttrEditMatrix = om.MFnMatrixAttribute()
        MatrixCombine.inEditMatrix = nAttrEditMatrix.create(
            "editMatrix", "emx")
        nAttrEditMatrix.keyable = False

        nAttrNum1 = om.MFnNumericAttribute()
        MatrixCombine.inOverridingIntensity = nAttrNum1.create(
            "overridingIntensity", "oi", om.MFnNumericData.kFloat, 0.0)
        nAttrNum1.keyable = False

        nAttrNum2 = om.MFnNumericAttribute()
        MatrixCombine.inOverridingWeight = nAttrNum2.create(
            "overridingWeight", "ow", om.MFnNumericData.kFloat, 1.0)
        nAttrNum2.keyable = False

        nAttrNum2 = om.MFnNumericAttribute()
        MatrixCombine.inOverridingPoseIndex = nAttrNum2.create(
            "overridingPoseIndex", "oid", om.MFnNumericData.kInt, 0)
        nAttrNum2.keyable = False

        nAttrOut = om.MFnNumericAttribute()
        MatrixCombine.outTranslationX = nAttrOut.create(
            'outTranslationX', 'otx', om.MFnNumericData.kFloat, 0.0)
        nAttrOut.keyable = False
        nAttrOut.storable = False

        nAttrOut = om.MFnNumericAttribute()
        MatrixCombine.outTranslationY = nAttrOut.create(
            'outTranslationY', 'oty', om.MFnNumericData.kFloat, 0.0)
        nAttrOut.keyable = False
        nAttrOut.storable = False

        nAttrOut = om.MFnNumericAttribute()
        MatrixCombine.outTranslationZ = nAttrOut.create(
            'outTranslationZ', 'otz', om.MFnNumericData.kFloat, 0.0)
        nAttrOut.keyable = False
        nAttrOut.storable = False

        nAttrOut = om.MFnUnitAttribute()
        MatrixCombine.outRotationX = nAttrOut.create(
            'outRotationX', 'orx', om.MFnUnitAttribute.kAngle, 0.0)
        nAttrOut.keyable = False
        nAttrOut.storable = False

        nAttrOut = om.MFnUnitAttribute()
        MatrixCombine.outRotationY = nAttrOut.create(
            'outRotationY', 'ory', om.MFnUnitAttribute.kAngle, 0.0)
        nAttrOut.keyable = False
        nAttrOut.storable = False

        nAttrOut = om.MFnUnitAttribute()
        MatrixCombine.outRotationZ = nAttrOut.create(
            'outRotationZ', 'orz', om.MFnUnitAttribute.kAngle, 0.0)
        nAttrOut.keyable = False
        nAttrOut.storable = False

        # add the attributes
        om.MPxNode.addAttribute(MatrixCombine.inInitialMatrix)
        om.MPxNode.addAttribute(MatrixCombine.inEditMode)
        om.MPxNode.addAttribute(MatrixCombine.inEditMatrix)
        om.MPxNode.addAttribute(MatrixCombine.inOverridingPoseIndex)
        om.MPxNode.addAttribute(MatrixCombine.inOverridingIntensity)
        om.MPxNode.addAttribute(MatrixCombine.inOverridingWeight)
        om.MPxNode.addAttribute(MatrixCombine.inAllPoseInfoList)

        om.MPxNode.addAttribute(MatrixCombine.outTranslationX)
        om.MPxNode.addAttribute(MatrixCombine.outTranslationY)
        om.MPxNode.addAttribute(MatrixCombine.outTranslationZ)
        om.MPxNode.addAttribute(MatrixCombine.outRotationX)
        om.MPxNode.addAttribute(MatrixCombine.outRotationY)
        om.MPxNode.addAttribute(MatrixCombine.outRotationZ)

        # establish effects on output
        om.MPxNode.attributeAffects(MatrixCombine.inOverridingIntensity,
                                    MatrixCombine.outTranslationX)
        om.MPxNode.attributeAffects(MatrixCombine.inOverridingPoseIndex,
                                    MatrixCombine.outTranslationX)
        om.MPxNode.attributeAffects(MatrixCombine.inOverridingWeight,
                                    MatrixCombine.outTranslationX)
        om.MPxNode.attributeAffects(MatrixCombine.inInitialMatrix,
                                    MatrixCombine.outTranslationX)
        om.MPxNode.attributeAffects(MatrixCombine.inAllPoseInfoList,
                                    MatrixCombine.outTranslationX)
        om.MPxNode.attributeAffects(MatrixCombine.inEditMode,
                                    MatrixCombine.outTranslationX)

        om.MPxNode.attributeAffects(MatrixCombine.inAllPoseInfoList,
                                    MatrixCombine.outRotationX)
        om.MPxNode.attributeAffects(MatrixCombine.inAllPoseInfoList,
                                    MatrixCombine.outRotationY)
        om.MPxNode.attributeAffects(MatrixCombine.inAllPoseInfoList,
                                    MatrixCombine.outRotationZ)
Esempio n. 15
0
    def initialize(cls):
        nAttr = OpenMaya.MFnNumericAttribute()
        tAttr = OpenMaya.MFnTypedAttribute()
        enumAttr = OpenMaya.MFnEnumAttribute()
        compAttr = OpenMaya.MFnCompoundAttribute()
        matrixAttr = OpenMaya.MFnMatrixAttribute()
        messageAttr = OpenMaya.MFnMessageAttribute()

        cls.boundingBoxCorner1 = nAttr.create("boundingBoxCorner1", "bb1", OpenMaya.MFnNumericData.k3Double, 0)
        nAttr.keyable = False
        cls.addAttribute(cls.boundingBoxCorner1)
        cls.boundingBoxCorner2 = nAttr.create("boundingBoxCorner2", "bb2", OpenMaya.MFnNumericData.k3Double, 0)
        nAttr.keyable = False
        cls.addAttribute(cls.boundingBoxCorner2)

        cls.forgeID = tAttr.create("forgeID", "fid", OpenMaya.MFnData.kString, OpenMaya.MObject.kNullObj)
        cls.addAttribute(cls.forgeID)

        cls.handleMatrix = matrixAttr.create("handleMatrix", "hm", OpenMaya.MFnMatrixAttribute.kDouble)
        cls.addAttribute(cls.handleMatrix)

        cls.guideInverseScale = nAttr.create("guideInverseScale", "gis", OpenMaya.MFnNumericData.k3Double, 1.0)
        cls.addAttribute(cls.guideInverseScale)

        cls.guide = messageAttr.create("guide", "g")
        cls.addAttribute(cls.guide)

        cls.parentHandle = messageAttr.create("parentHandle", "ph")
        cls.addAttribute(cls.parentHandle)

        cls.parentHandleMatrix = matrixAttr.create("parentHandleMatrix", "phm", OpenMaya.MFnMatrixAttribute.kDouble)
        cls.addAttribute(cls.parentHandleMatrix)

        cls.childHandle = messageAttr.create("childHandle", "ch")
        messageAttr.array = True
        cls.addAttribute(cls.childHandle)

        cls.childHandleMatrix = matrixAttr.create("childHandleMatrix", "chm", OpenMaya.MFnMatrixAttribute.kDouble)
        matrixAttr.array = True
        cls.addAttribute(cls.childHandleMatrix)

        cls.orientTarget = messageAttr.create("orientTarget", "ot")
        cls.addAttribute(cls.orientTarget)

        cls.orientTargetMatrix = matrixAttr.create("orientTargetMatrix", "otm", OpenMaya.MFnMatrixAttribute.kDouble)
        cls.addAttribute(cls.orientTargetMatrix)

        cls.childPosition = nAttr.create("childPosition", "cpos", OpenMaya.MFnNumericData.k3Double, 0)
        nAttr.array = True
        nAttr.usesArrayDataBuilder = True
        cls.addAttribute(cls.childPosition)

        cls.jointRotateOrder = enumAttr.create("jointRotateOrder", "jro", 0)
        enumAttr.addField("xyz", 0)
        enumAttr.addField("yzx", 1)
        enumAttr.addField("zxy", 2)
        enumAttr.addField("xzy", 3)
        enumAttr.addField("yxz", 4)
        enumAttr.addField("zyx", 5)
        enumAttr.keyable = False
        cls.addAttribute(cls.jointRotateOrder)

        cls.jointSide = enumAttr.create("jointSide", "js", 0)
        enumAttr.addField("center", 0)
        enumAttr.addField("left", 1)
        enumAttr.addField("right", 2)
        enumAttr.addField("none", 3)
        enumAttr.keyable = True
        cls.addAttribute(cls.jointSide)

        cls.jointExcludeFromBind = nAttr.create("jointExcludeFromBind", "jeb", OpenMaya.MFnNumericData.kBoolean, 0)
        cls.addAttribute(cls.jointExcludeFromBind)

        cls.aimAxis = enumAttr.create("aimAxis", "aa", 0)
        enumAttr.addField("X", 0)
        enumAttr.addField("Y", 1)
        enumAttr.addField("Z", 2)
        enumAttr.addField("-X", 3)
        enumAttr.addField("-Y", 4)
        enumAttr.addField("-Z", 5)
        enumAttr.keyable = False
        cls.addAttribute(cls.aimAxis)

        cls.upAxis = enumAttr.create("upAxis", "ua", 2)
        enumAttr.addField("X", 0)
        enumAttr.addField("Y", 1)
        enumAttr.addField("Z", 2)
        enumAttr.addField("-X", 3)
        enumAttr.addField("-Y", 4)
        enumAttr.addField("-Z", 5)
        enumAttr.keyable = False
        cls.addAttribute(cls.upAxis)

        cls.aimVector = nAttr.create("aimVector", "av", OpenMaya.MFnNumericData.k3Double)
        cls.addAttribute(cls.aimVector)

        cls.upVector = nAttr.create("upVector", "uv", OpenMaya.MFnNumericData.k3Double)
        cls.addAttribute(cls.upVector)

        cls.useGuideAim = nAttr.create("useGuideAim", "uga", OpenMaya.MFnNumericData.kBoolean)
        cls.addAttribute(cls.useGuideAim)

        cls.jointMatrix = matrixAttr.create("jointMatrix", "jm", OpenMaya.MFnMatrixAttribute.kDouble)
        cls.addAttribute(cls.jointMatrix)

        cls.handleColor = nAttr.createColor("handleColor", "hc")
        cls.addAttribute(cls.handleColor)

        cls.handleStyle = enumAttr.create("handleStyle", "hs", 0)
        enumAttr.addField("basic", 0)
        enumAttr.addField("spine", 1)
        enumAttr.addField("limb", 2)
        enumAttr.addField("limb base", 3)
        enumAttr.addField("limb hinge", 4)
        enumAttr.addField("limb end", 5)
        enumAttr.addField("free", 6)
        enumAttr.addField("world", 7)
        cls.addAttribute(cls.handleStyle)

        cls.attributeAffects(cls.handleMatrix, cls.boundingBoxCorner1)
        cls.attributeAffects(cls.handleMatrix, cls.boundingBoxCorner2)
        cls.attributeAffects(cls.handleMatrix, cls.childPosition)
        cls.attributeAffects(cls.childHandleMatrix, cls.boundingBoxCorner1)
        cls.attributeAffects(cls.childHandleMatrix, cls.boundingBoxCorner2)
        cls.attributeAffects(cls.childHandleMatrix, cls.childPosition)
        cls.attributeAffects(cls.handleStyle, cls.boundingBoxCorner1)
        cls.attributeAffects(cls.handleStyle, cls.boundingBoxCorner2)

        cls.attributeAffects(cls.handleMatrix, cls.jointMatrix)
        cls.attributeAffects(cls.orientTargetMatrix, cls.jointMatrix)
        cls.attributeAffects(cls.parentHandleMatrix, cls.jointMatrix)
        cls.attributeAffects(cls.aimAxis, cls.jointMatrix)
        cls.attributeAffects(cls.upAxis, cls.jointMatrix)
        cls.attributeAffects(cls.aimVector, cls.jointMatrix)
        cls.attributeAffects(cls.upVector, cls.jointMatrix)
        cls.attributeAffects(cls.useGuideAim, cls.jointMatrix)
Esempio n. 16
0
    def initialize():
        """
        Defines the set of attributes for our node. The attributes
        declared in this function are assigned as static members to our
        depthShader class. Instances of ReflectionLocatorNode will use these attributes
        to create plugs for use in the compute() method.
        :return:
        """
        eAttr = OpenMaya.MFnEnumAttribute()
        nAttr = OpenMaya.MFnNumericAttribute()
        mAttr = OpenMaya.MFnMatrixAttribute()

        # plane shape
        ReflectionLocatorNode.ui_type = eAttr.create("locatorShape", "ls", 0)
        eAttr.addField("rect", 1)
        eAttr.addField("locator", 2)
        eAttr.addField("circle", 3)
        eAttr.default = 2
        ReflectionLocatorNode.addAttribute(ReflectionLocatorNode.ui_type)

        # creates a vector attribute
        global defaultOutputPoint
        ReflectionLocatorNode.output_point = nAttr.create(
            'output', 'out', OpenMaya.MFnNumericData.k3Double)
        nAttr.storable = False
        nAttr.hidden = False
        nAttr.default = (defaultOutputPoint[0], defaultOutputPoint[1],
                         defaultOutputPoint[2])
        ReflectionLocatorNode.addAttribute(ReflectionLocatorNode.output_point)

        # creates a vector attribute
        global defaultInputPoint
        ReflectionLocatorNode.input_point = nAttr.create(
            'input', 'in', OpenMaya.MFnNumericData.k3Double)
        nAttr.storable = True
        nAttr.hidden = False
        nAttr.keyable = True
        nAttr.default = (defaultInputPoint[0], defaultInputPoint[1],
                         defaultInputPoint[2])
        ReflectionLocatorNode.addAttribute(ReflectionLocatorNode.input_point)
        ReflectionLocatorNode.attributeAffects(
            ReflectionLocatorNode.input_point,
            ReflectionLocatorNode.output_point)

        # create a matrix attribute
        ReflectionLocatorNode.plane_matrix = mAttr.create(
            "planeMatrix", "planeMatrix")
        ReflectionLocatorNode.addAttribute(ReflectionLocatorNode.plane_matrix)
        ReflectionLocatorNode.attributeAffects(
            ReflectionLocatorNode.plane_matrix,
            ReflectionLocatorNode.output_point)

        # create a reflected parentInverse attribute
        ReflectionLocatorNode.parent_inverse = mAttr.create(
            "reflectedParentInverse", "rpi")
        ReflectionLocatorNode.addAttribute(
            ReflectionLocatorNode.parent_inverse)
        ReflectionLocatorNode.attributeAffects(
            ReflectionLocatorNode.parent_inverse,
            ReflectionLocatorNode.output_point)

        # create a line width attribute to change the width of a line drawing
        global defaultLineWidth
        ReflectionLocatorNode.line_width = nAttr.create(
            "lineWidth", "lw", OpenMaya.MFnNumericData.kFloat,
            defaultLineWidth)
        nAttr.setMin(0.0)
        nAttr.storable = False
        nAttr.keyable = True
        ReflectionLocatorNode.addAttribute(ReflectionLocatorNode.line_width)

        # create a color attribute
        global defaultPlaneColor
        ReflectionLocatorNode.plane_color = nAttr.createColor(
            'planeColor', 'pc')
        nAttr.storable = True
        nAttr.default = (defaultPlaneColor[0], defaultPlaneColor[1],
                         defaultPlaneColor[2])
        ReflectionLocatorNode.addAttribute(ReflectionLocatorNode.plane_color)

        # create a scale attribute
        global defaultScaleValue
        ReflectionLocatorNode.scale = nAttr.create(
            "scale", "scale", OpenMaya.MFnNumericData.kDouble,
            defaultScaleValue)
        nAttr.keyable = True
        ReflectionLocatorNode.addAttribute(ReflectionLocatorNode.scale)
        ReflectionLocatorNode.attributeAffects(
            ReflectionLocatorNode.scale, ReflectionLocatorNode.output_point)
Esempio n. 17
0
def create_primitives_compound(classtype, name):

    mComp = OpenMaya.MFnCompoundAttribute()
    compound = mComp.create(name, name)
    setattr(classtype, name, compound)
    mComp.array = True
    mComp.storable = True
    mComp.writable = True

    mCompC = OpenMaya.MFnCompoundAttribute()
    capsule = mCompC.create(name + "Capsule", name + "Capsule")
    setattr(classtype, name + "Capsule", capsule)
    mCompC.array = True
    mCompC.storable = True
    mCompC.writable = True

    mAttr = OpenMaya.MFnMatrixAttribute()
    capsulematrix = mAttr.create(name + "CapsuleMatrix",
                                 name + "CapsuleMatrix")
    setattr(classtype, name + "CapsuleMatrix", capsulematrix)
    mAttr.array = False
    mAttr.storable = True
    mAttr.writable = True

    nAttr = OpenMaya.MFnNumericAttribute()
    capsuleradius = nAttr.create(name + "CapsuleRadius",
                                 name + "CapsuleRadius",
                                 OpenMaya.MFnNumericData.kDouble, 0.5)
    setattr(classtype, name + "CapsuleRadius", capsuleradius)
    nAttr.array = False
    nAttr.storable = True
    nAttr.writable = True

    nAttr = OpenMaya.MFnNumericAttribute()
    capsuleheight = nAttr.create(name + "CapsuleHeight",
                                 name + "CapsuleHeight",
                                 OpenMaya.MFnNumericData.kDouble, 1.0)
    setattr(classtype, name + "CapsuleHeight", capsuleheight)
    nAttr.array = False
    nAttr.storable = True
    nAttr.writable = True

    classtype.addAttribute(capsulematrix)
    classtype.addAttribute(capsuleradius)
    classtype.addAttribute(capsuleheight)

    mCompC.addChild(capsulematrix)
    mCompC.addChild(capsuleradius)
    mCompC.addChild(capsuleheight)

    classtype.addAttribute(capsule)

    nAttr = OpenMaya.MFnNumericAttribute()
    boneParent = nAttr.create(name + "BoneParent", name + "BoneParent",
                              OpenMaya.MFnNumericData.kInt, -1)
    setattr(classtype, name + "BoneParent", boneParent)
    nAttr.array = False
    nAttr.storable = True
    nAttr.writable = True

    classtype.addAttribute(boneParent)

    mComp.addChild(capsule)
    mComp.addChild(boneParent)

    classtype.addAttribute(compound)

    return compound
    def initialize():
        e_attr = om.MFnEnumAttribute()
        c_attr = om.MFnCompoundAttribute()
        n_attr = om.MFnNumericAttribute()

        AimConstaraintNode.aim_axis = e_attr.create("aim_axis", "axa", 0)
        # e_attr.setChannelBox(True)
        e_attr.keyable = False
        e_attr.addField("X", 0)
        e_attr.addField("Y", 1)
        e_attr.addField("Z", 2)

        mat_attr = om.MFnMatrixAttribute()
        AimConstaraintNode.input_aim_matrix = mat_attr.create(
            "input_aim_matrix", "iam")
        mat_attr.writable = True
        mat_attr.readable = False
        mat_attr.keyable = True

        AimConstaraintNode.input_target_parent_matrix = mat_attr.create(
            "input_target_parent_matrix", "itm")
        mat_attr.writable = True
        mat_attr.readable = False
        mat_attr.keyable = True

        AimConstaraintNode.input_target_position = c_attr.create(
            "input_target_position", "iapos")
        c_attr.writable = True
        c_attr.readable = False
        c_attr.keyable = True

        AimConstaraintNode.input_target_position_x = n_attr.create(
            "input_target_pos_x", "itposx", om.MFnNumericData.kFloat, 0.0)
        n_attr.writable = True
        c_attr.addChild(AimConstaraintNode.input_target_position_x)

        AimConstaraintNode.input_target_position_y = n_attr.create(
            "input_target_pos_y", "itposy", om.MFnNumericData.kFloat, 0.0)
        n_attr.writable = True
        c_attr.addChild(AimConstaraintNode.input_target_position_y)

        AimConstaraintNode.input_target_position_z = n_attr.create(
            "input_target_pos_z", "itposz", om.MFnNumericData.kFloat, 0.0)
        c_attr.addChild(AimConstaraintNode.input_target_position_z)
        n_attr.writable = True

        rotate_attr = om.MFnCompoundAttribute()
        AimConstaraintNode.output_rotate = rotate_attr.create(
            "output_rotate", "or")
        rotate_attr.writable = True

        rotate_unit_attr = om.MFnUnitAttribute()
        AimConstaraintNode.koAngles = [0, 0, 0]

        out_rotate_name = [
            "output_rotateX", "output_rotateY", "output_rotateZ"
        ]
        out_rotate_shortname = ["orx", "ory", "orz"]
        for _ in range(3):
            AimConstaraintNode.koAngles[_] = rotate_unit_attr.create(
                out_rotate_name[_], out_rotate_shortname[_],
                om.MFnUnitAttribute.kAngle, 0.0)
            rotate_unit_attr.writable = True
            rotate_attr.addChild(AimConstaraintNode.koAngles[_])

        AimConstaraintNode.addAttribute(AimConstaraintNode.aim_axis)
        AimConstaraintNode.addAttribute(AimConstaraintNode.input_aim_matrix)
        AimConstaraintNode.addAttribute(
            AimConstaraintNode.input_target_position)

        AimConstaraintNode.addAttribute(
            AimConstaraintNode.input_target_parent_matrix)
        AimConstaraintNode.addAttribute(AimConstaraintNode.output_rotate)

        AimConstaraintNode.attributeAffects(AimConstaraintNode.aim_axis,
                                            AimConstaraintNode.output_rotate)
        AimConstaraintNode.attributeAffects(
            AimConstaraintNode.input_aim_matrix,
            AimConstaraintNode.output_rotate)
        AimConstaraintNode.attributeAffects(
            AimConstaraintNode.input_target_parent_matrix,
            AimConstaraintNode.output_rotate)
        AimConstaraintNode.attributeAffects(
            AimConstaraintNode.input_target_position,
            AimConstaraintNode.output_rotate)
Esempio n. 19
0
    def initialize(cls):
        nAttr = OpenMaya.MFnNumericAttribute()
        tAttr = OpenMaya.MFnTypedAttribute()
        uAttr = OpenMaya.MFnUnitAttribute()
        enumAttr = OpenMaya.MFnEnumAttribute()
        compAttr = OpenMaya.MFnCompoundAttribute()
        matrixAttr = OpenMaya.MFnMatrixAttribute()
        messageAttr = OpenMaya.MFnMessageAttribute()

        cls.forgeID = tAttr.create("forgeID", "fid", OpenMaya.MFnData.kString,
                                   OpenMaya.MObject.kNullObj)
        cls.addAttribute(cls.forgeID)

        cls.guideMatrix = matrixAttr.create(
            "guideMatrix", "gm", OpenMaya.MFnMatrixAttribute.kDouble)
        cls.addAttribute(cls.guideMatrix)

        cls.handleInverseScale = nAttr.create("handleInverseScale", "his",
                                              OpenMaya.MFnNumericData.k3Double,
                                              1.0)
        cls.addAttribute(cls.handleInverseScale)

        cls.boundingBoxCorner1 = nAttr.create("boundingBoxCorner1", "bb1",
                                              OpenMaya.MFnNumericData.k3Double,
                                              0)
        nAttr.keyable = False
        cls.addAttribute(cls.boundingBoxCorner1)
        cls.boundingBoxCorner2 = nAttr.create("boundingBoxCorner2", "bb2",
                                              OpenMaya.MFnNumericData.k3Double,
                                              0)
        nAttr.keyable = False
        cls.addAttribute(cls.boundingBoxCorner2)

        cls.aimAxis = enumAttr.create("aimAxis", "aa", 0)
        enumAttr.addField("X", 0)
        enumAttr.addField("Y", 1)
        enumAttr.addField("Z", 2)
        enumAttr.addField("-X", 3)
        enumAttr.addField("-Y", 4)
        enumAttr.addField("-Z", 5)
        enumAttr.keyable = False
        cls.addAttribute(cls.aimAxis)

        cls.upAxis = enumAttr.create("upAxis", "ua", 2)
        enumAttr.addField("X", 0)
        enumAttr.addField("Y", 1)
        enumAttr.addField("Z", 2)
        enumAttr.addField("-X", 3)
        enumAttr.addField("-Y", 4)
        enumAttr.addField("-Z", 5)
        enumAttr.keyable = False
        cls.addAttribute(cls.upAxis)

        cls.aimVector = nAttr.create("aimVector", "av",
                                     OpenMaya.MFnNumericData.k3Double)
        cls.addAttribute(cls.aimVector)

        cls.upVector = nAttr.create("upVector", "uv",
                                    OpenMaya.MFnNumericData.k3Double)
        cls.addAttribute(cls.upVector)

        cls.provideAimVector = nAttr.create("provideAimVector", "pav",
                                            OpenMaya.MFnNumericData.kBoolean,
                                            0)
        cls.addAttribute(cls.provideAimVector)

        cls.handle = messageAttr.create("handle", "hndl")
        messageAttr.array = True
        cls.addAttribute(cls.handle)

        cls.handleColor = nAttr.createColor("handleColor", "hc")
        cls.addAttribute(cls.handleColor)

        cls.parentGuide = messageAttr.create("parentGuide", "pg")
        cls.addAttribute(cls.parentGuide)

        cls.parentGuideHandleIndex = nAttr.create(
            "parentGuideHandleIndex", "pghi", OpenMaya.MFnNumericData.kShort,
            -1)
        cls.addAttribute(cls.parentGuideHandleIndex)

        cls.childGuide = messageAttr.create("childGuide", "cg")
        cls.addAttribute(cls.childGuide)

        cls.attributeAffects(cls.guideMatrix, cls.boundingBoxCorner1)
        cls.attributeAffects(cls.guideMatrix, cls.boundingBoxCorner2)
        cls.attributeAffects(cls.guideMatrix, cls.handleInverseScale)
        cls.attributeAffects(cls.guideMatrix, cls.aimVector)
        cls.attributeAffects(cls.guideMatrix, cls.upVector)
Esempio n. 20
0
def nodeInitializer():
    classname = CapsuleLinkNode
    # input
    inputCapsuleA = create_capsule_compound(classname, 'inputCapsuleA')
    inputCapsuleB = create_capsule_compound(classname, 'inputCapsuleB')
    outputCapsuleA = create_capsule_compound(classname, 'outputCapsuleA')
    outputCapsuleB = create_capsule_compound(classname, 'outputCapsuleB')

    mAttr = OpenMaya.MFnMatrixAttribute()
    classname.outputA = mAttr.create("outputA", "outputA")
    mAttr.array = False
    mAttr.storable = True
    mAttr.writable = True

    classname.outputB = mAttr.create("outputB", "outputB")
    mAttr.array = False
    mAttr.storable = True
    mAttr.writable = True

    nAttr = OpenMaya.MFnNumericAttribute()
    classname.weight = nAttr.create("weight", "weight",
                                    OpenMaya.MFnNumericData.kDouble, 1.0)
    nAttr.array = False
    nAttr.storable = True
    nAttr.writable = True

    classname.abRatio = nAttr.create("abRatio", "abRatio",
                                     OpenMaya.MFnNumericData.kDouble, 0.0)
    nAttr.array = False
    nAttr.storable = True
    nAttr.writable = True

    classname.aOrientationRatio = nAttr.create("aOrientationRatio",
                                               "aOrientationRatio",
                                               OpenMaya.MFnNumericData.kDouble,
                                               1.0)
    nAttr.array = False
    nAttr.storable = True
    nAttr.writable = True

    classname.addAttribute(classname.outputA)
    classname.addAttribute(classname.outputB)
    classname.addAttribute(classname.weight)
    classname.addAttribute(classname.abRatio)
    classname.addAttribute(classname.aOrientationRatio)

    classname.attributeAffects(inputCapsuleA, classname.outputA)
    classname.attributeAffects(inputCapsuleA, classname.outputB)
    classname.attributeAffects(inputCapsuleB, classname.outputA)
    classname.attributeAffects(inputCapsuleB, classname.outputB)
    classname.attributeAffects(outputCapsuleA, classname.outputA)
    classname.attributeAffects(outputCapsuleA, classname.outputB)
    classname.attributeAffects(outputCapsuleB, classname.outputA)
    classname.attributeAffects(outputCapsuleB, classname.outputB)

    classname.attributeAffects(classname.weight, classname.outputA)
    classname.attributeAffects(classname.weight, classname.outputB)
    classname.attributeAffects(classname.abRatio, classname.outputA)
    classname.attributeAffects(classname.abRatio, classname.outputB)
    classname.attributeAffects(classname.aOrientationRatio, classname.outputA)
    classname.attributeAffects(classname.aOrientationRatio, classname.outputB)
Esempio n. 21
0
    def initialize():
        numericAttr = om.MFnNumericAttribute()
        compoundAttr = om.MFnCompoundAttribute()
        genericAttr = om.MFnGenericAttribute()
        matrixAttr = om.MFnMatrixAttribute()

        # output
        prKeepOut.output = numericAttr.createPoint('output', 'output')
        numericAttr.array = True
        numericAttr.usesArrayDataBuilder = True
        numericAttr.writable = False
        prKeepOut.addAttribute(prKeepOut.output)

        # input
        prKeepOut.enabled = numericAttr.create('enabled', 'enabled',
                                               om.MFnNumericData.kBoolean,
                                               True)
        numericAttr.keyable = True
        prKeepOut.addAttribute(prKeepOut.enabled)
        prKeepOut.attributeAffects(prKeepOut.enabled, prKeepOut.output)

        prKeepOut.offset = numericAttr.create('offset', 'offset',
                                              om.MFnNumericData.kFloat, 0.0)
        numericAttr.keyable = True
        prKeepOut.addAttribute(prKeepOut.offset)
        prKeepOut.attributeAffects(prKeepOut.offset, prKeepOut.output)

        prKeepOut.offsetExtendsPosition = numericAttr.create(
            'offsetExtendsPosition', 'offsetExtendsPosition',
            om.MFnNumericData.kBoolean, True)
        numericAttr.keyable = True
        prKeepOut.addAttribute(prKeepOut.offsetExtendsPosition)
        prKeepOut.attributeAffects(prKeepOut.offsetExtendsPosition,
                                   prKeepOut.output)

        prKeepOut.inputGeometry = genericAttr.create('inputGeometry',
                                                     'inputGeometry')
        genericAttr.addDataType(om.MFnMeshData.kMesh)
        genericAttr.addDataType(om.MFnNurbsSurfaceData.kNurbsSurface)
        genericAttr.array = True
        prKeepOut.addAttribute(prKeepOut.inputGeometry)
        prKeepOut.attributeAffects(prKeepOut.inputGeometry, prKeepOut.output)

        prKeepOut.enabledExtra = numericAttr.create('enabledExtra',
                                                    'enabledExtra',
                                                    om.MFnNumericData.kBoolean,
                                                    True)
        numericAttr.keyable = True
        prKeepOut.offsetExtra = numericAttr.create('offsetExtra',
                                                   'offsetExtra',
                                                   om.MFnNumericData.kFloat,
                                                   0.0)
        numericAttr.keyable = True
        prKeepOut.position1 = numericAttr.createPoint('position1', 'position1')
        numericAttr.keyable = True
        prKeepOut.position2 = numericAttr.createPoint('position2', 'position2')
        numericAttr.keyable = True
        prKeepOut.parentInverseMatrix = matrixAttr.create(
            'parentInverseMatrix',
            'parentInverseMatrix',
            type=matrixAttr.kFloat)
        matrixAttr.keyable = True

        prKeepOut.input = compoundAttr.create('input', 'input')
        compoundAttr.addChild(prKeepOut.enabledExtra)
        compoundAttr.addChild(prKeepOut.offsetExtra)
        compoundAttr.addChild(prKeepOut.position1)
        compoundAttr.addChild(prKeepOut.position2)
        compoundAttr.addChild(prKeepOut.parentInverseMatrix)
        compoundAttr.array = True
        prKeepOut.addAttribute(prKeepOut.input)
        prKeepOut.attributeAffects(prKeepOut.enabledExtra, prKeepOut.output)
        prKeepOut.attributeAffects(prKeepOut.offsetExtra, prKeepOut.output)
        prKeepOut.attributeAffects(prKeepOut.position1, prKeepOut.output)
        prKeepOut.attributeAffects(prKeepOut.position2, prKeepOut.output)
        prKeepOut.attributeAffects(prKeepOut.parentInverseMatrix,
                                   prKeepOut.output)
Esempio n. 22
0
def initialize():
    nAttr = om.MFnNumericAttribute()
    uAttr = om.MFnUnitAttribute()
    mAttr = om.MFnMatrixAttribute()

    flinJiggle.aOutput = nAttr.createPoint('output', 'output')
    nAttr.keyable = False
    nAttr.storable = False
    om.MPxNode.addAttribute(flinJiggle.aOutput)

    flinJiggle.aDamping = nAttr.create('damping', 'damping',
                                       om.MFnNumericData.kFloat, 0.0)
    nAttr.keyable = True
    nAttr.readable = True
    nAttr.storable = True
    nAttr.setMin(0)
    nAttr.setMax(1)
    flinJiggle.addAttribute(flinJiggle.aDamping)

    flinJiggle.aStiffness = nAttr.create('stiffness', 'stiffness',
                                         om.MFnNumericData.kFloat, 0.0)
    nAttr.keyable = True
    nAttr.readable = True
    nAttr.storable = True
    nAttr.setMin(0)
    nAttr.setMax(1)
    flinJiggle.addAttribute(flinJiggle.aStiffness)

    flinJiggle.aJiggle = nAttr.create('jiggle', 'jiggle',
                                      om.MFnNumericData.kFloat, 0.0)
    nAttr.keyable = True
    nAttr.readable = True
    nAttr.storable = True
    flinJiggle.addAttribute(flinJiggle.aJiggle)

    flinJiggle.aTime = uAttr.create('inTime', 'inTime',
                                    om.MFnUnitAttribute.kTime)
    uAttr.keyable = True
    uAttr.readable = True
    uAttr.storable = True
    flinJiggle.addAttribute(flinJiggle.aTime)

    flinJiggle.aGoal = nAttr.createPoint('goal', 'goal')
    nAttr.keyable = True
    nAttr.readable = True
    nAttr.storable = True
    flinJiggle.addAttribute(flinJiggle.aGoal)

    flinJiggle.aParentInverse = mAttr.create('parentInverse', 'parentInverse',
                                             om.MFnData.kMatrix)
    flinJiggle.addAttribute(flinJiggle.aParentInverse)

    flinJiggle.aGoalInverse = mAttr.create('goalInverse', 'goalInverse',
                                           om.MFnData.kMatrix)
    flinJiggle.addAttribute(flinJiggle.aGoalInverse)

    flinJiggle.attributeAffects(flinJiggle.aGoal, flinJiggle.aOutput)
    flinJiggle.attributeAffects(flinJiggle.aDamping, flinJiggle.aOutput)
    flinJiggle.attributeAffects(flinJiggle.aStiffness, flinJiggle.aOutput)
    flinJiggle.attributeAffects(flinJiggle.aTime, flinJiggle.aOutput)
    flinJiggle.attributeAffects(flinJiggle.aJiggle, flinJiggle.aOutput)
    flinJiggle.attributeAffects(flinJiggle.aParentInverse, flinJiggle.aOutput)
    flinJiggle.attributeAffects(flinJiggle.aGoalInverse, flinJiggle.aOutput)
Esempio n. 23
0
def init_decode():
    # (1) Setup attributes
    nAttr = om.MFnNumericAttribute()  # Maya's Numeric Attribute class
    tAttr = om.MFnTypedAttribute()
    mAttr = om.MFnMatrixAttribute()
    uAttr = om.MFnUnitAttribute()
    kFloat = om.MFnNumericData.kFloat  # Maya's float type
    k3Float = om.MFnNumericData.k3Float  # Maya's float type
    kAngle = om.MFnUnitAttribute.kAngle
    kDoubleArray = om.MFnNumericData.kDoubleArray
    kBool = om.MFnNumericData.kBoolean

    # Setup attribute helper functions and classes
    def add_nAttr(params):
        setattr(ikrig_decode, params[0],
                nAttr.create(params[0], params[1], params[2]))
        nAttr.hidden = False
        nAttr.keyable = True
        return getattr(ikrig_decode, params[0])

    def add_out_nAttr(params):
        setattr(ikrig_decode, params[0],
                nAttr.create(params[0], params[1], params[2]))
        mAttr.writable = False
        mAttr.storable = False
        mAttr.readable = True
        return getattr(ikrig_decode, params[0])

    class out_euler_nAttr:
        i = 0

        def create(self, params):
            rotX = uAttr.create("rotateX" + str(self.i), "rx" + str(self.i),
                                kAngle)
            uAttr.writable = False
            uAttr.storable = False
            rotY = uAttr.create("rotateY" + str(self.i), "ry" + str(self.i),
                                kAngle)
            uAttr.writable = False
            uAttr.storable = False
            rotZ = uAttr.create("rotateZ" + str(self.i), "rz" + str(self.i),
                                kAngle)
            uAttr.writable = False
            uAttr.storable = False
            setattr(ikrig_decode, params[0],
                    nAttr.create(params[0], params[1], rotX, rotY, rotZ))
            nAttr.writable = False
            nAttr.storable = False
            nAttr.readable = True
            self.i += 1
            return getattr(ikrig_decode, params[0])

    euler_nAttr = out_euler_nAttr()

    # (2) Setup the input attributes
    in_attributes = []
    ikrig_decode.encoded_pose = tAttr.create('encoded_pose', 'ep',
                                             kDoubleArray,
                                             om.MFnDoubleArrayData().create())
    tAttr.connectable = True
    tAttr.hidden = False
    ikrig_decode.offset_mat = mAttr.create('offset_mat', 'om')
    mAttr.keyable = True
    mAttr.hidden = False
    in_attributes.append(ikrig_decode.encoded_pose)
    in_attributes.append(ikrig_decode.offset_mat)
    in_attributes.append(add_nAttr(('height_hips', 'hh', kFloat)))
    in_attributes.append(add_nAttr(('root_offset_neck', 'o0', k3Float)))
    in_attributes.append(add_nAttr(('root_offset_leg_L', 'o1', k3Float)))
    in_attributes.append(add_nAttr(('root_offset_leg_R', 'o2', k3Float)))
    in_attributes.append(add_nAttr(('root_offset_arm_L', 'o3', k3Float)))
    in_attributes.append(add_nAttr(('root_offset_arm_R', 'o4', k3Float)))
    in_attributes.append(add_nAttr(('length_spine', 'l0', kFloat)))
    in_attributes.append(add_nAttr(('length_neck', 'l1', kFloat)))
    in_attributes.append(add_nAttr(('length_leg_L', 'l2', kFloat)))
    in_attributes.append(add_nAttr(('length_leg_R', 'l3', kFloat)))
    in_attributes.append(add_nAttr(('length_arm_L', 'l4', kFloat)))
    in_attributes.append(add_nAttr(('length_arm_R', 'l5', kFloat)))
    ikrig_decode.normalized_global_xfo = nAttr.create('normalized_global_xfo',
                                                      'nx', kBool, 1)
    nAttr.hidden = False
    nAttr.keyable = True

    # (3) Setup the output attributes
    out_attributes = []
    ikrig_decode.global_mat = mAttr.create('global_mat', 'gm')
    mAttr.writable = False
    mAttr.storable = False
    mAttr.connectable = True
    mAttr.readable = True
    out_attributes.append(ikrig_decode.global_mat)
    out_attributes.append(add_out_nAttr(('ik_Spine_root', 'ikp0', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Spine_dir', 'ikd0', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Spine_eff', 'ike0', k3Float)))
    out_attributes.append(euler_nAttr.create(('ik_Spine_eff_rot', 'ikr0')))
    out_attributes.append(add_out_nAttr(('ik_Neck_root', 'ikp1', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Neck_dir', 'ikd1', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Neck_eff', 'ike1', k3Float)))
    out_attributes.append(euler_nAttr.create(('ik_Neck_eff_rot', 'ikr1')))
    out_attributes.append(add_out_nAttr(('ik_Leg_root_L', 'ikp2', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Leg_dir_L', 'ikd2', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Leg_eff_L', 'ike2', k3Float)))
    out_attributes.append(euler_nAttr.create(('ik_Leg_eff_rot_L', 'ikr2')))
    out_attributes.append(add_out_nAttr(('ik_Leg_root_R', 'ikp3', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Leg_dir_R', 'ikd3', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Leg_eff_R', 'ike3', k3Float)))
    out_attributes.append(euler_nAttr.create(('ik_Leg_eff_rot_R', 'ikr3')))
    out_attributes.append(add_out_nAttr(('ik_Arm_root_L', 'ikp4', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Arm_dir_L', 'ikd4', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Arm_eff_L', 'ike4', k3Float)))
    out_attributes.append(euler_nAttr.create(('ik_Arm_eff_rot_L', 'ikr4')))
    out_attributes.append(add_out_nAttr(('ik_Arm_root_R', 'ikp5', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Arm_dir_R', 'ikd5', k3Float)))
    out_attributes.append(add_out_nAttr(('ik_Arm_eff_R', 'ike5', k3Float)))
    out_attributes.append(euler_nAttr.create(('ik_Arm_eff_rot_R', 'ikr5')))

    # (4) Add the attributes to the node
    for attribute in in_attributes:
        ikrig_decode.addAttribute(attribute)
    for attribute in out_attributes:
        ikrig_decode.addAttribute(attribute)
    ikrig_decode.addAttribute(ikrig_decode.normalized_global_xfo)

    # (5) Set the attribute dependencies
    for out_attribute in out_attributes:
        ikrig_decode.attributeAffects(ikrig_decode.normalized_global_xfo,
                                      out_attribute)
        for in_attribute in in_attributes:
            ikrig_decode.attributeAffects(in_attribute, out_attribute)
Esempio n. 24
0
def init_encode():
    # (1) Setup attributes
    nAttr = om.MFnNumericAttribute()
    mAttr = om.MFnMatrixAttribute()
    tAttr = om.MFnTypedAttribute()
    kDoubleArray = om.MFnNumericData.kDoubleArray
    kFloat = om.MFnNumericData.kFloat
    k3Float = om.MFnNumericData.k3Float
    kBool = om.MFnNumericData.kBoolean

    def add_nAttr(params):
        setattr(ikrig_encode, params[0],
                nAttr.create(params[0], params[1], params[2]))
        nAttr.hidden = False
        nAttr.keyable = True
        return getattr(ikrig_encode, params[0])

    def add_mAttr(params):
        setattr(ikrig_encode, params[0], mAttr.create(params[0], params[1]))
        mAttr.writable = True
        mAttr.storable = True
        mAttr.connectable = True
        mAttr.hidden = False
        return getattr(ikrig_encode, params[0])

    ikrig_encode.mirror = nAttr.create('mirror', 'mi', kBool, 0)
    nAttr.hidden = False
    nAttr.keyable = True
    ikrig_encode.normalize_global_xfo = nAttr.create('normalize_global_xfo',
                                                     'nx', kBool, 1)
    nAttr.hidden = False
    nAttr.keyable = True

    in_attributes = []

    # Character size attr.
    in_attributes.append(add_nAttr(('height_hips', 'hh', kFloat)))
    in_attributes.append(add_nAttr(('root_offset_neck', 'o0', k3Float)))
    in_attributes.append(add_nAttr(('root_offset_leg_L', 'o1', k3Float)))
    in_attributes.append(add_nAttr(('root_offset_leg_R', 'o2', k3Float)))
    in_attributes.append(add_nAttr(('root_offset_arm_L', 'o3', k3Float)))
    in_attributes.append(add_nAttr(('root_offset_arm_R', 'o4', k3Float)))
    in_attributes.append(add_nAttr(('length_spine', 'l0', kFloat)))
    in_attributes.append(add_nAttr(('length_neck', 'l1', kFloat)))
    in_attributes.append(add_nAttr(('length_leg_L', 'l2', kFloat)))
    in_attributes.append(add_nAttr(('length_leg_R', 'l3', kFloat)))
    in_attributes.append(add_nAttr(('length_arm_L', 'l4', kFloat)))
    in_attributes.append(add_nAttr(('length_arm_R', 'l5', kFloat)))

    # Character positional attr.
    in_attributes.append(add_mAttr(('mat_hips_rest', 'hr')))
    in_attributes.append(add_mAttr(('mat_hips', 'h')))
    in_attributes.append(add_mAttr(('mat_spine', 's')))
    in_attributes.append(add_mAttr(('mat_chest', 'c')))
    in_attributes.append(add_mAttr(('mat_neck', 'n')))
    in_attributes.append(add_mAttr(('mat_neck_mid', 'nm')))
    in_attributes.append(add_mAttr(('mat_head', 'e')))
    in_attributes.append(add_mAttr(('mat_leg_L', 'll')))
    in_attributes.append(add_mAttr(('mat_shin_L', 'sl')))
    in_attributes.append(add_mAttr(('mat_foot_L', 'fl')))
    in_attributes.append(add_mAttr(('mat_leg_R', 'lr')))
    in_attributes.append(add_mAttr(('mat_shin_R', 'sr')))
    in_attributes.append(add_mAttr(('mat_foot_R', 'fr')))
    in_attributes.append(add_mAttr(('mat_shoulder_L', 'ol')))
    in_attributes.append(add_mAttr(('mat_elbow_L', 'el')))
    in_attributes.append(add_mAttr(('mat_hand_L', 'al')))
    in_attributes.append(add_mAttr(('mat_shoulder_R', 'or')))
    in_attributes.append(add_mAttr(('mat_elbow_R', 'er')))
    in_attributes.append(add_mAttr(('mat_hand_R', 'ar')))

    #(2) Setup the output attributes
    ikrig_encode.result = tAttr.create('result', 'r', kDoubleArray,
                                       om.MFnDoubleArrayData().create())
    tAttr.writable = False
    tAttr.storable = False
    tAttr.readable = True

    # (3) Add the attributes to the node
    for attribute in in_attributes:
        ikrig_encode.addAttribute(attribute)
    ikrig_encode.addAttribute(ikrig_encode.mirror)
    ikrig_encode.addAttribute(ikrig_encode.normalize_global_xfo)
    ikrig_encode.addAttribute(ikrig_encode.result)

    # (4) Set the attribute dependencies
    for attribute in in_attributes:
        ikrig_encode.attributeAffects(attribute, ikrig_encode.result)
    ikrig_encode.attributeAffects(ikrig_encode.mirror, ikrig_encode.result)
    ikrig_encode.attributeAffects(ikrig_encode.normalize_global_xfo,
                                  ikrig_encode.result)
Esempio n. 25
0
    def initialize(cls):
        nAttr = om.MFnNumericAttribute()
        enumAttr = om.MFnEnumAttribute()
        matAttr = om.MFnMatrixAttribute()
        uAttr = om.MFnUnitAttribute()
        typedAttr = om.MFnTypedAttribute()

        cls.shapeAttr = enumAttr.create('shape', 'sh', 0)
        enumAttr.addField('Custom', -1)
        for idx, shape in enumerate(shapes):
            enumAttr.addField(shape['name'], idx)
        enumAttr.channelBox = True
        cls.addAttribute(cls.shapeAttr)

        cls.customMeshAttr = typedAttr.create("inCustomMesh", "icm",
                                              om.MFnMeshData.kMesh)
        typedAttr.storable = False
        # The kReset constant is missing from the Python 2.0 API.
        typedAttr.disconnectBehavior = 1
        cls.addAttribute(cls.customMeshAttr)

        cls.transformAttr = matAttr.create('transform', 't',
                                           om.MFnMatrixAttribute.kFloat)
        matAttr.keyable = False
        cls.addAttribute(cls.transformAttr)

        localRotateX = uAttr.create('localRotateX', 'lrx',
                                    om.MFnUnitAttribute.kAngle, 0.0)
        localRotateY = uAttr.create('localRotateY', 'lry',
                                    om.MFnUnitAttribute.kAngle, 0.0)
        localRotateZ = uAttr.create('localRotateZ', 'lrz',
                                    om.MFnUnitAttribute.kAngle, 0.0)
        cls.localRotateAttr = nAttr.create('localRotate', 'lr', localRotateX,
                                           localRotateY, localRotateZ)
        nAttr.channelBox = True
        nAttr.keyable = False
        cls.addAttribute(cls.localRotateAttr)

        cls.localTranslateAttr = nAttr.createPoint('localPosition', 'lp')
        nAttr.channelBox = True
        nAttr.keyable = False
        cls.addAttribute(cls.localTranslateAttr)

        localScaleX = nAttr.create('localScaleX', 'lsx',
                                   om.MFnNumericData.kFloat, 1)
        localScaleY = nAttr.create('localScaleY', 'lsy',
                                   om.MFnNumericData.kFloat, 1)
        localScaleZ = nAttr.create('localScaleZ', 'lsz',
                                   om.MFnNumericData.kFloat, 1)
        cls.localScaleAttr = nAttr.create('localScale', 'ls', localScaleX,
                                          localScaleY, localScaleZ)
        nAttr.channelBox = True
        nAttr.keyable = False
        cls.addAttribute(cls.localScaleAttr)

        cls.colorAttr = nAttr.createColor('color', 'dc')
        nAttr.default = (.38, 0, 0.02)
        cls.addAttribute(cls.colorAttr)

        cls.alphaAttr = nAttr.create('alpha', 'a', om.MFnNumericData.kFloat,
                                     0.333)
        nAttr.setSoftMin(0)
        nAttr.setSoftMax(1)
        nAttr.keyable = False
        cls.addAttribute(cls.alphaAttr)

        cls.borderColorAttr = nAttr.createColor('borderColor', 'bc')
        nAttr.default = (-1, -1, -1)
        cls.addAttribute(cls.borderColorAttr)

        cls.borderAlphaAttr = nAttr.create('borderAlpha', 'ba',
                                           om.MFnNumericData.kFloat, 1)
        nAttr.setSoftMin(0)
        nAttr.setSoftMax(1)
        nAttr.keyable = False
        cls.addAttribute(cls.borderAlphaAttr)

        cls.xrayAttr = nAttr.create('xray', 'xr', om.MFnNumericData.kBoolean,
                                    True)
        nAttr.keyable = False
        nAttr.channelBox = True
        cls.addAttribute(cls.xrayAttr)
Esempio n. 26
0
def addAttribute(node, longName, shortName, attrType=attrtypes.kMFnNumericDouble, isArray=False, apply=True):
    """This function uses the api to create attributes on the given node, currently WIP but currently works for
    string,int, float, bool, message, matrix. if the attribute exists a ValueError will be raised.

    :param node: MObject
    :param longName: str, the long name for the attribute
    :param shortName: str, the shortName for the attribute
    :param attrType: attribute Type, attrtypes constants
    :param apply: if False the attribute will be immediately created on the node else just return the attribute instance
    :rtype: om.MObject
    """
    if hasAttribute(node, longName):
        raise ValueError("Node -> '%s' already has attribute -> '%s'" % (nameFromMObject(node), longName))
    aobj = None
    attr = None
    if attrType == attrtypes.kMFnNumericDouble:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.kDouble)
    elif attrType == attrtypes.kMFnNumericFloat:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.kFloat)
    elif attrType == attrtypes.kMFnNumericBoolean:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.kBoolean)
    elif attrType == attrtypes.kMFnNumericInt:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.kInt)
    elif attrType == attrtypes.kMFnNumericShort:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.kShort)
    elif attrType == attrtypes.kMFnNumericLong:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.kLong)
    elif attrType == attrtypes.kMFnNumericByte:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.kByte)
    elif attrType == attrtypes.kMFnNumericChar:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.kChar)
    elif attrType == attrtypes.kMFnNumericAddr:
        attr = om2.MFnNumericAttribute()
        aobj = attr.createAddr(longName, shortName)
    elif attrType == attrtypes.kMFnkEnumAttribute:
        attr = om2.MFnEnumAttribute()
        aobj = attr.create(longName, shortName)
    elif attrType == attrtypes.kMFnCompoundAttribute:
        attr = om2.MFnCompoundAttribute()
        aobj = attr.create(longName, shortName)
    elif attrType == attrtypes.kMFnMessageAttribute:
        attr = om2.MFnMessageAttribute()
        aobj = attr.create(longName, shortName)
    elif attrType == attrtypes.kMFnDataString:
        attr = om2.MFnTypedAttribute()
        stringData = om2.MFnStringData().create("")
        aobj = attr.create(longName, shortName, om2.MFnData.kString, stringData)
    elif attrType == attrtypes.kMFnUnitAttributeDistance:
        attr = om2.MFnUnitAttribute()
        aobj = attr.create(longName, shortName, om2.MDistance())
    elif attrType == attrtypes.kMFnUnitAttributeAngle:
        attr = om2.MFnUnitAttribute()
        aobj = attr.create(longName, shortName, om2.MAngle())
    elif attrType == attrtypes.kMFnUnitAttributeTime:
        attr = om2.MFnUnitAttribute()
        aobj = attr.create(longName, shortName, om2.MTime())
    elif attrType == attrtypes.kMFnDataMatrix:
        attr = om2.MFnMatrixAttribute()
        aobj = attr.create(longName, shortName)
    elif attrType == attrtypes.kMFnDataFloatArray:
        attr = om2.MFnFloatArray()
        aobj = attr.create(longName, shortName)
    elif attrType == attrtypes.kMFnDataDoubleArray:
        data = om2.MFnDoubleArrayData().create(om2.MDoubleArray())
        attr = om2.MFnTypedAttribute()
        aobj = attr.create(longName, shortName, om2.MFnData.kDoubleArray, data)
    elif attrType == attrtypes.kMFnDataIntArray:
        data = om2.MFnIntArrayData().create(om2.MIntArray())
        attr = om2.MFnTypedAttribute()
        aobj = attr.create(longName, shortName, om2.MFnData.kIntArray, data)
    elif attrType == attrtypes.kMFnDataPointArray:
        data = om2.MFnPointArrayData().create(om2.MPointArray())
        attr = om2.MFnTypedAttribute()
        aobj = attr.create(longName, shortName, om2.MFnData.kPointArray, data)
    elif attrType == attrtypes.kMFnDataVectorArray:
        data = om2.MFnVectorArrayData().create(om2.MVectorArray())
        attr = om2.MFnTypedAttribute()
        aobj = attr.create(longName, shortName, om2.MFnData.kVectorArray, data)
    elif attrType == attrtypes.kMFnDataStringArray:
        data = om2.MFnStringArrayData().create(om2.MStringArray())
        attr = om2.MFnTypedAttribute()
        aobj = attr.create(longName, shortName, om2.MFnData.kStringArray, data)
    elif attrType == attrtypes.kMFnDataMatrixArray:
        data = om2.MFnMatrixArrayData().create(om2.MMatrixArray())
        attr = om2.MFnTypedAttribute()
        aobj = attr.create(longName, shortName, om2.MFnData.kMatrixArray, data)
    elif attrType == attrtypes.kMFnNumericInt64:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.kInt64)
    elif attrType == attrtypes.kMFnNumericLast:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.kLast)
    elif attrType == attrtypes.kMFnNumeric2Double:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.k2Double)
    elif attrType == attrtypes.kMFnNumeric2Float:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.k2Float)
    elif attrType == attrtypes.kMFnNumeric2Int:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.k2Int)
    elif attrType == attrtypes.kMFnNumeric2Long:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.k2Long)
    elif attrType == attrtypes.kMFnNumeric2Short:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.k2Short)
    elif attrType == attrtypes.kMFnNumeric3Double:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.k3Double)
    elif attrType == attrtypes.kMFnNumeric3Float:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.k3Float)
    elif attrType == attrtypes.kMFnNumeric3Int:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.k3Int)
    elif attrType == attrtypes.kMFnNumeric3Long:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.k3Long)
    elif attrType == attrtypes.kMFnNumeric3Short:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.k3Short)
    elif attrType == attrtypes.kMFnNumeric4Double:
        attr = om2.MFnNumericAttribute()
        aobj = attr.create(longName, shortName, om2.MFnNumericData.k4Double)

    if aobj is not None and apply:
        attr.array = isArray
        mod = om2.MDGModifier()
        mod.addAttribute(node, aobj)
        mod.doIt()
    return attr
Esempio n. 27
0
def nodeInitializer():
    # create attributes

    # pick your pointy poison
    solverAttrFn = om.MFnEnumAttribute()
    generalIk.aSolver = solverAttrFn.create("solver", "sol", 0)
    solverAttrFn.addField("CCD", 0)
    solverAttrFn.addField("FABRIK (not yet implemented)", 1)
    solverAttrFn.storable = True
    solverAttrFn.keyable = True
    solverAttrFn.readable = False
    solverAttrFn.writable = True
    om.MPxNode.addAttribute(generalIk.aSolver)

    iterAttrFn = om.MFnNumericAttribute()
    generalIk.aMaxIter = iterAttrFn.create("maxIterations", "mi",
                                           om.MFnNumericData.kLong, 30)
    iterAttrFn.storable = True
    iterAttrFn.keyable = True
    iterAttrFn.readable = False
    iterAttrFn.writable = True
    iterAttrFn.setMin(0)
    om.MPxNode.addAttribute(generalIk.aMaxIter)

    # how far will you go for perfection
    toleranceAttrFn = om.MFnNumericAttribute()
    generalIk.aTolerance = toleranceAttrFn.create("tolerance", "tol",
                                                  om.MFnNumericData.kDouble,
                                                  0.1)
    toleranceAttrFn.storable = True
    toleranceAttrFn.keyable = True
    toleranceAttrFn.readable = False
    toleranceAttrFn.writable = True
    toleranceAttrFn.setMin(0)
    om.MPxNode.addAttribute(generalIk.aTolerance)

    # weight of the world
    globalWeightAttrFn = om.MFnNumericAttribute()
    generalIk.aGlobalWeight = globalWeightAttrFn.create(
        "globalWeight", "globalWeight", om.MFnNumericData.kDouble, 0.8)
    globalWeightAttrFn.writable = True
    globalWeightAttrFn.keyable = True
    om.MPxNode.addAttribute(generalIk.aGlobalWeight)

    # let the past die?
    # cacheOnAttrFn = om.MFnNumericAttribute()
    # generalIk.aCacheOn = cacheOnAttrFn.create(
    # 	"cacheOn", "cacheOn", om.MFnNumericData.kBoolean, 1)
    # om.MPxNode.addAttribute(generalIk.aCacheOn)
    generalIk.aCacheOn = nodeio.makeBindAttr(generalIk, name="cache")
    om.MPxNode.addAttribute(generalIk.aCacheOn)

    # what are your goals in life
    targetMatAttrFn = om.MFnMatrixAttribute()
    generalIk.aTargetMat = targetMatAttrFn.create("targetMatrix", "targetMat",
                                                  1)
    targetMatAttrFn.storable = True
    targetMatAttrFn.readable = False
    targetMatAttrFn.keyable = False
    targetMatAttrFn.writable = True
    targetMatAttrFn.cached = True
    om.MPxNode.addAttribute(generalIk.aTargetMat)

    # compare and contrast
    endMatAttrFn = om.MFnMatrixAttribute()
    generalIk.aEndMat = endMatAttrFn.create("inputEndMatrix", "endMat", 1)
    endMatAttrFn.storable = True
    endMatAttrFn.readable = False
    endMatAttrFn.keyable = False
    endMatAttrFn.writable = True
    endMatAttrFn.cached = True
    om.MPxNode.addAttribute(generalIk.aEndMat)

    # once i built a tower
    jntMatAttrFn = om.MFnMatrixAttribute()
    generalIk.aJntMat = jntMatAttrFn.create("worldMatrix", "worldMatrix", 1)
    jntMatAttrFn.storable = False
    jntMatAttrFn.writable = True
    jntMatAttrFn.cached = False  # prevent ghost influences from staying

    # are you local
    jntLocalMatAttrFn = om.MFnMatrixAttribute()
    generalIk.aJntLocalMat = jntLocalMatAttrFn.create("localMatrix",
                                                      "localMatrix", 1)

    # joint orients
    orientRxAttrFn = om.MFnUnitAttribute()
    generalIk.aOrientRx = orientRxAttrFn.create("orientX", "orientX", 1, 0.0)

    orientRyAttrFn = om.MFnUnitAttribute()
    generalIk.aOrientRy = orientRyAttrFn.create("orientY", "orientY", 1, 0.0)

    orientRzAttrFn = om.MFnUnitAttribute()
    generalIk.aOrientRz = orientRzAttrFn.create("orientZ", "orientZ", 1, 0.0)

    orientRotAttrFn = om.MFnCompoundAttribute()
    generalIk.aOrientRot = orientRotAttrFn.create("orient", "orient")
    orientRotAttrFn.storable = False
    orientRotAttrFn.writable = True
    orientRotAttrFn.keyable = False
    orientRotAttrFn.addChild(generalIk.aOrientRx)
    orientRotAttrFn.addChild(generalIk.aOrientRy)
    orientRotAttrFn.addChild(generalIk.aOrientRz)

    # rotate order
    rotOrderAttrFn = om.MFnNumericAttribute()
    generalIk.aRotOrder = rotOrderAttrFn.create("rotateOrder", "rotateOrder",
                                                om.MFnNumericData.kLong, 0)

    # eye on the sky
    jntUpMatAttrFn = om.MFnMatrixAttribute()
    generalIk.aJntUpMat = jntUpMatAttrFn.create("upMatrix", "jntUpMat", 1)
    jntUpMatAttrFn.storable = True
    jntUpMatAttrFn.writable = True
    jntUpMatAttrFn.cached = True
    # om.MPxNode.addAttribute(generalIk.aJntUpMat)

    # but which way is up
    jntUpDirAttrFn = om.MFnNumericAttribute()
    generalIk.aJntUpDir = jntUpDirAttrFn.create("upDir", "upDir",
                                                om.MFnNumericData.k3Double)

    # who is the heftiest boi
    jntWeightAttrFn = om.MFnNumericAttribute()
    generalIk.aJntWeight = jntWeightAttrFn.create("weight", "jntWeight",
                                                  om.MFnNumericData.kDouble, 1)
    jntWeightAttrFn.storable = True
    jntWeightAttrFn.keyable = True
    jntWeightAttrFn.writable = True
    jntWeightAttrFn.setMin(0)
    # om.MPxNode.addAttribute(generalIk.aJntWeight)

    limitAttrFn = om.MFnCompoundAttribute()
    generalIk.aLimits = limitAttrFn.create("limits", "limits")

    # like really know them
    rxMaxAttrFn = om.MFnNumericAttribute()
    generalIk.aRxMax = rxMaxAttrFn.create("maxRotateX", "maxRx",
                                          om.MFnNumericData.kDouble, 0)
    # how low can you go
    rxMinAttrFn = om.MFnNumericAttribute()
    generalIk.aRxMin = rxMinAttrFn.create("minRotateX", "minRx",
                                          om.MFnNumericData.kDouble, 0)
    limitAttrFn.addChild(generalIk.aRxMax)
    limitAttrFn.addChild(generalIk.aRxMin)

    ## there is more to be done here

    # you will never break the chain
    jntArrayAttrFn = om.MFnCompoundAttribute()
    generalIk.aJnts = jntArrayAttrFn.create("inputJoints", "inputJoints")
    jntArrayAttrFn.array = True
    jntArrayAttrFn.usesArrayDataBuilder = True
    jntArrayAttrFn.addChild(generalIk.aJntMat)
    jntArrayAttrFn.addChild(generalIk.aJntLocalMat)
    jntArrayAttrFn.addChild(generalIk.aJntUpMat)
    jntArrayAttrFn.addChild(generalIk.aJntUpDir)
    jntArrayAttrFn.addChild(generalIk.aJntWeight)
    jntArrayAttrFn.addChild(generalIk.aOrientRot)
    jntArrayAttrFn.addChild(generalIk.aRotOrder)
    jntArrayAttrFn.addChild(generalIk.aLimits)
    # add limits later
    om.MPxNode.addAttribute(generalIk.aJnts)

    # fruits of labour
    outRxAttrFn = om.MFnUnitAttribute()
    generalIk.aOutRx = outRxAttrFn.create("rotateX", "outRx", 1, 0.0)
    outRxAttrFn.writable = False
    outRxAttrFn.keyable = False
    # om.MPxNode.addAttribute(generalIk.aOutRx)

    outRyAttrFn = om.MFnUnitAttribute()
    generalIk.aOutRy = outRyAttrFn.create("rotateY", "outRy", 1, 0.0)
    outRyAttrFn.writable = False
    outRyAttrFn.keyable = False
    # om.MPxNode.addAttribute(generalIk.aOutRy)

    outRzAttrFn = om.MFnUnitAttribute()
    generalIk.aOutRz = outRzAttrFn.create("rotateZ", "outRz", 1, 0.0)
    outRzAttrFn.writable = False
    outRzAttrFn.keyable = False
    # om.MPxNode.addAttribute(generalIk.aOutRz)

    outRotAttrFn = om.MFnCompoundAttribute()
    # generalIk.aOutRot = outRotAttrFn.create("outputRotate", "outRot",
    #     om.MFnNumericData.k3Double)
    generalIk.aOutRot = outRotAttrFn.create("rotate", "outRot")
    outRotAttrFn.storable = False
    outRotAttrFn.writable = False
    outRotAttrFn.keyable = False
    outRotAttrFn.addChild(generalIk.aOutRx)
    outRotAttrFn.addChild(generalIk.aOutRy)
    outRotAttrFn.addChild(generalIk.aOutRz)
    om.MPxNode.addAttribute(generalIk.aOutRot)

    # # add smooth jazz

    outTransAttrFn = om.MFnNumericAttribute()
    generalIk.aOutTrans = outTransAttrFn.create("translate", "outTrans",
                                                om.MFnNumericData.k3Double)
    outTransAttrFn.storable = False
    outTransAttrFn.writable = False
    outTransAttrFn.keyable = False
    om.MPxNode.addAttribute(generalIk.aOutTrans)

    # all that the sun touches
    outArrayAttrFn = om.MFnCompoundAttribute()
    generalIk.aOutArray = outArrayAttrFn.create("outputJoints", "out")
    outArrayAttrFn.array = True
    outArrayAttrFn.usesArrayDataBuilder = True
    outArrayAttrFn.storable = False
    outArrayAttrFn.writable = False
    outArrayAttrFn.keyable = False
    outArrayAttrFn.addChild(generalIk.aOutRot)
    outArrayAttrFn.addChild(generalIk.aOutTrans)
    om.MPxNode.addAttribute(generalIk.aOutArray)
    # investigate rolling this into the input hierarchy

    # convenience end attributes for babies
    outEndTransFn = om.MFnNumericAttribute()
    generalIk.aOutEndTrans = outEndTransFn.create("outputEndTranslate",
                                                  "outputEndTranslate",
                                                  om.MFnNumericData.k3Double)
    outEndTransFn.writable = False
    om.MPxNode.addAttribute(generalIk.aOutEndTrans)

    outEndRotFn = om.MFnCompoundAttribute()
    generalIk.aOutEndRot = outEndRotFn.create("outputEndRotate",
                                              "outputEndRotate")
    outEndRotFn.writable = False
    outEndRxAttrFn = om.MFnUnitAttribute()
    generalIk.aOutEndRx = outEndRxAttrFn.create("outputEndRotateX", "outEndRx",
                                                1, 0.0)
    outEndRotFn.addChild(generalIk.aOutEndRx)
    outEndRyAttrFn = om.MFnUnitAttribute()
    generalIk.aOutEndRy = outEndRyAttrFn.create("outputEndRotateY", "outEndRy",
                                                1, 0.0)
    outEndRotFn.addChild(generalIk.aOutEndRy)
    outEndRzAttrFn = om.MFnUnitAttribute()
    generalIk.aOutEndRz = outEndRzAttrFn.create("outputEndRotateZ", "outEndRz",
                                                1, 0.0)
    outEndRotFn.addChild(generalIk.aOutEndRz)
    om.MPxNode.addAttribute(generalIk.aOutEndRot)

    # debug
    debugTargetFn = om.MFnMatrixAttribute()
    generalIk.aDebugTarget = debugTargetFn.create("debugTarget", "debugTarget",
                                                  1)
    om.MPxNode.addAttribute(generalIk.aDebugTarget)

    debugOffset = om.MFnNumericAttribute()
    generalIk.aDebugOffset = debugOffset.create("debugOffset", "debugOffset",
                                                om.MFnNumericData.kDouble, 0)
    om.MPxNode.addAttribute(generalIk.aDebugOffset)

    # caching results to persist across graph evaluations
    cacheMatricesFn = om.MFnTypedAttribute()
    matrixArrayData = om.MFnMatrixArrayData().create()
    generalIk.aCacheMatrices = cacheMatricesFn.create(
        "cacheMatrices", "cacheMatrices", 12, matrixArrayData)  # matrix array
    cacheMatricesFn.writable = True
    cacheMatricesFn.readable = True
    cacheMatricesFn.cached = True
    cacheMatricesFn.keyable = True
    om.MPxNode.addAttribute(generalIk.aCacheMatrices)

    # everyone's counting on you
    drivers = [
        generalIk.aTargetMat, generalIk.aEndMat, generalIk.aJnts,
        generalIk.aMaxIter, generalIk.aGlobalWeight, generalIk.aTolerance,
        generalIk.aJntWeight, generalIk.aCacheOn
    ]
    driven = [
        generalIk.aOutArray, generalIk.aOutEndTrans, generalIk.aOutEndRot,
        generalIk.aDebugTarget, generalIk.aDebugOffset
    ]

    nodeio.setAttributeAffects(drivers, driven, generalIk)
Esempio n. 28
0
    def initialize():
        matrixAttr = om.MFnMatrixAttribute()
        numericAttr = om.MFnNumericAttribute()
        enumAttr = om.MFnEnumAttribute()
        typedAttr = om.MFnTypedAttribute()

        # OUTPUT
        prUpCurveSpline.outputMatrix = matrixAttr.create(
            'outputMatrix', 'outputMatrix')
        matrixAttr.array = True
        matrixAttr.usesArrayDataBuilder = True
        matrixAttr.writable = False
        prUpCurveSpline.addAttribute(prUpCurveSpline.outputMatrix)

        # INPUTS
        prUpCurveSpline.curve = typedAttr.create(
            'curve', 'curve', om.MFnNurbsCurveData.kNurbsCurve)
        prUpCurveSpline.addAttribute(prUpCurveSpline.curve)
        prUpCurveSpline.attributeAffects(prUpCurveSpline.curve,
                                         prUpCurveSpline.outputMatrix)

        prUpCurveSpline.upCurve = typedAttr.create(
            'upCurve', 'upCurve', om.MFnNurbsCurveData.kNurbsCurve)
        prUpCurveSpline.addAttribute(prUpCurveSpline.upCurve)
        prUpCurveSpline.attributeAffects(prUpCurveSpline.upCurve,
                                         prUpCurveSpline.outputMatrix)

        prUpCurveSpline.startOrientMatrix = matrixAttr.create(
            'startOrientMatrix', 'startOrientMatrix')
        prUpCurveSpline.addAttribute(prUpCurveSpline.startOrientMatrix)
        prUpCurveSpline.attributeAffects(prUpCurveSpline.startOrientMatrix,
                                         prUpCurveSpline.outputMatrix)

        prUpCurveSpline.endOrientMatrix = matrixAttr.create(
            'endOrientMatrix', 'endOrientMatrix')
        prUpCurveSpline.addAttribute(prUpCurveSpline.endOrientMatrix)
        prUpCurveSpline.attributeAffects(prUpCurveSpline.endOrientMatrix,
                                         prUpCurveSpline.outputMatrix)

        # SETTINGS
        prUpCurveSpline.parameterType = enumAttr.create(
            'parameterType', 'parameterType', 1)
        enumAttr.addField('param', 0)
        enumAttr.addField('param normalized', 1)
        enumAttr.addField('length', 2)
        enumAttr.addField('fractionMode', 3)
        enumAttr.keyable = True
        prUpCurveSpline.addAttribute(prUpCurveSpline.parameterType)
        prUpCurveSpline.attributeAffects(prUpCurveSpline.parameterType,
                                         prUpCurveSpline.outputMatrix)

        prUpCurveSpline.aimAxis = enumAttr.create('aimAxis', 'aimAxis', 0)
        enumAttr.addField('x', 0)
        enumAttr.addField('y', 1)
        enumAttr.addField('z', 2)
        enumAttr.addField('-x', 3)
        enumAttr.addField('-y', 4)
        enumAttr.addField('-z', 5)
        enumAttr.keyable = True
        prUpCurveSpline.addAttribute(prUpCurveSpline.aimAxis)
        prUpCurveSpline.attributeAffects(prUpCurveSpline.aimAxis,
                                         prUpCurveSpline.outputMatrix)

        prUpCurveSpline.upAxis = enumAttr.create('upAxis', 'upAxis', 1)
        enumAttr.addField('x', 0)
        enumAttr.addField('y', 1)
        enumAttr.addField('z', 2)
        enumAttr.addField('-x', 3)
        enumAttr.addField('-y', 4)
        enumAttr.addField('-z', 5)
        enumAttr.keyable = True
        prUpCurveSpline.addAttribute(prUpCurveSpline.upAxis)
        prUpCurveSpline.attributeAffects(prUpCurveSpline.upAxis,
                                         prUpCurveSpline.outputMatrix)

        prUpCurveSpline.startOrientMatrixWeight = numericAttr.create(
            'startOrientMatrixWeight', 'startOrientMatrixWeight',
            om.MFnNumericData.kFloat, 0.0)
        numericAttr.keyable = True
        numericAttr.setMin(0.0)
        numericAttr.setMax(1.0)
        prUpCurveSpline.addAttribute(prUpCurveSpline.startOrientMatrixWeight)
        prUpCurveSpline.attributeAffects(
            prUpCurveSpline.startOrientMatrixWeight,
            prUpCurveSpline.outputMatrix)

        prUpCurveSpline.endOrientMatrixWeight = numericAttr.create(
            'endOrientMatrixWeight', 'endOrientMatrixWeight',
            om.MFnNumericData.kFloat, 0.0)
        numericAttr.keyable = True
        numericAttr.setMin(0.0)
        numericAttr.setMax(1.0)
        prUpCurveSpline.addAttribute(prUpCurveSpline.endOrientMatrixWeight)
        prUpCurveSpline.attributeAffects(prUpCurveSpline.endOrientMatrixWeight,
                                         prUpCurveSpline.outputMatrix)

        prUpCurveSpline.parameter = numericAttr.create(
            'parameter', 'parameter', om.MFnNumericData.kFloat, 0.0)
        numericAttr.keyable = True
        numericAttr.array = True
        numericAttr.usesArrayDataBuilder = True
        prUpCurveSpline.addAttribute(prUpCurveSpline.parameter)
        prUpCurveSpline.attributeAffects(prUpCurveSpline.parameter,
                                         prUpCurveSpline.outputMatrix)
Esempio n. 29
0
    return tuple(mfn.get(i) for i in range(mfn.length()))


_api_type_table = {
    _om2.MFn.kDoubleLinearAttribute:
    lambda plug: plug.asMDistance().asUnits(_om2.MDistance.uiUnit()),
    _om2.MFn.kFloatLinearAttribute:
    lambda plug: plug.asMDistance().asUnits(_om2.MDistance.uiUnit()),
    _om2.MFn.kDoubleAngleAttribute:
    lambda plug: plug.asMAngle().asUnits(_om2.MAngle.uiUnit()),
    _om2.MFn.kFloatAngleAttribute:
    lambda plug: plug.asMAngle().asUnits(_om2.MAngle.uiUnit()),
    _om2.MFn.kEnumAttribute:
    lambda plug: plug.asInt(),
    _om2.MFn.kMatrixAttribute:
    lambda plug: _om2.MFnMatrixAttribute(plug.asMObject()).matrix(),
}

_typed_attr_table = {
    _om2.MFnData.kString:
    lambda plug: plug.asString(),
    _om2.MFnData.kMatrix:
    lambda plug: _om2.MFnMatrixData(plug.asMObject()).matrix(),
    _om2.MFnData.kComponentList:
    _get_component_list_data,
}

_numeric_attr_table = {
    _om2.MFnNumericData.kBoolean: lambda plug: plug.asBool(),
    _om2.MFnNumericData.kInt: lambda plug: plug.asInt(),
    _om2.MFnNumericData.kByte: lambda plug: plug.asInt(),
Esempio n. 30
0
    def initialize():
        mtxMFnAttr = om2.MFnMatrixAttribute()
        compoundMFnAttr = om2.MFnCompoundAttribute()
        numericMFnAttr = om2.MFnNumericAttribute()
        numMFnAttr = om2.MFnNumericAttribute()
        mFnNumericData = om2.MFnNumericData()

        Vectors2Matrix.mtxOut = mtxMFnAttr.create('matrixOut', 'mtxOut')
        mtxMFnAttr.readable = True
        Vectors2Matrix.addAttribute(Vectors2Matrix.mtxOut)

        Vectors2Matrix.row0 = compoundMFnAttr.create('row0', 'row0')
        r0XChild = numMFnAttr.create("r0X", "r0X", mFnNumericData.kFloat, 1.0)
        r0YChild = numMFnAttr.create("r0Y", "r0Y", mFnNumericData.kFloat, 0.0)
        r0ZChild = numMFnAttr.create("r0Z", "r0Z", mFnNumericData.kFloat, 0.0)
        mtxMFnAttr.readable = True
        mtxMFnAttr.writable = True
        mtxMFnAttr.storable = True
        compoundMFnAttr.addChild(r0XChild)
        compoundMFnAttr.addChild(r0YChild)
        compoundMFnAttr.addChild(r0ZChild)
        Vectors2Matrix.addAttribute(Vectors2Matrix.row0)

        Vectors2Matrix.row0W = numericMFnAttr.create('row0W', 'row0W',
                                                     mFnNumericData.kFloat,
                                                     0.0)
        mtxMFnAttr.readable = True
        mtxMFnAttr.writable = True
        mtxMFnAttr.storable = True
        Vectors2Matrix.addAttribute(Vectors2Matrix.row0W)

        Vectors2Matrix.row1 = compoundMFnAttr.create('row1', 'row1')
        r1xChild = numMFnAttr.create("r1X", "r1X", mFnNumericData.kFloat, 0.0)
        r1yChild = numMFnAttr.create("r1Y", "r1Y", mFnNumericData.kFloat, 1.0)
        r1zChild = numMFnAttr.create("r1Z", "r1Z", mFnNumericData.kFloat, 0.0)
        mtxMFnAttr.readable = True
        mtxMFnAttr.writable = True
        mtxMFnAttr.storable = True
        compoundMFnAttr.addChild(r1xChild)
        compoundMFnAttr.addChild(r1yChild)
        compoundMFnAttr.addChild(r1zChild)
        Vectors2Matrix.addAttribute(Vectors2Matrix.row1)

        Vectors2Matrix.row1W = numericMFnAttr.create('row1W', 'row1W',
                                                     mFnNumericData.kFloat,
                                                     0.0)
        mtxMFnAttr.readable = True
        mtxMFnAttr.writable = True
        mtxMFnAttr.storable = True
        Vectors2Matrix.addAttribute(Vectors2Matrix.row1W)

        Vectors2Matrix.row2 = compoundMFnAttr.create('row2', 'row2')
        r2xChild = numMFnAttr.create("r2X", "r2X", mFnNumericData.kFloat, 0.0)
        r2yChild = numMFnAttr.create("r2Y", "r2Y", mFnNumericData.kFloat, 0.0)
        r2zChild = numMFnAttr.create("r2Z", "r2Z", mFnNumericData.kFloat, 1.0)
        mtxMFnAttr.readable = True
        mtxMFnAttr.writable = True
        mtxMFnAttr.storable = True
        compoundMFnAttr.addChild(r2xChild)
        compoundMFnAttr.addChild(r2yChild)
        compoundMFnAttr.addChild(r2zChild)
        Vectors2Matrix.addAttribute(Vectors2Matrix.row2)

        Vectors2Matrix.row2W = numericMFnAttr.create('row2W', 'row2W',
                                                     mFnNumericData.kFloat,
                                                     0.0)
        mtxMFnAttr.readable = True
        mtxMFnAttr.writable = True
        mtxMFnAttr.storable = True
        Vectors2Matrix.addAttribute(Vectors2Matrix.row2W)

        Vectors2Matrix.row3 = compoundMFnAttr.create('row3', 'row3')
        r3xChild = numMFnAttr.create("r3X", "r3X", mFnNumericData.kFloat, 0.0)
        r3yChild = numMFnAttr.create("r3Y", "r3Y", mFnNumericData.kFloat, 0.0)
        r3zChild = numMFnAttr.create("r3Z", "r3Z", mFnNumericData.kFloat, 0.0)
        mtxMFnAttr.readable = True
        mtxMFnAttr.writable = True
        mtxMFnAttr.storable = True
        compoundMFnAttr.addChild(r3xChild)
        compoundMFnAttr.addChild(r3yChild)
        compoundMFnAttr.addChild(r3zChild)
        Vectors2Matrix.addAttribute(Vectors2Matrix.row3)

        Vectors2Matrix.row3W = numericMFnAttr.create('row3W', 'row3W',
                                                     mFnNumericData.kFloat,
                                                     1.0)
        mtxMFnAttr.readable = True
        mtxMFnAttr.writable = True
        mtxMFnAttr.storable = True
        Vectors2Matrix.addAttribute(Vectors2Matrix.row3W)

        Vectors2Matrix.attributeAffects(Vectors2Matrix.row0,
                                        Vectors2Matrix.mtxOut)
        Vectors2Matrix.attributeAffects(Vectors2Matrix.row0W,
                                        Vectors2Matrix.mtxOut)

        Vectors2Matrix.attributeAffects(Vectors2Matrix.row1,
                                        Vectors2Matrix.mtxOut)
        Vectors2Matrix.attributeAffects(Vectors2Matrix.row1W,
                                        Vectors2Matrix.mtxOut)

        Vectors2Matrix.attributeAffects(Vectors2Matrix.row2,
                                        Vectors2Matrix.mtxOut)
        Vectors2Matrix.attributeAffects(Vectors2Matrix.row2W,
                                        Vectors2Matrix.mtxOut)

        Vectors2Matrix.attributeAffects(Vectors2Matrix.row3,
                                        Vectors2Matrix.mtxOut)
        Vectors2Matrix.attributeAffects(Vectors2Matrix.row3W,
                                        Vectors2Matrix.mtxOut)