コード例 #1
0
ファイル: relax_node.py プロジェクト: gbarlier/relax_node
 def node_init(cls):
     '''Maya API node initialize
     '''
     double_attr_type = OpenMaya.MFnNumericAttribute()
     
     # Add strength setting attribute
     cls._strength_attr = double_attr_type.create( "strength", "str", OpenMaya.MFnNumericData.kFloat )
     double_attr_type.setKeyable( True )
     double_attr_type.setMin(0)
     double_attr_type.setMax(1)
     double_attr_type.setDefault(0.5)
     cls.addAttribute(cls._strength_attr)
     
     # Add iteration setting attribute
     cls._iteration_attr = double_attr_type.create( "iterations", "itr", OpenMaya.MFnNumericData.kInt )
     double_attr_type.setKeyable( True )
     double_attr_type.setMin(0)
     double_attr_type.setDefault(0)
     cls.addAttribute(cls._iteration_attr)
     
     # Add steps setting attribute
     cls._steps_attr = double_attr_type.create( "steps", "stp", OpenMaya.MFnNumericData.kInt )
     double_attr_type.setKeyable( True )
     double_attr_type.setMin(0)
     double_attr_type.setDefault(3)
     cls.addAttribute(cls._steps_attr)
     
     # Update affectation list
     outputGeom = OpenMayaMPx.cvar.MPxGeometryFilter_outputGeom
     cls.attributeAffects( cls._strength_attr, outputGeom )
     cls.attributeAffects( cls._iteration_attr, outputGeom )
     cls.attributeAffects( cls._steps_attr, outputGeom )
     
     # Make deformer weights paintable
     cmds.makePaintable(cls.kPluginNodeName, 'weights', attrType='multiFloat', shapeMode='deformer')
コード例 #2
0
def addRmanPrimVar(mesh, attrName, attrType='float', paintable=False):
    '''
	'''
    # Prefix attr
    attr = 'rmanF' + attrName

    # Data type
    if attrType == 'float': dataType = 'doubleArray'
    if attrType == 'vector': dataType = 'vectorArray'
    if attrType == 'string': dataType = 'stringArray'

    # Check mesh
    if not glTools.utils.mesh.isMesh(mesh):
        raise Exception('Mesh "' + mesh + '" does not exist!!')

    # Check attr
    if mc.objExists(mesh + '.' + attr):
        raise Exception('Attribute "' + mesh + '.' + attr +
                        '" already exists!!')

    # Get shape
    meshShape = mc.listRelatives(mesh, s=True, ni=True, pa=True)
    if not meshShape:
        raise Exception('Unable to determine shape for mesh "' + mesh + '"!!')

    # Add attribute
    mc.addAttr(meshShape[0], ln=attr, dt=dataType)

    # Make paintable
    if paintable: mc.makePaintable('mesh', attr, attrType=dataType)
コード例 #3
0
def addPaintAttr(mesh, attr='vertexMap', attrType='doubleArray'):
    '''
	Add a paintable array attribute to the specified mesh geometry.
	@param mesh: Mesh to add paintable attr to
	@type mesh: str
	@param attr: Name for the new attribute
	@type attr: str
	@param attrType: Data type for the new attribute
	@type attrType: str
	'''
    # Check mesh
    if not glTools.utils.mesh.isMesh(mesh):
        raise Exception('Mesh "' + mesh + '" does not exist!!')

    # Check attr
    if mc.objExists(mesh + '.' + attr):
        raise Exception('Attribute "' + mesh + '.' + attr +
                        '" already exists!!')

    # Get shape
    meshShape = mc.listRelatives(mesh, s=True, ni=True, pa=True)
    if not meshShape:
        raise Exception('Unable to determine shape for mesh "' + mesh + '"!!')

    # Add attribute
    mc.addAttr(meshShape[0], ln=attr, dt=attrType)

    # Make paintable
    mc.makePaintable('mesh', attr, attrType=attrType)
コード例 #4
0
    def initialize():
        tattr = om.MFnTypedAttribute()
        mattr = om.MFnMatrixAttribute()

        # Path to the training data outputData.json
        MLDeformerNode.data_loc = tattr.create('trainingData', 'ta',
                                               om.MFnData.kString)
        tattr.setHidden(False)
        tattr.setKeyable(True)
        MLDeformerNode.addAttribute(MLDeformerNode.data_loc)
        MLDeformerNode.attributeAffects(MLDeformerNode.data_loc,
                                        outputGeomAttr)

        # List of input joints.
        MLDeformerNode.in_mats = mattr.create('matrix', 'mat')
        mattr.setKeyable(True)
        mattr.setArray(True)
        MLDeformerNode.addAttribute(MLDeformerNode.in_mats)
        MLDeformerNode.attributeAffects(MLDeformerNode.in_mats, outputGeomAttr)

        # Finally let us paint weights so we can control where the deformer applies.
        mc.makePaintable(MLDeformerNode.name,
                         'weights',
                         attrType='multiFloat',
                         shapeMode='deformer')
コード例 #5
0
ファイル: primvar.py プロジェクト: RiggingDojoAdmin/glTools
def addRmanPrimVar(mesh,attrName,attrType='float',paintable=False):
	'''
	'''
	# Prefix attr
	attr = 'rmanF'+attrName
	
	# Data type
	if attrType == 'float': dataType = 'doubleArray'
	if attrType == 'vector': dataType = 'vectorArray'
	if attrType == 'string': dataType = 'stringArray'
	
	# Check mesh
	if not glTools.utils.mesh.isMesh(mesh):
		raise Exception('Mesh "'+mesh+'" does not exist!!')
	
	# Check attr
	if mc.objExists(mesh+'.'+attr):
		raise Exception('Attribute "'+mesh+'.'+attr+'" already exists!!')
	
	# Get shape
	meshShape = mc.listRelatives(mesh,s=True,ni=True,pa=True)
	if not meshShape:
		raise Exception('Unable to determine shape for mesh "'+mesh+'"!!')
	
	# Add attribute
	mc.addAttr(meshShape[0],ln=attr,dt=dataType)
	
	# Make paintable
	if paintable: mc.makePaintable('mesh',attr,attrType=dataType)
コード例 #6
0
def nodeInitializer():

    numericAttributeFn = OpenMaya.MFnNumericAttribute()

    RippleNode.mObjAmplitude = numericAttributeFn.create(
        'Amplitude', 'amp', OpenMaya.MFnNumericData.kFloat, 0.0)
    numericAttributeFn.setMin(0.0)
    numericAttributeFn.setMax(1.0)
    numericAttributeFn.setKeyable(1)
    RippleNode.addAttribute(RippleNode.mObjAmplitude)

    RippleNode.mObjDisplace = numericAttributeFn.create(
        'Displace', 'dis', OpenMaya.MFnNumericData.kFloat, 0.0)
    numericAttributeFn.setMin(0.0)
    numericAttributeFn.setMax(10.0)
    numericAttributeFn.setKeyable(1)
    RippleNode.addAttribute(RippleNode.mObjDisplace)

    mFnMatrixAttr = OpenMaya.MFnMatrixAttribute()
    RippleNode.mObjMatrix = mFnMatrixAttr.create('MtrixAttribute', 'matAttr')
    mFnMatrixAttr.setStorable(0)
    mFnMatrixAttr.setConnectable(1)
    RippleNode.addAttribute(RippleNode.mObjMatrix)

    print dir(OpenMayaMPx.cvar)

    RippleNode.attributeAffects(RippleNode.mObjAmplitude, kOutputGeom)
    RippleNode.attributeAffects(RippleNode.mObjDisplace, kOutputGeom)
    RippleNode.attributeAffects(RippleNode.mObjMatrix, kOutputGeom)
    cmds.makePaintable(nodeName,
                       'weights',
                       attrType='multiFloat',
                       shapeMode='deformer')
コード例 #7
0
ファイル: dynWeights.py プロジェクト: auqeyjf/glTools
def addPaintAttr(mesh, attr="vertexMap", attrType="doubleArray"):
    """
	Add a paintable array attribute to the specified mesh geometry.
	@param mesh: Mesh to add paintable attr to
	@type mesh: str
	@param attr: Name for the new attribute
	@type attr: str
	@param attrType: Data type for the new attribute
	@type attrType: str
	"""
    # Check mesh
    if not glTools.utils.mesh.isMesh(mesh):
        raise Exception('Mesh "' + mesh + '" does not exist!!')

        # Check attr
    if mc.objExists(mesh + "." + attr):
        raise Exception('Attribute "' + mesh + "." + attr + '" already exists!!')

        # Get shape
    meshShape = mc.listRelatives(mesh, s=True, ni=True, pa=True)
    if not meshShape:
        raise Exception('Unable to determine shape for mesh "' + mesh + '"!!')

    # Add attribute
    mc.addAttr(meshShape[0], ln=attr, dt=attrType)

    # Make paintable
    mc.makePaintable("mesh", attr, attrType=attrType)
コード例 #8
0
def uninitializePlugin(plugin):
    pluginFN = ommpx.MFnPlugin(plugin)
    cmds.makePaintable(NyCollisionDeformer.NODE_NAME, "weights", remove=True)
    try:
        pluginFN.deregisterNode(NyCollisionDeformer.NODE_TYPEID)
    except:
        om.MGlobal.displayError("Failed to deregister node:{}".format(
            NyCollisionDeformer.NODE_NAME))
コード例 #9
0
def uninitializePlugin(plugin):
    pluginFN = ommpx.MFnPlugin(plugin)
    cmds.makePaintable(MultiCollision.nodeName, "weights", remove=True)
    try:
        pluginFN.deregisterNode(MultiCollision.nodeTypeId)
    except:
        om.MGlobal.displayError("Failed to deregister node:{}".format(
            MultiCollision.nodeName))
