如何使用一组{camera}在c4d中排队进行批渲染✕ {纹理}(笛卡尔积)?

2024-09-19 23:39:58 发布

您现在位置:Python中文网/ 问答频道 /正文

使用python脚本,我尝试使用不同的(vray)摄影机、给定(vray)材质的不同纹理路径、不同的渲染图像文件名和特定设置排队渲染当前项目。我找不到控制排队的方法

我的问题是:

  1. 如何获取当前文档中所有(vray)摄像头的列表? 伪代码:camNameList = [c.GetName() for c in currentbasedocument.GetAllCameras()]

  2. 如何编辑(vray)材质的纹理

  3. 如何对集合{cameras}进行排队✕ {纹理}和渲染

我在一个项目中使用了vray摄像头:

camNameList = ["vray Cam2 global", "vray Cam1 close tree", "vray Cam3 closer tree",
    "vray Cam4 angle L", "vray Cam5 angle R", "vray Cam6", "floor"]

但我没有设法访问它们:

batch = documents.GetBatchRender()
batch.Open()
batch.AddFile(file, 1) # works but I have not control over 1) which camera
    # 2) which render setting 3) which filename for the rendered image

camOList = doc.SearchObject("vray Cam2 global")
print (camOList) # result: None
  
bd  = doc.GetActiveBaseDraw()
cam = bd.GetEditorCamera()
cname = bd.GetSceneCamera(doc)
print(cam.GetName()) # result: "Camera" but it is not in camNameList
print(cname.GetName()) # result: "Camera"

我将使用这些函数来做{cameras}的笛卡尔积✕ {textures}并指定渲染文件名:

from os.path import isfile, join

doneFiles = ["im1.JPG", "im2.JPG"]
def GetTex(path):
    return [f for f in listdir(path) if isfile(join(path, f)) and f.endswith(".JPG") and f not in doneFiles]

def FilterCams(camNameList, camTagList):
    return [c for c in camNameList for t in camTagList if t in c]
  
def GetRenderUple(renderList):
    finalUple = []
    for file, camtag in renderList:
        filetag = file.split(".")[0]
        cameraName = [c for c in camNameList if camtag in c][0]
        renderFile = filetag + "_" + camtag + ".tif"
        finalUple.append((file, cameraName, renderFile))
    return finalUple

笛卡尔积没有问题:

from os import listdir
from itertools import product

camNumbers = [2,1,4,5]
camTagList = ["Cam"+str(i) for i in camNumbers]

selectedCam = FilterCams(camNameList, camTagList)
# print(selectedCam)

renderList = list(product(flist, camTagList))
# print(renderList)

Tags: pathinwhichforbatchnotfile排队