def generate(self): for shader in self.shaders.keys(): assignation = tdLib.getShaderAssignation(shader) filename = self.assetName.upper() + '_' + shader + '_Small.tga' fullpath = os.path.join(self.exportPath, filename) text = create_text_image(fullpath, self.assetName, shader, 1024, self.fillColor) texture, placed2dtexture = tdLib.createFileNode() cmds.connectAttr(texture + '.outColor', shader + '.color', force=True) cmds.setAttr(texture + '.fileTextureName', fullpath, type='string') self.shaders[shader] = [assignation, fullpath, texture, placed2dtexture]
def __init__(self, shaderName, mode, renderAttr, shaderAttr): self.mode = mode self.name = shaderName self.shadingGroup = tdLib.getSGsFromMaterial(shaderName)[0] self.renderAttr = renderAttr self.shaderAttr = shaderAttr self.assignation = tdLib.getShaderAssignation(shaderName) self.shapes = self.getShapes() self.udims = self.getAllUDIMs() self.udimsTotal = copy.copy(self.udims) self.texturePath, self.fileName = self.getTexturePath() # self.checkValidity() Shader.instances.append(self)
def generate(self): for shader in self.shaders.keys(): assignation = tdLib.getShaderAssignation(shader) filename = self.assetName.upper() + '_' + shader + '_Small.tga' fullpath = os.path.join(self.exportPath, filename) text = create_text_image(fullpath, self.assetName, shader, 1024, self.fillColor) texture, placed2dtexture = tdLib.createFileNode() cmds.connectAttr(texture + '.outColor', shader + '.color', force=True) cmds.setAttr(texture + '.fileTextureName', fullpath, type='string') self.shaders[shader] = [ assignation, fullpath, texture, placed2dtexture ]
for sel in selection: try: ncloth = tdLib.getFirstItem(cmds.listConnections(sel + '.inMesh', source=True, shapes=True)) shape = tdLib.getFirstItem(cmds.listConnections(ncloth + '.inputMesh', source=True, shapes=True)) OBJS.append(shape) OBJSCOPY.append(sel) except TypeError: pass shadingGroups = list(tdLib.flatten([tdLib.getSGsFromShape(i) for i in OBJS])) shaders = [tdLib.getMaterialFromSG(i) for i in shadingGroups] assignation = {} for i in shaders: assignation[i] = tdLib.getShaderAssignation(i) objs = {} for i, u in zip(OBJS, OBJSCOPY): objs[i] = u assignationNew = {} for shader, assign in assignation.iteritems(): assignationNew[shader] = [] for ass in assign: splitted = ass.split('.')[0] try: assignationNew[shader].append(ass.replace(splitted, objs[splitted])) except KeyError, e: pass
ncloth = tdLib.getFirstItem( cmds.listConnections(sel + '.inMesh', source=True, shapes=True)) shape = tdLib.getFirstItem( cmds.listConnections(ncloth + '.inputMesh', source=True, shapes=True)) OBJS.append(shape) OBJSCOPY.append(sel) except TypeError: pass shadingGroups = list(tdLib.flatten([tdLib.getSGsFromShape(i) for i in OBJS])) shaders = [tdLib.getMaterialFromSG(i) for i in shadingGroups] assignation = {} for i in shaders: assignation[i] = tdLib.getShaderAssignation(i) objs = {} for i, u in zip(OBJS, OBJSCOPY): objs[i] = u assignationNew = {} for shader, assign in assignation.iteritems(): assignationNew[shader] = [] for ass in assign: splitted = ass.split('.')[0] try: assignationNew[shader].append(ass.replace(splitted, objs[splitted])) except KeyError, e: pass