コード例 #10
0
def prepareBaseMesh():
    ''' Initialize the base mesh with the proper Paintable Attribute on its Shape Node, as well as generate the Control Sphere and vertex graph. '''

    if mc.attributeQuery('growthWeights', node=baseMeshShape,
                         exists=True) == False:
        mc.addAttr(baseMeshShape,
                   ln='growthWeights',
                   nn='GrowthWeights',
                   dt='doubleArray')

    mc.makePaintable('mesh', 'growthWeights', at='doubleArray')

    # Create the control sphere and assign it a semi-transparent material
    if mc.objExists(controlSphereName) == False:
        mc.polySphere(n=controlSphereName, r=1)
        semitransparentMaterial = mc.shadingNode('blinn', asShader=True)
        mc.setAttr(semitransparentMaterial + '.transparency',
                   0.3,
                   0.3,
                   0.3,
                   type='double3')
        mc.select(controlSphereName)
        mc.hyperShade(a=semitransparentMaterial)

    mSel = om.MSelectionList()
    mSel.add(baseMeshName)
    om.MGlobal.getActiveSelectionList(mSel)
    dagPath = om.MDagPath()
    component = om.MObject()
    mSel.getDagPath(0, dagPath, component)

    # Get positions of all vertices on the mesh
    meshFn = om.MFnMesh(dagPath)
    positions = om.MPointArray()
    meshFn.getPoints(positions, om.MSpace.kWorld)

    # Iterate and calculate vectors based on connected vertices
    iter = om.MItMeshVertex(dagPath, component)
    connectedVertices = om.MIntArray()
    checkedNodes = [False] * positions.length()

    # Initialize the graph with the base mesh's vertices
    while not iter.isDone():
        curVertexID = iter.index()
        checkedNodes[curVertexID] = True

        g.addVertex(curVertexID)
        iter.getConnectedVertices(connectedVertices)

        for i in range(connectedVertices.length()):
            neighbourID = connectedVertices[i]
            if checkedNodes[neighbourID] == False:
                g.addVertex(neighbourID)
                g.addEdge(
                    curVertexID, neighbourID,
                    squareDistance(positions[curVertexID],
                                   positions[neighbourID]))
        iter.next()
コード例 #11
0
def uninitializePlugin(plugin):
    cmds.makePaintable(BreathingDeformerNode.TYPE_NAME, "weights", remove=True)

    plugin_fn = ommpx.MFnPlugin(plugin)
    try:
        plugin_fn.deregisterNode(BreathingDeformerNode.TYPE_ID)
    except:
        om.MGlobal.displayError("Failed to deregister node: {0}".format(
            BreathingDeformerNode.TYPE_NAME))
コード例 #12
0
ファイル: rbfwrap.py プロジェクト: antonstattin/mayadev
def nodeInitializer():

    polyMeshAttr = OpenMaya.MFnTypedAttribute()
    enumAttr = OpenMaya.MFnEnumAttribute()
    nAttr = OpenMaya.MFnNumericAttribute()

    rbfWrapDeformer.driver_mesh = polyMeshAttr.create("driverInput", "dinput",
                                                      OpenMaya.MFnData.kMesh)
    polyMeshAttr.setStorable(False)
    polyMeshAttr.setConnectable(True)
    rbfWrapDeformer.addAttribute(rbfWrapDeformer.driver_mesh)
    rbfWrapDeformer.attributeAffects(
        rbfWrapDeformer.driver_mesh,
        OpenMayaMPx.cvar.MPxGeometryFilter_outputGeom)

    rbfWrapDeformer.initialized_data = enumAttr.create("initialize", "ini")
    enumAttr.addField("Off", 0)
    enumAttr.addField("Re-Set Bind", 1)
    enumAttr.addField("Bound", 2)
    enumAttr.setKeyable(True)
    enumAttr.setStorable(True)
    enumAttr.setReadable(True)
    enumAttr.setWritable(True)
    enumAttr.setDefault(0)
    rbfWrapDeformer.addAttribute(rbfWrapDeformer.initialized_data)
    rbfWrapDeformer.attributeAffects(
        rbfWrapDeformer.initialized_data,
        OpenMayaMPx.cvar.MPxGeometryFilter_outputGeom)

    # deltas
    rbfWrapDeformer.deltaData = nAttr.createPoint('deltaData', 'dData')
    nAttr.setKeyable(False)
    nAttr.setArray(True)
    nAttr.setStorable(True)
    nAttr.setReadable(True)
    nAttr.setWritable(True)
    rbfWrapDeformer.addAttribute(rbfWrapDeformer.deltaData)
    rbfWrapDeformer.attributeAffects(
        rbfWrapDeformer.deltaData,
        OpenMayaMPx.cvar.MPxGeometryFilter_outputGeom)

    # bind
    rbfWrapDeformer.bindData = nAttr.createPoint('bindData', 'bdata')
    nAttr.setKeyable(False)
    nAttr.setArray(True)
    nAttr.setStorable(True)
    nAttr.setReadable(True)
    nAttr.setWritable(True)
    rbfWrapDeformer.addAttribute(rbfWrapDeformer.bindData)
    rbfWrapDeformer.attributeAffects(
        rbfWrapDeformer.bindData,
        OpenMayaMPx.cvar.MPxGeometryFilter_outputGeom)

    # make weights paintable
    cmds.makePaintable(kPluginNodeTypeName, 'weights', attrType='multiFloat')
コード例 #13
0
 def initPlugin(self, deformerType):
     meshes = pm.selected( type="transform" )
     if len(meshes)<2:
         return
     pm.select( meshes[-1])
     deformer = cmds.deformer(type=deformerType)[0]
     shape=meshes[-2].getShapes()[0]
     cmds.connectAttr(shape+".worldMesh[0]", deformer+".cageMesh")
     # Make deformer weights paintable
     cmds.makePaintable(deformerType, 'weights', attrType='multiFloat', shapeMode='deformer')
     self.updateUI()
コード例 #14
0
ファイル: jiggleDeformer.py プロジェクト: dayelov/MayaPython
def initializePlugin(MObj):
    MPlugin = ompx.MFnPlugin(MObj, 'Yixiong Xu', '1.0')

    try:
        MPlugin.registerNode(nodeName, nodeID, deformerCreator,
                             nodeInitializer, ompx.MPxNode.kDeformerNode)
        # paint default weights
        cmds.makePaintable(nodeName, 'weights', at='multiFloat', sm='deformer')

    except:
        raise RuntimeError
        print 'Failed to register command: %s .\n' % nodeName
コード例 #15
0
ファイル: primvar.py プロジェクト: fsanges/glTools-1
def addRmanPrimVar(mesh, attrName, attrType='float', paintable=False):
    '''
	Add a prman primVar attribute to the specified mesh shape.
	@param mesh: Mesh shape to add primVar attribute to.
	@type mesh: str
	@param attrName: Base primVar attribute name. The correct primVar prefix will be added to the final attribute name.
	@type attrName: str
	@param attrType: PrimVar attribute type. Accepted values are: "float", "vector", "color" and "string"
	@type attrType: str
	@param paintable: Paintable state of the primVar attribute.
	@type paintable: bool
	'''
    # Prefix attr
    attr = ''

    # Data type
    if attrType == 'float':
        dataType = 'doubleArray'
        attr = 'rmanF' + attrName
    elif attrType == 'vector':
        dataType = 'vectorArray'
        attr = 'rmanV' + attrName
    elif attrType == 'string':
        dataType = 'stringArray'
        attr = 'rmanS' + attrName
    elif attrType == 'color':
        dataType = 'vectorArray'
        attr = 'rmanC' + attrName
    else:
        raise Exception(
            'Invalid attribute type! Accepted values are: "float", "vector", "color" and "string".'
        )

    # Check mesh
    if not glTools.utils.mesh.isMesh(mesh):
        raise Exception('Mesh "' + mesh + '" does not exist!!')

    # Check attr
    if mc.objExists(mesh + '.' + attr):
        raise Exception('Attribute "' + mesh + '.' + attr +
                        '" already exists!!')

    # Get shape
    meshShape = mc.listRelatives(mesh, s=True, ni=True, pa=True)
    if not meshShape:
        raise Exception('Unable to determine shape for mesh "' + mesh + '"!!')

    # Add attribute
    mc.addAttr(meshShape[0], ln=attr, dt=dataType)

    # Make paintable
    if paintable: mc.makePaintable('mesh', attr, attrType=dataType)
コード例 #16
0
def initializePlugin(mObj):
    # Because mayaCore has already prepared a handle(named mObj here, which is in form of MObject)
    # for the Pointer above, define a plugin function set and pass the handle to it.
    mplugin = openmayampx.MFnPlugin(mObj, "Yixiong Xu", "1.0")
    try:
        mplugin.registerNode(nodeName, nodeID, deformerCreator, nodeInitializer, openmayampx.MPxNode.kDeformerNode)

        ''' This is to explicitly define that weights attribute of the deformer is paintable'''
        # openmaya.MGlobal.executeCommand("makePaintable -attrType \"multiFloat\" -sm deformer \"" + nodeName + "\" \"weights\";")
        cmds.makePaintable(nodeName, 'weights', at='multiFloat', sm='deformer')

    except:
        sys.stderr.write("Failed to register command: %s .\n" % nodeName)
コード例 #17
0
 def initPlugin(self, deformerType):
     if deformerType=="probeLocator":
         cmds.createNode('probeLocator')
         return
     # get transform nodes for the selected objects
     transforms = pm.selected(tr=1)
     if not transforms:
         return
     pm.select( transforms[-1])       # the deformer is attached to the last selected object
     node = pm.ls(cmds.deformer(type=deformerType)[0])[0]
     cmds.makePaintable(deformerType, 'weights', attrType='multiFloat', shapeMode='deformer')
     if len(transforms)>1:
         self.addProbe(node,deformerType,transforms[:-1])
     self.updateUI()
コード例 #18
0
 def initPlugin(self, deformerType):
     if deformerType=="probeLocator":
         cmds.createNode('probeLocator')
         return
     # get transform nodes for the selected objects
     transforms = pm.selected(tr=1)
     if not transforms:
         return
     pm.select( transforms[-1])       # the deformer is attached to the last selected object
     node = pm.ls(cmds.deformer(type=deformerType)[0])[0]
     cmds.makePaintable(deformerType, 'weights', attrType='multiFloat', shapeMode='deformer')
     if len(transforms)>1:
         self.addProbe(node,deformerType,transforms[:-1])
     self.updateUI()
コード例 #19
0
 def initPlugin(self, deformerType):
     meshes = pm.selected(type="transform")
     if len(meshes) < 2:
         return
     pm.select(meshes[-1])
     deformer = cmds.deformer(type=deformerType)[0]
     shape = meshes[-2].getShapes()[0]
     cmds.connectAttr(shape + ".worldMesh[0]", deformer + ".cageMesh")
     # Make deformer weights paintable
     cmds.makePaintable(deformerType,
                        'weights',
                        attrType='multiFloat',
                        shapeMode='deformer')
     self.updateUI()
