Fix Print3D Toolbox: fix button alignment
[blender-addons.git] / uv_texture_atlas.py
blob9283840238ab664520d81cf5dc102976146ae990
1 # BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # END GPL LICENSE BLOCK #####
20 bl_info = {
21 "name": "Texture Atlas",
22 "author": "Andreas Esau, Paul Geraskin, Campbell Barton",
23 "version": (0, 2, 0),
24 "blender": (2, 67, 0),
25 "location": "Properties > Render",
26 "description": "A simple Texture Atlas for unwrapping many objects. It creates additional UV",
27 "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/UV/TextureAtlas",
28 "tracker_url": "http://projects.blender.org/scm/viewvc.php/trunk/py/scripts/addons/uv_texture_atlas.py?view=log&root=bf-extensions",
29 "category": "UV"}
31 import bpy
32 from bpy.types import (Operator,
33 Panel,
34 PropertyGroup,
37 from bpy.props import (BoolProperty,
38 CollectionProperty,
39 EnumProperty,
40 FloatProperty,
41 IntProperty,
42 StringProperty,
44 import mathutils
47 def check_all_objects_visible(self, context):
48 scene = context.scene
49 group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
50 isAllObjectsVisible = True
51 bpy.ops.object.select_all(action='DESELECT')
52 for thisObject in bpy.data.groups[group.name].objects:
53 isThisObjectVisible = False
54 # scene.objects.active = thisObject
55 for thisLayerNumb in range(20):
56 if thisObject.layers[thisLayerNumb] is True and scene.layers[thisLayerNumb] is True:
57 isThisObjectVisible = True
58 break
59 # If Object is on an invisible Layer
60 if isThisObjectVisible is False:
61 isAllObjectsVisible = False
62 return isAllObjectsVisible
65 def check_group_exist(self, context, use_report=True):
66 scene = context.scene
67 group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
69 if group.name in bpy.data.groups:
70 return True
71 else:
72 if use_report:
73 self.report({'INFO'}, "No Such Group %r!" % group.name)
74 return False
77 class TextureAtlas(Panel):
78 bl_label = "Texture Atlas"
79 bl_space_type = 'PROPERTIES'
80 bl_region_type = 'WINDOW'
81 bl_context = "render"
82 COMPAT_ENGINES = {'BLENDER_RENDER'}
84 def draw(self, context):
85 scene = context.scene
86 ob = context.object
88 col = self.layout.column()
89 row = self.layout.row()
90 split = self.layout.split()
92 row.template_list("UI_UL_list", "template_list_controls", scene,
93 "ms_lightmap_groups", scene, "ms_lightmap_groups_index", rows=2, maxrows=5)
94 col = row.column(align=True)
95 col.operator("scene.ms_add_lightmap_group", icon='ZOOMIN', text="")
96 col.operator("scene.ms_del_lightmap_group", icon='ZOOMOUT', text="")
98 row = self.layout.row(align=True)
100 # Resolution and Unwrap types (only if Lightmap group is added)
101 if context.scene.ms_lightmap_groups:
102 group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
103 row.prop(group, 'resolution', text='Resolution', expand=True)
104 row = self.layout.row()
105 row.prop(group, 'unwrap_type', text='Lightmap', expand=True)
106 row = self.layout.row()
108 row = self.layout.row()
109 row.operator("scene.ms_remove_other_uv",
110 text="RemoveOtherUVs", icon="GROUP")
111 row.operator("scene.ms_remove_selected",
112 text="RemoveSelected", icon="GROUP")
113 row = self.layout.row()
114 row = self.layout.row()
115 row = self.layout.row()
116 row.operator("scene.ms_add_selected_to_group",
117 text="AddSelected", icon="GROUP")
118 row.operator("scene.ms_select_group",
119 text="SelectGroup", icon="GROUP")
121 row = self.layout.row()
122 row.operator(
123 "object.ms_auto", text="Auto Unwrap", icon="LAMP_SPOT")
124 row = self.layout.row()
125 row.operator(
126 "object.ms_run", text="StartManualUnwrap", icon="LAMP_SPOT")
127 row.operator(
128 "object.ms_run_remove", text="FinshManualUnwrap", icon="LAMP_SPOT")
131 class RunAuto(Operator):
132 bl_idname = "object.ms_auto"
133 bl_label = "Auto Unwrapping"
134 bl_description = "Auto Unwrapping"
136 def execute(self, context):
137 scene = context.scene
138 old_context = context.area.type
140 # Check if group exists
141 if check_group_exist(self, context) is False:
142 return {'CANCELLED'}
144 group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
145 context.area.type = 'VIEW_3D'
147 if bpy.ops.object.mode_set.poll():
148 bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
150 if group.bake is True and bpy.data.groups[group.name].objects:
152 # Check if objects are all on the visible Layers.
153 isAllObjVisible = check_all_objects_visible(self, context)
155 if isAllObjVisible is True:
156 res = int(group.resolution)
157 bpy.ops.object.ms_create_lightmap(
158 group_name=group.name, resolution=res)
159 bpy.ops.object.ms_merge_objects(
160 group_name=group.name, unwrap=True)
161 bpy.ops.object.ms_separate_objects(group_name=group.name)
162 else:
163 self.report({'INFO'}, "Not All Objects Are Visible!!!")
165 context.area.type = old_context
167 return{'FINISHED'}
170 class RunStart(Operator):
171 bl_idname = "object.ms_run"
172 bl_label = "Make Manual Unwrapping Object"
173 bl_description = "Makes Manual Unwrapping Object"
175 def execute(self, context):
176 scene = context.scene
177 old_context = context.area.type
179 # Check if group exists
180 if check_group_exist(self, context) is False:
181 return {'CANCELLED'}
183 context.area.type = 'VIEW_3D'
184 group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
186 if bpy.ops.object.mode_set.poll():
187 bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
189 if group.bake is True and bpy.data.groups[group.name].objects and bpy.data.objects.get(group.name + "_mergedObject") is None:
191 # Check if objects are all on the visible Layers.
192 isAllObjVisible = check_all_objects_visible(self, context)
194 if isAllObjVisible is True:
195 res = int(group.resolution)
196 bpy.ops.object.ms_create_lightmap(
197 group_name=group.name, resolution=res)
198 bpy.ops.object.ms_merge_objects(
199 group_name=group.name, unwrap=False)
200 else:
201 self.report({'INFO'}, "Not All Objects Are Visible!!!")
203 context.area.type = old_context
205 return{'FINISHED'}
208 class RunFinish(Operator):
209 bl_idname = "object.ms_run_remove"
210 bl_label = "Remove Manual Unwrapping Object"
211 bl_description = "Removes Manual Unwrapping Object"
213 def execute(self, context):
214 scene = context.scene
215 old_context = context.area.type
217 # Check if group exists
218 if check_group_exist(self, context) is False:
219 return {'CANCELLED'}
221 group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
222 context.area.type = 'VIEW_3D'
224 if bpy.ops.object.mode_set.poll():
225 bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
227 if group.bake is True and bpy.data.groups[group.name].objects:
229 # Check if objects are all on the visible Layers.
230 isAllObjVisible = check_all_objects_visible(self, context)
232 if isAllObjVisible is True:
233 bpy.ops.object.ms_separate_objects(group_name=group.name)
234 else:
235 self.report({'INFO'}, "Not All Objects Are Visible!!!")
237 context.area.type = old_context
238 return{'FINISHED'}
241 class MSUVLayers(PropertyGroup):
242 name = StringProperty(default="")
245 class MSVertexGroups(PropertyGroup):
246 name = StringProperty(default="")
249 class MSGroups(PropertyGroup):
250 name = StringProperty(default="")
253 class MSLightmapGroups(PropertyGroup):
255 name = StringProperty(default="")
256 bake = BoolProperty(default=True)
258 unwrap_type = EnumProperty(
259 name="unwrap_type",
260 items=(('0', 'Smart_Unwrap', 'Smart_Unwrap'),
261 ('1', 'Lightmap', 'Lightmap'),
262 ('2', 'No_Unwrap', 'No_Unwrap'),
265 resolution = EnumProperty(
266 name="resolution",
267 items=(('256', '256', ''),
268 ('512', '512', ''),
269 ('1024', '1024', ''),
270 ('2048', '2048', ''),
271 ('4096', '4096', ''),
272 ('8192', '8192', ''),
273 ('16384', '16384', ''),
276 template_list_controls = StringProperty(
277 default="bake",
278 options={"HIDDEN"},
282 class MSMergedObjects(PropertyGroup):
283 name = StringProperty()
284 vertex_groups = CollectionProperty(
285 type=MSVertexGroups,
287 groups = CollectionProperty(type=MSGroups)
288 uv_layers = CollectionProperty(type=MSUVLayers)
291 class AddSelectedToGroup(Operator):
292 bl_idname = "scene.ms_add_selected_to_group"
293 bl_label = "Add to Group"
294 bl_description = "Adds selected Objects to current Group"
296 def execute(self, context):
297 scene = context.scene
298 group_name = scene.ms_lightmap_groups[
299 scene.ms_lightmap_groups_index].name
301 # Create a New Group if it was deleted.
302 obj_group = bpy.data.groups.get(group_name)
303 if obj_group is None:
304 obj_group = bpy.data.groups.new(group_name)
306 # Add objects to a group
307 if bpy.ops.object.mode_set.poll():
308 bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
310 for object in context.selected_objects:
311 if object.type == 'MESH' and object.name not in obj_group.objects:
312 obj_group.objects.link(object)
314 return {'FINISHED'}
317 class SelectGroup(Operator):
318 bl_idname = "scene.ms_select_group"
319 bl_label = "sel Group"
320 bl_description = "Selected Objects of current Group"
322 def execute(self, context):
323 scene = context.scene
324 group_name = scene.ms_lightmap_groups[
325 scene.ms_lightmap_groups_index].name
327 # Check if group exists
328 if check_group_exist(self, context) is False:
329 return {'CANCELLED'}
331 if bpy.ops.object.mode_set.poll():
332 bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
334 bpy.ops.object.select_all(action='DESELECT')
335 obj_group = bpy.data.groups[group_name]
336 for object in obj_group.objects:
337 object.select = True
338 return {'FINISHED'}
341 class RemoveFromGroup(Operator):
342 bl_idname = "scene.ms_remove_selected"
343 bl_label = "del Selected"
344 bl_description = "Remove Selected Group and UVs"
346 # remove all modifiers
347 # for m in mesh.modifiers:
348 # bpy.ops.object.modifier_remove(modifier=m.name)
350 def execute(self, context):
351 scene = context.scene
353 # Check if group exists
354 if check_group_exist(self, context) is False:
355 return {'CANCELLED'}
357 if bpy.ops.object.mode_set.poll():
358 bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
360 for group in scene.ms_lightmap_groups:
361 group_name = group.name
363 obj_group = bpy.data.groups[group_name]
364 for object in context.selected_objects:
365 scene.objects.active = object
367 if object.type == 'MESH' and object.name in obj_group.objects:
369 # remove UV
370 tex = object.data.uv_textures.get(group_name)
371 if tex is not None:
372 object.data.uv_textures.remove(tex)
374 # remove from group
375 obj_group.objects.unlink(object)
376 object.hide_render = False
378 return {'FINISHED'}
381 class RemoveOtherUVs(Operator):
382 bl_idname = "scene.ms_remove_other_uv"
383 bl_label = "remOther"
384 bl_description = "Remove Other UVs from Selected"
386 def execute(self, context):
387 scene = context.scene
388 group_name = scene.ms_lightmap_groups[
389 scene.ms_lightmap_groups_index].name
391 # Check if group exists
392 if check_group_exist(self, context) is False:
393 return {'CANCELLED'}
395 if bpy.ops.object.mode_set.poll():
396 bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
397 # bpy.ops.object.select_all(action='DESELECT')
399 obj_group = bpy.data.groups[group_name]
401 # Remove other UVs of selected objects
402 for object in context.selected_objects:
403 scene.objects.active = object
404 if object.type == 'MESH' and object.name in obj_group.objects:
406 # remove UVs
407 UVLIST = []
408 for uv in object.data.uv_textures:
409 if uv.name != group_name:
410 UVLIST.append(uv.name)
412 for uvName in UVLIST:
413 tex = object.data.uv_textures[uvName]
414 object.data.uv_textures.remove(tex)
416 UVLIST.clear() # clear array
418 return {'FINISHED'}
421 class AddLightmapGroup(Operator):
422 bl_idname = "scene.ms_add_lightmap_group"
423 bl_label = "add Lightmap"
424 bl_description = "Adds a new Lightmap Group"
426 name = StringProperty(name="Group Name", default='TextureAtlas')
428 def execute(self, context):
429 scene = context.scene
430 obj_group = bpy.data.groups.new(self.name)
432 item = scene.ms_lightmap_groups.add()
433 item.name = obj_group.name
434 item.resolution = '1024'
435 scene.ms_lightmap_groups_index = len(scene.ms_lightmap_groups) - 1
437 # Add selested objects to group
438 for object in context.selected_objects:
439 if object.type == 'MESH':
440 obj_group.objects.link(object)
442 return {'FINISHED'}
444 def invoke(self, context, event):
445 wm = context.window_manager
446 return wm.invoke_props_dialog(self)
449 class DelLightmapGroup(Operator):
450 bl_idname = "scene.ms_del_lightmap_group"
451 bl_label = "delete Lightmap"
452 bl_description = "Deletes active Lightmap Group"
454 def execute(self, context):
455 scene = context.scene
456 if len(scene.ms_lightmap_groups) > 0:
457 idx = scene.ms_lightmap_groups_index
458 group_name = scene.ms_lightmap_groups[idx].name
460 # Remove Group
461 group = bpy.data.groups.get(group_name)
462 if group is not None:
464 # Unhide Objects if they are hidden
465 for obj in group.objects:
466 obj.hide_render = False
467 obj.hide = False
469 bpy.data.groups.remove(group)
471 # Remove Lightmap Group
472 scene.ms_lightmap_groups.remove(scene.ms_lightmap_groups_index)
473 scene.ms_lightmap_groups_index -= 1
474 if scene.ms_lightmap_groups_index < 0:
475 scene.ms_lightmap_groups_index = 0
477 return {'FINISHED'}
480 class CreateLightmap(Operator):
481 bl_idname = "object.ms_create_lightmap"
482 bl_label = "TextureAtlas - Generate Lightmap"
483 bl_description = "Generates a Lightmap"
485 group_name = StringProperty(default='')
486 resolution = IntProperty(default=1024)
488 def execute(self, context):
489 scene = context.scene
491 # Create/Update Image
492 image = bpy.data.images.get(self.group_name)
493 if image is None:
494 image = bpy.data.images.new(
495 name=self.group_name, width=self.resolution, height=self.resolution)
497 image.generated_type = 'COLOR_GRID'
498 image.generated_width = self.resolution
499 image.generated_height = self.resolution
500 obj_group = bpy.data.groups[self.group_name]
502 # non MESH objects for removal list
503 NON_MESH_LIST = []
505 for object in obj_group.objects:
506 # Remove non MESH objects
508 if object.type != 'MESH':
509 NON_MESH_LIST.append(object)
510 elif object.type == 'MESH' and len(object.data.vertices) == 0:
511 NON_MESH_LIST.append(object)
512 else:
513 # Add Image to faces
514 if object.data.uv_textures.active is None:
515 tex = object.data.uv_textures.new()
516 tex.name = self.group_name
517 else:
518 if self.group_name not in object.data.uv_textures:
519 tex = object.data.uv_textures.new()
520 tex.name = self.group_name
521 tex.active = True
522 tex.active_render = True
523 else:
524 tex = object.data.uv_textures[self.group_name]
525 tex.active = True
526 tex.active_render = True
528 for face_tex in tex.data:
529 face_tex.image = image
531 # remove non NESH objects
532 for object in NON_MESH_LIST:
533 obj_group.objects.unlink(object)
535 NON_MESH_LIST.clear() # clear array
537 return{'FINISHED'}
540 class MergeObjects(Operator):
541 bl_idname = "object.ms_merge_objects"
542 bl_label = "TextureAtlas - MergeObjects"
543 bl_description = "Merges Objects and stores Origins"
545 group_name = StringProperty(default='')
546 unwrap = BoolProperty(default=False)
548 def execute(self, context):
549 scene = context.scene
551 # objToDelete = None
552 bpy.ops.object.select_all(action='DESELECT')
553 for obj in scene.objects:
554 if obj.name == self.group_name + "_mergedObject":
555 obj.select = True
556 scene.objects.active = obj
557 bpy.ops.object.delete(use_global=False)
559 me = bpy.data.meshes.new(self.group_name + '_mergedObject')
560 ob_merge = bpy.data.objects.new(self.group_name + '_mergedObject', me)
561 ob_merge.location = scene.cursor_location # position object at 3d-cursor
562 scene.objects.link(ob_merge) # Link object to scene
563 me.update()
564 ob_merge.select = False
566 bpy.ops.object.select_all(action='DESELECT')
568 for object in bpy.data.groups[self.group_name].objects:
570 # make object temporary unhidden
571 isObjHideSelect = object.hide_select
572 object.hide = False
573 object.hide_select = False
575 bpy.ops.object.select_all(action='DESELECT')
576 object.select = True
578 # activate lightmap uv if existant
579 for uv in object.data.uv_textures:
580 if uv.name == self.group_name:
581 uv.active = True
582 scene.objects.active = object
584 # Duplicate Temp Object
585 bpy.ops.object.select_all(action='DESELECT')
586 object.select = True
587 scene.objects.active = object
588 bpy.ops.object.duplicate(linked=False, mode='TRANSLATION')
589 activeNowObject = scene.objects.active
590 activeNowObject.select = True
592 # hide render of original mesh
593 object.hide_render = True
594 object.hide = True
595 object.select = False
596 object.hide_select = isObjHideSelect
598 # remove unused UV
599 # remove UVs
600 UVLIST = []
601 for uv in activeNowObject.data.uv_textures:
602 if uv.name != self.group_name:
603 UVLIST.append(uv.name)
605 for uvName in UVLIST:
606 tex = activeNowObject.data.uv_textures[uvName]
607 activeNowObject.data.uv_textures.remove(tex)
609 UVLIST.clear() # clear array
611 # create vertex groups for each selected object
612 scene.objects.active = activeNowObject
613 vgroup = activeNowObject.vertex_groups.new(name=object.name)
614 vgroup.add(
615 list(range(len(activeNowObject.data.vertices))), weight=1.0, type='ADD')
617 # save object name and object location in merged object
618 item = ob_merge.ms_merged_objects.add()
619 item.name = object.name
621 # Add material to a tempObject if there are no materialSlots on the object
622 if not activeNowObject.data.materials:
623 matName = "zz_TextureAtlas_NO_Material"
624 mat = bpy.data.materials.get(matName)
626 if mat is None:
627 mat = bpy.data.materials.new(matName)
629 activeNowObject.data.materials.append(mat)
631 # merge objects together
632 bpy.ops.object.select_all(action='DESELECT')
633 activeNowObject.select = True
634 ob_merge.select = True
635 scene.objects.active = ob_merge
636 bpy.ops.object.join()
638 # make Unwrap
639 bpy.ops.object.select_all(action='DESELECT')
640 ob_merge.select = True
641 scene.objects.active = ob_merge
643 if self.unwrap is True:
644 unwrapType = scene.ms_lightmap_groups[self.group_name].unwrap_type
646 if unwrapType == '0' or unwrapType == '1':
647 bpy.ops.object.mode_set(mode='EDIT')
648 bpy.ops.mesh.reveal()
649 bpy.ops.mesh.select_all(action='SELECT')
651 if unwrapType == '0':
652 bpy.ops.uv.smart_project(
653 angle_limit=72.0, island_margin=0.2, user_area_weight=0.0)
654 elif unwrapType == '1':
655 bpy.ops.uv.lightmap_pack(
656 PREF_CONTEXT='ALL_FACES', PREF_PACK_IN_ONE=True, PREF_NEW_UVLAYER=False,
657 PREF_APPLY_IMAGE=False, PREF_IMG_PX_SIZE=1024, PREF_BOX_DIV=48, PREF_MARGIN_DIV=0.2)
658 bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
660 return{'FINISHED'}
663 class SeparateObjects(Operator):
664 bl_idname = "object.ms_separate_objects"
665 bl_label = "TextureAtlas - Separate Objects"
666 bl_description = "Separates Objects and restores Origin"
668 group_name = StringProperty(default='')
670 def execute(self, context):
671 scene = context.scene
673 for obj in scene.objects:
674 if obj.name == self.group_name + "_mergedObject":
676 # if scene.objects.active is not None:
677 # bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
678 bpy.ops.object.select_all(action='DESELECT')
679 ob_merged = obj
680 obj.hide = False
681 ob_merged.select = True
682 groupSeparate = bpy.data.groups.new(ob_merged.name)
683 groupSeparate.objects.link(ob_merged)
684 ob_merged.select = False
686 for ms_obj in ob_merged.ms_merged_objects:
687 # select vertex groups and separate group from merged
688 # object
689 bpy.ops.object.select_all(action='DESELECT')
690 ob_merged.select = True
691 scene.objects.active = ob_merged
693 bpy.ops.object.mode_set(mode='EDIT')
694 bpy.ops.mesh.reveal()
695 bpy.ops.mesh.select_all(action='DESELECT')
696 ob_merged.vertex_groups.active_index = ob_merged.vertex_groups[
697 ms_obj.name].index
698 bpy.ops.object.vertex_group_select()
699 bpy.ops.mesh.separate(type='SELECTED')
700 bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
701 # scene.objects.active.select = False
703 # find separeted object
704 ob_separeted = None
705 for obj in groupSeparate.objects:
706 if obj != ob_merged:
707 ob_separeted = obj
708 break
710 # Copy UV Coordinates to the original mesh
711 if ms_obj.name in scene.objects:
712 ob_merged.select = False
713 ob_original = scene.objects[ms_obj.name]
714 isOriginalToSelect = ob_original.hide_select
715 ob_original.hide_select = False
716 ob_original.hide = False
717 ob_original.select = True
718 scene.objects.active = ob_separeted
719 bpy.ops.object.join_uvs()
720 ob_original.hide_render = False
721 ob_original.select = False
722 ob_original.hide_select = isOriginalToSelect
724 # delete separeted object
725 bpy.ops.object.select_all(action='DESELECT')
726 ob_separeted.select = True
727 bpy.ops.object.delete(use_global=False)
729 # delete duplicated object
730 bpy.ops.object.select_all(action='DESELECT')
731 ob_merged.select = True
732 bpy.ops.object.delete(use_global=False)
734 return{'FINISHED'}
737 def register():
738 bpy.utils.register_class(TextureAtlas)
740 bpy.utils.register_class(AddLightmapGroup)
741 bpy.utils.register_class(DelLightmapGroup)
742 bpy.utils.register_class(AddSelectedToGroup)
743 bpy.utils.register_class(SelectGroup)
744 bpy.utils.register_class(RemoveFromGroup)
745 bpy.utils.register_class(RemoveOtherUVs)
747 bpy.utils.register_class(RunAuto)
748 bpy.utils.register_class(RunStart)
749 bpy.utils.register_class(RunFinish)
750 bpy.utils.register_class(MergeObjects)
751 bpy.utils.register_class(SeparateObjects)
752 bpy.utils.register_class(CreateLightmap)
754 # types
755 bpy.utils.register_class(MSUVLayers)
756 bpy.utils.register_class(MSVertexGroups)
757 bpy.utils.register_class(MSGroups)
759 bpy.utils.register_class(MSMergedObjects)
760 bpy.types.Object.ms_merged_objects = CollectionProperty(
761 type=MSMergedObjects)
763 bpy.utils.register_class(MSLightmapGroups)
764 bpy.types.Scene.ms_lightmap_groups = CollectionProperty(
765 type=MSLightmapGroups)
766 bpy.types.Scene.ms_lightmap_groups_index = IntProperty()
769 def unregister():
770 bpy.utils.unregister_class(TextureAtlas)
772 bpy.utils.unregister_class(AddLightmapGroup)
773 bpy.utils.unregister_class(DelLightmapGroup)
774 bpy.utils.unregister_class(AddSelectedToGroup)
775 bpy.utils.unregister_class(SelectGroup)
776 bpy.utils.unregister_class(RemoveFromGroup)
777 bpy.utils.unregister_class(RemoveOtherUVs)
779 bpy.utils.unregister_class(RunAuto)
780 bpy.utils.unregister_class(RunStart)
781 bpy.utils.unregister_class(RunFinish)
782 bpy.utils.unregister_class(MergeObjects)
783 bpy.utils.unregister_class(SeparateObjects)
784 bpy.utils.unregister_class(CreateLightmap)
786 # types
787 bpy.utils.unregister_class(MSUVLayers)
788 bpy.utils.unregister_class(MSVertexGroups)
789 bpy.utils.unregister_class(MSGroups)
791 bpy.utils.unregister_class(MSMergedObjects)
793 bpy.utils.unregister_class(MSLightmapGroups)
796 if __name__ == "__main__":
797 register()