# coding: utf-8
error_string = "Error: no image"
image_object_name = "UV_image"
image_size =(512,512)
paint_color =(1.0, 0.0, 0.0)
def draw_line(image_object,vec2_1,vec2_2,paint_color):
w=vec2_2[0] - vec2_1[0]; h=vec2_2[1] - vec2_1[1]
if w== 0:
for i in xrange(int(abs(h))):
x = int(vec2_1[0] ); y = int(vec2_1[1] + i*cmp(h,0))
image_object.image.set_pixel(x,y,paint_color)
elif abs(w) > abs(h) :
a = h/w
for i in xrange(int(abs(w))):
x = int(vec2_1[0] + i*cmp(w,0)); y = int(vec2_1[1] + i*a*cmp(w,0))
image_object.image.set_pixel(x,y,paint_color)
else:
a = w/h
for i in xrange(int(abs(h))):
x = int(vec2_1[0] + i*a*cmp(h,0)); y = int(vec2_1[1] + i*cmp(h,0))
image_object.image.set_pixel(x,y,paint_color)
scene = xshade.scene()
if scene.rendering.image:
image_object = scene.create_master_image(image_object_name)
image_object.image = xshade.create_image(image_size , 32)
else:
xshade.show_message_box(error_string, False)
for shape_ in xshade.scene().active_shapes:
for i in xrange(shape_.number_of_faces):
uv_list = shape_.face(i).distance_uv
for j in xrange(len(uv_list)):
vec2_1= (uv_list[j-1][0] * image_size[0] , uv_list[j-1][1] * image_size[1])
vec2_2= (uv_list[j][0] * image_size[0] , uv_list[j][1] * image_size[1])
draw_line(image_object,vec2_1,vec2_2,paint_color)
image_object.image.create_window()
投稿者 Yukimi` : 2008年5月 9日 03:57
|