コード例 #20
0
ファイル: primvar.py プロジェクト: bennymuller/glTools
def addRmanPrimVar(mesh, attrName, attrType='float', paintable=False):
    """
    Add a prman primVar attribute to the specified mesh shape.
    @param mesh: Mesh shape to add primVar attribute to.
    @type mesh: str
    @param attrName: Base primVar attribute name. The correct primVar prefix will be added to the final attribute name.
    @type attrName: str
    @param attrType: PrimVar attribute type. Accepted values are: "float", "vector", "color" and "string"
    @type attrType: str
    @param paintable: Paintable state of the primVar attribute.
    @type paintable: bool
    """
    # Prefix attr
    attr = ''

    # Data type
    if attrType == 'float':
        dataType = 'doubleArray'
        attr = 'rmanF' + attrName
    elif attrType == 'vector':
        dataType = 'vectorArray'
        attr = 'rmanV' + attrName
    elif attrType == 'string':
        dataType = 'stringArray'
        attr = 'rmanS' + attrName
    elif attrType == 'color':
        dataType = 'vectorArray'
        attr = 'rmanC' + attrName
    else:
        raise Exception('Invalid attribute type! Accepted values are: "float", "vector", "color" and "string".')

    # Check mesh
    if not glTools.utils.mesh.isMesh(mesh):
        raise Exception('Mesh "' + mesh + '" does not exist!!')

    # Check attr
    if cmds.objExists(mesh + '.' + attr):
        raise Exception('Attribute "' + mesh + '.' + attr + '" already exists!!')

    # Get shape
    meshShape = cmds.listRelatives(mesh, s=True, ni=True, pa=True)
    if not meshShape:
        raise Exception('Unable to determine shape for mesh "' + mesh + '"!!')

    # Add attribute
    cmds.addAttr(meshShape[0], ln=attr, dt=dataType)

    # Make paintable
    if paintable: cmds.makePaintable('mesh', attr, attrType=dataType)
コード例 #21
0
def initializePlugin(plugin):
    vendor = "Nazmi 'printer' Yazici"
    version = "0.9.0"
    pluginFN = ommpx.MFnPlugin(plugin, vendor, version)
    cmds.makePaintable(NyCollisionDeformer.NODE_NAME,
                       "weights",
                       attrType="multiFloat",
                       shapeMode="deformer")
    try:
        pluginFN.registerNode(NyCollisionDeformer.NODE_NAME,
                              NyCollisionDeformer.NODE_TYPEID,
                              NyCollisionDeformer.creator,
                              NyCollisionDeformer.initialize,
                              ommpx.MPxNode.kDeformerNode)
    except:
        om.MGlobal.displayError("Failed to register node:{}".format(
            NyCollisionDeformer.NODE_NAME))
コード例 #22
0
    def initialize():
        nAttr = om.MFnNumericAttribute()

        PushDeformer.push = nAttr.create('push', 'p', om.MFnNumericData.kFloat,
                                         0.0)
        nAttr.setKeyable(True)
        nAttr.setStorable(True)
        nAttr.setChannelBox(True)

        PushDeformer.addAttribute(PushDeformer.push)
        PushDeformer.attributeAffects(PushDeformer.push, outputGeomAttr)

        # We also want to make our node paintable
        cmds.makePaintable(PushDeformer.name,
                           'weights',
                           attrType='multiFloat',
                           shapeMode='deformer')
コード例 #23
0
def initializePlugin(plugin):
    vendor = "Nazmi 'printer' Yazici"
    version = "0.6.0"
    pluginFN = ommpx.MFnPlugin(plugin, vendor, version)
    cmds.makePaintable(MultiCollision.nodeName,
                       "weights",
                       attrType="multiFloat",
                       shapeMode="deformer")
    try:
        pluginFN.registerNode(MultiCollision.nodeName,
                              MultiCollision.nodeTypeId,
                              MultiCollision.creator,
                              MultiCollision.initialize,
                              ommpx.MPxNode.kDeformerNode)
    except:
        om.MGlobal.displayError("Failed to register node:{}".format(
            MultiCollision.nodeName))
コード例 #24
0
ファイル: utilities.py プロジェクト: auqeyjf/pubTool
	def makePaintable(self):
		'''
		Sets up the surfaceSkin weight attributes to be paintable with the artisan paint attribute tool.
		'''
		# Remove paintable status of surfaceSkin weights attributes
		mc.makePaintable( 'surfaceSkin', 'weights', rm=True )
		mc.makePaintable( 'surfaceSkin', 'paintWeight', rm=True )
		# Make surfaceSkin weights attributes paintable 
		mc.makePaintable( 'surfaceSkin', 'weights', attrType='multiFloat', sm='deformer' )
		mc.makePaintable( 'surfaceSkin', 'paintWeight', attrType='multiFloat', sm='deformer' )
コード例 #25
0
def initializePlugin(plugin):
    vendor = "Audrey Deschamps-Brower"
    version = "1.0.0"

    plugin_fn = ommpx.MFnPlugin(plugin, vendor, version)
    try:
        plugin_fn.registerNode(BreathingDeformerNode.TYPE_NAME,
                               BreathingDeformerNode.TYPE_ID,
                               BreathingDeformerNode.creator,
                               BreathingDeformerNode.initialize,
                               ommpx.MPxNode.kDeformerNode)
    except:
        om.MGlobal.displayError("Failed to register node: {0}".format(
            BreathingDeformerNode.TYPE_NAME))
    cmds.makePaintable(BreathingDeformerNode.TYPE_NAME,
                       "weights",
                       attrType="multiFloat",
                       shapeMode="deformer")
コード例 #26
0
ファイル: relax_node.py プロジェクト: Owacle/reference-code
    def node_init(cls):
        '''Maya API node initialize
        '''
        double_attr_type = OpenMaya.MFnNumericAttribute()

        # Add strength setting attribute
        cls._strength_attr = double_attr_type.create(
            "strength", "str", OpenMaya.MFnNumericData.kFloat)
        double_attr_type.setKeyable(True)
        double_attr_type.setMin(0)
        double_attr_type.setMax(1)
        double_attr_type.setDefault(0.5)
        cls.addAttribute(cls._strength_attr)

        # Add iteration setting attribute
        cls._iteration_attr = double_attr_type.create(
            "iterations", "itr", OpenMaya.MFnNumericData.kInt)
        double_attr_type.setKeyable(True)
        double_attr_type.setMin(0)
        double_attr_type.setDefault(0)
        cls.addAttribute(cls._iteration_attr)

        # Add steps setting attribute
        cls._steps_attr = double_attr_type.create("steps", "stp",
                                                  OpenMaya.MFnNumericData.kInt)
        double_attr_type.setKeyable(True)
        double_attr_type.setMin(0)
        double_attr_type.setDefault(3)
        cls.addAttribute(cls._steps_attr)

        # Update affectation list
        outputGeom = OpenMayaMPx.cvar.MPxDeformerNode_outputGeom
        cls.attributeAffects(cls._strength_attr, outputGeom)
        cls.attributeAffects(cls._iteration_attr, outputGeom)
        cls.attributeAffects(cls._steps_attr, outputGeom)

        # Make deformer weights paintable
        cmds.makePaintable(cls.kPluginNodeName,
                           'weights',
                           attrType='multiFloat',
                           shapeMode='deformer')
コード例 #27
0
    def initialize():
        """
        Defines the set of attributes for this node. The attributes declared in this function are assigned
        as static members to TestNode class. Instances of TestNode will use these attributes to create plugs
        for use in the compute() method.
        """
        nAttr = om1.MFnNumericAttribute()
        mAttr = om1.MFnMatrixAttribute()

        TestDeformer.inAmplitude = nAttr.create("amplitude", "amplitude",
                                                om1.MFnNumericData.kFloat, 0.0)
        nAttr.setMin(0.0)
        nAttr.setMax(1.0)
        INPUT_ATTR(nAttr)

        TestDeformer.inDisplace = nAttr.create("displace", "displace",
                                               om1.MFnNumericData.kFloat, 0.0)
        nAttr.setMin(0.0)
        nAttr.setMax(10.0)
        INPUT_ATTR(nAttr)

        TestDeformer.inMatrix = mAttr.create("matrix", "matrix")
        INPUT_ATTR(mAttr)

        TestDeformer.addAttribute(TestDeformer.inAmplitude)
        TestDeformer.addAttribute(TestDeformer.inDisplace)
        TestDeformer.addAttribute(TestDeformer.inMatrix)

        TestDeformer.attributeAffects(TestDeformer.inAmplitude,
                                      ompx.cvar.MPxGeometryFilter_outputGeom)
        TestDeformer.attributeAffects(TestDeformer.inDisplace,
                                      ompx.cvar.MPxGeometryFilter_outputGeom)
        TestDeformer.attributeAffects(TestDeformer.inMatrix,
                                      ompx.cvar.MPxGeometryFilter_outputGeom)

        cmds.makePaintable(TestDeformer.kNodeName,
                           "weights",
                           at="multiFloat",
                           sm="deformer")
コード例 #28
0
    def addPaintAttribute(shape, attrName, subName='mesh'):
        """Create a attribute with is paintable

        Arguments:
            shape {String} -- shape of the mesh
            attrName {String} -- Name of the attribute
            subName {String} -- Name of the node ex: mesh.polyHide, deformer.weights

        Returns:
            Plug -- Plug of the attribute
        """
        plug = '{}.{}'.format(shape, attrName)
        vertCount = mc.polyEvaluate(shape, vertex=True)

        if not mc.objExists(plug):
            mc.addAttr(shape, longName=attrName, dataType='doubleArray')
            mc.makePaintable(subName, attrName)
            pm.PyNode(plug).set([0] * vertCount, type='doubleArray')
        else:
            if not vertCount == len(list(mc.getAttr(plug))):
                pm.PyNode(plug).set([0] * pm.polyEvaluate(shape, vertex=True),
                                    type='doubleArray')
        return plug
