def controls(self): """return controls of pose""" data = pickle.load(open(self.posePath, "rb")) return mn.Nodes([ Pose.NAMESPACE + o.name for o in data.keys() if mn.Node(Pose.NAMESPACE + o.name).exists ])
def create(self): """docstring for create""" scalp = str(self.scalp_le.text()) for index in xrange(self.groups_lw.count()): grp = mn.Node(str(self.groups_lw.item(index).text())) mc.select(grp.children) asd = hr.hairSystemAutomator(sysName=grp.name.replace( '_lock_grp', ''), scalp=scalp)
def isolate(node): """isolate node""" nod = mn.Node(node) nod() currPanel = mc.getPanel(withFocus=True) panelType = mc.getPanel(to=currPanel) if panelType == 'modelPanel': mc.isolateSelect(currPanel, state=1) mm.eval('enableIsolateSelect %s 1;' % currPanel)
def __init__(self, mesh, hairSystem=None, scalp=None): self._mesh = None self._curveMesh = None self._hairSystem = None self._curves = [] self._follicles = [] self._scalp = None if isinstance(mesh, mn.Node): self._mesh = mesh else: self._mesh = mn.Node(mesh) if isinstance(hairSystem, mn.Node): self._hairSystem = hairSystem else: self._hairSystem = mn.Node(hairSystem) if isinstance(scalp, mn.Node): self._scalp = scalp else: self._scalp = mn.Node(scalp)
def mixPose(self, val): """mix values of slider""" for o in self.basePoseData.keys(): for a in self.basePoseData[o].keys(): mixedValue = (self.poseTargetData[o][a] * float(val) / 100.0) + (self.basePoseData[o][a] * (1 - float(val) / 100.0)) finalA = mn.NodeAttribute(mn.Node(Pose.NAMESPACE + o.name), a.name) finalA.v = mixedValue
def load(self): """docstring for load""" data = self.controlsDataFromFile for o in data.keys(): if not o.exists: continue for a in data[o].keys(): finalA = mn.NodeAttribute(mn.Node(Pose.NAMESPACE + o.name), a.name) if finalA.exists: finalA.v = data[o][a]
def hairSystemAutomator(sysName='', scalp=None): """creates a hair system based on selected lock meshes, if you specify a scalp it will use that to place follicles""" hair_polygons = mn.ls(sl=1) all_grp = mn.Node(mc.group(n=sysName + '_hair_grp', em=True)) hairSystem = mn.createNode('hairSystem') hairSystemPar = hairSystem.parent hairSystemPar.name = sysName + '_hairSystem' hairSystemPar.parent = all_grp hairSystem = hairSystemPar.shape pfxHair = mn.createNode('pfxHair') pfxHairPar = pfxHair.parent pfxHairPar.name = sysName + '_pfxHair' pfxHairPar.parent = all_grp pfxHair = pfxHairPar.shape foll_grp = mn.Node(mc.group(n=sysName + '_foll_grp', em=True)) foll_grp.parent = all_grp curve_grp = mn.Node(mc.group(n=sysName + '_crv_grp', em=True)) curve_grp.parent = all_grp allFollicles = [] allHairCurves = [] allFtbHairCurves = [] hairCount = 0 plugCount = 0 badMesh = [] for hair_poly in hair_polygons: hairLock = HairLock(hair_poly, hairSystem, scalp) hairLock.create() for i in range(5): hairLock.follicles[i].parent = foll_grp #if not scalp: hairLock.curves[i].parent = curve_grp #hairSystem.attr( "clumpFlatness[0].clumpFlatness_Position" ).v = 0 #hairSystem.attr( "clumpFlatness[0].clumpFlatness_FloatValue" ).v = 0.5 hairSystem.a.simulationMethod.v = 1 hairSystem.a.outputRenderHairs >> pfxHair.a.renderHairs ti = mn.Node('time1') ti.a.outTime >> hairSystem.a.currentTime
def __init__(self, project, pose=None, parent=uiH.getMayaWindow()): if uiH.USEPYQT: super(base, self).__init__(parent) else: super(PoseThumbnailCreatorUi, self).__init__(parent) self.setupUi(self) self.project = project self.pose = pose layout = mui.MQtUtil.fullName( long(shiboken.getCppPointer(self.viewport_lay)[0])) self.cam = mn.Node('Capture_Pose') if not self.cam.exists: self.camShape = mn.createNode('camera', ss=True) self.camShape.parent.name = 'Capture_Pose' mc.viewSet(self.cam.name, p=True) self.cam.shape.a.focalLength.v = 100 self.cam.a.v.v = 0 self.executer = mc.modelPanel(mbv=False, camera=self.cam.name, p=layout) mc.modelEditor(self.executer, e=True, grid=0, da="smoothShaded", allObjects=0, nurbsSurfaces=1, polymeshes=1, subdivSurfaces=1) #self.viewport_lay.addWidget( uiH.toQtObject( self.executer ) ) self.setObjectName('PoseThumbnailCreatorUi') self._makeConnections() self.saveCameraPreset = 0 #READ, 1.. WRITE self.settings = sti.Settings() gen = self.settings.General skin = gen["skin"] if skin: uiH.loadSkin(self, skin) if pose: self.poseName_le.setText(pose.name) self.fillSections()
def createScatter(self): """create scatter based on UI""" curv = str(self.curve_le.text()) objCount = self.controlCount_sbx.value() random = self.random_chb.isChecked() useTip = self.useTips_chb.isChecked() keepConn = self.keepConnected_chb.isChecked() tangent = self.tangent_chb.isChecked() groupIt = self.groupIt_chb.isChecked() animated = self.animated_chb.isChecked() objs = [] for index in xrange(self.objects_lw.count()): objs.append(mn.Node(str(self.objects_lw.item(index).text()))) crvScat.CurveScatter(curve=crv.Curve(curv), objects=objs, pointsCount=objCount, useTips=useTip, keepConnected=keepConn, tangent=tangent, rand=random, groupit=groupIt, animated=animated)
def playblast(movFil): """main playblast function param path: string for the path for the playblast""" mm.eval('setAllMainWindowComponentsVisible 0;') try: resNode = mn.Node('defaultResolution') #resolution = [ resNode.a.width.v, resNode.a.height.v ] resolution = [1280, 720] #CREATE PLAYBLAST #write files in tmp dir mc.setAttr('defaultRenderGlobals.imageFormat', 32) tmpFile = tempfile.gettempdir() + '/playblastTmp/' + movFil.name asd = mc.playblast(format="image", filename=tmpFile, forceOverwrite=True, viewer=0, showOrnaments=0, percent=100, widthHeight=resolution) print asd finally: mm.eval('setAllMainWindowComponentsVisible 1;') #ADD FRAME NUMBERS print tmpFile + '.png' #sqFil.sequenceFile( tmpFile + '.png' ).insertFrameNumber( tempfile.gettempdir() + '/playblastTmp/', 1, movFil.name ) #EXPORT MOV FILE audioPath = '' audio = [a for a in mn.ls(typ='audio') if a.a.mute.v == 0] if audio: audioPath = audio[0].a.filename.v fps = {'film': 24, 'pal': 25} curFps = mc.currentUnit(q=True, time=True) sqFile = sqFil.sequenceFile(tmpFile + '.png') sqFile.createMov( movFil.dirPath.replace('\\', '/').replace('//', '/'), audioPath, fps[curFps], movFil.name) os.system("start " + str(movFil.path)) shutil.rmtree(tempfile.gettempdir() + '/playblastTmp/')
import general.mayaNode.mayaNode as mn import random as rd import maya.cmds as mc rbfNode = mn.createNode('rbfSolver') baseSphere = mn.Node('pSphere1') sha = baseSphere.shader.a.surfaceShader.input.node distance = 30 samples = mn.createNode('transform') samples.name = 'samples' samplesCount = 30 centersCount = 5 for n in range(samplesCount): newSphere = baseSphere.duplicate() newSha = sha.duplicate() newSphere.a.t.v = [ rd.uniform(-(distance), distance), rd.uniform(-(distance), distance), rd.uniform(-(distance), distance) ] newSha.a.outColor.v = [ rd.uniform(0, 1), rd.uniform(0, 1), rd.uniform(0, 1) ] mc.select(newSphere) mc.hyperShade(a=newSha) newSphere.a.t >> rbfNode.attr("inPos[" + str(n) + "]") newSha.a.outColorR >> rbfNode.attr("inValues[" + str(n) + "].inValue[0]") newSha.a.outColorG >> rbfNode.attr("inValues[" + str(n) + "].inValue[1]") newSha.a.outColorB >> rbfNode.attr("inValues[" + str(n) + "].inValue[2]") newSphere.parent = samples
def nodes(self): """return the nodes of the reference""" return [mn.Node(a) for a in mc.referenceQuery(self.name, nodes=True)]
def __init__(self, curve, objects, pointsCount, useTips=False, keepConnected=True, tangent=False, rand=False, groupit=False, animated=False): """creates objects allong curve, curve: Curve Class object that handles the curve objects: Array of one o more transforms objects to position allong curve pointsCount: Amount of points in the curve useTips: is to position objects in the curve keepConnected: Keep pointOnCurveInfo connected between transform and curve tangent: Manage rotation on objects also rand: Place the objects in random order animated: Add speed attribute to move objects along curve""" self._nodes = [] self._curve = curve if useTips: val = -1 else: val = 1 startParam = 1.0 / (pointsCount + val) param = 0 objsIter = it.bicycle(objects) grp = mn.Node(curve.name + '_grp') if groupit: grp = mn.Node(mc.group(n=grp.name, em=True)) if animated: grp.a.laps.add(k=True) with undo.Undo(): for p in range(pointsCount): #place transform in param point if not useTips: param += startParam if rand: baseobj = random.choice(objects) else: baseobj = objsIter.next() obj = baseobj.duplicate() self._nodes.append(obj) if groupit: obj.parent = grp pcurveNode = mn.Node( mc.pathAnimation(obj.name, su=0.5, c=curve.name, fm=True, follow=tangent, followAxis='z', upAxis='y', worldUpType='object', worldUpObject=curve.parent.name)) animCurve = pcurveNode.a.uValue.input.node animCurve.delete() if keepConnected: obj.a.parameter.add(k=True) obj.a.parameter.v = param obj.a.parameter.min = 0 obj.a.parameter.max = 1 obj.a.parameter >> pcurveNode.a.uValue else: if param > 1.0: param = 1 pcurveNode.a.uValue.v = param t = obj.a.t.v r = obj.a.r.v pcurveNode.delete() obj.a.t.v = t[0] obj.a.r.v = r[0] if useTips: param += startParam if animated: cmd = obj.a.parameter.fullname + ' = ( abs( ' + str( obj.a.parameter.v ) + ' + ' + grp.a.laps.fullname + ' ) ) % 1;' mc.expression(s=cmd)