I have a model that I want to change the texture of in-game. This is my script so far:
from Blender import Texture, Image, Material
# 1. Get material | 2. Get all textures:
male_material = Material.Get("male_material")
male_textures = male_material.getTextures()
# Name textures:
skin = male_textures[0]
pants = male_textures[1]
pants_tex = Texture.Get("Pants")
pants_tex.setType("Image")
pants_img = Image.Load("new_texture.png")
pants_tex.image = pants_img
#print male_material.MTex().mapto ... how to I set the "Map to" (UV, ORCO, DISP)?
male_material.setTexture(1, pants_tex)
The script does apply the new texture, but not before I’ve gone out and into the game again. (It sets the texture, but it doesn’t update it, like I want it to.)
Also, see the commented like (MTex thing). How do I do that?
I’ve been trying to solve this issue for a long time now, but with no luck. I really hope someone could help me.
this function (from the rasterizer) looks very interesting for your problem (i don`t know what it exacly does)
setMaterialSettings
or
setMaterialMode
and maybe in the poly proxy
My recommendation is to get an svn build of Blender and use the VideoTexture module. It is intended for, well, video textures, but it can also handle images. So, you can use it to change textures.