[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4605] [TextureAtlas] move to trunk the script! Yahoooo!!!!
paul geraskin
paul_geraskin at mail.ru
Tue Jun 25 21:09:25 CEST 2013
Revision: 4605
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4605
Author: mifth
Date: 2013-06-25 19:09:24 +0000 (Tue, 25 Jun 2013)
Log Message:
-----------
[TextureAtlas] move to trunk the script! Yahoooo!!!!
Added Paths:
-----------
trunk/py/scripts/addons/uv_texture_atlas.py
Removed Paths:
-------------
contrib/py/scripts/addons/uv_texture_atlas.py
Deleted: contrib/py/scripts/addons/uv_texture_atlas.py
===================================================================
--- contrib/py/scripts/addons/uv_texture_atlas.py 2013-06-25 16:34:14 UTC (rev 4604)
+++ contrib/py/scripts/addons/uv_texture_atlas.py 2013-06-25 19:09:24 UTC (rev 4605)
@@ -1,763 +0,0 @@
-# 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",
- "version": (0, 18),
- "blender": (2, 6, 6),
- "location": "Properties > Render",
- "description": "A simple Texture Atlas for unwrapping many objects. It creates additional UV",
- "wiki_url": "http://code.google.com/p/blender-addons-by-mifth/",
- "tracker_url": "http://code.google.com/p/blender-addons-by-mifth/issues/list",
- "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.groups[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.groups:
- return True
- else:
- if use_report:
- self.report({'INFO'}, "No Such Group %r!" % group.name)
- return False
-
-
-class TextureAtlas(Panel):
- bl_label = "Texture Atlas"
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "render"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- 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='ZOOMIN', text="")
- col.operator("scene.ms_del_lightmap_group", icon='ZOOMOUT', 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.prop(group, 'resolution', text='Resolution', expand=True)
- row = self.layout.row()
- row.prop(group, 'unwrap_type', text='Lightmap', expand=True)
- row = self.layout.row()
-
- 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")
- row = self.layout.row()
- row = self.layout.row()
- 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")
-
- row = self.layout.row()
- row.operator(
- "object.ms_auto", text="Auto Unwrap", icon="LAMP_SPOT")
- row = self.layout.row()
- row.operator(
- "object.ms_run", text="StartManualUnwrap", icon="LAMP_SPOT")
- row.operator(
- "object.ms_run_remove", text="FinshManualUnwrap", icon="LAMP_SPOT")
-
-
-class RunAuto(Operator):
- bl_idname = "object.ms_auto"
- bl_label = "Auto Unwrapping"
- bl_description = "Auto Unwrapping"
-
- def execute(self, context):
- scene = context.scene
- 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]
- context.area.type = 'VIEW_3D'
- if scene.objects.active is not None:
- bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
-
- if group.bake is True and bpy.data.groups[group.name].objects:
-
- # Check if objects are all on the visible Layers.
- isAllObjVisible = check_all_objects_visible(self, context)
-
- if isAllObjVisible is True:
- res = int(group.resolution)
- bpy.ops.object.ms_create_lightmap(
- group_name=group.name, resolution=res)
- 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!!!")
-
- context.area.type = old_context
-
- return{'FINISHED'}
-
-
-class 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
- # 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 scene.objects.active is not None:
- bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
-
- if group.bake is True and bpy.data.groups[group.name].objects and bpy.data.objects.get(group.name + "_mergedObject") is None:
-
- # Check if objects are all on the visible Layers.
- isAllObjVisible = check_all_objects_visible(self, context)
-
- if isAllObjVisible is True:
- res = int(group.resolution)
- bpy.ops.object.ms_create_lightmap(
- group_name=group.name, resolution=res)
- bpy.ops.object.ms_merge_objects(
- group_name=group.name, unwrap=False)
- else:
- self.report({'INFO'}, "Not All Objects Are Visible!!!")
-
- return{'FINISHED'}
-
-
-class RunFinish(Operator):
- bl_idname = "object.ms_run_remove"
- bl_label = "Remove Manual Unwrapping Object"
- bl_description = "Removes Manual Unwrapping Object"
-
- def execute(self, context):
- scene = context.scene
- 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]
- context.area.type = 'VIEW_3D'
-
- if scene.objects.active is not None:
- bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
-
- if group.bake is True and bpy.data.groups[group.name].objects:
-
- # Check if objects are all on the visible Layers.
- isAllObjVisible = check_all_objects_visible(self, context)
-
- if isAllObjVisible is True:
- bpy.ops.object.ms_separate_objects(group_name=group.name)
- else:
- self.report({'INFO'}, "Not All Objects Are Visible!!!")
-
- context.area.type = old_context
- return{'FINISHED'}
-
-
-class MSUVLayers(PropertyGroup):
- name = StringProperty(default="")
-
-
-class MSVertexGroups(PropertyGroup):
- name = StringProperty(default="")
-
-
-class MSGroups(PropertyGroup):
- name = StringProperty(default="")
-
-
-class MSLightmapGroups(PropertyGroup):
-
- name = StringProperty(default="")
- bake = BoolProperty(default=True)
-
- unwrap_type = EnumProperty(
- name="unwrap_type",
- items=(('0', 'Smart_Unwrap', 'Smart_Unwrap'),
- ('1', 'Lightmap', 'Lightmap'),
- ('2', 'No_Unwrap', 'No_Unwrap'),
- ),
- )
- resolution = EnumProperty(
- name="resolution",
- items=(('256', '256', ''),
- ('512', '512', ''),
- ('1024', '1024', ''),
- ('2048', '2048', ''),
- ('4096', '4096', ''),
- ('8192', '8192', ''),
- ('16384', '16384', ''),
- ),
- )
- template_list_controls = StringProperty(
- default="bake",
- options={"HIDDEN"},
- )
-
-
-class MSMergedObjects(PropertyGroup):
- name = StringProperty()
- vertex_groups = CollectionProperty(
- type=MSVertexGroups,
- )
- groups = CollectionProperty(type=MSGroups)
- uv_layers = CollectionProperty(type=MSUVLayers)
-
-
-class AddSelectedToGroup(Operator):
- bl_idname = "scene.ms_add_selected_to_group"
- bl_label = "Add to Group"
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list