OSDN Git Service

implement createMaterials.
[meshio/meshio.git] / swig / blender / bl25.py
1 import bpy
2 import os
3
4 def createEmptyObject(scene, name):
5     empty=bpy.data.objects.new(name, None)
6     scene.objects.link(empty)
7     return empty
8
9 def createMaterial(m):
10     material = bpy.data.materials.new(m.getName())
11     material.diffuse_color=[m.color.r, m.color.g, m.color.b]
12     material.alpha=m.color.a
13     material.diffuse_intensity=m.diffuse
14     # temporary
15     material.emit=1.0
16     return material
17
18 def createTexture(path):
19     texture=bpy.data.textures.new(os.path.basename(path))
20     texture.type='IMAGE'
21     texture=texture.recast_type()
22     image=bpy.data.images.load(path)
23     texture.image=image
24     texture.mipmap = True
25     texture.interpolation = True
26     texture.use_alpha = True
27     return texture, image
28
29 def materialAddTexture(material, texture):
30     #material.add_texture(texture, "UV", {"COLOR", "ALPHA"})
31     material.add_texture(texture, "UV", "COLOR")
32