我是Blender和Python的新手。我有一个Blender模型(.blend),我想批量渲染为多个图像,并为每个图像提供一些属性。
我编写了一个带有这些参数的Python脚本,类似于:
import bpy
pi = 3.14159265
fov = 50
scene = bpy.data.scenes["Scene"]
# Set render resolution
scene.render.resolution_x = 480
scene.render.resolution_y = 359
# Set camera fov in degrees
scene.camera.data.angle = fov*(pi/180.0)
# Set camera rotation in euler angles
scene.camera.rotation_mode = 'XYZ'
scene.camera.rotation_euler[0] = 0.0*(pi/180.0)
scene.camera.rotation_euler[1] = 0.0*(pi/180.0)
scene.camera.rotation_euler[2] = -30.0*(pi/180.0)
# Set camera translation
scene.camera.location.x = 0.0
scene.camera.location.y = 0.0
scene.camera.location.z = 80.0
然后我像这样运行它
blender -b marker_a4.blend --python "marker_a4.py" -o //out -F JPEG -x 1 -f 1
例如,如果我尝试使用参数来运行Python脚本
...
import sys
...
fov = float(sys.argv[5])
...
然后运行它:
blender -b marker_a4.blend --python "marker_a4.py" 80.0 -o //out -F JPEG -x 1 -f 1
渲染完成了,但是我在开始时收到了这些消息。
read blend: /home/roho/workspace/encuadro/renders/marker/model/marker_a4.blend
read blend: /home/roho/workspace/encuadro/renders/marker/model/80.0
Unable to open "/home/roho/workspace/encuadro/renders/marker/model/80.0": No such file or directory.
...
有人能告诉我这是什么原因吗?我认为blender也将其解析为模型,但不明白为什么。后来我尝试了更复杂的Python参数解析(argparse),但完全没有起作用。所以我想可能在这个层面上发生了一些奇怪的事情。
谢谢!