def Main(): opts = ParseOpts() loglevel = logging.DEBUG if opts.debug else logging.INFO logging.basicConfig(level=loglevel, filename=stdlogutils.GetTimestampedFilename2( iconrendering.APPNAME), format=stdlogutils.Fmt.NTLM) streamh = logging.StreamHandler(sys.stdout) streamh.setFormatter(stdlogutils.Fmt.FMT_NTLM) L.addHandler(streamh) out = os.path.join(opts.outroot, opts.outfolder) if opts.removedir: osutils.SafeRmTree(out) resmapper = fsdauthoringutils.GraphicsCache(devenv.EVEROOT) invmapper = inventory.InventoryMapper(opts.branch) _appsetup.CreateTrinityApp() mgr = rendermanagement.RenderManager(resmapper, invmapper, L, out, opts.takeonly) iec.DoRender(mgr, opts.takeonly, whatToRender=opts.imagebatch, logger=L) sys.exit(0)
def Main(): opts = ParseOpts() loglevel = logging.DEBUG if opts.debug else logging.INFO logging.basicConfig(level=loglevel, filename=stdlogutils.GetTimestampedFilename2( iconrendering.APPNAME), format=stdlogutils.Fmt.NTLM) streamh = logging.StreamHandler(sys.stdout) streamh.setFormatter(stdlogutils.Fmt.FMT_NTLM) L.addHandler(streamh) renderFolder = GetTmpRenderPath() if os.path.exists(renderFolder): osutils.SafeRmTree(renderFolder) resmapper = fsdauthoringutils.GraphicsCache(devenv.EVEROOT) invmapper = None _appsetup.CreateTrinityApp() mgr = rendermanagement.RenderManager(resmapper, invmapper, L, renderFolder, opts.takeonly) if opts.respath or opts.dna: mgr.RenderSingle(resPath=opts.respath, dnaString=opts.dna) else: mgr.RenderInGameIcons() if opts.checkout: L.debug('P4 Checkout started.') p4 = ccpp4.P4Init() dest_dict = GetDestDirs(renderFolder) before = set(map(string.lower, dest_dict.keys())) after = GetFiles(renderFolder) added = list(after.difference(before)) deleted = list(before.difference(after)) filesToCompare = list(after.intersection(before)) changed = [] for fileName in filesToCompare: iconResPath = dest_dict[fileName] renderPath = os.path.join(renderFolder, fileName) iconPath = respathutils.ExpandResPath(iconResPath, respathutils.GetClientRes()) if os.path.exists(iconPath): diffResult = imgdiff.ImgDiff(iconPath, renderPath, normal=False, alpha=False) error = diffResult['Color']['MeanAbsoluteError'] if error > TOLERANCE: changed.append(fileName) else: changed.append(fileName) if opts.checkout: for fileName in added + changed: iconResPath = dest_dict[fileName] iconPath = respathutils.ExpandResPath(iconResPath, respathutils.GetClientRes()) renderPath = os.path.join(renderFolder, fileName) L.debug('P4 Edit or Add: %s', fileName) p4.EditOrAdd(iconPath) icon_dir = os.path.dirname(iconPath) if not os.path.exists(icon_dir): os.makedirs(icon_dir) if os.path.exists(renderPath): shutil.copy(renderPath, iconPath) allfiles = added + changed GetPath = lambda fileName: respathutils.ExpandResPath( dest_dict[fileName], respathutils.GetClientRes()) if not (opts.takeonly or opts.respath): for deletedFile in deleted: L.debug('P4 Deleting: %s', deletedFile) p4.run_delete(GetPath(deletedFile)) allfiles = allfiles + deleted osfiles = map(GetPath, allfiles) depotFiles = map(lambda wh: wh['depotFile'], p4.run_where(osfiles)) if len(depotFiles): c = p4.Change(description='Ingame Icon generation.', files=depotFiles, save=False) changeno = p4.SaveChange(c) L.debug('P4 Checkout done.') if opts.cleanup: osutils.SafeRmTree(renderFolder)
def Main(): subprocess.Popen('explorer %s' % OUTPUT_FOLDER.replace('/', '\\')) opts = ParseArgs() loglevel = logging.DEBUG if opts.debug else logging.INFO logging.basicConfig(level=loglevel, filename=stdlogutils.GetTimestampedFilename2(APPNAME), format=stdlogutils.Fmt.NTLM) streamh = logging.StreamHandler(sys.stdout) streamh.setFormatter(stdlogutils.Fmt.FMT_NTLM) L.addHandler(streamh) resmapper = fsdauthoringutils.GraphicsCache(devenv.EVEROOT) invmapper = inventory.InventoryMapper(opts.branch) _appsetup.CreateTrinityApp() typeIDs = opts.types if opts.cameraYPR and len(opts.cameraYPR) == 3: cameraAngle = map(float, opts.cameraYPR) else: cameraAngle = None if opts.sunDirection and len(opts.sunDirection) == 3: sunDirection = map(float, opts.sunDirection) else: sunDirection = (-0.4592, -0.4602, 0.6614) tempRenders = [] for typeID in typeIDs: gID = resmapper.GetGraphicIDForTypeID(typeID) sofData = resmapper.GetSOFDataForGraphicID(gID) raceID = invmapper.GetTypeData(typeID)[2] scenePath = photo.GetScenePathByRaceID(raceID) sofDNA = '' if all(sofData): sofDataForType = resmapper.GetSOFDataForTypeID(typeID) sofDNA = CombineSOFDNA(sofAddition=sofDataForType[0], *sofData) graphicFile = resmapper.GetGraphicFileForGraphicID(gID) if not sofDNA and not graphicFile: L.error('Type %s does not have a graphicFile nor SOF data' % typeID) continue sourceFiles = [] for color, suffix in COLORS: outPath = os.path.join(OUTPUT_FOLDER, str(typeID) + '_' + suffix + '.png') L.debug('Rendering %s' % outPath) photo.RenderSpaceObject(outPath=outPath, scenePath=scenePath, objectPath=graphicFile, sofDNA=sofDNA, size=512, bgColor=color, transparent=True, cameraAngle=cameraAngle, sunDirection=sunDirection) sourceFiles.append(outPath) tempRenders.extend(sourceFiles) finalPath = os.path.join(OUTPUT_FOLDER, str(typeID) + u'.png') CreateAlpha(finalPath, sourceFiles) if not opts.keepsource: for filePath in tempRenders: os.remove(filePath) sys.exit(0)