示例#1
0
def arsenal_materialIDset(selection = list()):
    if len(selection) == 0 or selection is None:
        OpenMaya.MGlobal.displayError('[Arsenal ToolBox] No material(s) node(s) or shading(s) engine node(s) selected or found.')
        return 
    for mySelect in selection:
        if pm.objectType(mySelect) in ('particleCloud', 'shaderGlow', 'hairTubeShader', 'layeredShader', 'oceanShader', 'useBackground'):
            print '[Arsenal ToolBox] ' + mySelect.name() + ' must not have materialID.'
            continue
        if not pm.attributeQuery('vrayColorId', n=mySelect.name(), ex=True) or not pm.attributeQuery('vrayMaterialId', n=mySelect.name(), ex=True):
            print '[Arsenal ToolBox] Material ID attributes of ' + mySelect.name() + " doen't exist."
            continue
        if mySelect.vrayColorId.isLocked() or mySelect.vrayMaterialId.isLocked():
            print '[Arsenal ToolBox] Material ID attributes of ' + mySelect.name() + ' is locked.'
            continue
        (multimatteID, rgb,) = arsenal_generateNumberFromString(string=mySelect.name())
        if multimatteID is None:
            OpenMaya.MGlobal.displayError('[Arsenal ToolBox] Can set ID.')
            return 
        if not mySelect.vrayColorId.isLocked():
            mySelect.vrayColorId.set(rgb[0], rgb[1], rgb[2], type='double3')
            print '[Arsenal ToolBox] vrayColorId attributes of ' + mySelect.name() + ' setted.'
        else:
            print '[Arsenal ToolBox] vrayColorId attributes of ' + mySelect.name() + ' is locked. Skipped.'
        if not mySelect.vrayMaterialId.isLocked():
            mySelect.vrayMaterialId.set(multimatteID)
            print '[Arsenal ToolBox] vrayMaterialId attributes of ' + mySelect.name() + ' setted.'
        else:
            print '[Arsenal ToolBox] vrayMaterialId attributes of ' + mySelect.name() + ' is locked. Skipped.'
示例#2
0
 def get_non_linear_type(self, **kwargs):
     non_linear_node = kwargs.get("non_linear_node", None)
     node_type = self.nonLinear_dict["other"]
     for key in self.nonLinear_dict.keys():
         if pm.attributeQuery(key, node=non_linear_node, exists=True):
             node_type = self.nonLinear_dict[key]
     return node_type
示例#3
0
def arsenal_materialIDdelete(selection = list()):
    if len(selection) == 0 or selection is None:
        OpenMaya.MGlobal.displayError('[Arsenal ToolBox] No material(s) node(s) or shading(s) engine node(s) selected or found.')
        return 
    for mySelect in selection:
        if pm.objectType(mySelect) in ('particleCloud', 'shaderGlow', 'hairTubeShader', 'layeredShader', 'oceanShader', 'useBackground'):
            print '[Arsenal ToolBox] ' + mySelect.name() + ' must not have materialID.'
            continue
        if not pm.attributeQuery('vrayColorId', n=mySelect.name(), ex=True) or not pm.attributeQuery('vrayMaterialId', n=mySelect.name(), ex=True):
            print '[Arsenal ToolBox] Material ID attributes of ' + mySelect.name() + " doen't exist."
            continue
        if mySelect.vrayColorId.isLocked() or mySelect.vrayMaterialId.isLocked():
            print '[Arsenal ToolBox] Material ID attributes of ' + mySelect.name() + ' is locked.'
            continue
        pm.mel.eval('vray addAttributesFromGroup ' + mySelect.name() + ' vray_material_id 0;')
        print '[Arsenal ToolBox] Remove material ID attributes to ' + mySelect.name()
示例#4
0
 def initializeSet(self, *args):
     self.vraySettings = pm.PyNode('vraySettings')
     if pm.attributeQuery('deeXVrayFastOptimized', n=self.vraySettings.name(), ex=True):
         self.deeXVrayFastOptimized = True
         self.vraySettings.samplerType.set(1)
         if not pm.attributeQuery('deeXVrayFastLastQuality', n=self.vraySettings.name(), ex=True):
             self.deeXVrayFastLastQuality = 50
             locked = False
             if pm.lockNode(self.vraySettings.name(), query=True, lock=True)[0]:
                 locked = True
                 pm.lockNode(self.vraySettings.name(), lock=False)
             pm.addAttr(self.vraySettings.name(), ln='deeXVrayFastLastQuality', at='long')
             if locked:
                 pm.lockNode(self.vraySettings.name(), lock=True)
             self.vraySettings.deeXVrayFastLastQuality.set(self.deeXVrayFastLastQuality)
         else:
             self.deeXVrayFastLastQuality = self.vraySettings.deeXVrayFastLastQuality.get()
示例#5
0
    def backSetting(self, *args):
        if pm.attributeQuery('deeXVrayFastActualSettings', n='vraySettings', ex=True):
            if pm.objExists('deeXVrayFastExpression'):
                pm.delete('deeXVrayFastExpression')
                print '[Arsenal Quality] OdeeXVrayFastExpression deleted.'
            lines = pm.getAttr('vraySettings.deeXVrayFastActualSettings')
            dico = eval(lines)
            for myAttr in dico:
                value = dico[myAttr]
                if type(dico[myAttr]) == list:
                    value = dico[myAttr][0]
                if value:
                    try:
                        locked = 0
                        if pm.getAttr('vraySettings.' + myAttr, lock=True) == 1:
                            pm.setAttr('vraySettings.' + myAttr, lock=False)
                            locked = 1
                        pm.setAttr('vraySettings.' + myAttr, value)
                        if locked == 1:
                            pm.setAttr('vraySettings.' + myAttr, lock=True)
                    except:
                        print '[Arsenal Quality] ' + myAttr + ' value can not be setted.'

            locked = False
            if pm.lockNode('vraySettings', query=True, lock=True)[0]:
                locked = True
                pm.lockNode('vraySettings', lock=False)
            attToDelete = ['deeXVrayFastLastQuality',
             'deeXVrayFastOptimized',
             'deeXVrayFastActualSettings',
             'deeXVrayFastoptimizationChooserSettings',
             'deeXVrayFastLastTypePreset',
             'deeXVrayFastLastPresetPreComp']
            for myAttr in attToDelete:
                if pm.attributeQuery(myAttr, n='vraySettings', ex=True):
                    pm.deleteAttr('vraySettings.' + myAttr)

            if locked:
                pm.lockNode('vraySettings', lock=True)
            print '[Arsenal Quality] Original settings applied.'
        else:
            print '[Arsenal Quality] deeXVrayFastActualSettings attribute not found'
