def cb_selectPaintingLayer(self, value):

    lNode = paintingLayers.getLayerNodeById(
        bpy.context.scene.mlpLayerTreeCollection_ID)

    if lNode != None:

        cs = paintingLayers.getLayerColorSpace()
        if cs == "color":
            colorImage = lNode.node_tree.nodes["Color"].image
            bpy.context.tool_settings.image_paint.canvas = colorImage
        else:
            maskImage = lNode.node_tree.nodes["Mask"].image
            bpy.context.tool_settings.image_paint.canvas = maskImage

        if lNode.node_tree.nodes["Mask"].image != None:
            lNode.node_tree.nodes["PL_InputMaskOpacity"].outputs[
                0].default_value = 1
        else:
            lNode.node_tree.nodes["PL_InputMaskOpacity"].outputs[
                0].default_value = 0

    bpy.context.scene.mlpFilterLayerCollection.clear()
    bpy.context.scene.mlpFilterLayerCollection_ID = -1

    bpy.ops.vtoolpt.collectlayerfilter()
Ejemplo n.º 2
0
def cb_setLayerVisibilty(self, value):

    #lNode = paintingLayers.getLayerNodeById(bpy.context.scene.mlpLayerTreeCollection_ID)
    lNode = paintingLayers.getLayerNodeById(self.layerID)

    if self.visible == True:
        lNode.node_tree.nodes["PL_OpacityOffset"].inputs[0].default_value = 1
    else:
        lNode.node_tree.nodes["PL_OpacityOffset"].inputs[0].default_value = 0
Ejemplo n.º 3
0
def cb_selectPaintingLayer(self, value):

    lNode = paintingLayers.getLayerNodeById(
        bpy.context.scene.mlpLayerTreeCollection_ID)

    if lNode != None:

        deselectAllLayerNodes()
        nodeSet = paintingLayers.getActiveLayerSet(False)
        mainTree = nodeSet.node_tree

        #selecciona y activa los nodos activos

        nodeSet.select = True
        bpy.context.object.active_material.node_tree.nodes.active = nodeSet
        lNode.select = True
        mainTree.nodes.active = lNode

        #elige la textura a pintar

        cs = paintingLayers.getLayerColorSpace()
        if cs == "color":
            colorNode = lNode.node_tree.nodes["Color"]
            colorNode.select = True
            lNode.node_tree.nodes.active = colorNode

            colorImage = colorNode.image

            if colorImage != None:
                findPaintingSlot(colorImage.name)
                bpy.context.tool_settings.image_paint.canvas = colorImage

        else:
            maskNode = lNode.node_tree.nodes["Mask"]
            maskNode.select = True
            lNode.node_tree.nodes.active = maskNode

            maskImage = maskNode.image
            if maskImage != None:
                findPaintingSlot(maskImage.name)
                bpy.context.tool_settings.image_paint.canvas = maskImage

        if lNode.node_tree.nodes["Mask"].image != None:
            lNode.node_tree.nodes["PL_InputMaskOpacity"].outputs[
                0].default_value = 1
        else:
            lNode.node_tree.nodes["PL_InputMaskOpacity"].outputs[
                0].default_value = 0

    else:
        deselectAllLayerNodes()
        #bpy.context.object.active_material.paint_active_slot = -1

    bpy.context.scene.mlpFilterLayerCollection.clear()
    bpy.context.scene.mlpFilterLayerCollection_ID = -1

    bpy.ops.vtoolpt.collectlayerfilter()
def setupLayersForBake(pNumLayers):
    
    tmpBakeNodes = []
    als = paintingLayers.getActiveLayerSet(False)
    firstLayerId = bpy.context.scene.mlpLayerTreeCollection_ID
    slId = firstLayerId
    
    firstLayer = paintingLayers.getLayerNodeById(firstLayerId)
    
    for i in range(pNumLayers):
        
        lId = firstLayerId - i
        tmp_n = paintingLayers.getLayerNodeById(lId)
        
        if tmp_n != None:
            tmp_bake = als.node_tree.nodes.new(type="ShaderNodeGroup")
            tmp_bake.node_tree = tmp_n.node_tree
            tmp_bake.inputs["Opacity"].default_value = tmp_n.inputs["Opacity"].default_value
            tmp_bake.inputs["Global Filter"].default_value = tmp_n.inputs["Global Filter"].default_value
            
            tmpBakeNodes.append(tmp_bake)
            tmp_bake.location = (200*i*-1, 400)
        else:
            break
    
    numBakingNodes = len(tmpBakeNodes)
    bakeNodes = tmpBakeNodes[::-1]
    print("BAKE NODES ", tmpBakeNodes, " -- ", bakeNodes)
    
    for i in range(numBakingNodes):
        n1 = bakeNodes[i]
        
        if i+1 < numBakingNodes:
            n2 = bakeNodes[i+1]
        else:
            break
        
        paintingLayers.connectLayerNodes(n1,n2)
        
        
    return bakeNodes    