コード例 #29
0
ファイル: primvar.py プロジェクト: bennymuller/glTools
def addAbcPrimVar(geo, attrName, attrType=None, dataType='long', keyable=False, paintable=False, geoIsMesh=False):
    """
    Add an alembic primVar attribute to the specified geometry.
    @param geo: Geometry to add primVar attribute to.
    @type geo: str
    @param attrName: Base primVar attribute name. The correct primVar prefix will be added to the final attribute name.
    @type attrName: str
    @param attrType: PrimVar attribute type. Accepted values are: <None> (per object), "var" (varying per face), "vtx" (varying per vertex), "uni" (uniform) and "fvr" (?)
    @type attrType: str
    @param dataType: The data type for the attribute. Only used when attrType=''. If empty, default to "long" (int). Alternative is "float".
    @type dataType: str
    @param keyable: Keyable state of the primVar attribute.
    @type keyable: bool
    @param paintable: Paintable state of the primVar attribute.
    @type paintable: bool
    @param geoIsMesh: Check if the specified geo node is a mesh, if not raise an exception.
    @type geoIsMesh: bool
    """
    # ==========
    # - Checks -
    # ==========

    # Check Geometry
    if not cmds.objExists(geo):
        raise Exception('Geometry "' + geo + '" does not exist!!')
    if geoIsMesh and not glTools.utils.mesh.isMesh(geo):
        raise Exception('Geometry "' + geo + '" is not a valid mesh!!')

    # Check Attribute
    attr = 'ABC_' + attrName
    if cmds.objExists(geo + '.' + attr):
        # cmds.deleteAttr(geo+'.'+attr)
        raise Exception('Attribute "' + geo + '.' + attr + '" already exists!!')

    # Check Attribute Type
    typeList = ['var', 'vtx', 'uni', 'fvr']
    if attrType and not typeList.count(attrType):
        raise Exception(
            'Invalid attribute type! Accepted values are: "var", "vtx", "uni" and "fvr" (or <None> for per object attribute).')

    # =================
    # - Add Attribute -
    # =================

    # Data type
    if not attrType:

        # Check Data Type
        if not dataType: dataType = 'long'

        # Add primVar attribute
        cmds.addAttr(geo, ln=attr, at=dataType, k=keyable)

    else:

        # Set Attribute Data Type
        dataType = 'doubleArray'

        # Add primVar attribute
        cmds.addAttr(geo, ln=attr, dt=dataType)

        # Set Geometey Scope Value
        attrTypeAttr = 'ABC_' + attrName + '_AbcGeomScope'
        cmds.addAttr(geo, ln=attrTypeAttr, dt='string')
        cmds.setAttr(geo + '.' + attrTypeAttr, attrType, type='string', l=True)

        # Make paintable
        if paintable: cmds.makePaintable('mesh', attr, attrType=dataType)

    # =================
    # - Return Result -
    # =================

    return geo + '.' + attr
コード例 #30
0
def nodeInitializer():
    # default attr
    outgeoAr = OpenMayaMPx.cvar.MPxDeformerNode_outputGeom
    # attribute type variables
    gAttr = om.MFnGenericAttribute()
    nAttr = om.MFnNumericAttribute()
    mAttr = om.MFnMatrixAttribute()
    rAttr = om.MRampAttribute()
    eAttr = om.MFnEnumAttribute()
    
    # aWarnings
    prAttractNode.aWarnings = nAttr.create( "showWarnings", "showWarnings", om.MFnNumericData.kBoolean, 1 )
    prAttractNode.addAttribute( prAttractNode.aWarnings )
    # aMaxDistance
    prAttractNode.aMaxDistance = nAttr.create( "maxDistance", "maxDistance", om.MFnNumericData.kFloat, 1.0 )
    nAttr.setKeyable(True)
    nAttr.setMin(0.0)
    prAttractNode.addAttribute( prAttractNode.aMaxDistance )
    prAttractNode.attributeAffects(prAttractNode.aMaxDistance, outgeoAr)
    # aFalloff
    prAttractNode.aFalloff = rAttr.createCurveRamp( "falloff", "falloff" )
    prAttractNode.addAttribute( prAttractNode.aFalloff )
    prAttractNode.attributeAffects(prAttractNode.aFalloff, outgeoAr)
    # aMaxDistanceUv
    prAttractNode.aMaxDistanceUv = rAttr.createCurveRamp( "maxDistanceUv", "maxDistanceUv" )
    prAttractNode.addAttribute( prAttractNode.aMaxDistanceUv )
    prAttractNode.attributeAffects(prAttractNode.aMaxDistanceUv, outgeoAr)
    # aProjectOnNormal
    prAttractNode.aProjectOnNormal = nAttr.create( "projectOnNormal", "projectOnNormal", om.MFnNumericData.kFloat, 0.0 )
    nAttr.setKeyable(True)
    nAttr.setMin( 0.0 )
    nAttr.setMax( 1.0 )
    prAttractNode.addAttribute( prAttractNode.aProjectOnNormal )
    prAttractNode.attributeAffects(prAttractNode.aProjectOnNormal, outgeoAr)
    # aNormalDirectionLimit
    prAttractNode.aNormalDirectionLimit = eAttr.create( "normalDirectionLimit", "normalDirectionLimit", 0 )
    eAttr.setKeyable(True)
    eAttr.addField( "Off", 0 )
    eAttr.addField( "Only positive", 1 )
    eAttr.addField( "Only negative", 2 )
    prAttractNode.addAttribute( prAttractNode.aNormalDirectionLimit )
    prAttractNode.attributeAffects(prAttractNode.aNormalDirectionLimit, outgeoAr)
    # aClosestVertex
    prAttractNode.aClosestVertex = nAttr.create( "closestVertex", "closestVertex", om.MFnNumericData.kFloat, 0.0 )
    nAttr.setKeyable(True)
    nAttr.setMin( 0.0 )
    nAttr.setMax( 1.0 )
    prAttractNode.addAttribute( prAttractNode.aClosestVertex )
    prAttractNode.attributeAffects(prAttractNode.aClosestVertex, outgeoAr)
    
    # aInputShape
    prAttractNode.aInputShape = gAttr.create( "inputShape", "inputShape" )
    gAttr.setReadable(False)
    gAttr.addDataAccept( om.MFnNurbsCurveData.kNurbsCurve )
    gAttr.addDataAccept( om.MFnNurbsSurfaceData.kNurbsSurface )
    gAttr.addDataAccept( om.MFnMeshData.kMesh )
    prAttractNode.addAttribute( prAttractNode.aInputShape )
    prAttractNode.attributeAffects(prAttractNode.aInputShape, outgeoAr)
    # aInputMatrix
    prAttractNode.aInputMatrix = mAttr.create( "inputMatrix", "inputMatrix" )
    mAttr.setReadable(False)
    prAttractNode.addAttribute( prAttractNode.aInputMatrix )
    prAttractNode.attributeAffects(prAttractNode.aInputMatrix, outgeoAr)
    
    # paintable
    import maya.cmds as mc
    mc.makePaintable('prSlideNode', 'weights', attrType='multiFloat', shapeMode='deformer')
コード例 #31
0
ファイル: ZvRadialBlendShape.py プロジェクト: Bumpybox/Tapp
def zvRadialBlendShape():
	# load plugin
	if not cmds.pluginInfo(_rbsNodeName, q=True, l=True):
		cmds.loadPlugin(_rbsNodeName)
	
	# make attribute paintable
	cmds.makePaintable(_rbsNodeName, 'weights', attrType='multiFloat', sm='deformer')
	
	# create window
	winName = 'ZvRadialBlendShapeWin'
	if cmds.window(winName, exists=True):
		cmds.deleteUI(winName, window=True)

	cmds.window(winName, title='%s %s' % (__product__, __version__))
	
	mainLAY = cmds.formLayout()

	# geometry
	f1 = cmds.frameLayout(l='Geometry', borderStyle='etchedOut', mw=2, mh=2)
	cmds.columnLayout(adj=True)
	cmds.rowLayout(nc=3, adj=3, ct3=['both', 'both', 'both'], cl3=['center', 'center', 'left'], cw=[1, 120])
	cmds.button(l='Get geometry', ann='Refresh UI using selected geometry', c=cb(getGeoCmd))
	cmds.separator(w=8, st='none')
	geoTXT = cmds.text(l='')
	cmds.setParent(f1)
	cmds.rowLayout(nc=3, adj=3, ct3=['both', 'both', 'both'], cl3=['center', 'center', 'left'], cw=[1, 120])
	createBT = cmds.button(l='Create deformer', ann='Create Radial Blend Shape node', c=cb(createCmd))
	cmds.separator(w=8, st='none')
	rbsTXT = cmds.text(l='')
	
	# eyes
	cmds.setParent(mainLAY)
	f2 = cmds.frameLayout(l='Eyes', borderStyle='etchedOut', mw=2, mh=2)
	eyeFormLAY = cmds.formLayout(nd=20)
	addEyeBT = cmds.button(l='Add...', ann='Add shape group', c=cb(addEyeCmd))
	tabs = cmds.tabLayout(innerMarginWidth=2, innerMarginHeight=2)
	cmds.formLayout(eyeFormLAY, e=True,
	                attachForm=[(addEyeBT, 'top', 0), (addEyeBT, 'left', 0), (addEyeBT, 'right', 0), (tabs, 'left', 0), (tabs, 'right', 0), (tabs, 'bottom', 0)],
	                attachControl=[(tabs, 'top', 4, addEyeBT)])
	
	# tools
	cmds.setParent(mainLAY)
	f3 = cmds.frameLayout(l='Tools', borderStyle='etchedOut', mw=2, mh=2)
	cmds.columnLayout(adj=True, rs=2)
	
	membLAY = cmds.formLayout(nd=20)
	editMembBT = cmds.button(l='Edit membership', ann='Edit affected vertices', c=cb(editMembershipCmd))
	autoMembBT = cmds.button(l='Auto membership', ann='Optimize affected vertices', c=cb(autoMembershipCmd))
	cmds.formLayout(membLAY, e=True, attachForm=[(editMembBT, 'top', 0), (editMembBT, 'left', 0), (editMembBT, 'bottom', 0), (autoMembBT, 'top', 0), (autoMembBT, 'right', 0), (autoMembBT, 'bottom', 0)],
	                attachPosition=[(editMembBT, 'right', 1, 10), (autoMembBT, 'left', 1, 10)])
	
	cmds.setParent('..')
	computeDispBT = cmds.button(l='Compute displacements', ann='Compute maximum displacements for all shapes.\nThis must be done after a shape edit to make sure the offset controls work properly.', c=cb(computeDispCmd))
	deleteBT = cmds.button(l='Delete deformer', ann='Remove the Radial Blend Shape node attached to this geometry', c=cb(deleteCmd))
	cmds.button(l='Help', ann='Online documentation', bgc=(0.9, 0.8, 0.4), c=cb(helpCmd))

	cmds.formLayout(mainLAY, e=True,
	                attachForm=[(f1, 'top', 0), (f1, 'left', 0), (f1, 'right', 0), (f2, 'left', 0), (f2, 'right', 0), (f3, 'left', 0), (f3, 'right', 0), (f3, 'bottom', 0)],
	                attachControl=[(f2, 'top', 10, f1), (f2, 'bottom', 10, f3)])
	
	# control dict
	_controls['geo'] = geoTXT
	_controls['rbs'] = rbsTXT
	_controls['createBT'] = createBT
	_controls['addEyeBT'] = addEyeBT
	_controls['tabLAY'] = tabs
	_controls['editMembBT'] = editMembBT
	_controls['autoMembBT'] = autoMembBT
	_controls['deleteBT'] = deleteBT
	_controls['computeDispBT'] = computeDispBT

	_updateUI()
	
	# show window
	cmds.showWindow(winName)
	cmds.window(winName, edit=True, widthHeight=(320, 750))

	sys.stdout.write("%s %s          %s\n" % (__product__, __version__, __author__))

