问题
I need to set up an animated (i.e. from video file) world texture in blender 2.58 using python. I make a texture like this:
import bpy
# create new clouds texture
bpy.ops.texture.new()
wtex = bpy.data.textures[-1]
# set World texture
wrld = bpy.data.worlds['World']
slot = wrld.texture_slots.add()
slot.texture = wtex
slot.use_map_horizon = True
This creates a new CloudsTexture and binds it to slot. How can I make an ImageTexture and set it up to have a video as a source? Or, how can I specify the type of a new texture made by bpy.ops.texture.new()?
回答1:
For data addition/removal, its best not to use operators, we have api functions from bpy.data for this.
import bpy
# create new clouds texture
wtex = bpy.data.textures.new(name="MyTexture", type='IMAGE')
# set World texture
wrld = bpy.context.scene.world
if wrld:
slot = wrld.texture_slots.add()
slot.texture = wtex
slot.use_map_horizon = True
Tested with blender 2.58a
来源:https://stackoverflow.com/questions/6681039/blender-2-5-python-animated-world-texture-setup