示例#6
0
    def optimizeLights(self):
        allLights = pm.ls(type=['VRayLightIESShape',
         'VRayLightRectShape',
         'VRayLightSphereShape',
         'VRayLightDomeShape',
         'directionalLight',
         'pointLight',
         'spotLight',
         'areaLight'])
        for myLight in allLights:
            if pm.attributeQuery('subdivs', n=myLight, ex=True):
                if not myLight.subdivs.get(lock=True):
                    if myLight.nodeType() == 'VRayLightDomeShape':
                        myLight.subdivs.set(50)
                    else:
                        myLight.subdivs.set(5)
            if pm.attributeQuery('shadowRays', n=myLight, ex=True):
                if not myLight.shadowRays.get(lock=True):
                    myLight.shadowRays.set(5)

        print '[Arsenal Quality] All lights optimized.'
示例#7
0
    def _genTypeGUI(self, attrname, typ, val):
        if pm.attributeQuery(attrname, node=self.obj.node, h=True): return

        pm.text(l='Attribute')
        if typ == cr_types.url:
            pm.attrControlGrp(attribute=self.obj.node.name()+'.'+attrname)
            pm.button(label="Find", w=128, c=
                    pm.Callback(gui.setAttrFromFileDialog, self.obj.node,
                        attrname))
        else:
            pm.attrControlGrp(attribute=self.obj.node.name()+'.'+attrname)
            pm.button(label="Ignore", w=128, en=False)
示例#8
0
def arsenal_objectIDremove(selection = list()):
    if len(selection) == 0 or selection is None:
        OpenMaya.MGlobal.displayError('[Arsenal ToolBox] No mesh(s) selected or found. Select mesh(s), not transform(s).')
        return 
    for mySelect in selection:
        if not pm.attributeQuery('vrayObjectID', n=mySelect.name(), ex=True):
            print '[Arsenal ToolBox] Object ID attributes of ' + mySelect.name() + " doen't exist."
            continue
        if mySelect.vrayObjectID.isLocked():
            print '[Arsenal ToolBox] Object ID attributes of ' + mySelect.name() + ' is locked.'
            continue
        pm.mel.eval('vray addAttributesFromGroup ' + mySelect.name() + ' vray_objectID 0;')
        print '[Arsenal ToolBox] Remove object ID attributes to ' + mySelect.name()
示例#9
0
    def saveSetting(self, *args):
        dicoAttr = {}
        for myAttr in pm.listAttr(self.vraySettings.name()):
            try:
                dicoAttr[myAttr] = pm.getAttr('vraySettings.' + myAttr)
            except:
                OpenMaya.MGlobal.displayInfo('[Arsenal Quality] ' + myAttr + ' value can not be saved or have not value.')

        if not pm.attributeQuery('deeXVrayFastActualSettings', n=self.vraySettings.name(), ex=True):
            locked = False
            if pm.lockNode(self.vraySettings.name(), query=True, lock=True)[0]:
                locked = True
                pm.lockNode(self.vraySettings.name(), lock=False)
            pm.addAttr(self.vraySettings.name(), ln='deeXVrayFastActualSettings', dt='string')
            if locked:
                pm.lockNode(self.vraySettings.name(), lock=True)
        self.vraySettings.deeXVrayFastActualSettings.set(str(dicoAttr))
示例#10
0
def arsenal_objectIDset(selection = list()):
    if len(selection) == 0 or selection is None:
        OpenMaya.MGlobal.displayError('[Arsenal ToolBox] No mesh(s) selected or found. Select mesh(s), not transform(s).')
        return 
    for mySelect in selection:
        if not pm.attributeQuery('vrayObjectID', n=mySelect.name(), ex=True):
            print '[Arsenal ToolBox] Object ID attributes of ' + mySelect.name() + " doen't exist."
            continue
        if mySelect.vrayObjectID.isLocked():
            print '[Arsenal ToolBox] Object ID attributes of ' + mySelect.name() + ' is locked.'
            continue
        objectID = arsenal_generateNumberFromString(string=mySelect.name())
        if objectID is None:
            OpenMaya.MGlobal.displayError('[Arsenal ToolBox] Can set ID.')
            return 
        mySelect.vrayObjectID.set(objectID[0])
        print '[Arsenal ToolBox] Object ID attributes of ' + mySelect.name() + ' setted.'
示例#11
0
 def get_non_linear_type(self, **kwargs):
     """
     return the type of nonLinear node based on attributes of the nodes
     """
     non_linear_node = kwargs.get("non_linear_node", None)
     self.nonLinear_dict = {
         "endFlareX": "flare",
         "maxRadius": "wave",
         "curvature": "bend",
         "endSmoothness": "squash",
         "endAngle": "twist",
         "other": "sine"
     }
     node_type = self.nonLinear_dict["other"]
     for key in self.nonLinear_dict.keys():
         if pm.attributeQuery(key, node=non_linear_node, exists=True):
             node_type = self.nonLinear_dict[key]
     return node_type