##
# TODO sovragruppi
コード例 #32
0
newNode = mc.deformer(type=nodeType)[0]

print('BUILD TEST __________________________ CONNECT IN')

print('BUILD TEST __________________________ CONNECT OUT')

print('BUILD TEST __________________________ SET ATTR')
mc.setAttr(newNode + '.envelope', 1)
mc.setAttr(newNode + '.cache', 0)
mc.refresh()
mc.setAttr(newNode + '.cache', 1)

print('BUILD TEST __________________________ DONE')
mc.select(newNode)

mc.makePaintable(clearAll=True)
mc.makePaintable(nodeType, "weights", attrType="multiFloat", sm="deformer")

#LOAD DRAW

print('BUILD TEST __________________________ PREPARE SCENE')
camera = "persp"
print('BUILD TEST __________________________ LOAD NODE')
mc.loadPlugin(pathNodeCppDraw)
print('BUILD TEST __________________________ CREATE NODE')
drawNode = mc.createNode(nodeTypeDraw)

print('BUILD TEST __________________________ CONNECT IN')
mc.connectAttr((camera + '.worldMatrix[0]'), '{}.camMatrix'.format(drawNode))
mc.connectAttr((newNode + '.outDraw'), '{}.inDraw'.format(drawNode))
コード例 #33
0
def zvRadialBlendShape():
    # load plugin
    if not cmds.pluginInfo(_rbsNodeName, q=True, l=True):
        cmds.loadPlugin(_rbsNodeName)

    # make attribute paintable
    cmds.makePaintable(_rbsNodeName,
                       'weights',
                       attrType='multiFloat',
                       sm='deformer')

    # create window
    winName = 'ZvRadialBlendShapeWin'
    if cmds.window(winName, exists=True):
        cmds.deleteUI(winName, window=True)

    cmds.window(winName, title='%s %s' % (__product__, __version__))

    mainLAY = cmds.formLayout()

    # geometry
    f1 = cmds.frameLayout(l='Geometry', borderStyle='etchedOut', mw=2, mh=2)
    cmds.columnLayout(adj=True)
    cmds.rowLayout(nc=3,
                   adj=3,
                   ct3=['both', 'both', 'both'],
                   cl3=['center', 'center', 'left'],
                   cw=[1, 120])
    cmds.button(l='Get geometry',
                ann='Refresh UI using selected geometry',
                c=cb(getGeoCmd))
    cmds.separator(w=8, st='none')
    geoTXT = cmds.text(l='')
    cmds.setParent(f1)
    cmds.rowLayout(nc=3,
                   adj=3,
                   ct3=['both', 'both', 'both'],
                   cl3=['center', 'center', 'left'],
                   cw=[1, 120])
    createBT = cmds.button(l='Create deformer',
                           ann='Create Radial Blend Shape node',
                           c=cb(createCmd))
    cmds.separator(w=8, st='none')
    rbsTXT = cmds.text(l='')

    # eyes
    cmds.setParent(mainLAY)
    f2 = cmds.frameLayout(l='Eyes', borderStyle='etchedOut', mw=2, mh=2)
    eyeFormLAY = cmds.formLayout(nd=20)
    addEyeBT = cmds.button(l='Add...', ann='Add shape group', c=cb(addEyeCmd))
    tabs = cmds.tabLayout(innerMarginWidth=2, innerMarginHeight=2)
    cmds.formLayout(eyeFormLAY,
                    e=True,
                    attachForm=[(addEyeBT, 'top', 0), (addEyeBT, 'left', 0),
                                (addEyeBT, 'right', 0), (tabs, 'left', 0),
                                (tabs, 'right', 0), (tabs, 'bottom', 0)],
                    attachControl=[(tabs, 'top', 4, addEyeBT)])

    # tools
    cmds.setParent(mainLAY)
    f3 = cmds.frameLayout(l='Tools', borderStyle='etchedOut', mw=2, mh=2)
    cmds.columnLayout(adj=True, rs=2)

    membLAY = cmds.formLayout(nd=20)
    editMembBT = cmds.button(l='Edit membership',
                             ann='Edit affected vertices',
                             c=cb(editMembershipCmd))
    autoMembBT = cmds.button(l='Auto membership',
                             ann='Optimize affected vertices',
                             c=cb(autoMembershipCmd))
    cmds.formLayout(membLAY,
                    e=True,
                    attachForm=[(editMembBT, 'top', 0),
                                (editMembBT, 'left', 0),
                                (editMembBT, 'bottom', 0),
                                (autoMembBT, 'top', 0),
                                (autoMembBT, 'right', 0),
                                (autoMembBT, 'bottom', 0)],
                    attachPosition=[(editMembBT, 'right', 1, 10),
                                    (autoMembBT, 'left', 1, 10)])

    cmds.setParent('..')
    computeDispBT = cmds.button(
        l='Compute displacements',
        ann=
        'Compute maximum displacements for all shapes.\nThis must be done after a shape edit to make sure the offset controls work properly.',
        c=cb(computeDispCmd))
    deleteBT = cmds.button(
        l='Delete deformer',
        ann='Remove the Radial Blend Shape node attached to this geometry',
        c=cb(deleteCmd))
    cmds.button(l='Help',
                ann='Online documentation',
                bgc=(0.9, 0.8, 0.4),
                c=cb(helpCmd))

    cmds.formLayout(mainLAY,
                    e=True,
                    attachForm=[(f1, 'top', 0), (f1, 'left', 0),
                                (f1, 'right', 0), (f2, 'left', 0),
                                (f2, 'right', 0), (f3, 'left', 0),
                                (f3, 'right', 0), (f3, 'bottom', 0)],
                    attachControl=[(f2, 'top', 10, f1),
                                   (f2, 'bottom', 10, f3)])

    # control dict
    _controls['geo'] = geoTXT
    _controls['rbs'] = rbsTXT
    _controls['createBT'] = createBT
    _controls['addEyeBT'] = addEyeBT
    _controls['tabLAY'] = tabs
    _controls['editMembBT'] = editMembBT
    _controls['autoMembBT'] = autoMembBT
    _controls['deleteBT'] = deleteBT
    _controls['computeDispBT'] = computeDispBT

    _updateUI()

    # show window
    cmds.showWindow(winName)
    cmds.window(winName, edit=True, widthHeight=(320, 750))

    sys.stdout.write("%s %s          %s\n" %
                     (__product__, __version__, __author__))


##
# TODO sovragruppi
コード例 #34
0
ファイル: primvar.py プロジェクト: fsanges/glTools-1
def addAbcPrimVar(geo,
                  attrName,
                  attrType=None,
                  dataType='long',
                  keyable=False,
                  paintable=False,
                  geoIsMesh=False):
    '''
	Add an alembic primVar attribute to the specified geometry.
	@param geo: Geometry to add primVar attribute to.
	@type geo: str
	@param attrName: Base primVar attribute name. The correct primVar prefix will be added to the final attribute name.
	@type attrName: str
	@param attrType: PrimVar attribute type. Accepted values are: <None> (per object), "var" (varying per face), "vtx" (varying per vertex), "uni" (uniform) and "fvr" (?)
	@type attrType: str
	@param dataType: The data type for the attribute. Only used when attrType=''. If empty, default to "long" (int). Alternative is "float".
	@type dataType: str
	@param keyable: Keyable state of the primVar attribute.
	@type keyable: bool
	@param paintable: Paintable state of the primVar attribute.
	@type paintable: bool
	@param geoIsMesh: Check if the specified geo node is a mesh, if not raise an exception.
	@type geoIsMesh: bool
	'''
    # ==========
    # - Checks -
    # ==========

    # Check Geometry
    if not mc.objExists(geo):
        raise Exception('Geometry "' + geo + '" does not exist!!')
    if geoIsMesh and not glTools.utils.mesh.isMesh(geo):
        raise Exception('Geometry "' + geo + '" is not a valid mesh!!')

    # Check Attribute
    attr = 'ABC_' + attrName
    if mc.objExists(geo + '.' + attr):
        # mc.deleteAttr(geo+'.'+attr)
        raise Exception('Attribute "' + geo + '.' + attr +
                        '" already exists!!')

    # Check Attribute Type
    typeList = ['var', 'vtx', 'uni', 'fvr']
    if attrType and not typeList.count(attrType):
        raise Exception(
            'Invalid attribute type! Accepted values are: "var", "vtx", "uni" and "fvr" (or <None> for per object attribute).'
        )

    # =================
    # - Add Attribute -
    # =================

    # Data type
    if not attrType:

        # Check Data Type
        if not dataType: dataType = 'long'

        # Add primVar attribute
        mc.addAttr(geo, ln=attr, at=dataType, k=keyable)

    else:

        # Set Attribute Data Type
        dataType = 'doubleArray'

        # Add primVar attribute
        mc.addAttr(geo, ln=attr, dt=dataType)

        # Set Geometey Scope Value
        attrTypeAttr = 'ABC_' + attrName + '_AbcGeomScope'
        mc.addAttr(geo, ln=attrTypeAttr, dt='string')
        mc.setAttr(geo + '.' + attrTypeAttr, attrType, type='string', l=True)

        # Make paintable
        if paintable: mc.makePaintable('mesh', attr, attrType=dataType)

    # =================
    # - Return Result -
    # =================

    return geo + '.' + attr
