[英]Blender: how to move the camera from python script
Here is an answer . 这是一个答案 。 But the answer uses euler angles instead of setting the i,j,k base coordinates in the cam's model matrix.
但是答案是使用欧拉角,而不是在凸轮模型矩阵中设置i,j,k基本坐标。 I'd like to set the camera's orientation by its i,j,k coordinates (these are the coordinates in the model matrix which sets the object's orientation and scaling).
我想通过其i,j,k坐标设置相机的方向(这些是模型矩阵中用于设置对象方向和缩放比例的坐标)。 What is the Blender python API for doing it?
Blender python API是做什么的?
Blender's mathutils module is used to work with matrices. Blender的mathutils模块用于处理矩阵。 To transform any object using a matrix you set the objects
matrix_world
property. 要使用矩阵转换任何对象,请设置对象
matrix_world
属性。
import bpy
import mathutils
import math
mat_loc = mathutils.Matrix.Translation((2.0, 3.0, 4.0))
mat_sca = mathutils.Matrix.Scale(0.5, 4, (0.0, 0.0, 1.0))
mat_rot = mathutils.Matrix.Rotation(math.radians(45.0), 4, 'X')
mat_comb = mat_loc * mat_rot * mat_sca
cam = bpy.data.objects['Camera']
cam.matrix_world = mat_comb
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.