【发布时间】:2012-02-07 19:29:25
【问题描述】:
我正在尝试编写一个非常基本的导出到搅拌机(从原始形状)脚本。我必须以不同的角度和位置绘制圆柱体。我有偏移位置和尺寸的信息。
import bpy
import bgl
from mathutils import *
from math import *
material = bpy.data.materials.new('red')
material.diffuse_color = (1.0,0.0,0.0)
def draw_cylinder(name,material,radius,depth,location,rotation,offsetPosition,offsetAngle):
bgl.glRotatef(*offsetAngle[:4])
bgl.glTranslatef(*offsetPosition[:3])
bpy.ops.mesh.primitive_cylinder_add(radius=radius, depth=depth, location=location, rotation=rotation)
Cylinder = bpy.context.active_object
Cylinder.name = name
Cylinder.active_material = material
bgl.glTranslatef(*[i*-1 for i in offsetPosition[:3]])
bgl.glRotatef(*[i*-1 for i in offsetAngle[:4]])
return Cylinder
cmpt = draw_cylinder('first',material,radius=1,depth=2,location=(-1,0,0),rotation=(pi/2,0,0),offsetPosition=(10,2,7),offsetAngle=(pi/2,0,1,0))
这不会在 (9,2,7) 处绘制圆柱体 [也不会沿 y 轴旋转] 我哪里错了?我该如何纠正这个。非常感谢您的帮助。
编辑:使用 Blender 2.60 版(python 交互式控制台 3.2.2) 输出显示圆柱体,位于 (-1,0,0)。我希望/需要它在 (9,2,7) (location+offsetPosition)
【问题讨论】:
-
请说明 Blender 版本,因为 2.49 之后的 Blender 使用 Python 3 和不同的 API
-
添加了询问的详细信息。