18
18
"author" : "mattedickson" ,
19
19
"wiki_url" : "https://github.com/mattedicksoncom/blender-xatlas/" ,
20
20
"tracker_url" : "https://github.com/mattedicksoncom/blender-xatlas/issues" ,
21
- "version" : (0 , 0 , 4 ),
21
+ "version" : (0 , 0 , 5 ),
22
22
"blender" : (2 , 83 , 0 ),
23
23
"location" : "3D View > Toolbox" ,
24
24
"category" : "Object" ,
@@ -196,14 +196,14 @@ class PG_ChartProperties (PropertyGroup):
196
196
197
197
198
198
def get_collectionNames (self , context ):
199
- colllectionNames = [];
199
+ colllectionNames = []
200
200
for collection in bpy .data .collections :
201
201
colllectionNames .append ((collection .name , collection .name , "" ))
202
- return colllectionNames ;
202
+ return colllectionNames
203
203
204
204
class PG_SharedProperties (PropertyGroup ):
205
205
206
- unwrapSelection = EnumProperty (
206
+ unwrapSelection : EnumProperty (
207
207
name = "" ,
208
208
description = "Which Objects to unwrap" ,
209
209
items = [ ('SELECTED' , "Selection" , "" ),
@@ -212,26 +212,64 @@ class PG_SharedProperties (PropertyGroup):
212
212
]
213
213
)
214
214
215
- atlasLayout = EnumProperty (
215
+ atlasLayout : EnumProperty (
216
216
name = "" ,
217
217
description = "How to Layout the atlases" ,
218
218
items = [ ('OVERLAP' , "Overlap" , "Overlap all the atlases" ),
219
- ('SPREADX' , "Spread x " , "Seperate each atlas along the x-axis" ),
219
+ ('SPREADX' , "Spread X " , "Seperate each atlas along the x-axis" ),
220
220
]
221
221
)
222
222
223
- selectedCollection = EnumProperty (
223
+ selectedCollection : EnumProperty (
224
224
name = "" ,
225
225
items = get_collectionNames
226
- )
226
+ )
227
227
228
228
mainUVIndex : IntProperty (
229
- name = "Main UV Index " ,
229
+ name = "" ,
230
230
description = "The index of the primary none lightmap uv" ,
231
231
default = 0 ,
232
232
min = 0 ,
233
233
max = 1000
234
- )
234
+ )
235
+
236
+ lightmapUVIndex : IntProperty (
237
+ name = "" ,
238
+ description = "The index of the lightmap uv" ,
239
+ default = 0 ,
240
+ min = 0 ,
241
+ max = 1000
242
+ )
243
+
244
+
245
+ mainUVChoiceType : EnumProperty (
246
+ name = "" ,
247
+ description = "The method to obtain the main UV" ,
248
+ items = [ ('NAME' , "By Name" , "" ),
249
+ ('INDEX' , "By Index" , "" ),
250
+ ]
251
+ )
252
+
253
+ mainUVName : StringProperty (
254
+ name = "" ,
255
+ description = "The name of the main (non-lightmap) UV" ,
256
+ default = "UVMap" ,
257
+ )
258
+
259
+
260
+ lightmapUVChoiceType : EnumProperty (
261
+ name = "" ,
262
+ description = "The method to obtain the lightmap UV" ,
263
+ items = [ ('NAME' , "By Name" , "" ),
264
+ ('INDEX' , "By Index" , "" ),
265
+ ]
266
+ )
267
+
268
+ lightmapUVName : StringProperty (
269
+ name = "" ,
270
+ description = "The name of the lightmap UV (If it doesn't exist it will be created)" ,
271
+ default = "UVMap_Lightmap" ,
272
+ )
235
273
236
274
237
275
# end PropertyGroups---------------------------
@@ -325,12 +363,21 @@ def execute(self, context):
325
363
if obj .data .users > 1 :
326
364
obj .data = obj .data .copy () #make single user copy
327
365
uv_layers = obj .data .uv_layers
328
- if not "UVMap_Lightmap" in uv_layers :
329
- uvmap = uv_layers .new (name = "UVMap_Lightmap" )
366
+
367
+ #setup the lightmap uvs
368
+ uvName = "UVMap_Lightmap"
369
+ if sharedProperties .lightmapUVChoiceType == "NAME" :
370
+ uvName = sharedProperties .lightmapUVName
371
+ elif sharedProperties .lightmapUVChoiceType == "INDEX" :
372
+ if sharedProperties .lightmapUVIndex < len (uv_layers ):
373
+ uvName = uv_layers [sharedProperties .lightmapUVIndex ].name
374
+
375
+ if not uvName in uv_layers :
376
+ uvmap = uv_layers .new (name = uvName )
330
377
uv_layers .active_index = len (uv_layers ) - 1
331
378
else :
332
379
for i in range (0 , len (uv_layers )):
333
- if uv_layers [i ].name == 'UVMap_Lightmap' :
380
+ if uv_layers [i ].name == uvName :
334
381
uv_layers .active_index = i
335
382
obj .select_set (True )
336
383
@@ -347,7 +394,9 @@ def execute(self, context):
347
394
export_obj_simple .save (
348
395
context = bpy .context ,
349
396
filepath = fakeFile ,
397
+ mainUVChoiceType = sharedProperties .mainUVChoiceType ,
350
398
uvIndex = sharedProperties .mainUVIndex ,
399
+ uvName = sharedProperties .mainUVName ,
351
400
use_selection = True ,
352
401
use_animation = False ,
353
402
use_mesh_modifiers = True ,
@@ -563,7 +612,28 @@ class OBJECT_PT_xatlas_panel (Panel):
563
612
bl_label = "Xatlas Tools"
564
613
bl_space_type = "VIEW_3D"
565
614
bl_region_type = "UI"
566
- bl_category = "Tool"
615
+ bl_category = "Xatlas"
616
+ bl_context = ""
617
+
618
+ @classmethod
619
+ def poll (self ,context ):
620
+ return context .object is not None
621
+
622
+ def draw (self , context ):
623
+ layout = self .layout
624
+ scene = context .scene
625
+ packtool = scene .pack_tool
626
+ mytool = scene .chart_tool
627
+
628
+
629
+
630
+ class OBJECT_PT_pack_panel (Panel ):
631
+ bl_idname = "OBJECT_PT_pack_panel"
632
+ bl_label = "Pack Options"
633
+ bl_space_type = "VIEW_3D"
634
+ bl_region_type = "UI"
635
+ bl_category = "Xatlas"
636
+ bl_parent_id = 'OBJECT_PT_xatlas_panel'
567
637
bl_context = ""
568
638
569
639
@classmethod
@@ -578,25 +648,88 @@ def draw(self, context):
578
648
579
649
#add the pack options
580
650
box = layout .box ()
581
- label = box .label (text = "Pack Options" )
651
+ # label = box.label(text="Pack Options")
582
652
for tool in packtool .__annotations__ .keys ():
583
653
box .prop ( packtool , tool )
584
654
655
+ class OBJECT_PT_chart_panel (Panel ):
656
+ bl_idname = "OBJECT_PT_chart_panel"
657
+ bl_label = "Chart Options"
658
+ bl_space_type = "VIEW_3D"
659
+ bl_region_type = "UI"
660
+ bl_category = "Xatlas"
661
+ bl_parent_id = 'OBJECT_PT_xatlas_panel'
662
+ bl_context = ""
663
+
664
+ @classmethod
665
+ def poll (self ,context ):
666
+ return context .object is not None
667
+
668
+ def draw (self , context ):
669
+ layout = self .layout
670
+ scene = context .scene
671
+ packtool = scene .pack_tool
672
+ mytool = scene .chart_tool
673
+
585
674
#add the chart options
586
675
box = layout .box ()
587
- label = box .label (text = "Chart Options" )
588
676
for tool in mytool .__annotations__ .keys ():
589
677
box .prop ( mytool , tool )
590
678
679
+ class OBJECT_PT_run_panel (Panel ):
680
+ bl_idname = "OBJECT_PT_run_panel"
681
+ bl_label = "Run Xatlas"
682
+ bl_space_type = "VIEW_3D"
683
+ bl_region_type = "UI"
684
+ bl_category = "Xatlas"
685
+ bl_parent_id = 'OBJECT_PT_xatlas_panel'
686
+ bl_context = ""
687
+
688
+ @classmethod
689
+ def poll (self ,context ):
690
+ return context .object is not None
691
+
692
+ def draw (self , context ):
693
+ layout = self .layout
694
+ scene = context .scene
695
+ packtool = scene .pack_tool
696
+ mytool = scene .chart_tool
697
+
591
698
box = layout .box ()
592
- label = box .label (text = "Run" )
593
- box .prop ( scene . shared_properties , 'unwrapSelection' )
594
- box . prop ( scene . shared_properties , 'mainUVIndex' )
595
- box .prop ( scene .shared_properties , 'atlasLayout ' )
699
+ # label = box.label(text="Run")
700
+ row = box .row ( )
701
+ row . label ( text = "Unwrap" )
702
+ row .prop ( scene .shared_properties , 'unwrapSelection ' )
596
703
if scene .shared_properties .unwrapSelection == "COLLECTION" :
597
704
box .prop ( scene .shared_properties , 'selectedCollection' )
598
- box .operator ("object.setup_unwrap" , text = "Run Xatlas" )
599
705
706
+ box = layout .box ()
707
+ row = box .row ()
708
+ row .label (text = "Lightmap UV" )
709
+ row .prop ( scene .shared_properties , 'lightmapUVChoiceType' )
710
+ if scene .shared_properties .lightmapUVChoiceType == "NAME" :
711
+ box .prop ( scene .shared_properties , 'lightmapUVName' )
712
+ elif scene .shared_properties .lightmapUVChoiceType == "INDEX" :
713
+ box .prop ( scene .shared_properties , 'lightmapUVIndex' )
714
+
715
+ box = layout .box ()
716
+ row = box .row ()
717
+ row .label (text = "Main UV" )
718
+ row .prop ( scene .shared_properties , 'mainUVChoiceType' )
719
+ if scene .shared_properties .mainUVChoiceType == "NAME" :
720
+ box .prop ( scene .shared_properties , 'mainUVName' )
721
+ elif scene .shared_properties .mainUVChoiceType == "INDEX" :
722
+ box .prop ( scene .shared_properties , 'mainUVIndex' )
723
+ # box.prop( scene.shared_properties, 'mainUVName')
724
+
725
+ # box.prop( scene.shared_properties, 'mainUVIndex')
726
+
727
+ box = layout .box ()
728
+ row = box .row ()
729
+ row .label (text = "Atlas Layout" )
730
+ row .prop ( scene .shared_properties , 'atlasLayout' )
731
+
732
+ box .operator ("object.setup_unwrap" , text = "Run Xatlas" )
600
733
# end panels------------------------------
601
734
602
735
@@ -612,6 +745,9 @@ def draw(self, context):
612
745
Setup_Unwrap ,
613
746
Unwrap_Lightmap_Group_Xatlas_2 ,
614
747
OBJECT_PT_xatlas_panel ,
748
+ OBJECT_PT_pack_panel ,
749
+ OBJECT_PT_chart_panel ,
750
+ OBJECT_PT_run_panel ,
615
751
)
616
752
617
753
def register ():
0 commit comments