def loadWeightMap(nCloth, attr, filePath, loadAsVertexMap=False): """ Load nCloth attribute weight map from file. Optionally, load the weight values to a vertex map as opposed to a texture map @param nCloth: nCloth object to load attribute weights for. @type nCloth: str @param attr: nCloth attributes to load weights for @type attr: str @param filePath: File path to the attribute weight map. @type filePath: str @param loadAsVertexMap: Load the attribute weight values to a vertex map instead of a texture map. @type loadAsVertexMap: bool """ # Checks nCloth connNCloth = getConnectedNCloth(nCloth) if not connNCloth: raise Exception('Object "' + nCloth + '" is not a valid nCloth object!') nCloth = connNCloth[0] # Check file path if not os.path.isfile(filePath): raise Exception('Weight map file path "' + filePath + '" does not exist!') # Create file node fileName = os.path.basename(filePath) fileName = fileName.replace('.' + fileName.split('.')[-1], '') fileNode = cmds.shadingNode('file', asTexture=True, n=fileName) cmds.setAttr(fileNode + '.fileTextureName', filePath, type='string') # Connect to nCloth cmds.connectAttr(fileNode + '.outAlpha', nCloth + '.' + attr + 'Map', f=True) cmds.setAttr(nCloth + '.' + attr + 'MapType', 2) # Texture Map # Convert to vertex map if loadAsVertexMap: cmds.nBase(nCloth, e=True, textureToVertex=attr + 'Map') cmds.setAttr(nCloth + '.' + attr + 'MapType', 1) # Per-vertex cmds.delete(fileNode)
def loadWeightMap(nCloth,attr,filePath,loadAsVertexMap=False): ''' Load nCloth attribute weight map from file. Optionally, load the weight values to a vertex map as opposed to a texture map @param nCloth: nCloth object to load attribute weights for. @type nCloth: str @param attr: nCloth attributes to load weights for @type attr: str @param filePath: File path to the attribute weight map. @type filePath: str @param loadAsVertexMap: Load the attribute weight values to a vertex map instead of a texture map. @type loadAsVertexMap: bool ''' # Checks nCloth connNCloth = getConnectedNCloth(nCloth) if not connNCloth: raise Exception('Object "'+nCloth+'" is not a valid nCloth object!') nCloth = connNCloth[0] # Check file path if not os.path.isfile(filePath): raise Exception('Weight map file path "'+filePath+'" does not exist!') # Create file node fileName = os.path.basename(filePath) fileName = fileName.replace('.'+fileName.split('.')[-1],'') fileNode = mc.shadingNode('file',asTexture=True,n=fileName) mc.setAttr(fileNode+'.fileTextureName',filePath,type='string') # Connect to nCloth mc.connectAttr(fileNode+'.outAlpha',nCloth+'.'+attr+'Map',f=True) mc.setAttr(nCloth+'.'+attr+'MapType',2) # Texture Map # Convert to vertex map if loadAsVertexMap: mc.nBase(nCloth,e=True,textureToVertex=attr+'Map') mc.setAttr(nCloth+'.'+attr+'MapType',1) # Per-vertex mc.delete(fileNode)
def nbase(): # Stuff the current positions and velocities into nCloth1's startPositions and # startVelocities. cmds.nBase( 'nCloth1', e=True, stuffStart=True ) # Clear nCloth1's startPositions and startVelocities. cmds.nBase( 'nCloth1', e=True, clearStart=True ) # Transfer the texture map data for the thicknessMap attribute into the # thicknessPerVertex attribute. cmds.nBase( 'nCloth1', e=True, textureToVertex='thicknessMap' )
def nBase(*args, **kwargs): res = cmds.nBase(*args, **kwargs) if not kwargs.get('query', kwargs.get('q', False)): res = _factories.maybeConvert(res, _general.PyNode) return res