我正在尝试创建一个渲染对象 360 度旋转的脚本。我对搅拌机一点也不熟悉,但我一直在努力做到这一点。
我正在使用 Python 编写一个脚本,该脚本导入一个 STL 文件并创建它的 360 度渲染。我的问题是,移动相机时,相机不会在正确的平面上移动。
这是一张图片专辑,描述了我的意思:
我用来执行此操作的功能是:
def rotateCameraAroundOrigin(rx=0):
cam = bpy.data.objects['Camera']
old_x = cam.location.x
old_y = cam.location.y
old_z = cam.location.z
radius = math.sqrt((math.pow(old_x,2) + math.pow(old_y,2)))
current_angle = math.degrees(math.atan2( old_y, old_x))
print("CUR:\t%+04d degrees" % (current_angle))
new_angle = current_angle + rx
print("FROM:\t%+04d, %+04d, %+04d" % (old_x,old_y,old_z))
new_x = radius * math.cos(math.radians(new_angle))
new_y = radius * math.sin(math.radians(new_angle))
moveCamTo(new_x,new_y,old_z)
print("TO:\t%+04d, %+04d, %+04d\n" % (new_x,new_y,old_z))
接着:
for i in range(1, 10):
print("Rotation %01d" % (i))
image = 'images/' + sys.argv[-1] + str(i) + '.' + filetype
rotateCameraAroundOrigin(36)
render_thumb(image,gl=False)
这会产生 imgur 专辑中显示的输出:
Rotation 1
CUR: +000 degrees
FROM: +302, +000, +000
TO: +244, +177, +000
Rotation 2
CUR: +035 degrees
FROM: +244, +177, +000
TO: +093, +287, +000
Rotation 3
CUR: +071 degrees
FROM: +093, +287, +000
TO: -093, +287, +000
Rotation 4
CUR: +107 degrees
FROM: -093, +287, +000
TO: -244, +177, +000
Rotation 5
CUR: +143 degrees
FROM: -244, +177, +000
TO: -302, +000, +000
Rotation 6
CUR: +179 degrees
FROM: -302, +000, +000
TO: -244, -177, +000
Rotation 7
CUR: -144 degrees
FROM: -244, -177, +000
TO: -093, -287, +000
Rotation 8
CUR: -108 degrees
FROM: -093, -287, +000
TO: +093, -287, +000
Rotation 9
CUR: -072 degrees
FROM: +093, -287, +000
TO: +244, -177, +000
我不知所措。我的飞机倾斜了,但我不知道为什么。我想围绕物体平滑旋转。
谢谢你的帮助,
H