示例#12
0
 def optimize(self):
     self.deeXVrayFastOptimized = True
     locked = False
     if pm.lockNode(self.vraySettings.name(), query=True, lock=True)[0]:
         locked = True
         pm.lockNode(self.vraySettings.name(), lock=False)
     if not pm.attributeQuery('deeXVrayFastOptimized', n=self.vraySettings.name(), ex=True):
         pm.addAttr(self.vraySettings.name(), ln='deeXVrayFastOptimized', at='bool')
         self.vraySettings.deeXVrayFastOptimized.set(1)
         pm.addAttr(self.vraySettings.name(), ln='deeXVrayFastLastQuality', at='long')
         self.vraySettings.deeXVrayFastLastQuality.set(50)
         pm.addAttr('vraySettings', ln='deeXVrayFastLastTypePreset', dt='string')
         self.vraySettings.deeXVrayFastLastTypePreset.set('deeX_interior')
         pm.addAttr('vraySettings', ln='deeXVrayFastLastPresetPreComp', dt='string')
         self.vraySettings.deeXVrayFastLastPresetPreComp.set('deeX_basic')
         pm.addAttr('vraySettings', ln='deeXVrayFastoptimizationChooserSettings', dt='string')
         self.vraySettings.deeXVrayFastoptimizationChooserSettings.set("{'OptimizationChooserGlobalOptionInt': [False, 0], 'OptimizationChooserImageSamplerInt': [False, 0], 'OptimizationChooserDMCSamplerInt': [False, 0], 'OptimizationChooserIrradianceMapInt': [False, 0], 'OptimizationChooserLightCacheInt': [False, 0], 'OptimizationChooserSystemInt': [False, 0]}")
     if locked:
         pm.lockNode(self.vraySettings.name(), lock=True)
     self.initAttributes()
     self.refresh()
示例#13
0
    def create_switching(self):
        # Create setDrivenKey on layered texture
        sel_switch = self.text_lst.getSelectItem()[0]
        enum_attr_list = pm.attributeQuery(sel_switch,
                                           node=self.ctr,
                                           listEnum=True)
        enum_attr_list = enum_attr_list[0].split(":")
        self.lyr_tex_sel = pm.ls(selection=True)
        if not self.lyr_tex_sel:
            pm.displayError("Please select layered texture node")
            return None
        self.lyr_tex_sel = self.lyr_tex_sel[0]
        if not isinstance(self.lyr_tex_sel, pm.LayeredTexture):
            pm.displayError("Please select layered texture node type")
            return None

        lyr_attr_lst = self.get_tex_layer_attrs()

        if not lyr_attr_lst:
            return None

        if not len(enum_attr_list) == len(lyr_attr_lst):
            pm.displayError("Switch and Layers number mismatch")
            return None

        driver_attr = self.ctr + "." + sel_switch
        for driver_index in range(len(enum_attr_list)):
            for driven_index in range(len(lyr_attr_lst)):
                driven_attr = self.lyr_tex_sel + "." + lyr_attr_lst[
                    driven_index]
                driven_val = 0
                if driver_index == driven_index:
                    driven_val = 1
                pm.setDrivenKeyframe(driven_attr,
                                     currentDriver=driver_attr,
                                     driverValue=driver_index,
                                     value=driven_val)

        return None
