Exemplo n.º 1
0
    def run(self):
        time_Start = time.time()
        count = 0
        for aov in self.aov_list:
            for i in self.num_list:
                ice_images_list = []
                num = "%04d" % i
                beauty_name = self.img_base_name + "_" + self.final_name + "_" + aov + "_filtered" + "." + num + ".exr"
                export_file = self.outDir + "/" + beauty_name
                for channel in self.affect_channel_list:
                    image = self.filter_file_dir + "/" + self.img_base_name + "_" + channel + "_" + aov + "_filtered" + "." + num + ".exr"
                    ice_image = ice.Load(image)
                    ice_images_list.append(ice_image)

                box = ice_images_list[0].DataBox()
                color = [0, 0, 0, 0]
                black_card = ice.FilledImage(ice.constants.FLOAT, box, color)
                result = black_card
                for image in ice_images_list:
                    result = result.Add(image)
                final_result = result.Interleave(black_card, [-3, -2, -1, 4])
                final_result.Save(export_file, ice.constants.FMT_EXRFLOAT)
                count = count + 1
                self.count.emit(count)
                self.img_complete.emit(beauty_name)
            time.sleep(0.5)
        time_end = time.time()
        real_time = time_end - time_Start
        self.cost_time.emit(real_time)
        self.all_complete.emit()
        self.quit()
Exemplo n.º 2
0
def defineImageAtlasData(maxImageW, maxImageH, imageName):

    allImagesMeshInAtlas = cmds.listRelatives("imageAtlas",
                                              c=True,
                                              ad=True,
                                              type="mesh")
    print "allImagesMeshInAtlas allImagesMeshInAtlas_________111", allImagesMeshInAtlas
    allImageList = []
    allPageImagesAtlas = []
    allPages = []
    for i in allImagesMeshInAtlas:
        imagePlane = cmds.listRelatives(i, p=True, type="transform")[0]

        #print "imagePlane"
        allImageList.append(imagePlane)
        shadingGrps = cmds.listConnections(i, type='shadingEngine')
        shaders = cmds.ls(cmds.listConnections(shadingGrps), materials=1)

        fileNode = cmds.listConnections('%s.color' % (shaders[0]), type='file')

        currentFile = cmds.getAttr("%s.fileTextureName" % fileNode[0])
        imageName = currentFile.split('/')[-1].split('.')[0]
        imageBB = cmds.exactWorldBoundingBox(imagePlane)
        minX = imageBB[0]
        maxX = imageBB[3]
        minY = imageBB[1]
        maxY = imageBB[4]
        #if int(minY)/ int(maxImageH) >=0 and int(maxX)/int(maxImageW) <= 1:
        # print "ooooooooooooooo imageName",imageName,maxY,minY
        if maxY <= maxImageH and minY >= 0:
            # print  "currentFile",currentFile,minX,maxX,minY,maxY
            pageCount = int(minX) / int(maxImageW)
            if pageCount in allPages:
                pass
            else:
                allPages.append(pageCount)
        # print "pageCount",pageCount
            x = int(minX - maxImageW * pageCount)
            y = int(maxImageH - maxY)
            image = ice.Load(currentFile)
            imageMetaData = image.GetMetaData()
            currentImage = i.split('/')[-1]
            # print "i i i i i i imageName",imageName

            #imageSize = imageMetaData['Original Size']
            w = int(imageMetaData['Original Size'].split(" ")[0].split("(")[1])
            h = int(imageMetaData['Original Size'].split(" ")[1].split(")")[0])
            allPageImagesAtlas.append({
                "image": imageName,
                "page": pageCount,
                "x": x,
                "y": y,
                "w": w,
                "h": h,
                "url": currentFile
            })
    print "allPageImagesAtlas allPageImagesAtlas allPageImagesAtlas 000000000", allPageImagesAtlas
    return allPageImagesAtlas, allPages
Exemplo n.º 3
0
def txConvertIce():
    parser = argparse.ArgumentParser()
    parser.add_argument("inputFile", help="input file to convert")
    parser.add_argument("outputFile", help="output file returned after conversion")

    args = parser.parse_args()
    inputFile = (args.inputFile)
    outputFile = (args.outputFile)
    loadFile = ice.Load(inputFile)
    loadFile.Save(outputFile)
def getImageMetaData(fileNode):
    
    currentFile = cmds.getAttr("%s.fileTextureName" % fileNode)
    fileInSlot = currentFile.split("/")[-1].split(".png")[0]
    image = ice.Load(currentFile)
    imageMetaData = image.GetMetaData()
    imageSize = imageMetaData['Original Size']
    imageWidth = int(imageMetaData['Original Size'].split(" ")[0].split("(")[1])
    imageHeight = int(imageMetaData['Original Size'].split(" ")[1].split(")")[0])

    return currentFile,imageWidth,imageHeight
