# ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### bl_info = { "name": "ImageChanger", "author": "Dalai Felinto (dfelinto)", "version": (1,0), "blender": (2, 5, 9), "api": 39000, "location": "Properties > Texture", "description": "Change your texture everyframe", "wiki_url": "", "tracker_url": "", "category": "Texture"} # ######################################################## # Image Changer # (note barely based in an old script, completely remodernized to Blender 2.5) # # Dalai Felinto (dfelinto) # www.dalaifelinto.com # # Rio de Janeiro - Brasil # Vancouver - Canada # ######################################################## import bpy import os class DATA_PT_image_changer(bpy.types.Panel): bl_label = "Image Changer" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "texture" @classmethod def poll(cls, context): if context.texture.type != 'IMAGE': return False return True def draw(self, context): layout = self.layout layout.prop(context.texture, "image_hash") layout.prop(context.texture, "image_slide") def slideUpdate(self, context): # extract properties from the texture object image_hash = self.image_hash image_slide = self.image_slide imageChanger(self, image_slide, image_hash) def imageChanger(texture, image_slide, image_hash): """""" VERBOSE = False if texture.type != 'IMAGE': return image = texture.image basedir = os.path.dirname(image.filepath) filename = image_hash % image_slide filepath = os.path.join(basedir, filename) image.filepath = filepath # image automatically reloaded def register(): bpy.types.Texture.image_hash = bpy.props.StringProperty( name="Hash", default="%03d.png", description="String formatting for the filename. Use python notation (e.g. \"img-%03d.png\" will be \"img-003.png\" or \"img-9999.png\")", update=slideUpdate) bpy.types.Texture.image_slide = bpy.props.IntProperty( name="Slide", min=0, subtype='UNSIGNED', description="Slide number to use in this frame", update=slideUpdate) bpy.utils.register_module(__name__) def unregister(): del bpy.types.Texture.image_hash del bpy.types.Texture.image_slide bpy.utils.unregister_module(__name__) if __name__ == "__main__": register()