def btnCheGradClicked (self): current_languge = cfgl.configLoader()[14] SelectionData = gen_func.checkSelection() SelectedShapes = SelectionData[0] if len(SelectedShapes) > 0: CurrentShaderData = getCurrentShader(SelectedShapes) self.PreviousShadersArray = CurrentShaderData[0] self.ObjectsWithShadersArray = CurrentShaderData[1] if checkShaderIntegrity("04") == True: changeCheckerTexture ("checker_gradient", SelectedShapes) else: createCheckerMaterial("04") changeCheckerTexture ("checker_gradient", SelectedShapes) self.checkerRoutineFunctions(SelectedShapes) conclusion_text = conclusion.uvOperationConclusion (current_languge, "assign_grad_checker") self.txtbrowUVConclusion.setHtml(conclusion_text) self.showInfo("info", "Gradient checker was assigned!") else: conclusion_text = conclusion.noSelection(current_languge, "assign_grad_checker") self.txtbrowUVConclusion.setHtml(conclusion_text) self.showInfo("warn", "Cant assign checker. Please select mesh object in Object Mode.")
def btnSetTexelClicked (self): SelectionData = gen_func.checkSelection() #shapes array SelectedShapes = SelectionData[0] current_languge = cfgl.configLoader()[14] self.checkDesiredTexel() if len(SelectedShapes) > 0: print"" try: #get map res MapResValue = self.cboxTexRes.currentText() #get texel TexelValue = (str(float(self.edtSetTex.text())/100)) for i in range(len(SelectedShapes)): cmds.select(SelectedShapes[i]) #set texel maya.mel.eval('texSetTexelDensity ' + TexelValue + ' ' + MapResValue + ';') print (gen_func.shortNamer(SelectedShapes[i]) + ". Texel has been set to " + str(float(TexelValue)*100) + " px/m for map size " + MapResValue + "x" + MapResValue + "px") print "" #return selection cmds.select (SelectedShapes) uvOutsideData = gen_func.uvRangeStat(SelectedShapes) if uvOutsideData[1] != []: shapesOutside = False else: shapesOutside = True #conclusion output conclusion_text = conclusion.setTexelConclusion(current_languge, int(self.edtSetTex.text()), shapesOutside, len(SelectedShapes)) self.txtbrowTexConclusion.setHtml(conclusion_text) print "" LongText = ("The number of objects on which the texel is changed: " + str(len(SelectedShapes)) + "\n" + "Texel has been set to " + str(float(TexelValue)*100) + " px/m for map size " + MapResValue + "x" + MapResValue + "px") self.showInfo("info", LongText) except: self.setTexelWarningText() else: self.showInfo("warn", "Can't Set Texel. Please select mesh object in Object Mode.") conclusion_text = conclusion.noSelection(current_languge, "set_texel") self.txtbrowTexConclusion.setHtml(conclusion_text)
def btnMoveUVDownClicked (self): current_languge = cfgl.configLoader()[14] SelectionData = gen_func.checkSelection() SelectedShapes = SelectionData[0] if len(SelectedShapes) > 0: moveUV (SelectedShapes, "Down", 0, -1) self.showInfo("info", "UV moved Down.") else: conclusion_text = conclusion.noSelection(current_languge, "move_uv_down") self.txtbrowUVConclusion.setHtml(conclusion_text) self.showInfo("warn", "Cant assign checker. Please select mesh object in Object Mode.")
def btnScale2Clicked(self): current_languge = cfgl.configLoader()[14] SelectionData = gen_func.checkSelection() SelectedShapes = SelectionData[0] if len(SelectedShapes) > 0: scaleUV (SelectedShapes, "Up", 2, 2) self.showInfo("info", "UV scaled Up.") else: conclusion_text = conclusion.noSelection(current_languge, "scale_uv_up") self.txtbrowUVConclusion.setHtml(conclusion_text) self.showInfo("warn", "Cant assign checker. Please select mesh object in Object Mode.")
def btnCleanCheckClicked(self): SelectionData = gen_func.checkSelection() #shapes array selectedShapes = SelectionData[0] current_languge = cfgl.configLoader()[14] if len(selectedShapes) > 0: try: for i in range(len(selectedShapes)): CurrentColorSet = cmds.polyColorSet(selectedShapes[i], q=True, currentColorSet=True) if CurrentColorSet != None: cmds.polyColorSet (selectedShapes[i], delete=True ) print gen_func.shortNamer(selectedShapes[i]), "was cleaned." self.showInfo("info", "Check Texel Density results have been cleared!") self.lblInRangeInfo.setText("Previous check results have been cleared!") self.btnSelectTinyUVShell.setText("Not checked yet") self.btnSelectTinyFace.setText("Not checked yet") self.btnSelectTinyFace.setDisabled(True) self.btnSelectTinyUVShell.setDisabled(True) self.tiny_uv_arr=[] self.tiny_geo_arr=[] self.pbChekProgress.setValue(0) cmds.select( selectedShapes ) conclusion_text = conclusion.CleanCheckClicked(current_languge, True) self.txtbrowTexConclusion.setHtml(conclusion_text) except: self.showInfo("warn", "There is nothing to clean! Try to clean after checking.") conclusion_text = conclusion.CleanCheckClicked(current_languge, False) self.txtbrowTexConclusion.setHtml(conclusion_text) else: self.showInfo("warn", "Can't clean check texel density results. Please select already checked mesh object in Object Mode.") conclusion_text = conclusion.noSelection(current_languge, "clean_check") self.txtbrowTexConclusion.setHtml(conclusion_text)
def btnViewUVPressed(self): current_languge = cfgl.configLoader()[14] SelectionData = gen_func.checkSelection() SelectedShapes = SelectionData[0] #delete colorsets for i in range(len(SelectedShapes)): CurrentColorSet = cmds.polyColorSet(SelectedShapes[i], q=True, currentColorSet=True) if CurrentColorSet != None: cmds.polyColorSet (SelectedShapes[i], delete=True ) #create and delete file if len(SelectedShapes) > 0: #if pressed if self.btnViewUV.isChecked() == True: #delete shader if cmds.objExists('pt_uv_shader'): DelUVShaders() self.btnViewUV.setText("Show UV") #assign prev mat for i in range(len(self.PreviousShadersArray)): try: cmds.sets(self.ObjectsWithShadersArray[i], e=True, forceElement = self.PreviousShadersArray[i]) except: pass self.showInfo("info", "UV Snapshot was removed.") else: try: #get previous shader CurrentShaderData = getCurrentShader(SelectedShapes) self.PreviousShadersArray = CurrentShaderData[0] self.ObjectsWithShadersArray = CurrentShaderData[1] #remove old uv if exist if cmds.objExists('pt_uv_shader') == True: DelUVShaders() self.btnViewUV.setText("Show UV") #create and showe shader createUVTexture(SelectedShapes) cmds.sets(SelectedShapes, e=True, forceElement='pt_shading_group_uv') cmds.select(SelectedShapes) self.btnViewUV.setText("Hide UV") conclusion_text = conclusion.uvOperationConclusion (current_languge, "assign_uv") self.txtbrowUVConclusion.setHtml(conclusion_text) self.showInfo("info", "UV Snapshot was assigned to objects.") except: self.showInfo ("warn", "Can't create UV Snapshot.") else: conclusion_text = conclusion.noSelection(current_languge, "show_uv") self.txtbrowUVConclusion.setHtml(conclusion_text) #If nothing selected self.btnViewUV.setChecked(True) #delete shader if not selected if cmds.objExists('pt_uv_shader'): DelUVShaders() self.btnViewUV.setText("Show UV") self.showInfo ("info", "UV Snapshot was removed.") else: self.showInfo ("warn", "Please select something. Mesh object for example...")
def btnCheckTexelClicked(self): GreenBox = ("<font color='#80ff80'>" + u'\N{BLACK SQUARE}' + "</font> In-Range: ") BlueBox = (u'\N{BOX DRAWINGS LIGHT VERTICAL}' + " <font color='#80c0ff'>" + u'\N{BLACK SQUARE}' + "</font> Streched: ") RedBox = (u'\N{BOX DRAWINGS LIGHT VERTICAL}' + "<font color='#ffc0c0'>" + u'\N{BLACK SQUARE}' + "</font> Compressed: ") self.lblInfo_01.setText("") self.checkTexelValue() self.btnSelectTinyUVShell.setDisabled(True) self.btnSelectTinyUVShell.setText("Not checked yet") self.btnSelectTinyFace.setDisabled(True) self.btnSelectTinyFace.setText("Not checked yet") SelectionData = gen_func.checkSelection() #shapes array selectedShapes = SelectionData[0] current_languge = cfgl.configLoader()[14] if len(selectedShapes) > 0: try: all_sel_obj = cmds.ls ( selection=True, objectsOnly=True, long=1, shortNames=1 ) #total polygons totalpoly = cmds.polyEvaluate( face=True ) #set range from 0 to max polycount self.pbChekProgress.setRange ( 0, 100 ) self.pbChekProgress.setValue(0) #turn on vertex color for i in range(len(selectedShapes)): cmds.polyColorPerVertex (selectedShapes[i], colorDisplayOption=1 ) #get selected texture selected_texture_index = int(self.cboxTexRes.currentIndex()) print "-----------------------------------------" print " PolygonTools. Check Texle Density" print "-----------------------------------------" current_time = time.strftime("%H:%M:%S ", time.localtime()) print "Check Start at", current_time print "" #texture area selected_texture_area = resolutionSelected(selected_texture_index) #print "Selected Texture Area:", selected_texture_area #get curent texel current_texel = float(self.edtCurTexel.text()) #get curent diff DifferenceMargin = float(self.spnDiff.value()) #get current tiny tiny_polygon_area = float(self.edtTinyIt.text()) CurrentTinyUVValue = int(self.edtTinyPX.text()) print "Current Tiny UV:", CurrentTinyUVValue SelectedResolution = self.cboxTexRes.currentText() #main func CheckTexelData = CheckTexel (selectedShapes, selected_texture_index, current_texel, DifferenceMargin, tiny_polygon_area, SelectedResolution, CurrentTinyUVValue, True) #global_inrange_arr, global_streched_arr, global_compressed_arr, global_tiny_uv_arr, global_tiny_geo_arr correct=[] streched=[] compressed=[] self.tiny_uv_arr = [] self.tiny_geo_arr = [] for k in range(len(selectedShapes)): for i in range(len(CheckTexelData)): if i == 0: correct.append(len(CheckTexelData[i][k])) if i == 1: streched.append(len(CheckTexelData[i][k])) if i == 2: compressed.append(len(CheckTexelData[i][k])) if i == 3: if CheckTexelData[i][k] != []: self.tiny_uv_arr.append(CheckTexelData[i][k]) if i == 4: if CheckTexelData[i][k] != []: self.tiny_geo_arr.append(CheckTexelData[i][k]) self.pbChekProgress.setValue(100) TinyFace = False TinyUV = False if self.tiny_uv_arr != [] and len(selectedShapes) == 1: self.btnSelectTinyUVShell.setDisabled(False) self.btnSelectTinyUVShell.setText("Select " + str(len(self.tiny_uv_arr[0])) + " tiny UV Shell(s)") TinyUV = True elif self.tiny_uv_arr != []: self.btnSelectTinyUVShell.setText("Tiny UV Shells on " + str(len(self.tiny_uv_arr)) + " objects") TinyUV = True if self.tiny_geo_arr != [] and len(selectedShapes) == 1: self.btnSelectTinyFace.setDisabled(False) self.btnSelectTinyFace.setText("Select " + str(len(self.tiny_geo_arr[0])) + " tiny face(s)") TinyFace = True elif self.tiny_geo_arr != []: self.btnSelectTinyFace.setText("Tiny faces on " + str(len(self.tiny_geo_arr)) + " objects") TinyFace = True print "" LongText = ("Check texel density complete! See log for details." +"\n" + "Number of checked objects: " + str(len(selectedShapes))) self.showInfo("info", LongText) print "" self.lblInRangeInfo.setText(GreenBox + str(sum(correct)) + RedBox + str(sum(streched)) + BlueBox + str(sum(compressed))) print ("Correct: " + str(sum(correct)) + " | Streched: " + str(sum(streched)) + " | Compressed: " + str(sum(compressed))) print "" print "Objects with Tiny geometry area:", len(self.tiny_geo_arr) print "Objects with Tiny UV Shells:", len(self.tiny_uv_arr) print "" current_time = time.strftime("%H:%M:%S ", time.localtime()) print "Check complete at", current_time print "-----------------------------------------" conclusion_text = conclusion.checkTexelConclusion(current_languge, DifferenceMargin, correct, streched, compressed, TinyUV, TinyFace) self.txtbrowTexConclusion.setHtml(conclusion_text) cmds.select( selectedShapes ) except: self.showInfo("warn", "Error. Can't Check Texel. Please select mesh object in Object Mode.") self.pbChekProgress.setValue(0) conclusion_text = conclusion.noSelection(current_languge, "set_texel") self.txtbrowTexConclusion.setHtml(conclusion_text) else: self.showInfo("warn", "Can't Check Texel. Please select mesh object in Object Mode.") conclusion_text = conclusion.noSelection(current_languge, "check_texel") self.txtbrowTexConclusion.setHtml(conclusion_text)