Exemplo n.º 5
0
def txConvertIce():
    parser = argparse.ArgumentParser()
    parser.add_argument("inputFile", help="input file to convert")
    parser.add_argument("outputFile",
                        help="output file returned after conversion")

    args = parser.parse_args()
    inputFile = (args.inputFile)
    outputFile = (args.outputFile)
    loadFile = ice.Load(inputFile)
    bits = loadFile.GetMetaData()

    if bits['Original Bits Per Sample'] == 32:
        formatFile = ice.constants.FMT_EXRFLOAT
        loadFile.Save(outputFile, formatFile)
    if bits['Original Bits Per Sample'] in (16, 8):
        formatFile = ice.constants.FMT_EXRHALF
        loadFile.Save(outputFile, formatFile)
Exemplo n.º 6
0
def writeImage(imageName, pageCount, exportDir, maxImageW, maxImageH,
               currentImageAtlasData):

    if pageCount == 0:
        imageAtlasFileName = exportDir + '/' + imageName + '.png'
    else:
        imageAtlasFileName = exportDir + '/' + imageName + str(pageCount +
                                                               1) + '.png'
    print "currentImageAtlasData_____________2", currentImageAtlasData
    #fileName = exportDir +'/' +imageName

    box = [0, maxImageW, 0, maxImageH]
    color = [0.0, 0.0, 0.0, 0.0]

    bg = ice.FilledImage(ice.constants.FLOAT, box, color)
    format = ice.constants.FMT_PNG
    # print "currentImageAtlasData_______1",currentImageAtlasData
    for i in currentImageAtlasData:
        fileName = i["url"]
        x = i["x"]
        y = i["y"]
        w = i["w"]
        h = i["h"]
        print "pageCount,file", pageCount, fileName, x, y, w, h
        print "image is existed ", os.path.isfile(fileName)
        fg = ice.Load(fileName)
        fgbox = [0, 0, w, h]
        fgCard = ice.FilledImage(ice.constants.FLOAT, fgbox, color)
        fgResult = fgCard.Cover(fg)
        #cropBox = [x,(x+w),y,(y+h)]
        #fgCorp = fg.SubImageWorld(cropBox)
        translateAmount = (x, y)
        translateFilter = ice.constants.FILTER_CATROM
        fgResult = fgResult.Translate(translateAmount, translateFilter)
        #fgResult = fgResult.SubImageWorld(cropBox)
        bg = bg.Cover(fgResult)

    #  fgResult = fg.Scale(scaleAmoiunt, scaleFilter)

    #  bg = bg.Over(fgResult)
    bg.Save(imageAtlasFileName, format)
