forked from SpectralVectors/CustomObjects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnrealObjectsPanel.py
1342 lines (1063 loc) · 44.9 KB
/
UnrealObjectsPanel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import bpy
from bpy.props import (
StringProperty,
FloatProperty,
FloatVectorProperty,
IntProperty,
)
from bpy.types import (
Operator,
Panel
)
bl_info = {
'name': 'Unreal Objects',
'category': 'Object',
'Author': 'Spectral Vectors',
'version': (0, 0, 2),
'blender': (2, 80, 0),
'location': 'Toolbar & Add Menu'
}
# Comment Box Operator
class BLUI_OT_comment_box(Operator):
bl_idname = "blui.comment_box"
bl_label = "Comment Box"
bl_description = "Frames around the selected nodes, requests name and color"
bl_options = {'REGISTER', 'UNDO'}
bl_space_type = 'NODE_EDITOR'
bl_context_mode = 'OBJECT'
bl_property = 'comment_name'
comment_name = bpy.props.StringProperty(
name='Label -',
default='Your Text Here'
)
comment_color = bpy.props.FloatVectorProperty(
name='Color -',
default=(0.3, 0.3, 0.3),
min=0, max=1, step=1, precision=3,
subtype='COLOR_GAMMA', size=3
)
@classmethod
def poll(cls, context):
return context.area.type == 'NODE_EDITOR'
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)
def execute(self, context):
nodes = context.selected_nodes
selected = []
for node in nodes:
if node.select == True:
selected.append(node)
bpy.ops.node.add_node(type='NodeFrame')
frame = context.active_node
frame.label = self.comment_name
frame.use_custom_color = True
frame.color = self.comment_color
for node in selected:
node.parent = frame
return {'FINISHED'}
# Object Adding Operators
####################### Empty and Camera
# Add Empty #
class BLUI_OT_add_empty(Operator):
bl_idname = "blui.add_empty"
bl_label = "Add Empty"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.object.empty_add(radius=20)
return {'FINISHED'}
# Add Camera w Distant Clip End #
class BLUI_OT_add_long_camera(Operator):
bl_idname = "blui.add_long_camera"
bl_label = "Camera - Far Clip End"
bl_description = "Adds a Camera with the Clip End set to 100000"
bl_options = {'REGISTER', 'UNDO'}
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.object.camera_add(location=(00, -200, 100), rotation=(1, 0, 0))
bpy.context.object.data.clip_end = 10000000
bpy.context.object.scale[0] = 50
bpy.context.object.scale[1] = 50
bpy.context.object.scale[2] = 50
return {'FINISHED'}
# Meshes
# Add Cube #
class BLUI_OT_add_cube(Operator):
bl_idname = "blui.add_cube"
bl_label = "Add Cube"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_cube_add(size=50, location=(0,0,25))
return {'FINISHED'}
# Add UV Sphere #
class BLUI_OT_add_uv_sphere(Operator):
bl_idname = "blui.add_uv_sphere"
bl_label = "Add UV Sphere"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_uv_sphere_add(radius=30, location=(0,0,30))
return {'FINISHED'}
# Add Ico Sphere #
class BLUI_OT_add_ico_sphere(Operator):
bl_idname = "blui.add_ico_sphere"
bl_label = "Add Ico Sphere"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_ico_sphere_add(radius=30, location=(0,0,30))
return {'FINISHED'}
# Add UV Cylinder #
class BLUI_OT_add_cylinder(Operator):
bl_idname = "blui.add_cylinder"
bl_label = "Add Cylinder"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_cylinder_add(radius=20, depth=50, location=(0,0,25))
return {'FINISHED'}
# Add Cone #
class BLUI_OT_add_cone(Operator):
bl_idname = "blui.add_cone"
bl_label = "Add Cone"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_cone_add(radius1=30, radius2=0, depth=60, location=(0,0,30))
return {'FINISHED'}
# Add Torus #
class BLUI_OT_add_torus(Operator):
bl_idname = "blui.add_torus"
bl_label = "Add Torus"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_torus_add(major_radius=50, minor_radius=20, location=(0,0,20))
return {'FINISHED'}
# Add Monkey #
class BLUI_OT_add_monkey(Operator):
bl_idname = "blui.add_monkey"
bl_label = "Add Monkey"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_monkey_add(size=50, location=(0,0,25))
return {'FINISHED'}
# Add Plane #
class BLUI_OT_add_plane(Operator):
bl_idname = "blui.add_plane"
bl_label = "Add Plane"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_plane_add(size=100)
return {'FINISHED'}
# Add Floor Plane #
class BLUI_OT_add_floor_plane(Operator):
bl_idname = "blui.add_floor_plane"
bl_label = "Add Floor Plane"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_plane_add(size=10000)
return {'FINISHED'}
# Add Circle #
class BLUI_OT_add_circle(Operator):
bl_idname = "blui.add_circle"
bl_label = "Add Circle"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_circle_add(radius=50)
return {'FINISHED'}
# Lights
# Add a Point Light #
class BLUI_OT_add_point_light(Operator):
bl_idname = "blui.add_point_light"
bl_label = "Add Point Light"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.object.light_add(type='POINT', location=(0, 0, 300))
bpy.context.object.data.energy = 1000000
return {'FINISHED'}
# Add a Directional Light #
class BLUI_OT_add_directional_light(Operator):
bl_idname = "blui.add_directional_light"
bl_label = "Add Directional Light"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.object.light_add(type='AREA', location=(0, 0, 300))
bpy.context.object.data.energy = 1000000
bpy.context.object.scale[0] = 200
bpy.context.object.scale[1] = 200
bpy.context.object.scale[2] = 200
return {'FINISHED'}
# Add a Spot Light #
class BLUI_OT_add_spot_light(Operator):
bl_idname = "blui.add_spot_light"
bl_label = "Add Spot Light"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.object.light_add(type='SPOT', location=(0, 0, 300))
bpy.context.object.data.energy = 1000000
bpy.context.object.scale[0] = 50
bpy.context.object.scale[1] = 50
bpy.context.object.scale[2] = 50
return {'FINISHED'}
# Add a Sun Light #
class BLUI_OT_add_sun_light(Operator):
bl_idname = "blui.add_sun_light"
bl_label = "Add Sun Light"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.object.light_add(type='SUN', location=(0, 0, 300))
bpy.context.object.data.energy = 5
bpy.context.object.scale[0] = 50
bpy.context.object.scale[1] = 50
bpy.context.object.scale[2] = 50
return {'FINISHED'}
# Lightprobes / Reflection Captures
# Add a Cubemap #
class BLUI_OT_add_cubemap(Operator):
bl_idname = "blui.add_cubemap"
bl_label = "Add Cubemap"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.object.lightprobe_add(type='CUBEMAP', radius=100)
return {'FINISHED'}
# Add a Planar Reflection Capture #
class BLUI_OT_add_planar(Operator):
bl_idname = "blui.add_planar"
bl_label = "Add Planar"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.object.lightprobe_add(type='PLANAR', radius=100)
return {'FINISHED'}
# Add a Grid Reflection Capture #
class BLUI_OT_add_grid(Operator):
bl_idname = "blui.add_grid"
bl_label = "Add Grid"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.object.lightprobe_add(type='GRID', radius=100)
return {'FINISHED'}
###### Extras #######
# Add an Unreal Mannequin Skeleton #
class BLUI_OT_add_skeleton(Operator):
bl_idname = "blui.add_skeleton"
bl_label = "Add Unreal compatible skeleton"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
# Add a small cylinder, name it 'boneshape', rotate, then apply the rotation
# This is the mesh that will stand in for the actual bones
bpy.ops.mesh.primitive_cylinder_add(radius=0.1, depth=0.7)
boneshape = bpy.context.object
boneshape.name = "boneshape"
boneshape.delta_rotation_euler = (0,1.5708,0)
bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
# Add an armature, then begin adding bones
bpy.ops.object.armature_add(radius=20, enter_editmode=True)
root = bpy.context.object
root.name = "root"
edit_bones = root.data.edit_bones
# Spine - parent
pelvis = edit_bones.new('pelvis')
pelvis.head = (0, 1.0562, 96.7506)
pelvis.tail = (0, 10.7616, 96.7861)
pelvis.roll = -1.5708
spine_01 = edit_bones.new('spine_01')
spine_01.head = (0, 0.1652, 107.556)
spine_01.tail = (0, 19.2608, 110.024)
spine_01.roll = -1.5708
spine_01.parent = pelvis
spine_02 = edit_bones.new('spine_02')
spine_02.head = (0, 1.516, 126.763)
spine_02.tail = (0, 14.8383, 125.198)
spine_02.roll = -1.5708
spine_02.parent = spine_01
spine_03 = edit_bones.new('spine_03')
spine_03.head = (0, 3.4979, 140.03)
spine_03.tail = (0, 17.3384, 137.719)
spine_03.roll = -1.5708
spine_03.parent = spine_02
# Left Arm - child of 'spine_03'
clavicle_l = edit_bones.new('clavicle_l')
clavicle_l.head = (3.782, 2.7604, 152.201)
clavicle_l.tail = (-3.2703, 16.8823, 152.201)
clavicle_l.roll = 0.169297
clavicle_l.parent = spine_03
upperarm_l = edit_bones.new('upperarm_l')
upperarm_l.head = (17.7002, 9.711, 149.53)
upperarm_l.tail = (16.6509, 25.0845, 150.106)
upperarm_l.roll = 0.872665
upperarm_l.parent = clavicle_l
lowerarm_l = edit_bones.new('lowerarm_l')
lowerarm_l.head = (37.2646, 11.9106, 126.445)
lowerarm_l.tail = (41.8992, 30.1114, 118.26)
lowerarm_l.roll = 0.698132
lowerarm_l.parent = upperarm_l
# Left Hand - child of 'lowerarm_l'
hand_l = edit_bones.new('hand_l')
hand_l.head = (56.646, 0.3352, 111.68)
hand_l.tail = (50.0167, 1.0778, 103.198)
hand_l.roll = 1.11701
hand_l.parent = lowerarm_l
# Left Index - child of 'hand_l'
index_01_l = edit_bones.new('index_01_l')
index_01_l.head = (63.0423, -6.7664, 103.815)
index_01_l.tail = (59.9164, -4.7108, 101.721)
index_01_l.roll = 1.3439
index_01_l.parent = hand_l
index_02_l = edit_bones.new('index_02_l')
index_02_l.head = (64.6721, -8.0948, 100.078)
index_02_l.tail = (62.0295, -6.2201, 99.0685)
index_02_l.roll = 1.44862
index_02_l.parent = index_01_l
index_03_l = edit_bones.new('index_03_l')
index_03_l.head = (65.4362 , -8.7624, 96.8398)
index_03_l.tail = (62.9962 , -6.9696, 95.3068)
index_03_l.roll = 1.36136
index_03_l.parent = index_02_l
# Left Middle - child of 'hand_l'
middle_01_l = edit_bones.new('middle_01_l')
middle_01_l.head = (64.49, -4.4795, 103.481)
middle_01_l.tail = (60.6792, -3.2446, 101.139)
middle_01_l.roll = 1.309
middle_01_l.parent = hand_l
middle_02_l = edit_bones.new('middle_02_l')
middle_02_l.head = (66.5308, -5.7249, 99.5043)
middle_02_l.tail = (63.2161, -4.6874, 98.3863)
middle_02_l.roll = 1.48353
middle_02_l.parent = middle_01_l
middle_03_l = edit_bones.new('middle_03_l')
middle_03_l.head = (67.435, -6.5422, 96.065)
middle_03_l.tail = (64.4945, -5.7117, 94.0706)
middle_03_l.roll = 1.20428
middle_03_l.parent = middle_02_l
# Left Ring - child of 'hand_l'
ring_01_l = edit_bones.new('ring_01_l')
ring_01_l.head = (64.5756, -2.0826, 103.039)
ring_01_l.tail = (60.6571, -2.0405, 100.973)
ring_01_l.roll = 1.29154
ring_01_l.parent = hand_l
ring_02_l = edit_bones.new('ring_02_l')
ring_02_l.head = (66.5923, -2.9755, 99.197)
ring_02_l.tail = (63.2372, -2.7639, 98.3107)
ring_02_l.roll = 1.48353
ring_02_l.parent = ring_01_l
ring_03_l = edit_bones.new('ring_03_l')
ring_03_l.head = (67.4341, -3.5502, 95.8732)
ring_03_l.tail = (64.349, -3.4936, 94.2714)
ring_03_l.roll = 1.32645
ring_03_l.parent = ring_02_l
# Left Pinky - child of 'hand_l'
pinky_01_l = edit_bones.new('pinky_01_l')
pinky_01_l.head = (64.025, 0.1589, 103.017)
pinky_01_l.tail = (61.0139, -0.2218, 101.136)
pinky_01_l.roll = 1.09956
pinky_01_l.parent = hand_l
pinky_02_l = edit_bones.new('pinky_02_l')
pinky_02_l.head = (65.9371, -0.1266, 100.015)
pinky_02_l.tail = (63.1542, -0.3373, 98.9544)
pinky_02_l.roll = 1.29154
pinky_02_l.parent = pinky_01_l
pinky_03_l = edit_bones.new('pinky_03_l')
pinky_03_l.head = (67.0124 , -0.3546 , 97.2392 )
pinky_03_l.tail = (64.2102 , -0.5383 , 96.2253 )
pinky_03_l.roll = 1.36136
pinky_03_l.parent = pinky_02_l
# Left Thumb - child of 'hand_l'
thumb_01_l = edit_bones.new('thumb_01_l')
thumb_01_l.head = (57.478 , -3.8766 , 107.639 )
thumb_01_l.tail = (59.7358 , -2.0499 , 105.082 )
thumb_01_l.roll = 1.20428
thumb_01_l.parent = hand_l
thumb_02_l = edit_bones.new('thumb_02_l')
thumb_02_l.head = (57.6075 , -7.0769 , 105.467 )
thumb_02_l.tail = (59.9538 , -4.3965 , 103.515 )
thumb_02_l.roll = 1.309
thumb_02_l.parent = thumb_01_l
thumb_03_l = edit_bones.new('thumb_03_l')
thumb_03_l.head = (57.7842 , -9.5661 , 102.262 )
thumb_03_l.tail = (60.2511 , -7.5595 , 99.7346 )
thumb_03_l.roll = 1.36136
thumb_03_l.parent = thumb_02_l
# Right Arm - child of 'spine_03'
clavicle_r = edit_bones.new('clavicle_r')
clavicle_r.head = (-3.782, 2.7604, 152.201)
clavicle_r.tail = (-10.8342, -11.3614, 152.201)
clavicle_r.roll = -2.96706
clavicle_r.parent = spine_03
upperarm_r = edit_bones.new('upperarm_r')
upperarm_r.head = (-17.7002, 9.711, 149.53)
upperarm_r.tail = (-18.7495, -5.6625, 148.955)
upperarm_r.roll = 3.00197
upperarm_r.parent = clavicle_r
lowerarm_r = edit_bones.new('lowerarm_r')
lowerarm_r.head = (-37.2646, 11.9106, 126.445)
lowerarm_r.tail = (-32.6301, -6.2902, 134.631)
lowerarm_r.roll = 1.72788
lowerarm_r.parent = upperarm_r
# Right Hand - child of 'lowerarm_r'
hand_r = edit_bones.new('hand_r')
hand_r.head = (-56.646, 0.3352, 111.68)
hand_r.tail = (-63.2754, -0.4075, 120.161)
hand_r.roll = -0.20944
hand_r.parent = lowerarm_r
# Right Index - child of 'hand_r'
index_01_r = edit_bones.new('index_01_r')
index_01_r.head = (-63.0421, -6.76643, 103.815)
index_01_r.tail = (-66.1682, -8.82212, 105.909)
index_01_r.roll = -0.619672
index_01_r.parent = hand_r
index_02_r = edit_bones.new('index_02_r')
index_02_r.head = (-64.6721, -8.09492, 100.078)
index_02_r.tail = (-67.3147, -9.96964, 101.088)
index_02_r.roll = -0.967554
index_02_r.parent = index_01_r
index_03_r = edit_bones.new('index_03_r')
index_03_r.head = (-65.4362, -8.76252, 96.8397)
index_03_r.tail = (-67.8762, -10.5553, 98.3727)
index_03_r.roll = -0.649723
index_03_r.parent = index_02_r
# Right Middle - child of 'hand_r'
middle_01_r = edit_bones.new('middle_01_r')
middle_01_r.head = (-64.49, -4.47954, 103.481)
middle_01_r.tail = (-68.3009, -5.71443, 105.824)
middle_01_r.roll = -0.737538
middle_01_r.parent = hand_r
middle_02_r = edit_bones.new('middle_02_r')
middle_02_r.head = (-66.5307, -5.72502, 99.5041)
middle_02_r.tail = (-69.8456, -6.76257, 100.622)
middle_02_r.roll = -1.00971
middle_02_r.parent = middle_01_r
middle_03_r = edit_bones.new('middle_03_r')
middle_03_r.head = (-67.4349, -6.5423, 96.0648)
middle_03_r.tail = (-70.3755, -7.37286, 98.0592)
middle_03_r.roll = -0.747729
middle_03_r.parent = middle_02_r
# Right Ring - child of 'hand_r'
ring_01_r = edit_bones.new('ring_01_r')
ring_01_r.head = (-64.5756, -2.08277, 103.039)
ring_01_r.tail = (-68.4938, -2.12491, 105.105)
ring_01_r.roll = -0.882559
ring_01_r.parent = hand_r
ring_02_r = edit_bones.new('ring_02_r')
ring_02_r.head = (-66.5922, -2.97553, 99.1971)
ring_02_r.tail = (-69.9473, -3.18709, 100.083)
ring_02_r.roll = -1.14615
ring_02_r.parent = ring_01_r
ring_03_r = edit_bones.new('ring_03_r')
ring_03_r.head = (-67.4341, -3.55024, 95.8733)
ring_03_r.tail = (-70.5193, -3.60684, 97.4751)
ring_03_r.roll = -0.86413
ring_03_r.parent = ring_02_r
# Right Pinky - child of 'hand_r'
pinky_01_r = edit_bones.new('pinky_01_r')
pinky_01_r.head = (-64.0249, 0.158811, 103.017)
pinky_01_r.tail = (-67.0361, 0.539548, 104.899)
pinky_01_r.roll = -0.931809
pinky_01_r.parent = hand_r
pinky_02_r = edit_bones.new('pinky_02_r')
pinky_02_r.head = (-65.937, -0.126716, 100.015)
pinky_02_r.tail = (-68.7197, 0.084021, 101.076)
pinky_02_r.roll = -1.13001
pinky_02_r.parent = pinky_01_r
pinky_03_r = edit_bones.new('pinky_03_r')
pinky_03_r.head = (-67.0125, -0.354654, 97.2393)
pinky_03_r.tail = (-69.8145, -0.171015, 98.2531)
pinky_03_r.roll = -1.07827
pinky_03_r.parent = pinky_02_r
# Right Thumb - child of 'hand_r'
thumb_01_r = edit_bones.new('thumb_01_r')
thumb_01_r.head = (-57.4781, -3.87677, 107.639)
thumb_01_r.tail = (-55.2203, -5.70348, 110.196)
thumb_01_r.roll = 2.64777
thumb_01_r.parent = hand_r
thumb_02_r = edit_bones.new('thumb_02_r')
thumb_02_r.head = (-57.6074, -7.07692, 105.467)
thumb_02_r.tail = (-55.2611, -9.75726, 107.42)
thumb_02_r.roll = 3.06475
thumb_02_r.parent = thumb_01_r
thumb_03_r = edit_bones.new('thumb_03_r')
thumb_03_r.head = (-57.7841, -9.56623, 102.262)
thumb_03_r.tail = (-55.3172, -11.5729, 104.79)
thumb_03_r.roll = 2.90462
thumb_03_r.parent = thumb_02_r
# Neck - child of spine_03
neck_01 = edit_bones.new('neck_01')
neck_01.head = (0.000007, 5.87469, 156.421)
neck_01.tail = (0.000007, 14.8884, 158.673)
neck_01.roll = -1.5708
neck_01.parent = spine_03
head = edit_bones.new('head')
head.head = (0.000008, 3.97763, 165.516)
head.tail = (0.000008, 13.2659, 165.302)
head.roll = -1.5708
head.parent = neck_01
# Left Leg - child of pelvis
thigh_l = edit_bones.new('thigh_l')
thigh_l.head = (9.00581, 0.530028, 95.2999)
thigh_l.tail = (4.22747, 32.506, 95.673)
thigh_l.roll = -1.69577
thigh_l.parent = pelvis
calf_l = edit_bones.new('calf_l')
calf_l.head = (14.2178, 1.80179, 53.0672)
calf_l.tail = (12.2905, 31.7257, 57.6673)
calf_l.roll = -1.64697
calf_l.parent = thigh_l
foot_l = edit_bones.new('foot_l')
foot_l.head = (17.0763, 8.07371, 13.4659)
foot_l.tail = (16.1807, 27.6506, 13.7035)
foot_l.roll = -1.58592
foot_l.parent = calf_l
ball_l = edit_bones.new('ball_l')
ball_l.head = (17.9087, -8.35531, 2.81181)
ball_l.tail = (17.6464, -9.24983, 22.3885)
ball_l.roll = -1.53847
ball_l.parent = foot_l
# Right Leg - child of pelvis
thigh_r = edit_bones.new('thigh_r')
thigh_r.head = (-9.0058, 0.530023, 95.3)
thigh_r.tail = (-13.7842, -31.446, 94.9268)
thigh_r.roll = 1.28994
thigh_r.parent = pelvis
calf_r = edit_bones.new('calf_r')
calf_r.head = (-14.2179, 1.80179, 53.0672)
calf_r.tail = (-16.1452, -28.1223, 48.467)
calf_r.roll = -0.853457
calf_r.parent = thigh_r
foot_r = edit_bones.new('foot_r')
foot_r.head = (-17.0763, 8.07373, 13.4657)
foot_r.tail = (-17.9718, -11.5031, 13.2281)
foot_r.roll = 1.03695
foot_r.parent = calf_r
ball_r = edit_bones.new('ball_r')
ball_r.head = (-17.9087, -8.35523, 2.81168)
ball_r.tail = (-18.1711, -7.46071, -16.7649)
ball_r.roll = -1.51168
ball_r.parent = foot_r
# Cleanup
# This removes the bone automatically added with the armature, named 'Bone'
for bone in edit_bones:
if bone.name == "Bone":
edit_bones.remove(bone)
# Now we switch to Object mode to assign a custom mesh to our bones
bpy.ops.object.mode_set(mode='OBJECT')
# Looping through all the bones, and setting them all to use our 'boneshape' mesh
for bone in root.pose.bones:
bone.custom_shape = boneshape
# Finally, we select the original 'boneshape' mesh and delete it, leaving only the skeleton
ob = bpy.context.scene.objects["boneshape"]
bpy.ops.object.select_all(action='DESELECT')
bpy.context.view_layer.objects.active = ob
ob.select_set(True)
bpy.ops.object.delete()
return {'FINISHED'}
# Add Mirror Cube #
class BLUI_OT_add_mirror_cube(Operator):
bl_idname = "blui.add_mirror_cube"
bl_label = "Add Cube w Mirror Modifier"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_cube_add(size=50, location=(0, 0, 25))
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.bisect(plane_co=(0, 0, 0), plane_no=(1, 0, 0), xstart=0, xend=100, ystart=0, yend=100, clear_outer=False, clear_inner=True)
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.modifier_add(type='MIRROR')
bpy.context.object.modifiers["Mirror"].use_clip = True
return {'FINISHED'}
# Add Mirror Sphere #
class BLUI_OT_add_mirror_sphere(Operator):
bl_idname = "blui.add_mirror_sphere"
bl_label = "Add UV Sphere w Mirror Modifier"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_uv_sphere_add(radius=30, location=(0, 0, 30))
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.bisect(plane_co=(0, 0, 0), plane_no=(1, 0, 0), xstart=0, xend=100, ystart=0, yend=100, clear_outer=False, clear_inner=True)
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.modifier_add(type='MIRROR')
bpy.context.object.modifiers["Mirror"].use_clip = True
return {'FINISHED'}
# Add Hard Surface Plane #
class BLUI_OT_add_hs_plane(Operator):
bl_idname = "blui.add_hs_plane"
bl_label = "Add Hard Surface Plane"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_plane_add(size=100)
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.bisect(plane_co=(0, 0, 0), plane_no=(1, 0, 0), xstart=0, xend=100, ystart=0, yend=100, clear_outer=False, clear_inner=True)
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.modifier_add(type='MIRROR')
bpy.context.object.modifiers["Mirror"].use_clip = True
bpy.ops.object.modifier_add(type='SOLIDIFY')
bpy.context.object.modifiers["Solidify"].thickness = 2
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.context.object.modifiers["Subdivision"].uv_smooth = 'NONE'
bpy.context.object.modifiers["Subdivision"].subdivision_type = 'SIMPLE'
bpy.context.object.modifiers["Subdivision"].levels = 2
bpy.ops.object.modifier_add(type='BEVEL')
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.context.object.modifiers["Subdivision.001"].uv_smooth = 'NONE'
bpy.context.object.modifiers["Subdivision.001"].levels = 2
bpy.ops.object.shade_smooth()
return {'FINISHED'}
# Add Hard Surface Cube #
class BLUI_OT_add_hs_cube(Operator):
bl_idname = "blui.add_hs_cube"
bl_label = "Add Hard Surface Cube"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.ops.mesh.primitive_cube_add(size=50, location=(0, 0, 25))
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.bisect(plane_co=(0, 0, 0), plane_no=(1, 0, 0), xstart=0, xend=100, ystart=0, yend=100, clear_outer=False, clear_inner=True)
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.modifier_add(type='MIRROR')
bpy.context.object.modifiers["Mirror"].use_clip = True
bpy.ops.object.modifier_add(type='SOLIDIFY')
bpy.context.object.modifiers["Solidify"].thickness = 2
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.context.object.modifiers["Subdivision"].uv_smooth = 'NONE'
bpy.context.object.modifiers["Subdivision"].subdivision_type = 'SIMPLE'
bpy.context.object.modifiers["Subdivision"].levels = 2
bpy.ops.object.modifier_add(type='BEVEL')
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.context.object.modifiers["Subdivision.001"].uv_smooth = 'NONE'
bpy.context.object.modifiers["Subdivision.001"].levels = 2
bpy.ops.object.shade_smooth()
return {'FINISHED'}
################## Panel Operators ############################
# Create an integer to track which Panel to display
bpy.types.Scene.PanelSelect = bpy.props.IntProperty(
name="Panel Select",
default=0,
min=0,
max=4
)
bpy.types.Scene.PanelSelect = 0
# Panel Selection Operators
# Show the Basic Panel #
class BLUI_OT_show_basic_panel(Operator):
bl_idname = "blui.show_basic_panel"
bl_label = "Shows the Basic Panel Items"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.types.Scene.PanelSelect = 0
return {'FINISHED'}
# Show the Lights Panel #
class BLUI_OT_show_lights_panel(Operator):
bl_idname = "blui.show_lights_panel"
bl_label = "Shows the Lights Panel Items"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.types.Scene.PanelSelect = 1
return {'FINISHED'}
# Show the Camera Panel #
class BLUI_OT_show_camera_panel(Operator):
bl_idname = "blui.show_camera_panel"
bl_label = "Shows the Camera Panel Items"
bl_space_type = 'VIEW_3D'
bl_context_mode = 'OBJECT'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def execute(self, context):
bpy.types.Scene.PanelSelect = 2