I have a blender object , a chair specifically. Below is the image of the chair -
Now I use the following script to change the texture of one of the component -
def createMaterial(material):
tex = bpy.data.textures.new('ColorTex', type = 'IMAGE')
tex.image = bpy.data.images.load(realpath_of_image)
tex.use_alpha = True
# Create shadeless material and MTex
mat = bpy.data.materials.new('TexMat')
mat.use_shadeless = True
mtex = mat.texture_slots.add()
mtex.texture = tex
mtex.texture_coords = 'UV'
mtex.use_map_color_diffuse = True
return mat
def make_chnges(components, randomno):
ob = bpy.data.objects[0]
mat = createMaterial(material)
ob.data.materials.append(mat)
ob.active_material = mat
Now the output image that I get is -
As you can see the rendered texture looks like a flat surface. What changes should be there to show up a similar surface?
Edit 1
This is the blender screenshot of what I see when I add a new material to the polygon.
Here the object component looks allright(doesnt look like a flat surface), except that the new material doesnt show up. Just the white color is seen.
Edit 2
The material I am applying is -