[Bf-extensions-cvs] [d356c73] master: Cacharanth addon, by Pablo Vazquez.
Lukas Tönne
noreply at git.blender.org
Thu Feb 5 17:31:49 CET 2015
Commit: d356c7385ff2d379a62857f6fe306cd7704e4119
Author: Lukas Tönne
Date: Thu Feb 5 16:34:29 2015 +0100
Branches: master
https://developer.blender.org/rBACd356c7385ff2d379a62857f6fe306cd7704e4119
Cacharanth addon, by Pablo Vazquez.
This addon automates a workflow for using mesh caches to avoid linking
armatures, making proxies and the associated problems.
===================================================================
A cacharanth/__init__.py
A cacharanth/meshcache.py
A cacharanth/ui.py
A cacharanth/util.py
===================================================================
diff --git a/cacharanth/__init__.py b/cacharanth/__init__.py
new file mode 100644
index 0000000..6d9cb8d
--- /dev/null
+++ b/cacharanth/__init__.py
@@ -0,0 +1,45 @@
+### 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 #####
+
+# <pep8 compliant>
+
+bl_info = {
+ "name": "Cacharanth",
+ "author": "Pablo Vazquez, Lukas Toenne",
+ "version": (0, 2),
+ "blender": (2, 7, 3),
+ "location": "View3D > Cacharanth (Tab)",
+ "description": "Import and Export Caches",
+ "warning": "",
+ "wiki_url": "",
+ "category": "Import-Export",
+ }
+
+import bpy
+from cacharanth import ui, meshcache
+
+def register():
+ ui.register()
+ meshcache.register()
+
+def unregister():
+ ui.unregister()
+ meshcache.unregister()
+
+if __name__ == "__main__":
+ register()
diff --git a/cacharanth/meshcache.py b/cacharanth/meshcache.py
new file mode 100644
index 0000000..e12ec12
--- /dev/null
+++ b/cacharanth/meshcache.py
@@ -0,0 +1,202 @@
+### 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 #####
+
+# <pep8 compliant>
+
+import bpy
+from bpy.types import Operator
+from bpy.props import *
+
+
+def meshcache_export(context):
+
+ scene = context.scene
+ objects = []
+ howmany_exported = 0
+ howmany_excluded = 0
+
+ if scene.use_meshcache_exclude_names:
+ excluded = []
+
+ if scene.meshcache_exclude_names:
+ for ex in scene.meshcache_exclude_names:
+ if ex.name != '':
+ excluded.append(ex.name)
+
+ print("\n== Meshcache Export Start ==")
+
+ if scene.meshcache_apply_to == 'GROUP':
+ objects = bpy.data.groups[scene.meshcache_group].objects
+ else:
+ objects = bpy.context.selected_objects
+
+ for ob in objects:
+ if ob and ob.type == 'MESH':
+
+ is_excluded = False
+
+ if scene.use_meshcache_exclude_names:
+ for e in excluded:
+ if e in ob.name:
+ is_excluded = True
+
+ if is_excluded:
+ howmany_excluded += 1
+ print("** {0} - Excluded".format(ob.name))
+ else:
+ filename = scene.meshcache_folder + "/" + scene.meshcache_group + "_" + ob.name + ".cache.mdd"
+
+ if ob.modifiers:
+ for mo in ob.modifiers:
+ if mo.type == 'SUBSURF':
+ mo.show_viewport = False
+
+ context.scene.objects.active = ob
+
+ bpy.ops.export_shape.mdd(filepath=filename,
+ frame_start=scene.meshcache_frame_start,
+ frame_end=scene.meshcache_frame_end,
+ fps=scene.meshcache_frame_rate)
+ print("{0} - Exported".format(ob.name))
+ howmany_exported += 1
+
+ MESH_OP_MeshcacheExport.howmany_exported = howmany_exported
+ MESH_OP_MeshcacheExport.howmany_excluded = howmany_excluded
+
+ print("\n== Meshcache Export Finished ==")
+ print("== {0} Exported, {1} Excluded ==".format(
+ howmany_exported, howmany_excluded))
+
+
+def meshcache_import(context):
+
+ scene = context.scene
+ mc_mod_name = "MeshCacheAM"
+ objects = []
+ howmany_imported = 0
+ howmany_excluded = 0
+
+ import os.path
+
+ if scene.use_meshcache_exclude_names:
+ excluded = []
+
+ if scene.meshcache_exclude_names:
+ for ex in scene.meshcache_exclude_names:
+ if ex.name != '':
+ excluded.append(ex.name)
+
+ print("\n== Meshcache Import Start ==")
+
+ if scene.meshcache_apply_to == 'GROUP':
+ objects = bpy.data.groups[scene.meshcache_group].objects
+ else:
+ objects = bpy.context.selected_objects
+
+ for ob in objects:
+ if ob and ob.type == 'MESH':
+
+ is_excluded = False
+
+ if scene.use_meshcache_exclude_names:
+ for e in excluded:
+ if e in ob.name:
+ is_excluded = True
+
+ if is_excluded:
+ howmany_excluded += 1
+ print("** {0} - Excluded".format(ob.name))
+ else:
+ filename = scene.meshcache_folder + "/" + scene.meshcache_group + "_" + ob.name + ".cache.mdd"
+
+ if os.path.isfile(filename):
+ has_meshcache = False
+
+ if ob.modifiers:
+ for mo in ob.modifiers:
+ if mo.type == 'MESH_CACHE':
+ has_meshcache = True
+ mo.name = mc_mod_name
+
+ if not has_meshcache:
+ ob.modifiers.new(mc_mod_name, "MESH_CACHE")
+
+ ob.modifiers[mc_mod_name].filepath = filename
+ ob.modifiers[mc_mod_name].frame_start = scene.meshcache_frame_start
+
+ print("{0} - Imported".format(ob.name))
+ howmany_imported += 1
+ else:
+ print("! No Meshcache found for {0}".format(ob.name))
+
+
+ MESH_OP_MeshcacheImport.howmany_imported = howmany_imported
+ MESH_OP_MeshcacheImport.howmany_excluded = howmany_excluded
+
+ print("\n== Meshcache Import Finished ==")
+ print("== {0} Imported, {1} Excluded ==".format(
+ howmany_imported, howmany_excluded))
+
+
+class MESH_OP_MeshcacheExport(Operator):
+ """Export Meshcache"""
+ bl_idname = "object.meshcache_export"
+ bl_label = "Export Mesh Cache"
+ howmany_exported = 0
+ howmany_excluded = 0
+
+ @classmethod
+ def poll(cls, context):
+ if context.scene.meshcache_apply_to == 'GROUP':
+ return len(bpy.data.groups) != 0
+ else:
+ return context.active_object is not None
+
+ def execute(self, context):
+ meshcache_export(context)
+ self.report({'INFO'}, "Meshcache Exported")
+ return {'FINISHED'}
+
+
+class MESH_OP_MeshcacheImport(Operator):
+ """Import Meshcache (creates Meshcache modifiers when necessary)"""
+ bl_idname = "object.meshcache_import"
+ bl_label = "Import Mesh Cache"
+ howmany_imported = 0
+ howmany_excluded = 0
+
+ @classmethod
+ def poll(cls, context):
+ if context.scene.meshcache_apply_to == 'GROUP':
+ return len(bpy.data.groups) != 0
+ else:
+ return context.active_object is not None
+
+ def execute(self, context):
+ meshcache_import(context)
+ self.report({'INFO'}, "Meshcache Imported")
+ return {'FINISHED'}
+
+
+def register():
+ bpy.utils.register_class(MESH_OP_MeshcacheExport)
+ bpy.utils.register_class(MESH_OP_MeshcacheImport)
+
+def unregister():
+ bpy.utils.unregister_class(MESH_OP_MeshcacheExport)
+ bpy.utils.unregister_class(MESH_OP_MeshcacheImport)
diff --git a/cacharanth/ui.py b/cacharanth/ui.py
new file mode 100644
index 0000000..276fa75
--- /dev/null
+++ b/cacharanth/ui.py
@@ -0,0 +1,253 @@
+### 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 #####
+
+# <pep8 compliant>
+
+import bpy, os
+from bpy.types import Operator, Panel, UIList
+from bpy.props import *
+from bpy_extras.io_utils import ImportHelper
+
+from cacharanth import meshcache
+from cacharanth.meshcache import MESH_OP_MeshcacheExport, MESH_OP_MeshcacheImport
+
+
+class MESH_OP_MeshcacheRefresh(Operator):
+ """Refresh"""
+ bl_idname = "scene.meshcache_refresh"
+ bl_label = "Refresh"
+
+ def execute(self, context):
+ context.scene.frame_current = context.scene.frame_current
+ return {'FINISHED'}
+
+
+class CACHARANTH_GroupSelect(Operator):
+ bl_idname = "cacharanth.group_select"
+ bl_label = "Select Group"
+ bl_description = "Switch to another material in this mesh"
+
+ def avail_groups(self,context):
+ items = [(str(i),x.name,x.name, "GROUP", i) for i,x in enumerate(bpy.data.groups)]
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list