[Bf-extensions-cvs] [b4f4f8b6] master: uv_texture_atlas/bake to vcols: moved to contrib: update class names: T63750

meta-androcto noreply at git.blender.org
Fri May 24 11:22:01 CEST 2019


Commit: b4f4f8b62f5b751813cf7b9b268fbc49fe9395a3
Author: meta-androcto
Date:   Fri May 24 19:21:36 2019 +1000
Branches: master
https://developer.blender.org/rBACb4f4f8b62f5b751813cf7b9b268fbc49fe9395a3

uv_texture_atlas/bake to vcols: moved to contrib: update class names: T63750

===================================================================

M	uv_bake_texture_to_vcols.py
A	uv_texture_atlas.py

===================================================================

diff --git a/uv_bake_texture_to_vcols.py b/uv_bake_texture_to_vcols.py
index 9a83c6dc..fe1337a1 100644
--- a/uv_bake_texture_to_vcols.py
+++ b/uv_bake_texture_to_vcols.py
@@ -35,7 +35,7 @@ bl_info = {
         "to a Vertex Color layer.",
     "author": "Patrick Boelens, CoDEmanX",
     "version": (0, 6),
-    "blender": (2, 63, 0),
+    "blender": (2, 79, 0),
     "location": "3D View > Vertex Paint > Toolshelf > Bake",
     "warning": "Requires image texture, generated textures aren't supported.",
     "wiki_url": "http://wiki.blender.org/index.php?title=Extensions:2.6/Py/"
@@ -329,7 +329,8 @@ class UV_OT_bake_texture_to_vcols(bpy.types.Operator):
 class VIEW3D_PT_tools_uv_bake_texture_to_vcols(bpy.types.Panel):
     bl_label = "Bake"
     bl_space_type = "VIEW_3D"
-    bl_region_type = "TOOLS"
+    bl_region_type = "UI"
+    bl_category = "Paint"
     bl_options = {'DEFAULT_CLOSED'}
 
     @classmethod
@@ -343,8 +344,15 @@ class VIEW3D_PT_tools_uv_bake_texture_to_vcols(bpy.types.Panel):
         col.separator()
         col.operator("uv.bake_texture_to_vcols", text="UV Texture to VCols")
 
+classes = (
+    UV_OT_bake_texture_to_vcols,
+    VIEW3D_PT_tools_uv_bake_texture_to_vcols
+)
+
 def register():
-    bpy.utils.register_module(__name__)
+    for cls in classes:
+        bpy.utils.register_class(cls)
+
     bpy.types.Scene.uv_bake_alpha_color = FloatVectorProperty(
         name="Alpha Color",
         description="Color to be used for transparency",
@@ -353,7 +361,8 @@ def register():
         max=1.0)
 
 def unregister():
-    bpy.utils.unregister_module(__name__)
+    for cls in classes:
+        bpy.utils.unregister_class(cls)
     del bpy.types.Scene.uv_bake_alpha_color
 
 if __name__ == "__main__":
diff --git a/uv_texture_atlas.py b/uv_texture_atlas.py
new file mode 100644
index 00000000..966b98ff
--- /dev/null
+++ b/uv_texture_atlas.py
@@ -0,0 +1,845 @@
+# 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": "Texture Atlas",
+    "author": "Andreas Esau, Paul Geraskin, Campbell Barton",
+    "version": (0, 2, 2),
+    "blender": (2, 79, 0),
+    "location": "Properties > Render",
+    "description": "A simple Texture Atlas for unwrapping many objects. It creates additional UV",
+    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+                "Scripts/UV/TextureAtlas",
+    "category": "UV",
+}
+
+import bpy
+from bpy.types import (
+        Operator,
+        Panel,
+        PropertyGroup,
+        )
+from bpy.props import (
+        BoolProperty,
+        CollectionProperty,
+        EnumProperty,
+        FloatProperty,
+        IntProperty,
+        StringProperty,
+        )
+import mathutils
+
+
+def check_all_objects_visible(self, context):
+    scene = context.scene
+    group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
+    isAllObjectsVisible = True
+    bpy.ops.object.select_all(action='DESELECT')
+    for thisObject in bpy.data.collections[group.name].objects:
+        isThisObjectVisible = False
+        # scene.objects.active = thisObject
+        for thisLayerNumb in range(20):
+            if thisObject.layers[thisLayerNumb] is True and scene.layers[thisLayerNumb] is True:
+                isThisObjectVisible = True
+                break
+        # If Object is on an invisible Layer
+        if isThisObjectVisible is False:
+            isAllObjectsVisible = False
+    return isAllObjectsVisible
+
+
+def check_group_exist(self, context, use_report=True):
+    scene = context.scene
+    group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
+
+    if group.name in bpy.data.collections:
+        return True
+    else:
+        if use_report:
+            self.report({'INFO'}, "No Such Group %r!" % group.name)
+        return False
+
+
+class TexAtl_Main(Panel):
+    bl_idname = "UVTEX_ATLAS_PT_main"
+    bl_label = "Texture Atlas"
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "render"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    def draw(self, context):
+        scene = context.scene
+        ob = context.object
+
+        col = self.layout.column()
+        row = self.layout.row()
+        split = self.layout.split()
+
+        row.template_list("UI_UL_list", "template_list_controls", scene,
+                          "ms_lightmap_groups", scene, "ms_lightmap_groups_index", rows=2, maxrows=5)
+        col = row.column(align=True)
+        col.operator("scene.ms_add_lightmap_group", icon='ADD', text="")
+        col.operator("scene.ms_del_lightmap_group", icon='REMOVE', text="")
+
+        row = self.layout.row(align=True)
+
+        # Resolution and Unwrap types (only if Lightmap group is added)
+        if context.scene.ms_lightmap_groups:
+            group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
+            row.label(text="Resolution:")
+            row.prop(group, 'resolutionX', text='')
+            row.prop(group, 'resolutionY', text='')
+            row = self.layout.row()
+            #self.layout.separator()
+
+            row = self.layout.row()
+            row.operator("scene.ms_remove_other_uv",
+                         text="RemoveOtherUVs", icon="GROUP")
+            row.operator("scene.ms_remove_selected",
+                         text="RemoveSelected", icon="GROUP")
+            #self.layout.separator()
+
+            row = self.layout.row()
+            row.operator("scene.ms_add_selected_to_group",
+                         text="AddSelected", icon="GROUP")
+            row.operator("scene.ms_select_group",
+                         text="SelectGroup", icon="GROUP")
+
+            #self.layout.separator()
+            self.layout.label(text="Auto Unwrap:")
+            self.layout.prop(group, 'unwrap_type', text='Lightmap', expand=True)
+            row = self.layout.row()
+            row.operator(
+                "object.ms_auto", text="Auto Unwrap", icon="LIGHT_SPOT")
+            row.prop(group, 'autoUnwrapPrecision', text='')
+
+            self.layout.label(text="Manual Unwrap:")
+            row = self.layout.row()
+            row.operator(
+                "object.ms_run", text="StartManualUnwrap", icon="LIGHT_SPOT")
+            row.operator(
+                "object.ms_run_remove", text="FinishManualUnwrap", icon="LIGHT_SPOT")
+
+
+class TexAtl_RunAuto(Operator):
+    bl_idname = "object.ms_auto"
+    bl_label = "Auto Unwrapping"
+    bl_description = "Auto Unwrapping"
+
+    def execute(self, context):
+        scene = context.scene
+
+        # get old context
+        old_context = None
+        if context.area:
+            old_context = context.area.type
+
+        # Check if group exists
+        if check_group_exist(self, context) is False:
+            return {'CANCELLED'}
+
+        group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
+        if context.area:
+            context.area.type = 'VIEW_3D'
+
+        if bpy.ops.object.mode_set.poll():
+            bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
+
+        if group.bake is True and bpy.data.collections[group.name].objects:
+
+            # Check if objects are all on the visible Layers.
+            isAllObjVisible = check_all_objects_visible(self, context)
+
+            if isAllObjVisible is True:
+                resX = int(group.resolutionX)
+                resY = int(group.resolutionY)
+                bpy.ops.object.ms_create_lightmap(
+                    group_name=group.name, resolutionX=resX, resolutionY=resY)
+                bpy.ops.object.ms_merge_objects(
+                    group_name=group.name, unwrap=True)
+                bpy.ops.object.ms_separate_objects(group_name=group.name)
+            else:
+                self.report({'INFO'}, "Not All Objects Are Visible!!!")
+
+        # set old context back
+        if context.area:
+            context.area.type = old_context
+
+        return{'FINISHED'}
+
+
+class TexAtl_RunStart(Operator):
+    bl_idname = "object.ms_run"
+    bl_label = "Make Manual Unwrapping Object"
+    bl_description = "Makes Manual Unwrapping Object"
+
+    def execute(self, context):
+        scene = context.scene
+
+        # get old context
+        old_context = None
+        if context.area:
+            old_context = context.area.type
+
+        # Check if group exists
+        if check_group_exist(self, context) is False:
+            return {'CANCELLED'}
+
+        if context.area:
+            context.area.type = 'VIEW_3D'
+        group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
+
+        if bpy.ops.object.mode_set.poll():
+            bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
+
+        if group.bake is True and bpy.data.collections[group.name].objects:
+
+            # Check if objects are all on the visible Layers.
+            isAllObjVisible = check_all_objects_visible(self, context)
+
+            if bpy.data.objects.get(group.name + "_mergedObject") is not None:
+                self.report({'INFO'}, "Old Merged Object Exists!!!")
+            elif isAllObjVisible is False:
+                self.report({'INFO'}, "Not All Objects Are Visible!!!")
+            else:
+                resX = int(group.resolutionX)
+                resY = int(group.resolutionY)
+                bpy.ops.object.ms_create_lightmap(
+                    group_name=group.name, resolutionX=resX, resolutionY=resY)
+                bpy.ops.object.ms_merge_objects(
+             

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list