views:

44

answers:

0

Hello,

I'm trying to set a background World Texture in Blender 2.49.

I've made a texture:

import Blender 
from Blender import * 
import bpy 

world = World.GetCurrent() 
worldTex = Texture.New('worldTex') 
worldTex.setType('Image') 
worldIm = Image.Load('//blender_scene/tex/bg 001.jpg') 
worldIm.source = Image.Sources.SEQUENCE 
worldTex.setImage(worldIm)

When I try to apply to the world, that will throw and error, because, by default world.textures contains a tuple of None. so this wouldn't work:

world.textures[0].tex = worldTex

I've made a material so I can get an MTex instance:

worldMat = Material.New('WorldMat')
worldMat.setTexture(worldTex)

If I try to set the first texture:

world.textures[0] = worldMat.textures[0]

That will throw an error, since I can't assign a value to an already initialized tuple.

If I try to replace it:

world.textures = worldMat.textures

I get yet another error:

TypeError: expected tuple or list containing world MTex objects and NONE

'world MTex objects' got me thinking a bit. Is there another kind of MTex object ? a world MTex ? Where is it defined, how can I create an instance ?

Or as the title states...how do I set a texture to a world ?

Thanks