示例#14
0
    def refresh(self):
        if not self.deeXVrayFastOptimized:
            return 
        lines = self.vraySettings.deeXVrayFastoptimizationChooserSettings.get()
        dicoOptimizationChooser = eval(lines)
        valueAs = float(self.vraySettings.width.get() * 1.0 / (self.vraySettings.height.get() * 1.0))
        pm.mel.eval('vrayUpdateAspectRatio;')
        self.vraySettings.aspectRatio.set(valueAs)
        pm.mel.eval('vrayChangeResolution();')
        resolution = self.vraySettings.width.get() * self.vraySettings.height.get()
        realQuality = self.deeXVrayFastLastQuality
        enable = True
        if dicoOptimizationChooser:
            if dicoOptimizationChooser['OptimizationChooserGlobalOptionInt'][0]:
                realQuality += dicoOptimizationChooser['OptimizationChooserGlobalOptionInt'][1]
        if enable:
            multiplier = (float(self.vraySettings_globopt_mtl_maxDepthH) - float(self.vraySettings_globopt_mtl_maxDepthM)) / 50
            minValue = float(self.vraySettings_globopt_mtl_maxDepthM) - multiplier * 50
            if pm.attributeQuery('globopt_mtl_limitDepth', n='vraySettings', ex=True):
                if not self.vraySettings.globopt_mtl_limitDepth.get(lock=True):
                    self.vraySettings.globopt_mtl_limitDepth.set(1)
                value = minValue + realQuality * multiplier
                if value <= 2.0:
                    value = 2.0
                if not self.vraySettings.globopt_mtl_maxDepth.get(lock=True):
                    self.vraySettings.globopt_mtl_maxDepth.set(value)
        realQuality = self.deeXVrayFastLastQuality
        enable = True
        if dicoOptimizationChooser:
            if dicoOptimizationChooser['OptimizationChooserImageSamplerInt'][0]:
                realQuality += dicoOptimizationChooser['OptimizationChooserImageSamplerInt'][1]
        if enable:
            multiplier = (float(self.vraySettings_dmcMaxSubdivsH) - float(self.vraySettings_dmcMaxSubdivsM)) / 50
            minValue = float(self.vraySettings_dmcMaxSubdivsM) - multiplier * 50
            value = minValue + realQuality * multiplier
            if value <= 2:
                value = 2.0
            n = math.log(307200.0 / resolution) / math.log(4.0) * -1
            subdi = math.ceil(value / float(self.multiplicator_vraySettings_dmcMaxSubdivs) ** n)
            if pm.attributeQuery('dmcMaxSubdivs', n='vraySettings', ex=True):
                if not self.vraySettings.dmcMaxSubdivs.get(lock=True):
                    self.vraySettings.dmcMaxSubdivs.set(subdi)
            multiplier = (float(self.vraySettings_dmcMinSubdivsH) - float(self.vraySettings_dmcMinSubdivsM)) / 50
            minValue = float(self.vraySettings_dmcMinSubdivsM) - multiplier * 50
            value = minValue + realQuality * multiplier
            if value <= 1:
                value = 1
            if pm.attributeQuery('dmcMinSubdivs', n='vraySettings', ex=True):
                if not self.vraySettings.dmcMinSubdivs.get(lock=True):
                    self.vraySettings.dmcMinSubdivs.set(value)
            multiplier = (float(self.vraySettings_dmcThresholdM) - float(self.vraySettings_dmcThresholdH)) / 50
            minValue = float(self.vraySettings_dmcThresholdM) + multiplier * 50
            value = minValue - realQuality * multiplier
            if value <= 0.001:
                value = 0.001
            if pm.attributeQuery('dmcThreshold', n='vraySettings', ex=True):
                if not self.vraySettings.dmcThreshold.get(lock=True):
                    self.vraySettings.dmcThreshold.set(value)
        realQuality = self.deeXVrayFastLastQuality
        enable = True
        if dicoOptimizationChooser:
            if dicoOptimizationChooser['OptimizationChooserIrradianceMapInt'][0]:
                realQuality += dicoOptimizationChooser['OptimizationChooserIrradianceMapInt'][1]
        if enable:
            multiplier = (float(self.vraySettings_imap_minRateH) - float(self.vraySettings_imap_minRateM)) / 50
            minValue = float(self.vraySettings_imap_minRateM) - multiplier * 50
            value = minValue + realQuality * multiplier
            n = math.log(307200.0 / resolution) / math.log(4.0) * -1
            subdi = round(value + float(self.multiplicator_vraySettings_imap_minRate) * n)
            if pm.attributeQuery('imap_minRate', n='vraySettings', ex=True):
                if not self.vraySettings.imap_minRate.get(lock=True):
                    self.vraySettings.imap_minRate.set(subdi)
            multiplier = (float(self.vraySettings_imap_maxRateH) - float(self.vraySettings_imap_maxRateM)) / 50
            minValue = float(self.vraySettings_imap_maxRateM) - multiplier * 50
            value = minValue + realQuality * multiplier
            if value >= -1.0:
                value = -1.0
            n = math.log(307200.0 / resolution) / math.log(4.0) * -1
            subdi = round(value + float(self.multiplicator_vraySettings_imap_maxRate) * n)
            if pm.attributeQuery('imap_maxRate', n='vraySettings', ex=True):
                if not self.vraySettings.imap_maxRate.get(lock=True):
                    self.vraySettings.imap_maxRate.set(subdi)
            multiplier = (float(self.vraySettings_imap_colorThresholdM) - float(self.vraySettings_imap_colorThresholdH)) / 50
            minValue = float(self.vraySettings_imap_colorThresholdM) + multiplier * 50
            value = minValue - realQuality * multiplier
            if value <= 0.001:
                value = 0.001
            if pm.attributeQuery('imap_colorThreshold', n='vraySettings', ex=True):
                if not self.vraySettings.imap_colorThreshold.get(lock=True):
                    self.vraySettings.imap_colorThreshold.set(value)
            multiplier = (float(self.vraySettings_imap_normalThresholdM) - float(self.vraySettings_imap_normalThresholdH)) / 50
            minValue = float(self.vraySettings_imap_normalThresholdM) + multiplier * 50
            value = minValue - realQuality * multiplier
            if value <= 0.001:
                value = 0.001
            if pm.attributeQuery('imap_normalThreshold', n='vraySettings', ex=True):
                if not self.vraySettings.imap_normalThreshold.get(lock=True):
                    self.vraySettings.imap_normalThreshold.set(value)
            multiplier = (float(self.vraySettings_imap_distanceThresholdH) - float(self.vraySettings_imap_distanceThresholdM)) / 50
            minValue = float(self.vraySettings_imap_distanceThresholdM) - multiplier * 50
            value = minValue + multiplier * realQuality
            if value <= 0:
                value = 0
            if pm.attributeQuery('imap_distanceThreshold', n='vraySettings', ex=True):
                if not self.vraySettings.imap_distanceThreshold.get(lock=True):
                    self.vraySettings.imap_distanceThreshold.set(value)
            multiplier = (float(self.vraySettings_imap_subdivsM) - float(self.vraySettings_imap_subdivsH)) / 50
            minValue = float(self.vraySettings_imap_subdivsM) + multiplier * 50
            value = minValue - realQuality * multiplier
            if value <= 1:
                value = 1
            if pm.attributeQuery('imap_subdivs', n='vraySettings', ex=True):
                if not self.vraySettings.imap_subdivs.get(lock=True):
                    self.vraySettings.imap_subdivs.set(value)
            multiplier = (float(self.vraySettings_imap_interpSamplesM) - float(self.vraySettings_imap_interpSamplesH)) / 50
            minValue = float(self.vraySettings_imap_interpSamplesM) + multiplier * 50
            value = minValue - realQuality * multiplier
            if value <= 1:
                value = 1
            if pm.attributeQuery('imap_interpSamples', n='vraySettings', ex=True):
                if not self.vraySettings.imap_interpSamples.get(lock=True):
                    self.vraySettings.imap_interpSamples.set(value)
            multiplier = (float(eval(str(self.vraySettings_imap_detailRadiusH))) - float(self.vraySettings_imap_detailRadiusM)) / 50
            minValue = float(self.vraySettings_imap_detailRadiusM) - multiplier * 50
            value = minValue + realQuality * multiplier
            if value <= 1:
                value = 1
            n = math.log(307200.0 / resolution) / math.log(4.0) * -1
            radius = value * float(self.multiplicator_vraySettings_imap_detailRadius) ** n
            if pm.attributeQuery('imap_detailRadius', n='vraySettings', ex=True):
                if not self.vraySettings.imap_detailRadius.get(lock=True):
                    self.vraySettings.imap_detailRadius.set(radius)
            multiplier = (float(self.vraySettings_imap_detailSubdivsMultH) - float(self.vraySettings_imap_detailSubdivsMultM)) / 50
            minValue = float(self.vraySettings_imap_detailSubdivsMultM) - multiplier * 50
            value = minValue + realQuality * multiplier
            if value <= 0.001:
                value = 0.001
            if pm.attributeQuery('imap_detailSubdivsMult', n='vraySettings', ex=True):
                if not self.vraySettings.imap_detailSubdivsMult.get(lock=True):
                    self.vraySettings.imap_detailSubdivsMult.set(value)
        realQuality = self.deeXVrayFastLastQuality
        enable = True
        if dicoOptimizationChooser:
            if dicoOptimizationChooser['OptimizationChooserLightCacheInt'][0]:
                realQuality += dicoOptimizationChooser['OptimizationChooserLightCacheInt'][1]
        if enable:
            multiplier = (float(self.vraySettings_subdivsH) - float(self.vraySettings_subdivsM)) / 50
            minValue = float(self.vraySettings_subdivsM) - multiplier * 50
            value = minValue + realQuality * multiplier
            if value <= 388:
                value = 388
            if pm.attributeQuery('subdivs', n='vraySettings', ex=True):
                if not self.vraySettings.subdivs.get(lock=True):
                    self.vraySettings.subdivs.set(value)
            multiplier = (float(self.vraySettings_sampleSizeM) - float(self.vraySettings_sampleSizeH)) / 50
            minValue = float(self.vraySettings_sampleSizeM) + multiplier * 50
            value = minValue - realQuality * multiplier
            if value >= 0.02:
                value = 0.02
            if value <= 0.001:
                value = 0.001
            if pm.attributeQuery('sampleSize', n='vraySettings', ex=True):
                if not self.vraySettings.sampleSize.get(lock=True):
                    self.vraySettings.sampleSize.set(value)
            multiplier = (float(self.vraySettings_prefilterSamplesH) - float(self.vraySettings_prefilterSamplesM)) / 50
            minValue = float(self.vraySettings_prefilterSamplesM) - multiplier * 50
            value = minValue + realQuality * multiplier
            if value <= 11:
                value = 11
            if pm.attributeQuery('prefilter', n='vraySettings', ex=True):
                if not self.vraySettings.prefilter.get(lock=True):
                    self.vraySettings.prefilter.set(1)
            if pm.attributeQuery('prefilterSamples', n='vraySettings', ex=True):
                if not self.vraySettings.prefilterSamples.get(lock=True):
                    self.vraySettings.prefilterSamples.set(value)
            if pm.attributeQuery('useForGlossy', n='vraySettings', ex=True):
                if not self.vraySettings.useForGlossy.get(lock=True):
                    self.vraySettings.useForGlossy.set(1)
            if pm.attributeQuery('useRetraceThreshold', n='vraySettings', ex=True):
                if not self.vraySettings.useRetraceThreshold.get(lock=True):
                    self.vraySettings.useRetraceThreshold.set(1)
            multiplier = (float(self.vraySettings_filterSamplesH) - float(self.vraySettings_filterSamplesM)) / 50
            minValue = float(self.vraySettings_filterSamplesM) - multiplier * 50
            value = minValue + realQuality * multiplier
            if value <= 3:
                value = 3
            if pm.attributeQuery('filterSamples', n='vraySettings', ex=True):
                if not self.vraySettings.filterSamples.get(lock=True):
                    self.vraySettings.filterSamples.set(value)
            line = 'string $core[] = `hardware -npr`;\nvraySettings.numPasses = $core[0];'
            if not pm.objExists('deeXVrayFastExpression'):
                pm.expression(n='deeXVrayFastExpression', s=line)
            else:
                actualExpression = pm.expression('deeXVrayFastExpression', s=True, query=True)
                if line not in actualExpression:
                    pm.expression('deeXVrayFastExpression', edit=True, s=actualExpression + '\n' + line)
        else:
            line = 'string $core[] = `hardware -npr`;\nvraySettings.numPasses = $core[0];'
            if pm.objExists('deeXVrayFastExpression'):
                actualExpression = pm.expression('deeXVrayFastExpression', s=True, query=True)
                if line in actualExpression:
                    pm.expression('deeXVrayFastExpression', edit=True, s=actualExpression.replace(line, ''))
        realQuality = self.deeXVrayFastLastQuality
        enable = True
        if dicoOptimizationChooser:
            if dicoOptimizationChooser['OptimizationChooserDMCSamplerInt'][0]:
                realQuality += dicoOptimizationChooser['OptimizationChooserDMCSamplerInt'][1]
        if enable:
            multiplier = (float(self.vraySettings_dmcs_adaptiveAmountM) - float(self.vraySettings_dmcs_adaptiveAmountH)) / 50
            minValue = float(self.vraySettings_dmcs_adaptiveAmountM) + multiplier * 50
            value = minValue - realQuality * multiplier
            if value >= 1.0:
                value = 1.0
            if value <= 0.001:
                value = 0.001
            if pm.attributeQuery('dmcs_adaptiveAmount', n='vraySettings', ex=True):
                if not self.vraySettings.dmcs_adaptiveAmount.get(lock=True):
                    self.vraySettings.dmcs_adaptiveAmount.set(value)
            multiplier = (float(self.vraySettings_dmcs_adaptiveThresholdM) - float(self.vraySettings_dmcs_adaptiveThresholdH)) / 50
            minValue = float(self.vraySettings_dmcs_adaptiveThresholdM) + multiplier * 50
            value = minValue - realQuality * multiplier
            if value <= 0.001:
                value = 0.001
            if pm.attributeQuery('dmcs_adaptiveThreshold', n='vraySettings', ex=True):
                if not self.vraySettings.dmcs_adaptiveThreshold.get(lock=True):
                    self.vraySettings.dmcs_adaptiveThreshold.set(value)
            multiplier = (float(self.vraySettings_dmcs_adaptiveMinSamplesH) - float(self.vraySettings_dmcs_adaptiveMinSamplesM)) / 50
            minValue = float(self.vraySettings_dmcs_adaptiveMinSamplesM) - multiplier * 50
            value = minValue + realQuality * multiplier
            if value <= 8.0:
                value = 8.0
            if pm.attributeQuery('dmcs_adaptiveMinSamples', n='vraySettings', ex=True):
                if not self.vraySettings.dmcs_adaptiveMinSamples.get(lock=True):
                    self.vraySettings.dmcs_adaptiveMinSamples.set(value)
            multiplier = (float(self.vraySettings_dmcs_subdivsMultH) - float(self.vraySettings_dmcs_subdivsMultM)) / 50
            minValue = float(self.vraySettings_dmcs_subdivsMultM) - multiplier * 50
            value = minValue + realQuality * multiplier
            if value <= 0.5:
                value = 0.5
            if pm.attributeQuery('dmcs_subdivsMult', n='vraySettings', ex=True):
                if not self.vraySettings.dmcs_subdivsMult.get(lock=True):
                    self.vraySettings.dmcs_subdivsMult.set(value)
        realQuality = self.deeXVrayFastLastQuality
        enable = True
        if dicoOptimizationChooser:
            if dicoOptimizationChooser['OptimizationChooserSystemInt'][0]:
                realQuality += dicoOptimizationChooser['OptimizationChooserSystemInt'][1]
        if enable:
            if pm.attributeQuery('ddisplac_maxSubdivs', n='vraySettings', ex=True):
                if not self.vraySettings.ddisplac_maxSubdivs.get(lock=True):
                    self.vraySettings.ddisplac_maxSubdivs.set(23)
            if pm.attributeQuery('sys_regsgen_xylocked', n='vraySettings', ex=True):
                if not self.vraySettings.sys_regsgen_xylocked.get(lock=True):
                    self.vraySettings.sys_regsgen_xylocked.set(0)
            core = int(pm.hardware(npr=True)[0])
            count = 0
            value = 60
            for bucketSize in [self.vraySettings.width.get(), self.vraySettings.height.get()]:
                finalValue = 0
                lastValue = 80
                for i in range(40, 80):
                    if bucketSize % i <= lastValue:
                        lastValue = bucketSize % i
                        if lastValue == 0:
                            finalValue = i
                        else:
                            finalValue = i + 1

                if count == 0:
                    if self.vraySettings.width.get() <= 40 * core:
                        value = math.ceil(self.vraySettings.width.get() / int(core))
                        if value <= 1:
                            value = 1
                        if pm.attributeQuery('sys_regsgen_xc', n='vraySettings', ex=True):
                            if not self.vraySettings.sys_regsgen_xc.get(lock=True):
                                self.vraySettings.sys_regsgen_xc.set(value)
                    else:
                        value = finalValue
                        if value <= 1:
                            value = 1
                        if pm.attributeQuery('sys_regsgen_xc', n='vraySettings', ex=True):
                            if not self.vraySettings.sys_regsgen_xc.get(lock=True):
                                self.vraySettings.sys_regsgen_xc.set(value)
                elif self.vraySettings.height.get() <= 40 * core:
                    value = math.ceil(self.vraySettings.height.get() / int(core))
                    if value <= 1:
                        value = 1
                    if pm.attributeQuery('sys_regsgen_yc', n='vraySettings', ex=True):
                        if not self.vraySettings.sys_regsgen_yc.get(lock=True):
                            self.vraySettings.sys_regsgen_yc.set(value)
                else:
                    value = finalValue
                    if value <= 1:
                        value = 1
                    if pm.attributeQuery('sys_regsgen_yc', n='vraySettings', ex=True):
                        if not self.vraySettings.sys_regsgen_yc.get(lock=True):
                            self.vraySettings.sys_regsgen_yc.set(value)
                count += 1

            if pm.attributeQuery('sys_regsgen_seqtype', n='vraySettings', ex=True):
                if not self.vraySettings.sys_regsgen_seqtype.get(lock=True):
                    self.vraySettings.sys_regsgen_seqtype.set(3)
            line = 'python("import maya.cmds as cmds\\nvalue = cmds.memory(phy=True, megaByte=True)\\nif isinstance( value, int ):\\n\\tmemory = float(value)\\nelse:\\n\\tmemory = float(value[0])");\nfloat $memory = `python "memory"`;\nvraySettings.sys_rayc_dynMemLimit = $memory - 1500;'
            if not pm.objExists('deeXVrayFastExpression'):
                pm.expression(n='deeXVrayFastExpression', s=line)
            else:
                actualExpression = pm.expression('deeXVrayFastExpression', s=True, query=True)
                if line not in actualExpression:
                    pm.expression('deeXVrayFastExpression', edit=True, s=actualExpression + '\n' + line)
        else:
            line = 'python("import maya.cmds as cmds\\nvalue = cmds.memory(phy=True, megaByte=True)\\nif isinstance( value, int ):\\n\\tmemory = float(value)\\nelse:\\n\\tmemory = float(value[0])");\nfloat $memory = `python "memory"`;\nvraySettings.sys_rayc_dynMemLimit = $memory - 1500;'
            if pm.objExists('deeXVrayFastExpression'):
                actualExpression = pm.expression('deeXVrayFastExpression', s=True, query=True)
                if line in actualExpression:
                    pm.expression('deeXVrayFastExpression', edit=True, s=actualExpression.replace(line, ''))
