我想寫一個非常基本的導出到攪拌機(從原始形狀)腳本。我必須在不同的角度和位置上繪製圓柱體。我有偏移位置和尺寸的信息。原始攪拌機出口商攪拌機python腳本
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軸旋轉]繪製圓柱體,我在哪裏出現嚴重錯誤?我如何糾正這一點。非常感謝你的幫助。
編輯:使用攪拌機版本2.60(python交互式控制檯3.2.2) 輸出顯示圓柱體,在(-1,0,0)。我希望/需要它是在(9,2,7)(位置+ offsetPosition)
你有錯誤? – 2012-01-11 12:40:45
請註明Blender版本,因爲在2.49攪拌器使用Python 3與不同的API – jsbueno 2012-01-11 12:53:12
添加了要求的詳細信息。 – chaitu 2012-01-11 14:59:09