Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么使用python旋转在blender 2.6中不起作用?_Python_Blender - Fatal编程技术网

为什么使用python旋转在blender 2.6中不起作用?

为什么使用python旋转在blender 2.6中不起作用?,python,blender,Python,Blender,我是搅拌机新手。 我错过什么了吗 但是,控制台窗口中的类型:bpy.data.objects['Suzanne'].rotation\u euler[2]=1.25将使模型旋转 但是下面的代码根本不会旋转模型。为什么? import bpy import math cam = bpy.data.objects['Camera'] origin = bpy.data.objects['Suzanne'] step_count = 5 bpy.data.scenes["Scene"].cycle

我是搅拌机新手。 我错过什么了吗

但是,控制台窗口中的类型:
bpy.data.objects['Suzanne'].rotation\u euler[2]=1.25
将使模型旋转

但是下面的代码根本不会旋转模型。为什么?

import bpy
import math

cam = bpy.data.objects['Camera']
origin = bpy.data.objects['Suzanne']

step_count = 5
bpy.data.scenes["Scene"].cycles.samples=10

for step in range(0, step_count):
    r = math.pi * step * (360.0 / step_count) / 180.0
    print(r)
    origin.rotation_euler[2] = r       # seems not work!
    fn = '/tmp/mokey_%02d.jpg' % step
    print(fn)
    bpy.data.scenes["Scene"].render.filepath = fn
    bpy.ops.render.render( write_still=True )

你的代码运行得非常好。我刚刚用Blender 2.71验证过

然而,搅拌器中的旋转有一个小陷阱:搅拌器中有多种可能的旋转模式。修改euler角度不会产生效果,只要为特定对象激活了不同的旋转模式

您可以使用
rotation\u mode
成员强制执行右旋转模式(有关可能的旋转模式的完整列表,请参阅)。
在您的示例中,您可能希望使用xyz Euler角度:

origin.rotation_mode = 'XYZ' # Force using euler angles
以下是集成到您的示例中的变通方法:

import bpy
import math

cam = bpy.data.objects['Camera']
origin = bpy.data.objects['Suzanne']

step_count = 5
bpy.data.scenes["Scene"].cycles.samples=10

origin.rotation_mode = 'XYZ' # Force the right rotation mode

for step in range(0, step_count):
    r = math.pi * step * (360.0 / step_count) / 180.0
    print(r)
    origin.rotation_euler[2] = r
    fn = '/home/robert/mokey_%02d.jpg' % step
    print(fn)
    bpy.data.scenes["Scene"].render.filepath = fn
    bpy.ops.render.render( write_still=True )