def _visualizer_setup(self): """Add a shader to visualize the outValue and the coneAngle.""" visualize_sdr = pm.shadingNode('surfaceShader', asShader=True, n='visualize') sets = pm.sets(renderable=True, noSurfaceShader=True, empty=True, n='visualize') visualize_sdr.outColor >> sets.surfaceShader vis_ramp = pm.createNode('ramp', n='visualize') vis_ramp.setAttr('type', 1) vis_ramp.setAttr('colorEntryList[0].color', 0, 0, 0) vis_ramp.setAttr('colorEntryList[1].position', 1) vis_ramp.setAttr('colorEntryList[1].color', 0, 0, 0) vis_ramp.setAttr('colorEntryList[2].position', 0) cmds.setAttr('%s.colorEntryList[2].color' % vis_ramp, 0, 0, 0, type='double3') vis_ramp.setAttr('colorEntryList[3].color', 0, 0, 0) self.ramp.outColorR >> vis_ramp.colorEntryList[1].color.colorG rmv = pm.createNode('remapValue', n='visualize') rmv.setAttr('inputMin', -1) rmv.setAttr('inputMax', 0) rmv.setAttr('outputMin', 1) rmv.setAttr('outputMax', 0) self.ramp.outColorR >> rmv.inputValue rmv.outValue >> vis_ramp.colorEntryList[2].color.colorR (self.ramp.colorEntryList[0].position >> vis_ramp.colorEntryList[0].position) (self.ramp.colorEntryList[3].position >> vis_ramp.colorEntryList[3].position) vis_ramp.outColor >> visualize_sdr.outColor pm.defaultNavigation(source=visualize_sdr, destination=self.sphere.getShape().instObjGroups[0], connectToExisting=True)
def feetctrl(arg): value=pm.textField('cmm',q=True,tx=True) ctrsel = ["Ankle_L","ToesEnd_L","Ankle_R","ToesEnd_R"] fmsel = [] fmseladjust = ["footmask_LB","footmask_LF","footmask_RB","footmask_RF"] LBcube = pm.polyCube(n="footmask_LB",w=0.13,h=0.03,d=0.2) pm.move(0.095,-0.015,0.013) fmsel.append(LBcube) LFcube = pm.polyCube(n="footmask_LF",w=0.13,h=0.03,d=0.08) pm.move(0.095,-0.015,0.143) fmsel.append(LFcube) RBcube = pm.polyCube(n="footmask_RB",w=0.13,h=0.03,d=0.2) pm.move(-0.095,-0.015,0.013) fmsel.append(RBcube) RFcube = pm.polyCube(n="footmask_RF",w=0.13,h=0.03,d=0.08) pm.move(-0.095,-0.015,0.143) fmsel.append(RFcube) fmselNew = [i for i in fmseladjust if i not in fmsel] AiUNode = pm.shadingNode("aiUtility",asShader=True) SGNode = pm.createNode("shadingEngine") pm.setAttr(AiUNode+".hardwareColor",0,1,1) pm.setAttr(AiUNode+".shadeMode",2) for i in range(0,len(fmselNew)): shapeNode = pm.listRelatives(fmselNew[i],s=True,f=True) pm.defaultNavigation(source=AiUNode,destination =shapeNode[0]+".instObjGroups[0]" ,connectToExisting=True) pm.setAttr(shapeNode[0]+".castsShadows",0) pm.setAttr(shapeNode[0]+".receiveShadows",0) pm.setAttr(shapeNode[0]+".motionBlur",0) pm.setAttr(shapeNode[0]+".primaryVisibility",0) pm.setAttr(shapeNode[0]+".smoothShading",0) pm.setAttr(shapeNode[0]+".visibleInReflections",0) pm.setAttr(shapeNode[0]+".visibleInRefractions",0) pm.setAttr(shapeNode[0]+".doubleSided",0) pm.setAttr(shapeNode[0]+".aiSelfShadows",0) pm.setAttr(shapeNode[0]+".aiOpaque",0) pm.setAttr(shapeNode[0]+".aiVisibleInDiffuse",0) pm.setAttr(shapeNode[0]+".aiVisibleInGlossy",0) for i in range(0,len(fmselNew)): pm.makeIdentity(fmselNew[i],apply=True,t=1,r=1,s=1,n=0) pm.select(fmselNew,r=1) mel.eval('DeleteHistory') pm.group(fmselNew,name=value+'_feetMask_g') pm.rename(AiUNode,value) for i in range(0,len(ctrsel)): if pm.objExists(ctrsel[i]): pm.select(ctrsel[i]) pm.parentConstraint(ctrsel[i],fmselNew[i],mo=True,weight = 1) pm.scaleConstraint(ctrsel[i],fmselNew[i],mo=True,weight = 1) pm.setAttr(fmselNew[i] + '.primaryVisibility',0) pm.setAttr(fmselNew[i] + '.castsShadows',0) pm.setAttr(fmselNew[i] + '.receiveShadows',0) pm.rename(fmselNew[i],value +"_" + fmselNew[i])
def update_colours(self, colours, amount=20): shader_name = self._shader_build(colours, amount) increment = (amount - 1) / self._gen.highest for cube in self._cubes: distance = self.pm.getAttr('{}.gen_dist'.format(cube)) * increment i = int(round(distance)) pm.defaultNavigation( source=shader_name.format(i), destination='|{c}|{c}Shape.instObjGroups[0]'.format(c=cube), connectToExisting=True) self.bounding_box(time_slider=True, draw=False)
def _visualizer_setup(self): """Add a shader to visualize the outValue and the coneAngle.""" visualize_sdr = pm.shadingNode('surfaceShader', asShader=True, n='visualize') sets = pm.sets(renderable=True, noSurfaceShader=True, empty=True, n='visualize') visualize_sdr.outColor >> sets.surfaceShader vis_ramp = pm.createNode('ramp', n='visualize') vis_ramp.setAttr('type', 1) vis_ramp.setAttr('colorEntryList[0].color', 0, 0, 0) vis_ramp.setAttr('colorEntryList[1].position', 1) vis_ramp.setAttr('colorEntryList[1].color', 0, 0, 0) vis_ramp.setAttr('colorEntryList[2].position', 0) cmds.setAttr('%s.colorEntryList[2].color' % vis_ramp, 0, 0, 0, type='double3') vis_ramp.setAttr('colorEntryList[3].color', 0, 0, 0) self.ramp.outColorR >> vis_ramp.colorEntryList[1].color.colorG rmv = pm.createNode('remapValue', n='visualize') rmv.setAttr('inputMin', -1) rmv.setAttr('inputMax', 0) rmv.setAttr('outputMin', 1) rmv.setAttr('outputMax', 0) self.ramp.outColorR >> rmv.inputValue rmv.outValue >> vis_ramp.colorEntryList[2].color.colorR (self.ramp.colorEntryList[0].position >> vis_ramp.colorEntryList[0].position) (self.ramp.colorEntryList[3].position >> vis_ramp.colorEntryList[3].position) vis_ramp.outColor >> visualize_sdr.outColor pm.defaultNavigation( source=visualize_sdr, destination=self.sphere.getShape().instObjGroups[0], connectToExisting=True)
maxCubes = float( len( existingCubes ) ) if int( maxCubes ) == 0: print "No cubes found" else: print "Assigning colours to cubes..." for i in range( int( maxCubes ) ): #Setup shader details cubeName = existingCubes[i] colourValue = py.getAttr( cubeName + ".ColourValue" ) shaderNumber = int( round( ( numberOfShaders-1 ) * colourValue, 0 ) ) shaderName = nameOfShaders + str( shaderNumber ) shaderSelect = shaderName cubeSelect = "|" + letter.lower() + "GenGroup" + "|" + letter.lower() + "Cubes" + "|" + cubeName + "|" + cubeName + "Shape.instObjGroups[0]" #Assign shader py.defaultNavigation( source = shaderSelect, destination = cubeSelect, connectToExisting = True ) #Output progress if i % iterationsColour == 0: if time() > nextTime: nextTime = time() + timeIncrement percentage = i / maxCubes print indent + str( i ) + " cubes coloured (" + str( round( 100*percentage, 2 ) ) + "%)" codeStuff.UpdateViewport() ''' validate( self, shaderColours, shaderAmount, isPerShader = True ) return shadercolours, shaderamount, shadername py.defaultNavigation( source = shaderSelect, destination = cubeSelect, connectToExisting = True ) '''