コード例 #35
0
def nodeInitializer():
    nAttr = om.MFnNumericAttribute()
    rAttr = om.MRampAttribute()
    cAttr = om.MFnCompoundAttribute()
    eAttr = om.MFnEnumAttribute()
    mAttr = om.MFnMatrixAttribute()
    tAttr = om.MFnTypedAttribute()
    # input user
    #     aPosition
    prSlideNode.aPosition = nAttr.create("position", "pos",
                                         om.MFnNumericData.kInt, 0)
    nAttr.setKeyable(True)
    nAttr.setMin(0)
    prSlideNode.addAttribute(prSlideNode.aPosition)
    #     aAlgorithm
    prSlideNode.aAlgorithm = eAttr.create("algorithm", "alg", 0)
    eAttr.setKeyable(True)
    eAttr.addField("slide closestPoint", 0)
    eAttr.addField("slide paper", 1)
    prSlideNode.addAttribute(prSlideNode.aAlgorithm)
    #     aHandleVisibility
    prSlideNode.aFlipOpposingSide = nAttr.create("flipOpposingSide", "fos",
                                                 om.MFnNumericData.kBoolean,
                                                 0.0)
    nAttr.setKeyable(True)
    prSlideNode.addAttribute(prSlideNode.aFlipOpposingSide)
    #     aHandleVisibility
    prSlideNode.aHandleVisibility = nAttr.create("handleVisibility", "hv",
                                                 om.MFnNumericData.kBoolean,
                                                 1.0)
    nAttr.setKeyable(True)
    prSlideNode.addAttribute(prSlideNode.aHandleVisibility)
    #     aFalloffType
    prSlideNode.aFalloffType = eAttr.create("falloffType", "fot", 1)
    eAttr.setKeyable(True)
    eAttr.addField("painted weight", 0)
    eAttr.addField("radius", 1)
    prSlideNode.addAttribute(prSlideNode.aFalloffType)
    #     aRadius
    prSlideNode.aRadius = nAttr.create("radius", "rr",
                                       om.MFnNumericData.kFloat, 1.0)
    nAttr.setKeyable(True)
    nAttr.setMin(0.01)
    prSlideNode.addAttribute(prSlideNode.aRadius)
    #     aRadiusFalloff
    prSlideNode.aRadiusFalloff = rAttr.createCurveRamp("radiusFalloff", "rfo")
    prSlideNode.addAttribute(prSlideNode.aRadiusFalloff)
    #     aFalloffWeight
    prSlideNode.aFalloffWeights = tAttr.create('falloffWeights', 'fow',
                                               om.MFnNumericData.kDoubleArray)
    tAttr.setHidden(True)
    # default value... does not seem to be necessary/work properly
    # daWeightsDefault = om.MDoubleArray()
    # fnWeightsDefault = om.MFnDoubleArrayData()
    # oWeightsDefault = fnWeightsDefault.create( daWeightsDefault )
    # tAttr.setDefault( oWeightsDefault )
    #     aFalloffWeightList
    prSlideNode.aFalloffWeightList = cAttr.create('falloffWeightsList', 'fwl')
    cAttr.addChild(prSlideNode.aFalloffWeights)
    cAttr.setHidden(True)
    cAttr.setArray(True)
    cAttr.setUsesArrayDataBuilder(True)
    prSlideNode.addAttribute(prSlideNode.aFalloffWeightList)
    # input deformer
    #     aDisplace
    prSlideNode.aDisplaceX = nAttr.create("displaceX", "dpx",
                                          om.MFnNumericData.kDouble, 0.0)
    nAttr.setReadable(False)
    prSlideNode.aDisplaceY = nAttr.create("displaceY", "dpy",
                                          om.MFnNumericData.kDouble, 0.0)
    nAttr.setReadable(False)
    prSlideNode.aDisplaceZ = nAttr.create("displaceZ", "dpz",
                                          om.MFnNumericData.kDouble, 0.0)
    nAttr.setReadable(False)
    prSlideNode.aDisplace = cAttr.create("displace", "dsp")
    cAttr.addChild(prSlideNode.aDisplaceX)
    cAttr.addChild(prSlideNode.aDisplaceY)
    cAttr.addChild(prSlideNode.aDisplaceZ)
    cAttr.setKeyable(True)
    cAttr.setReadable(False)
    prSlideNode.addAttribute(prSlideNode.aDisplace)
    #     aNullParentInverse
    prSlideNode.aNullParentInverse = mAttr.create('nullParentInverse', 'npi')
    mAttr.setReadable(False)
    prSlideNode.addAttribute(prSlideNode.aNullParentInverse)
    # output deformer
    #     aNullTranslate
    prSlideNode.aNullTranslateX = nAttr.create("nullTranslateX", "ntx",
                                               om.MFnNumericData.kDouble, 0.0)
    nAttr.setWritable(False)
    prSlideNode.aNullTranslateY = nAttr.create("nullTranslateY", "nty",
                                               om.MFnNumericData.kDouble, 0.0)
    nAttr.setWritable(False)
    prSlideNode.aNullTranslateZ = nAttr.create("nullTranslateZ", "ntz",
                                               om.MFnNumericData.kDouble, 0.0)
    nAttr.setWritable(False)
    prSlideNode.aNullTranslate = cAttr.create("nullTranslate", "ntr")
    cAttr.addChild(prSlideNode.aNullTranslateX)
    cAttr.addChild(prSlideNode.aNullTranslateY)
    cAttr.addChild(prSlideNode.aNullTranslateZ)
    cAttr.setWritable(False)
    prSlideNode.addAttribute(prSlideNode.aNullTranslate)

    # affects
    aOutputgeom = OpenMayaMPx.cvar.MPxDeformerNode_outputGeom
    aInputgeom = OpenMayaMPx.cvar.MPxDeformerNode_inputGeom
    #     default
    prSlideNode.attributeAffects(aInputgeom, prSlideNode.aNullTranslate)
    #     input user
    prSlideNode.attributeAffects(prSlideNode.aPosition, aOutputgeom)
    prSlideNode.attributeAffects(prSlideNode.aPosition,
                                 prSlideNode.aNullTranslate)
    prSlideNode.attributeAffects(prSlideNode.aFalloffType, aOutputgeom)
    prSlideNode.attributeAffects(prSlideNode.aRadius, aOutputgeom)
    prSlideNode.attributeAffects(prSlideNode.aRadiusFalloff, aOutputgeom)
    prSlideNode.attributeAffects(prSlideNode.aAlgorithm, aOutputgeom)
    prSlideNode.attributeAffects(prSlideNode.aFlipOpposingSide, aOutputgeom)
    prSlideNode.attributeAffects(prSlideNode.aFalloffWeights, aOutputgeom)
    #     input deformer
    prSlideNode.attributeAffects(prSlideNode.aDisplace, aOutputgeom)
    #     output
    prSlideNode.attributeAffects(prSlideNode.aNullParentInverse,
                                 prSlideNode.aNullTranslate)

    # Make deformer weights paintable
    import maya.cmds as mc
    mc.makePaintable('prSlideNode',
                     'weights',
                     attrType='multiFloat',
                     shapeMode='deformer')
    mc.makePaintable('prSlideNode',
                     'falloffWeights',
                     attrType='doubleArray',
                     shapeMode='deformer')