Exemplo n.º 7
0
def createAtlasImage(maxImageW, maxImagwH):

    points = [(0, 0, 0), (0, maxImagwH, 0), (maxImageW, maxImagwH, 0),
              (maxImageW, 0, 0), (0, 0, 0)]

    atlasImageEditAreaCurve = cmds.ls("atlasImageEditArea")
    if len(atlasImageEditAreaCurve) == 0:
        curve = cmds.curve(d=1, p=points, n="atlasImageEditArea")
        textImage01 = cmds.textCurves(t="image_01",
                                      f='Arial',
                                      n="imageArea_01")

        print "textImage01", textImage01
        cmds.setAttr('%s.scaleX' % textImage01[0], 100)
        cmds.setAttr('%s.scaleY' % textImage01[0], 100)
        cmds.setAttr('%s.translateY' % textImage01[0], -100)

    else:
        pass

    tempTransformObj = cmds.ls(type="transform")
    spineRootObj = []

    for i in tempTransformObj:
        try:
            if cmds.getAttr('%s.spine_tag' % i) == "spine_RootSkeleton":
                if i in spineRootObj:
                    pass
                else:
                    spineRootObj.append(i)
        except:
            pass

    spineSlotNMeshInRoot = []
    for i in spineRootObj:
        for j in cmds.listRelatives(i, c=True, ad=True):
            spineSlotNMeshInRoot.append(j)

    tempMeshList = filter(lambda x: cmds.nodeType(x) == "mesh",
                          spineSlotNMeshInRoot)

    spineImageMeshList = []
    for i in tempMeshList:

        try:
            currentParent = cmds.listRelatives(i, p=True)[0]
            #  print cmds.listRelatives(i,p=True)[0],cmds.getAttr('%s.spine_tag'%currentParent)
            if cmds.getAttr(
                    '%s.spine_tag' %
                    currentParent) == "spine_slot" or cmds.getAttr(
                        '%s.spine_tag' % currentParent) == "spine_skin":
                if currentParent in spineImageMeshList:
                    pass
                else:
                    spineImageMeshList.append(i)
        except:
            pass

    spineImageList = []
    for i in spineImageMeshList:

        shadingGrps = cmds.listConnections(i, type='shadingEngine')
        shaders = cmds.ls(cmds.listConnections(shadingGrps), materials=1)

        fileNode = cmds.listConnections('%s.color' % (shaders[0]), type='file')

        currentFile = cmds.getAttr("%s.fileTextureName" % fileNode[0])
        if currentFile in spineImageList:
            pass
        else:
            spineImageList.append(currentFile)

    imageInfoDictList = []
    atlasImageList = []
    for i in spineImageList:
        image = ice.Load(i)
        imageMetaData = image.GetMetaData()
        currentImage = i.split('/')[-1]
        #imageSize = imageMetaData['Original Size']
        w = int(imageMetaData['Original Size'].split(" ")[0].split("(")[1])
        h = int(imageMetaData['Original Size'].split(" ")[1].split(")")[0])
        area = w * h
        pName = "imageAtlasPlane_" + currentImage.split('.')[0]
        #print pName
        imageInfoDictList.append({
            "image": currentImage,
            "w": w,
            "h": h,
            "area": area,
            "url": i,
            "pName": pName
        })
        if pName in atlasImageList:
            pass
        else:
            atlasImageList.append(pName)
    # print i,w,h

    widthFirstImageInfoList = list((sorted(imageInfoDictList,
                                           key=lambda x: x["w"],
                                           reverse=True)))  #reversed

    getImageAtlasGrp = cmds.ls("imageAtlas")

    if len(getImageAtlasGrp) == 0:
        cmds.createNode('transform', ss=True, n="imageAtlas")

    else:

        pass

    planeInImageAtlas = cmds.listRelatives("imageAtlas",
                                           c=True,
                                           typ="transform")
    existAtlasImage = []
    try:
        for i in planeInImageAtlas:

            shape = cmds.listRelatives(i, c=True, type="mesh")
            shadingGrps = cmds.listConnections(shape, type='shadingEngine')

            shaders = cmds.ls(cmds.listConnections(shadingGrps), materials=1)

            fileNode = cmds.listConnections('%s.color' % (shaders[0]),
                                            type='file')

            currentFile = cmds.getAttr("%s.fileTextureName" % fileNode[0])
            if currentFile in existAtlasImage:
                pass
            else:
                existAtlasImage.append(currentFile)

    except:
        pass

    for i in widthFirstImageInfoList:
        #  print i
        pw = i['w']
        ph = i['h']
        pName = i['pName']  #"imageAtlasPlane_"+i['image'].split('.')[0]

        targetFileName = i['url']
        if targetFileName in existAtlasImage:
            pass
        else:

            plane = cmds.polyPlane(sx=1, sy=1, w=pw, h=ph, name=pName)
            cmds.setAttr('%s.rotateX' % pName, 90)
            cmds.setAttr('%s.translateX' % pName, -2500)

            cmds.parent(plane, "imageAtlas")
            slotShaderName = pName + '_ia_shader'
            slotFileName = pName + '_ia_imageFile'
            slotSG = pName + '_ia_SG'
            shader = cmds.shadingNode("blinn", asShader=True, n=slotShaderName)
            file_node = cmds.shadingNode("file",
                                         asTexture=True,
                                         n=slotFileName)
            shading_group = cmds.sets(renderable=True,
                                      noSurfaceShader=True,
                                      empty=True,
                                      n=slotSG)
            cmds.connectAttr('%s.color' % shader,
                             '%s.surfaceShader' % shading_group)
            cmds.connectAttr('%s.outColor' % file_node, '%s.color' % shader)
            cmds.connectAttr('%s.outTransparency' % file_node,
                             '%s.transparency' % shader)
            cmds.connectAttr('%s.outAlpha' % file_node,
                             '%s.reflectivity' % shader)
            cmds.setAttr('%s.specularColor' % shader, 0, 0, 0, type='double3')
            cmds.setAttr('%s.ambientColor' % shader, 1, 1, 1, type='double3')
            cmds.setAttr('%s.diffuse' % shader, 0)

            cmds.setAttr('%s.reflectedColor' % shader, 0, 0, 0,
                         type='double3')  ### set to normal blend mode
            cmds.setAttr('%s.fileTextureName' % file_node,
                         targetFileName,
                         type='string')
            cmds.select(cl=True)

            cmds.select(plane)
            cmds.hyperShade(assign=shader)
            cmds.select(cl=True)

    try:
        cmds.parent("atlasImageEditArea", "imageAtlas")
        cmds.parent(textImage01[0], "imageAtlas")
    except:
        pass

    return widthFirstImageInfoList, atlasImageList
Exemplo n.º 8
0
    import ice
except:
    pass

import ice

max_frames_row = 10.0
frames = []
tile_width = 0
tile_height = 0

spritesheet_width = 0
spritesheet_height = 0

folder = "C:/Temp/testImage/1"
files = os.listdir(folder)
files.sort()
#print(files)

for i in files:
    filename = folder + '/' + i
    image = ice.Load(filename)
    imageMetaData = image.GetMetaData()
    frames.append(imageMetaData)

print frames
# imageSize = imageMetaData['Original Size']
#imageWidth = int(imageMetaData['Original Size'].split(" ")[0].split("(")[1])
#imageHeight = int(imageMetaData['Original Size'].split(" ")[1].split(")")[0])

###ref https://minzkraut.com/2016/11/23/making-a-simple-spritesheet-generator-in-python/