我正在寻找一个简单的脚本来使用 Python 在 Blender 2.61 中移动相机。
我认为这将是一项简单的任务,但 Camera 对象没有像 loc 或类似的属性。
我只在网上找到了 Blender 2.49 的脚本,但由于 Blender 2.5 的 API 发生了巨大的变化,它们不再工作了。
我将不胜感激任何提示。
Furtelwart的回答非常有用。我做了一些更多的挖掘,因此您还可以设置一些有关相机和渲染的其他非常有用的属性。
import bpy
tx = 0.0
ty = 0.0
tz = 80.0
rx = 0.0
ry = 0.0
rz = 0.0
fov = 50.0
pi = 3.14159265
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] = rx*(pi/180.0)
scene.camera.rotation_euler[1] = ry*(pi/180.0)
scene.camera.rotation_euler[2] = rz*(pi/180.0)
# Set camera translation
scene.camera.location.x = tx
scene.camera.location.y = ty
scene.camera.location.z = tz
我正在使用这个脚本来进行批量渲染。您可以在这里查看:http://code.google.com/p/encuadro/source/browse/renders/marker/model/marker_a4.py http://code.google.com/p/encuadro/source/browse/renders/marker/model/marker_a4.py
稍后将改进以获取命令行参数。我对 python 和 Blender 很陌生,所以这可能有点业余,但它确实有效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)