コード例 #36
0
    def initialize():
        numericAttr = om.MFnNumericAttribute()
        rampAttr = om.MRampAttribute()
        compoundAttr = om.MFnCompoundAttribute()
        unitAttr = om.MFnUnitAttribute()
        genericAttr = om.MFnGenericAttribute()

        prClosestPoint.enabled = numericAttr.create('enabled', 'enabled',
                                                    om.MFnNumericData.kBoolean,
                                                    True)
        numericAttr.setKeyable(True)
        prClosestPoint.addAttribute(prClosestPoint.enabled)
        prClosestPoint.attributeAffects(prClosestPoint.enabled,
                                        prClosestPoint.outputGeometry)

        # maxDistance
        prClosestPoint.maxDistanceEnabled = numericAttr.create(
            'maxDistanceEnabled', 'maxDistanceEnabled',
            om.MFnNumericData.kBoolean, True)
        numericAttr.setKeyable(True)
        prClosestPoint.addAttribute(prClosestPoint.maxDistanceEnabled)
        prClosestPoint.attributeAffects(prClosestPoint.maxDistanceEnabled,
                                        prClosestPoint.outputGeometry)

        prClosestPoint.maxDistance = unitAttr.create(
            'maxDistance', 'maxDistance', om.MFnUnitAttribute.kDistance, 1.0)
        unitAttr.setKeyable(True)
        unitAttr.setMin(0.0)
        prClosestPoint.addAttribute(prClosestPoint.maxDistance)
        prClosestPoint.attributeAffects(prClosestPoint.maxDistance,
                                        prClosestPoint.outputGeometry)

        prClosestPoint.maxDistanceWeights = numericAttr.create(
            'maxDistanceWeights', 'maxDistanceWeights',
            om.MFnNumericData.kFloat, 1.0)
        numericAttr.setMin(0.0)
        numericAttr.setMax(1.0)
        numericAttr.setArray(True)
        numericAttr.setUsesArrayDataBuilder(True)

        prClosestPoint.maxDistanceWeightList = compoundAttr.create(
            'maxDistanceWeightList', 'maxDistanceWeightList')
        compoundAttr.setArray(True)
        compoundAttr.setUsesArrayDataBuilder(True)
        compoundAttr.addChild(prClosestPoint.maxDistanceWeights)
        prClosestPoint.addAttribute(prClosestPoint.maxDistanceWeightList)
        prClosestPoint.attributeAffects(prClosestPoint.maxDistanceWeights,
                                        prClosestPoint.outputGeometry)

        prClosestPoint.maxDistanceUScaleEnabled = numericAttr.create(
            'maxDistanceUScaleEnabled', 'maxDistanceUScaleEnabled',
            om.MFnNumericData.kBoolean, False)
        numericAttr.setKeyable(True)
        prClosestPoint.addAttribute(prClosestPoint.maxDistanceUScaleEnabled)
        prClosestPoint.attributeAffects(
            prClosestPoint.maxDistanceUScaleEnabled,
            prClosestPoint.outputGeometry)

        prClosestPoint.maxDistanceUScale = rampAttr.createCurveRamp(
            'maxDistanceUScale', 'maxDistanceUScale')
        prClosestPoint.addAttribute(prClosestPoint.maxDistanceUScale)
        prClosestPoint.attributeAffects(prClosestPoint.maxDistanceUScale,
                                        prClosestPoint.outputGeometry)

        prClosestPoint.maxDistanceVScaleEnabled = numericAttr.create(
            'maxDistanceVScaleEnabled', 'maxDistanceVScaleEnabled',
            om.MFnNumericData.kBoolean, False)
        numericAttr.setKeyable(True)
        prClosestPoint.addAttribute(prClosestPoint.maxDistanceVScaleEnabled)
        prClosestPoint.attributeAffects(
            prClosestPoint.maxDistanceVScaleEnabled,
            prClosestPoint.outputGeometry)

        prClosestPoint.maxDistanceVScale = rampAttr.createCurveRamp(
            'maxDistanceVScale', 'maxDistanceVScale')
        prClosestPoint.addAttribute(prClosestPoint.maxDistanceVScale)
        prClosestPoint.attributeAffects(prClosestPoint.maxDistanceVScale,
                                        prClosestPoint.outputGeometry)

        # falloff
        prClosestPoint.falloffEnabled = numericAttr.create(
            'falloffEnabled', 'falloffEnabled', om.MFnNumericData.kBoolean,
            True)
        numericAttr.setKeyable(True)
        prClosestPoint.addAttribute(prClosestPoint.falloffEnabled)
        prClosestPoint.attributeAffects(prClosestPoint.falloffEnabled,
                                        prClosestPoint.outputGeometry)

        prClosestPoint.falloff = rampAttr.createCurveRamp('falloff', 'falloff')
        prClosestPoint.addAttribute(prClosestPoint.falloff)
        prClosestPoint.attributeAffects(prClosestPoint.falloff,
                                        prClosestPoint.outputGeometry)

        # inputTarget
        prClosestPoint.targetEnabled = numericAttr.create(
            'targetEnabled', 'targetEnabled', om.MFnNumericData.kBoolean, True)
        numericAttr.setKeyable(True)

        prClosestPoint.target = genericAttr.create('target', 'target')
        genericAttr.addDataAccept(om.MFnNurbsCurveData.kNurbsCurve)
        genericAttr.addDataAccept(om.MFnNurbsSurfaceData.kNurbsSurface)
        genericAttr.addDataAccept(om.MFnMeshData.kMesh)
        genericAttr.addDataAccept(om.MFnMatrixData.kMatrix)

        prClosestPoint.closestVertex = numericAttr.create(
            'closestVertex', 'closestVertex', om.MFnNumericData.kFloat, 0.0)
        numericAttr.setKeyable(True)
        numericAttr.setMin(0.0)
        numericAttr.setMax(1.0)

        prClosestPoint.inputTarget = compoundAttr.create(
            'inputTarget', 'inputTarget')
        compoundAttr.addChild(prClosestPoint.targetEnabled)
        compoundAttr.addChild(prClosestPoint.closestVertex)
        compoundAttr.addChild(prClosestPoint.target)
        compoundAttr.setArray(True)
        prClosestPoint.addAttribute(prClosestPoint.inputTarget)
        prClosestPoint.attributeAffects(prClosestPoint.targetEnabled,
                                        prClosestPoint.outputGeometry)
        prClosestPoint.attributeAffects(prClosestPoint.closestVertex,
                                        prClosestPoint.outputGeometry)
        prClosestPoint.attributeAffects(prClosestPoint.target,
                                        prClosestPoint.outputGeometry)

        mc.makePaintable('prClosestPoint',
                         'weights',
                         attrType='multiFloat',
                         shapeMode='deformer')
        mc.makePaintable('prClosestPoint',
                         'maxDistanceWeights',
                         attrType='multiFloat',
                         shapeMode='deformer')
コード例 #37
0
ファイル: prHeatDeformer.py プロジェクト: jonntd/prmaya
def nodeInitializer():
    outgeoAr = OpenMayaMPx.cvar.MPxDeformerNode_outputGeom
    # attribute type variables
    tAttr = om.MFnTypedAttribute()
    nAttr = om.MFnNumericAttribute()
    cAttr = om.MFnCompoundAttribute()
    gAttr = om.MFnGenericAttribute()
    eAttr = om.MFnEnumAttribute()

    # ###############################
    # essential (deformer)
    # ###############################
    # aOrigMesh
    prHeatDeformer.aOrigMesh = gAttr.create("origMesh", "origMesh")
    gAttr.setReadable(False)
    gAttr.addDataAccept(om.MFnMeshData.kMesh)
    prHeatDeformer.addAttribute(prHeatDeformer.aOrigMesh)
    prHeatDeformer.attributeAffects(prHeatDeformer.aOrigMesh, outgeoAr)

    # ###############################
    # blendshape (deformer)
    # ###############################
    # aSquashMesh
    prHeatDeformer.aSquashMesh = gAttr.create("squashMesh", "squashMesh")
    gAttr.setReadable(False)
    gAttr.addDataAccept(om.MFnMeshData.kMesh)
    prHeatDeformer.addAttribute(prHeatDeformer.aSquashMesh)
    prHeatDeformer.attributeAffects(prHeatDeformer.aSquashMesh, outgeoAr)
    # aStretchMesh
    prHeatDeformer.aStretchMesh = gAttr.create("stretchMesh", "stretchMesh")
    gAttr.setReadable(False)
    gAttr.addDataAccept(om.MFnMeshData.kMesh)
    prHeatDeformer.addAttribute(prHeatDeformer.aStretchMesh)
    prHeatDeformer.attributeAffects(prHeatDeformer.aStretchMesh, outgeoAr)

    # ###############################
    # Color
    # ###############################
    # aDisplayColors
    prHeatDeformer.aDisplayColors = nAttr.create("displayColors",
                                                 "displayColors",
                                                 om.MFnNumericData.kBoolean, 0)
    nAttr.setKeyable(True)
    prHeatDeformer.addAttribute(prHeatDeformer.aDisplayColors)
    prHeatDeformer.attributeAffects(prHeatDeformer.aDisplayColors, outgeoAr)
    # aColorBase
    prHeatDeformer.aColorBase = nAttr.createColor("colorBase", "colorBase")
    nAttr.setDefault(0.122, 0.122, 0.122)
    prHeatDeformer.addAttribute(prHeatDeformer.aColorBase)
    prHeatDeformer.attributeAffects(prHeatDeformer.aColorBase, outgeoAr)
    # aColorSquash
    prHeatDeformer.aColorSquash = nAttr.createColor("colorSquash",
                                                    "colorSquash")
    nAttr.setDefault(1.0, 0.0, 0.0)
    prHeatDeformer.addAttribute(prHeatDeformer.aColorSquash)
    prHeatDeformer.attributeAffects(prHeatDeformer.aColorSquash, outgeoAr)
    # aColorStretch
    prHeatDeformer.aColorStretch = nAttr.createColor("colorStretch",
                                                     "colorStretch")
    nAttr.setDefault(0.0, 1.0, 0.0)
    prHeatDeformer.addAttribute(prHeatDeformer.aColorStretch)
    prHeatDeformer.attributeAffects(prHeatDeformer.aColorStretch, outgeoAr)

    # ###############################
    # heat / algorithm
    # ###############################
    # aMeasureTypeHeat
    prHeatDeformer.aMeasureTypeHeat = eAttr.create("measureTypeHeat",
                                                   "measureTypeHeat", 0)
    eAttr.setKeyable(True)
    eAttr.addField("Face Area", 0)
    eAttr.addField("Edge Length", 1)
    prHeatDeformer.addAttribute(prHeatDeformer.aMeasureTypeHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aMeasureTypeHeat, outgeoAr)

    # aMultiplyHeat
    prHeatDeformer.aMultiplyHeat = nAttr.create("multiplyHeat", "multiplyHeat",
                                                om.MFnNumericData.kFloat, 1.0)
    nAttr.setSoftMin(0.0)
    nAttr.setKeyable(True)
    prHeatDeformer.addAttribute(prHeatDeformer.aMultiplyHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aMultiplyHeat, outgeoAr)
    # aSquashMultiplyHeat
    prHeatDeformer.aSquashMultiplyHeat = nAttr.create("squashMultiplyHeat",
                                                      "squashMultiplyHeat",
                                                      om.MFnNumericData.kFloat,
                                                      1.0)
    nAttr.setSoftMin(0.0)
    nAttr.setKeyable(True)
    prHeatDeformer.addAttribute(prHeatDeformer.aSquashMultiplyHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aSquashMultiplyHeat,
                                    outgeoAr)
    # aStretchMultiplyHeat
    prHeatDeformer.aStretchMultiplyHeat = nAttr.create(
        "stretchMultiplyHeat", "stretchMultiplyHeat", om.MFnNumericData.kFloat,
        1.0)
    nAttr.setSoftMin(0.0)
    nAttr.setKeyable(True)
    prHeatDeformer.addAttribute(prHeatDeformer.aStretchMultiplyHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aStretchMultiplyHeat,
                                    outgeoAr)

    # aMaxHeat
    prHeatDeformer.aMaxHeat = nAttr.create("maxHeat", "maxHeat",
                                           om.MFnNumericData.kBoolean, 1)
    nAttr.setKeyable(True)
    prHeatDeformer.addAttribute(prHeatDeformer.aMaxHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aMaxHeat, outgeoAr)
    # aSquashMaxHeat
    prHeatDeformer.aSquashMaxHeat = nAttr.create("squashMaxHeat",
                                                 "squashMaxHeat",
                                                 om.MFnNumericData.kFloat, 1.0)
    nAttr.setKeyable(True)
    nAttr.setMin(0.0)
    prHeatDeformer.addAttribute(prHeatDeformer.aSquashMaxHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aSquashMaxHeat, outgeoAr)
    # aStretchMaxHeat
    prHeatDeformer.aStretchMaxHeat = nAttr.create("stretchMaxHeat",
                                                  "stretchMaxHeat",
                                                  om.MFnNumericData.kFloat,
                                                  1.0)
    nAttr.setKeyable(True)
    nAttr.setMin(0.0)
    prHeatDeformer.addAttribute(prHeatDeformer.aStretchMaxHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aStretchMaxHeat, outgeoAr)

    # aGrowHeat
    prHeatDeformer.aGrowHeat = nAttr.create("growHeat", "growHeat",
                                            om.MFnNumericData.kInt, 0)
    nAttr.setKeyable(True)
    nAttr.setMin(0)
    nAttr.setSoftMax(10)
    prHeatDeformer.addAttribute(prHeatDeformer.aGrowHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aGrowHeat, outgeoAr)
    # aSquashGrowHeat
    prHeatDeformer.aSquashGrowHeat = nAttr.create("squashGrowHeat",
                                                  "squashGrowHeat",
                                                  om.MFnNumericData.kInt, 0)
    nAttr.setKeyable(True)
    nAttr.setMin(0)
    nAttr.setSoftMax(10)
    prHeatDeformer.addAttribute(prHeatDeformer.aSquashGrowHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aSquashGrowHeat, outgeoAr)
    # aStretchGrowHeat
    prHeatDeformer.aStretchGrowHeat = nAttr.create("stretchGrowHeat",
                                                   "stretchGrowHeat",
                                                   om.MFnNumericData.kInt, 0)
    nAttr.setKeyable(True)
    nAttr.setMin(0)
    nAttr.setSoftMax(10)
    prHeatDeformer.addAttribute(prHeatDeformer.aStretchGrowHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aStretchGrowHeat, outgeoAr)

    # aIterationsSmoothHeat
    prHeatDeformer.aIterationsSmoothHeat = nAttr.create(
        "iterationsSmoothHeat", "iterationsSmoothHeat", om.MFnNumericData.kInt,
        0)
    nAttr.setKeyable(True)
    nAttr.setMin(0)
    nAttr.setSoftMax(10)
    prHeatDeformer.addAttribute(prHeatDeformer.aIterationsSmoothHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aIterationsSmoothHeat,
                                    outgeoAr)
    # aStrengthSmoothHeat
    prHeatDeformer.aStrengthSmoothHeat = nAttr.create("strengthSmoothHeat",
                                                      "strengthSmoothHeat",
                                                      om.MFnNumericData.kFloat,
                                                      0.2)
    nAttr.setKeyable(True)
    nAttr.setMin(0.0)
    nAttr.setSoftMax(1.0)
    prHeatDeformer.addAttribute(prHeatDeformer.aStrengthSmoothHeat)
    prHeatDeformer.attributeAffects(prHeatDeformer.aStrengthSmoothHeat,
                                    outgeoAr)

    # ###############################
    # deformation type (user)
    # ###############################
    prHeatDeformer.aDeformationType = eAttr.create("deformationType",
                                                   "deformationType", 0)
    eAttr.setKeyable(True)
    eAttr.addField("None", 0)
    eAttr.addField("Normal Vector", 1)
    eAttr.addField("BlendShape", 2)
    prHeatDeformer.addAttribute(prHeatDeformer.aDeformationType)
    prHeatDeformer.attributeAffects(prHeatDeformer.aDeformationType, outgeoAr)

    # aIterationsSmoothDeformation
    prHeatDeformer.aIterationsSmoothDeformation = nAttr.create(
        "iterationsSmoothDeformer", "iterationsSmoothDeformer",
        om.MFnNumericData.kInt, 0)
    nAttr.setKeyable(True)
    nAttr.setMin(0)
    nAttr.setSoftMax(10)
    prHeatDeformer.addAttribute(prHeatDeformer.aIterationsSmoothDeformation)
    prHeatDeformer.attributeAffects(
        prHeatDeformer.aIterationsSmoothDeformation, outgeoAr)
    # aStrengthSmoothHeat
    prHeatDeformer.aStrengthSmoothDeformation = nAttr.create(
        "strengthSmoothDeformer", "strengthSmoothDeformer",
        om.MFnNumericData.kFloat, 0.2)
    nAttr.setKeyable(True)
    nAttr.setMin(0.0)
    nAttr.setSoftMax(1.0)
    prHeatDeformer.addAttribute(prHeatDeformer.aStrengthSmoothDeformation)
    prHeatDeformer.attributeAffects(prHeatDeformer.aStrengthSmoothDeformation,
                                    outgeoAr)

    # ###############################
    # BlendShape
    # ##############################
    prHeatDeformer.aTangentSpace = eAttr.create("tangentSpace", "tangentSpace",
                                                2)
    eAttr.setKeyable(True)
    eAttr.addField("Off", 0)
    eAttr.addField("Simple", 1)
    eAttr.addField("Full", 2)
    prHeatDeformer.addAttribute(prHeatDeformer.aTangentSpace)
    prHeatDeformer.attributeAffects(prHeatDeformer.aTangentSpace, outgeoAr)

    # ###############################
    # paintable
    # ###############################
    import maya.cmds as mc
    mc.makePaintable('prHeatDeformer',
                     'weights',
                     attrType='multiFloat',
                     shapeMode='deformer')
