python - 如何使用 Python 在 Blender 2.61 中移动相机

标签 python blender blender-2.61

我正在寻找一个简单的脚本来使用 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

以后会改进接受命令行参数。我是 python 和 blender 的新手,所以这可能有点业余,但它确实有效。

关于python - 如何使用 Python 在 Blender 2.61 中移动相机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8865672/

相关文章:

python - 矢量化:不是有效的集合

python - Django populate() 不可重入

python - 应用sklearn.Linear_model.LinearRegression时如何限制CPU使用率?

three.js,服装和形状键

textures - 纹理是 "inverted"

python - 如何为多个 HTML 表单提供单一 View - Django

python - 物体和相机之间的关联 Blender python

java - 如何变换网格?

unity-game-engine - 在 Blender 中导入 .fbx 字符

python - 生成 UV 球体的 blender 性能问题