示例#15
0
    def initAttributes(self):
        if not pm.attributeQuery('deeXVrayFastOptimized', n=self.vraySettings.name(), ex=True):
            self.deeXVrayFastOptimized = False
            return 
        self.deeXVrayFastLastQuality = self.vraySettings.deeXVrayFastLastQuality.get()
        self.deeXVrayFastLastTypePreset = self.vraySettings.deeXVrayFastLastTypePreset.get()
        self.deeXVrayFastLastPresetPreComp = self.vraySettings.deeXVrayFastLastPresetPreComp.get()
        self.deeXVrayFastoptimizationChooserSettings = self.vraySettings.deeXVrayFastoptimizationChooserSettings.get()
        (dico, dicoMultiplicator, commentString,) = self.presetTypeInitGetValue(self.deeXVrayFastLastTypePreset)
        for myAttr in dico:
            if myAttr == 'vraySettings.globopt_mtl_maxDepth':
                self.vraySettings_globopt_mtl_maxDepthM = dico[myAttr][0]
                self.vraySettings_globopt_mtl_maxDepthH = dico[myAttr][1]
            if myAttr == 'vraySettings.dmcMaxSubdivs':
                self.vraySettings_dmcMaxSubdivsM = dico[myAttr][0]
                self.vraySettings_dmcMaxSubdivsH = dico[myAttr][1]
            if myAttr == 'vraySettings.dmcMinSubdivs':
                self.vraySettings_dmcMinSubdivsM = dico[myAttr][0]
                self.vraySettings_dmcMinSubdivsH = dico[myAttr][1]
            if myAttr == 'vraySettings.dmcThreshold':
                self.vraySettings_dmcThresholdM = dico[myAttr][0]
                self.vraySettings_dmcThresholdH = dico[myAttr][1]
            if myAttr == 'vraySettings.imap_minRate':
                self.vraySettings_imap_minRateM = dico[myAttr][0]
                self.vraySettings_imap_minRateH = dico[myAttr][1]
            if myAttr == 'vraySettings.imap_maxRate':
                self.vraySettings_imap_maxRateM = dico[myAttr][0]
                self.vraySettings_imap_maxRateH = dico[myAttr][1]
            if myAttr == 'vraySettings.imap_colorThreshold':
                self.vraySettings_imap_colorThresholdM = dico[myAttr][0]
                self.vraySettings_imap_colorThresholdH = dico[myAttr][1]
            if myAttr == 'vraySettings.imap_normalThreshold':
                self.vraySettings_imap_normalThresholdM = dico[myAttr][0]
                self.vraySettings_imap_normalThresholdH = dico[myAttr][1]
            if myAttr == 'vraySettings.imap_distanceThreshold':
                self.vraySettings_imap_distanceThresholdM = dico[myAttr][0]
                self.vraySettings_imap_distanceThresholdH = dico[myAttr][1]
            if myAttr == 'vraySettings.imap_subdivs':
                self.vraySettings_imap_subdivsM = dico[myAttr][0]
                self.vraySettings_imap_subdivsH = dico[myAttr][1]
            if myAttr == 'vraySettings.imap_interpSamples':
                self.vraySettings_imap_interpSamplesM = dico[myAttr][0]
                self.vraySettings_imap_interpSamplesH = dico[myAttr][1]
            if myAttr == 'vraySettings.imap_detailRadius':
                self.vraySettings_imap_detailRadiusM = dico[myAttr][0]
                self.vraySettings_imap_detailRadiusH = dico[myAttr][1]
            if myAttr == 'vraySettings.imap_detailSubdivsMult':
                self.vraySettings_imap_detailSubdivsMultM = dico[myAttr][0]
                self.vraySettings_imap_detailSubdivsMultH = dico[myAttr][1]
            if myAttr == 'vraySettings.subdivs':
                self.vraySettings_subdivsM = dico[myAttr][0]
                self.vraySettings_subdivsH = dico[myAttr][1]
            if myAttr == 'vraySettings.sampleSize':
                self.vraySettings_sampleSizeM = dico[myAttr][0]
                self.vraySettings_sampleSizeH = dico[myAttr][1]
            if myAttr == 'vraySettings.prefilterSamples':
                self.vraySettings_prefilterSamplesM = dico[myAttr][0]
                self.vraySettings_prefilterSamplesH = dico[myAttr][1]
            if myAttr == 'vraySettings.filterSamples':
                self.vraySettings_filterSamplesM = dico[myAttr][0]
                self.vraySettings_filterSamplesH = dico[myAttr][1]
            if myAttr == 'vraySettings.dmcs_adaptiveAmount':
                self.vraySettings_dmcs_adaptiveAmountM = dico[myAttr][0]
                self.vraySettings_dmcs_adaptiveAmountH = dico[myAttr][1]
            if myAttr == 'vraySettings.dmcs_adaptiveThreshold':
                self.vraySettings_dmcs_adaptiveThresholdM = dico[myAttr][0]
                self.vraySettings_dmcs_adaptiveThresholdH = dico[myAttr][1]
            if myAttr == 'vraySettings.dmcs_adaptiveMinSamples':
                self.vraySettings_dmcs_adaptiveMinSamplesM = dico[myAttr][0]
                self.vraySettings_dmcs_adaptiveMinSamplesH = dico[myAttr][1]
            if myAttr == 'vraySettings.dmcs_subdivsMult':
                self.vraySettings_dmcs_subdivsMultM = dico[myAttr][0]
                self.vraySettings_dmcs_subdivsMultH = dico[myAttr][1]

        for myAttr in dicoMultiplicator:
            if myAttr == 'vraySettings.dmcMaxSubdivs':
                self.multiplicator_vraySettings_dmcMaxSubdivs = dicoMultiplicator[myAttr][0]
            if myAttr == 'vraySettings.imap_minRate':
                self.multiplicator_vraySettings_imap_minRate = dicoMultiplicator[myAttr][0]
            if myAttr == 'vraySettings.imap_maxRate':
                self.multiplicator_vraySettings_imap_maxRate = dicoMultiplicator[myAttr][0]
            if myAttr == 'vraySettings.imap_detailRadius':
                self.multiplicator_vraySettings_imap_detailRadius = dicoMultiplicator[myAttr][0]

        self.presetComment = commentString