Ejemplo n.º 5
0
def deselectAllLayerNodes():

    for i in range(0, len(bpy.context.scene.mlpLayerTreeCollection)):
        lNode = paintingLayers.getLayerNodeById(i)
        if lNode.node_tree != None:
            colorNode = lNode.node_tree.nodes["Color"]
            maskNode = lNode.node_tree.nodes["Mask"]

            lNode.node_tree.nodes.active = lNode.node_tree.nodes[0]
            colorNode.select = False
            maskNode.select = False
            lNode.select = False
Ejemplo n.º 6
0
    def draw_item(self, context, layout, data, item, icon, active_data,
                  active_propname):

        image = None
        selectedLayer = paintingLayers.getLayerNodeSelected()
        if selectedLayer != None:
            itemLayerNode = paintingLayers.getLayerNodeById(item.layerID)
            layerNode = paintingLayers.getLayerNodeByName(item.layerName)
            isSelectedLayer = selectedLayer.name == item.layerName
            cs = item.colorSpace

            colorEmboss = False
            maskEmboss = False

            if isSelectedLayer:
                if cs == "color":
                    layout.label(text="", icon="IMAGE")
                    colorEmboss = True
                else:
                    layout.label(text="", icon="IMAGE_ALPHA")
                    maskEmboss = True
            else:
                layout.label(text="", icon="DOT")

            row = layout.row(align=True)

            #row.operator(paintingLayers.VTOOLS_OP_DuplicatePaintingLayer.bl_idname, text="", icon='HIDE_OFF')

            if layerNode.node_tree != None:
                imageColor = layerNode.node_tree.nodes["Color"].image
                imageMask = layerNode.node_tree.nodes["Mask"].image

                if imageColor != None:
                    opm = row.operator(
                        paintingLayers.VTOOLS_OP_SelectLayerColorSpace.
                        bl_idname,
                        text="",
                        icon_value=imageColor.preview.icon_id,
                        emboss=colorEmboss)
                    opm.color = "color"
                    opm.layerID = item.layerID
                    #row.label(text="", icon_value=imageColor.preview.icon_id)
                else:
                    #row.label(text="", icon="FILE")
                    opm = row.operator(
                        paintingLayers.VTOOLS_OP_SelectLayerColorSpace.
                        bl_idname,
                        text="",
                        icon="FILE",
                        emboss=colorEmboss)
                    opm.color = "color"
                    opm.layerID = item.layerID

                if imageMask != None:
                    opm = row.operator(
                        paintingLayers.VTOOLS_OP_SelectLayerColorSpace.
                        bl_idname,
                        text="",
                        icon_value=imageMask.preview.icon_id,
                        emboss=maskEmboss)
                    opm.color = "mask"
                    opm.layerID = item.layerID
                    #row.label(text="", icon_value=imageMask.preview.icon_id)
                else:
                    #row.label(text="", icon="FILE")
                    opm = row.operator(
                        paintingLayers.VTOOLS_OP_SelectLayerColorSpace.
                        bl_idname,
                        text="",
                        icon="FILE",
                        emboss=maskEmboss)
                    opm.color = "mask"
                    opm.layerID = item.layerID

                row = layout.row(align=True)
                row.enabled = isSelectedLayer

                if cs == "color":
                    row.prop(layerNode.node_tree.nodes["Color"],
                             "image",
                             text="")
                else:
                    row.prop(layerNode.node_tree.nodes["Mask"],
                             "image",
                             text="")

                row = layout.row(align=True)
                row.prop(item,
                         "visible",
                         text="",
                         icon='HIDE_OFF',
                         translate=False)