コード例 #38
0
print( 'BUILD TEST __________________________ DONE')
mc.select(newNode)








print( 'BUILD TEST __________________________ LOAD NODE')
mc.loadPlugin( pathNodeCppWeightMap  )
print( 'BUILD TEST __________________________ CREATE NODE')
mc.select(mesh)
newNodeWM = mc.deformer( type = nodeTypeWeightMap)[0]
mc.makePaintable(  clearAll = True )
mc.makePaintable(  "weightMap" , "inWeightsDouble" ,attrType = "multiDouble" , sm ="deformer" )
mc.makePaintable(  "weightMap" , "inWeightsFloat" ,attrType = "multiFloat" , sm ="deformer" )
mc.makePaintable(  "weightMap" , "weights" ,attrType = "multiFloat" , sm ="deformer" )
mc.makePaintable(  "weightMap" , "outWeights" ,attrType = "multiFloat" , sm ="deformer" )

print( 'BUILD TEST __________________________ CONNECT IN')
mc.connectAttr( ( newNode      + '.outValuesList' )  , ( newNodeWM + '.inWeightsList'     ) )
print( 'BUILD TEST __________________________ CONNECT OUT')

print( 'BUILD TEST __________________________ SET ATTR')
mc.setAttr( newNode + '.envelope', 1)
mc.setAttr( newNode + '.cache', 0)
mc.refresh()
mc.setAttr( newNode + '.cache', 1)
コード例 #39
0
def nodeInitializer():
    # default attr
    outgeoAr = OpenMayaMPx.cvar.MPxDeformerNode_outputGeom
    # attribute type variables
    gAttr = om.MFnGenericAttribute()
    nAttr = om.MFnNumericAttribute()
    mAttr = om.MFnMatrixAttribute()
    rAttr = om.MRampAttribute()
    eAttr = om.MFnEnumAttribute()

    # aDebug
    prAttractNode.aDebug = eAttr.create("debug", "debug", 2)
    eAttr.setChannelBox(True)
    eAttr.addField("Off", 0)
    eAttr.addField("Warnings", 1)
    eAttr.addField("Show all", 2)
    prAttractNode.addAttribute(prAttractNode.aDebug)
    prAttractNode.attributeAffects(prAttractNode.aDebug, outgeoAr)
    # aMaxDistance
    prAttractNode.aMaxDistance = nAttr.create("maxDistance", "maxDistance", om.MFnNumericData.kFloat, 1)
    nAttr.setKeyable(True)
    nAttr.setMin(0.0)
    prAttractNode.addAttribute(prAttractNode.aMaxDistance)
    prAttractNode.attributeAffects(prAttractNode.aMaxDistance, outgeoAr)
    # aFalloff
    prAttractNode.aFalloff = rAttr.createCurveRamp("falloff", "falloff")
    prAttractNode.addAttribute(prAttractNode.aFalloff)
    prAttractNode.attributeAffects(prAttractNode.aFalloff, outgeoAr)
    # aMaxDistanceUv
    prAttractNode.aMaxDistanceUv = rAttr.createCurveRamp("maxDistanceUv", "maxDistanceUv")
    prAttractNode.addAttribute(prAttractNode.aMaxDistanceUv)
    prAttractNode.attributeAffects(prAttractNode.aMaxDistanceUv, outgeoAr)
    # aProjectOnNormal
    prAttractNode.aProjectOnNormal = nAttr.create("projectOnNormal", "projectOnNormal", om.MFnNumericData.kFloat, 0.0)
    nAttr.setKeyable(True)
    nAttr.setMin(0.0)
    nAttr.setMax(1.0)
    prAttractNode.addAttribute(prAttractNode.aProjectOnNormal)
    prAttractNode.attributeAffects(prAttractNode.aProjectOnNormal, outgeoAr)
    # aNormalDirectionLimit
    prAttractNode.aNormalDirectionLimit = eAttr.create("normalDirectionLimit", "normalDirectionLimit", 0)
    eAttr.setKeyable(True)
    eAttr.addField("Off", 0)
    eAttr.addField("Only positive", 1)
    eAttr.addField("Only negative", 2)
    prAttractNode.addAttribute(prAttractNode.aNormalDirectionLimit)
    prAttractNode.attributeAffects(prAttractNode.aNormalDirectionLimit, outgeoAr)
    # aClosestVertex
    prAttractNode.aClosestVertex = nAttr.create("closestVertex", "closestVertex", om.MFnNumericData.kFloat, 0.0)
    nAttr.setKeyable(True)
    nAttr.setMin(0.0)
    nAttr.setMax(1.0)
    prAttractNode.addAttribute(prAttractNode.aClosestVertex)
    prAttractNode.attributeAffects(prAttractNode.aClosestVertex, outgeoAr)

    # aInputShape
    prAttractNode.aInputShape = gAttr.create("inputShape", "inputShape")
    gAttr.setReadable(False)
    gAttr.addDataAccept(om.MFnNurbsCurveData.kNurbsCurve)
    gAttr.addDataAccept(om.MFnNurbsSurfaceData.kNurbsSurface)
    gAttr.addDataAccept(om.MFnMeshData.kMesh)
    prAttractNode.addAttribute(prAttractNode.aInputShape)
    prAttractNode.attributeAffects(prAttractNode.aInputShape, outgeoAr)
    # aInputMatrix
    prAttractNode.aInputMatrix = mAttr.create("inputMatrix", "inputMatrix")
    mAttr.setReadable(False)
    prAttractNode.addAttribute(prAttractNode.aInputMatrix)
    prAttractNode.attributeAffects(prAttractNode.aInputMatrix, outgeoAr)

    # paintable
    import maya.cmds as mc
    mc.makePaintable('prAttractNode', 'weights', attrType='multiFloat', shapeMode='deformer')
コード例 #40
0
 def rmvPaintAttribute(subName, attrName):
     mc.makePaintable(subName, attrName, rm=1)