示例#16
0
def setup_ik_spline(**kwargs):
    curve = kwargs.get("curve", None)
    joint_chain = kwargs.get("joint_chain", None)
    auto_curve = kwargs.get("auto_curve", True)
    use_curve = kwargs.get("use_curve", None)
    spans = kwargs.get("number_of_spans", 4)
    ctrl_jnts = kwargs.get("num_control_joints", 3)
    ik_name = kwargs.get("ik_name", "ikHandle")
    scale_stretch = kwargs.get("scale_stretch", False)
    create_dense_chain = kwargs.get("dense_chain", False)
    dense_division = kwargs.get("dense_chain_divisions", 3)
    auto_simplify = kwargs.get("auto_simplify_curve", False)
    stretch_exp = kwargs.get("stretch_exp", False)
    global_scale_check = kwargs.get("global_scale_check", False)
    global_scale_attr = kwargs.get("global_scale_attr", None)

    pm.select(joint_chain, hierarchy=True)
    joint_chain = pm.ls(selection=True)
    if not isinstance(joint_chain[0], pm.Joint):
        pm.displayInfo("selection should be of type joint")
        return None
    if len(joint_chain) < 2:
        pm.displayInfo("Chain should consist of more than one joint")
        return None

    if (global_scale_check):
        if (global_scale_attr is None):
            pm.displayInfo("Please input global scale attribute")
            return None
        else:
            obj = global_scale_attr.split(".")[0]
            global_attr = global_scale_attr.split(".")[1]
            check_global_attr = pm.attributeQuery(global_attr,
                                                  node=obj,
                                                  exists=True)
            if not check_global_attr:
                pm.displayInfo("Invalid global scale attribute")
                return None

    start_jnt = joint_chain[0]
    end_joint = joint_chain[-1]

    if create_dense_chain:
        rep_chain = pm.duplicate(joint_chain)
        start_jnt = rep_chain[0]
        end_joint = rep_chain[-1]
        dense_chain(joints=rep_chain, joints_inbetween=dense_division)
        rep_chain.append(end_joint)
        for index in range(len(joint_chain)):
            pm.parentConstraint(rep_chain[index],
                                joint_chain[index],
                                maintainOffset=False)
            #pm.scaleConstraint(rep_chain[index], joint_chain[index], maintainOffset=False)
            pm.connectAttr(
                str(rep_chain[index]) + ".scale",
                str(joint_chain[index]) + ".scale")
        pm.select(start_jnt, hierarchy=True)
        new_chain = pm.ls(selection=True)

    crv = ""

    #print "START", start_jnt
    #print "END",end_joint

    if auto_curve:
        ik_handle, eff, crv = pm.ikHandle(startJoint=start_jnt,
                                          createCurve=auto_curve,
                                          solver="ikSplineSolver",
                                          numSpans=spans,
                                          endEffector=end_joint,
                                          simplifyCurve=auto_simplify)

    else:
        crv = pm.PyNode(use_curve)
        ik_handle, eff = pm.ikHandle(startJoint=start_jnt,
                                     curve=use_curve,
                                     solver="ikSplineSolver",
                                     endEffector=end_joint,
                                     createCurve=False)

    crv.inheritsTransform.set(0)

    pm.rename(ik_handle, ik_name + "IK_Handle")
    pm.rename(crv, ik_name + "IK_Curve")

    ik_curve_shp = crv.getShape()
    crv_info_node = pm.createNode("curveInfo")
    pm.connectAttr(ik_curve_shp + ".worldSpace", crv_info_node + ".inputCurve")
    '''
    if stretch_exp:
        if create_dense_chain:
            stretch_expression(joints = new_chain, curve_info_node = crv_info_node, connect_scale = scale_stretch,
                               expression_name = ik_name+"_stretch_expression")
        else:
            stretch_expression(joints = joint_chain, curve_info_node = crv_info_node, connect_scale = scale_stretch,
                               expression_name = ik_name+"_stretch_expression")
    '''

    if ctrl_jnts:
        if ctrl_jnts == 1:
            print "Minimum 2 joints needed as controllers"
            print "skipping control joint creation process"
            pm.displayInfo("Minimum 2 joints needed as controllers")
        else:
            ctrl_jnts = joints_along_curve(number_of_joints=ctrl_jnts,
                                           curve=crv,
                                           bind_curve_to_joint=True)
            pm.select(clear=True)
            ctr_jnt_gp = pm.group(ctrl_jnts, name="control_joints")
            #print "JNT NAME", ctr_jnt_gp

    if stretch_exp:
        pm.addAttr(ctrl_jnts[-1],
                   longName="Stretch",
                   attributeType="enum",
                   enumName="off:on",
                   keyable=True)
        print "ATTRIBUTE TO", str(ctrl_jnts[-1])
        if create_dense_chain:
            stretch_expression(joints=new_chain,
                               curve_info_node=crv_info_node,
                               connect_scale=scale_stretch,
                               expression_name=ik_name + "_stretch_expression",
                               ctrl_attr=str(ctrl_jnts[-1]) + ".Stretch",
                               glbl_scl_stat=global_scale_check,
                               glbl_scl_attr=global_scale_attr)
        else:
            stretch_expression(joints=joint_chain,
                               curve_info_node=crv_info_node,
                               connect_scale=scale_stretch,
                               expression_name=ik_name + "_stretch_expression",
                               ctrl_attr=str(ctrl_jnts[-1]) + ".Stretch",
                               glbl_scl_stat=global_scale_check,
                               glbl_scl_attr=global_scale_attr)

    final_group = pm.group(name=ik_name + "_ik_group", empty=True)
    pm.parent(joint_chain[0], final_group)
    pm.parent(crv, final_group)
    pm.parent(ik_handle, final_group)
    if ctrl_jnts > 1:
        pm.parent(ctr_jnt_gp, final_group)
    if create_dense_chain:
        pm.select(clear=True)
        dense_grp = pm.group(start_jnt, name="dense_chain_group")
        pm.parent(dense_grp, final_group)

    return None