-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdditiveAnimsAlter.ms
745 lines (680 loc) · 23.2 KB
/
AdditiveAnimsAlter.ms
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
pluginManager.loadClass FBXEXP
global AX_IMPORTER_VERSION = 138
global g_lastDir1
global g_lastDir2
global g_lastDir3
global g_haveAnim
-- global g_lowerBody
-- global g_pelvis
-- global g_spineName
global Anims
global BoneRotationArray
global BoneLocationArray
global FrameBoneRotationArray
global FrameBoneLocationArray
global XMap
global YMap
global ZMap
global AixMap
global AddType
global boneNum
global FrameBoneFlag
global BaseAnimFileName
global AddAnimFileName
global CfgFileName
struct AnimInfoBinary
(
Name,
Address
)
struct BoneRotation
(
Index,
BoneName,
ValueX,
ValueY,
ValueZ
)
fn ReadAnimInfoBinary bstream =
(
v = AnimInfoBinary ()
v.Name = (getFileNameFile(bstream))
v.Address = bstream
v
)
fn SaveValue Num BoneName X Y Z =
(
w = BoneRotation()
w.Index = Num
w.BoneName = BoneName
w.ValueX = X
w.ValueY = Y
w.ValueZ = Z
w
)
-- configure FBX exporter
fn SetupFBX =
(
-- http://www.the-area.com/forum/autodesk-fbx/fbx-plug-ins-import-export-discussions/maxscript-export-dialog-properties/
-- both commands should be used to ensure all commands are functional
pluginManager.loadClass FBXIMP
pluginManager.loadClass FBXEXP
-- FbxExporterSetParam "Geometries" true -- <bool>
-- Controls the state of the "Geometries" checkbox in the FBX Export dialog.
FbxExporterSetParam "NormalsPerPoly" true -- <bool>
-- Controls the state of the "Support normals per polygon vertex" checkbox in the FBX Export dialog.
FbxExporterSetParam "Cameras" false -- <bool>
-- Controls the state of the "Cameras" checkbox in the FBX Export dialog.
FbxExporterSetParam "Lights" false -- <bool>
-- Controls the state of the "Lights" checkbox in the FBX Export dialog.
FbxExporterSetParam "GeomAsBone" true -- <bool>
-- Controls the state of the "Geometries used as bones, exported as bones" checkbox in the FBX Export dialog.
FbxExporterSetParam "Shape" false -- <bool>
-- Controls the state of the "Shape (Morph modifier)" checkbox in the FBX Export dialog.
FbxExporterSetParam "Skin" true -- <bool>
-- Controls the state of the "Skins (Skin Modifier and Physique)" checkbox in the FBX Export dialog.
FbxExporterSetParam "Animation" true -- <bool>
-- Controls the state of the "Animation" checkbox in the FBX Export dialog.
-- FbxExporterSetParam "Resampling" -- <float>
-- Controls the value of the "Resampling rate (when necessary)" field in the FBX Export dialog.
FbxExporterSetParam "ShowWarnings" false -- <bool>
-- Controls the state of the "Show warnings" checkbox in the FBX Export dialog.
FbxExporterSetParam "EmbedTextures" false -- <bool>
-- Controls the state of the "Embed textures in export file" checkbox in the FBX Export dialog.
FbxExporterSetParam "SmoothingGroups" true -- <bool>
-- True or false. See Smoothing Groups for an explanation of this setting.
FbxExporterSetParam "SmoothMeshExport" true -- <bool>
-- True or false. See TurboSmooth for an explanation of this setting.
)
SetupFBX()
g_lastDir1 = ""
g_lastDir2 = ""
g_lastDir3 = ""
g_haveAnim = true
-- g_lowerBody = false
-- g_pelvis = false
-- g_spineName = "spine_01"
boneNum = 1
FrameBoneFlag = 0
fn getMultiOpenFilenames caption: "Open" filename: "" types: "All Files (*.*)|*.*" default: 1 =
(
local dlg = DotNetObject "System.Windows.Forms.OpenFileDialog"
dlg.multiSelect = true
dlg.title = caption
local p = getFilenamePath filename
if doesFileExist p then
dlg.initialDirectory = p
-- MAXScript getOpenFilename uses trailing |;
-- OpenFileDialog filter does not.
if types == "|" then
dlg.filter = (substring types 1 (types.count - 1))
else
dlg.filter = types
dlg.filterIndex = default
local result = dlg.ShowDialog()
if (result.Equals result.OK) then
dlg.filenames
else
undefined
)
fn ImportAddAnimFile filename =
(
append Anims (ReadAnimInfoBinary filename)
)
fn FindAllBones_Recurse bones parent =
(
for i = 1 to parent.children.count do
(
node = parent.children[i]
if isKindOf node Dummy then
(
append bones node
)
FindAllBones_Recurse bones node
)
)
fn FindAllBones =
(
local bones = #()
FindAllBones_Recurse bones rootNode
bones
)
fn ExportAnim filename =
(
local Dir = getFilenamePath(filename)+"AlterAdditiveAnims"
makeDir Dir all:true
local savename =Dir+"\\"+getFilenameFile(filename)
local Exportname = getFilenameFile(filename)
local numFrames = animationrange.end
FBXExporterSetParam "SplitAnimationIntoTakes" "-clear"
FBXExporterSetParam "SplitAnimationIntoTakes" Exportname 0 numFrames
exportFile savename #noPrompt using:FBXEXP
)
fn RotationBone X Y Z BoneArray Map BaseAnimBones frame =
(
local RotationValue = 0
for a=1 to BoneArray.count do
(
case Map of
(
1:(RotationValue = BoneArray[a].ValueX)
2:(RotationValue = BoneArray[a].ValueY)
3:(RotationValue = BoneArray[a].ValueZ)
4:(RotationValue = (BoneArray[a].ValueX)*(-1))
5:(RotationValue = (BoneArray[a].ValueY)*(-1))
6:(RotationValue = (BoneArray[a].ValueZ)*(-1))
--default:(RotationValue = BoneRotationArray[a].ValueX)
)
if AddType==1 then
(
if g_haveAnim then
(
animate on at time frame in coordsys world rotate BaseAnimBones[(BoneArray[a].Index)] (EulerAngles (RotationValue*X) (RotationValue*Y) (RotationValue*Z))
)
else
(
in coordsys world rotate BaseAnimBones[(BoneArray[a].Index)] (EulerAngles (RotationValue*X) (RotationValue*Y) (RotationValue*Z))
)
)
else
(
animate on at time frame in coordsys parent rotate BaseAnimBones[(BoneArray[a].Index)] (EulerAngles (RotationValue*X) (RotationValue*Y) (RotationValue*Z))
)
)
)
fn MoveBone BoneArray BaseAnimBones frame =
(
local LocationValueX = 0
local LocationValueY = 0
local LocationValueZ = 0
for i=1 to BoneArray.count do
(
local LocationValueX = BoneArray[i].ValueX
local LocationValueY = BoneArray[i].ValueY
local LocationValueZ = BoneArray[i].ValueZ
if AddType==1 then
(
if g_haveAnim then
(
animate on at time frame in coordsys parent move BaseAnimBones[(BoneArray[i].Index)] [LocationValueX,LocationValueY,LocationValueZ]
)
else
(
in coordsys parent move BaseAnimBones[(BoneArray[i].Index)] [LocationValueX,LocationValueY,LocationValueZ]
)
)
)
)
fn CalculateAddRotation index =
(
importFile Anims[index].Address #noPrompt using:Wavefront_Object
local bones = FindAllBones()
local Value_X = 0
local Value_Y = 0
local Value_Z = 0
local Move_X = 0
local Move_Y = 0
local Move_Z = 0
local allFrame = 0
if g_haveAnim then
(
--�Ƚ���֡������Ĭ������
animationRange = interval 0 300
allFrame = bones[1].rotation.controller.keys.count --��ȡ�ؼ�֡�ij���
--����֡�����ó�Additive Anim�ij���
animationRange = interval 0 allFrame
FrameBoneRotationArray=#()
FrameBoneLocationArray=#()
for t=0 to allFrame do
(
BoneRotationArray = #()
BoneLocationArray = #()
for i=1 to bones.count do
(
if i>boneNum then
(
Value_X = ((at time t bones[i].rotInParent).x - (at time t bones[i].parent.rotInParent).x)
Value_Y = ((at time t bones[i].rotInParent).y - (at time t bones[i].parent.rotInParent).y)
Value_Z = ((at time t bones[i].rotInParent).z - (at time t bones[i].parent.rotInParent).z)
append BoneRotationArray (SaveValue i bones[i].name Value_X Value_Y Value_Z)
Move_X = (at time t bones[i].posInParent).x
Move_Y = (at time t bones[i].posInParent).y
Move_Z = (at time t bones[i].posInParent).z
append BoneLocationArray (SaveValue i bones[i].name Move_X Move_Y Move_Z)
)
)
append FrameBoneRotationArray BoneRotationArray
append FrameBoneLocationArray BoneLocationArray
)
)
else
(
BoneRotationArray = #()
BoneLocationArray = #()
for j=1 to bones.count do
(
if j>boneNum then
(
Value_X = ((at time 0 bones[j].rotInParent).x - (at time 0 bones[j].parent.rotInParent).x)
Value_Y = ((at time 0 bones[j].rotInParent).y - (at time 0 bones[j].parent.rotInParent).y)
Value_Z = ((at time 0 bones[j].rotInParent).z - (at time 0 bones[j].parent.rotInParent).z)
append BoneRotationArray (SaveValue j bones[j].name Value_X Value_Y Value_Z)
--��ȡ������λ��
Move_X = (at time 0 bones[j].posInParent).x
Move_Y = (at time 0 bones[j].posInParent).y
Move_Z = (at time 0 bones[j].posInParent).z
append BoneLocationArray (SaveValue j bones[j].name Move_X Move_Y Move_Z)
)
)
)
--Set Base Animation Rotation
if DoesFileExist BaseAnimFileName then
(
importFile BaseAnimFileName #noPrompt using:Wavefront_Object
max select all
macros.run "Animation Tools" "DeleteSelectedAnimation"
clearSelection()
local BaseAnimBones = FindAllBones()
scale BaseAnimBones[1] [(50.0/127.0),(50.0/127.0),(50.0/127.0)]
if g_haveAnim then
(
--�����ùؼ�֡
FrameBoneFlag = 1
local FrameBones = FindAllBones()
FrameBoneFlag = 0
for t=0 to allFrame do
(
for i=1 to FrameBones.count do
(
animate on at time t move FrameBones[i] [0,0,0]
animate on at time t scale FrameBones[i] [1,1,1]
animate on at time t rotate FrameBones[i] (EulerAngles 0 0 0)
)
)
--�������������
for t=0 to allFrame do
(
MoveBone FrameBoneLocationArray[t+1] BaseAnimBones t
)
--��������������ת
case AixMap of
(
1:(
for t=0 to allFrame do
(
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
)
)
2:(
for t=0 to allFrame do
(
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
)
)
3:(
for t=0 to allFrame do
(
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
)
)
4:(
for t=0 to allFrame do
(
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
)
)
5:(
for t=0 to allFrame do
(
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
)
)
6:(
for t=0 to allFrame do
(
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
)
)
)
)
else
(
--MoveBone BoneLocationArray BaseAnimBones 0
case AixMap of
(
1:( RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones 0
RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones 0
RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones 0)
2:( RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones 0
RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones 0
RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones 0)
3:( RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones 0
RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones 0
RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones 0)
4:( RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones 0
RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones 0
RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones 0)
5:( RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones 0
RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones 0
RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones 0)
6:( RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones 0
RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones 0
RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones 0)
)
)
ExportAnim Anims[index].Address
)
)
FindAllBonesb
fn GetAddRotation index =
(
--�Ƚ���֡������Ĭ������
animationRange = interval 0 300
importFile Anims[index].Address #noPrompt using:Wavefront_Object
local bones = FindAllBones()
local allFrame = bones[1].rotation.controller.keys.count --��ȡ�ؼ�֡�ij���
--����֡�����ó�Additive Anim�ij���
animationRange = interval 0 allFrame
FrameBoneRotationArray=#()
FrameBoneLocationArray=#()
local Value_X = 0
local Value_Y = 0
local Value_Z = 0
local Move_X = 0
local Move_Y = 0
local Move_Z = 0
for t=0 to allFrame do
(
BoneRotationArray = #()
BoneLocationArray = #()
for j=1 to bones.count do
(
if j>boneNum then
(
Value_X = (at time t bones[j].rotInParent).x
Value_Y = (at time t bones[j].rotInParent).y
Value_Z = (at time t bones[j].rotInParent).z
append BoneRotationArray (SaveValue j bones[j].name Value_X Value_Y Value_Z)
Move_X = (at time t bones[j].posInParent).x
Move_Y = (at time t bones[j].posInParent).y
Move_Z = (at time t bones[j].posInParent).z
append BoneLocationArray (SaveValue j bones[j].name Move_X Move_Y Move_Z)
)
)
append FrameBoneRotationArray BoneRotationArray
append FrameBoneLocationArray BoneLocationArray
)
--Set Base Animation Rotation
if DoesFileExist BaseAnimFileName then
(
importFile BaseAnimFileName #noPrompt using:Wavefront_Object
max select all
macros.run "Animation Tools" "DeleteSelectedAnimation"
clearSelection()
local BaseAnimBones = FindAllBones()
scale BaseAnimBones[1] [(50.0/127.0),(50.0/127.0),(50.0/127.0)]
--�����ùؼ�֡
FrameBoneFlag = 1
local FrameBones = FindAllBones()
FrameBoneFlag = 0
for t=0 to allFrame do
(
for i=1 to FrameBones.count do
(
animate on at time t move FrameBones[i] [0,0,0]
animate on at time t scale FrameBones[i] [1,1,1]
animate on at time t rotate FrameBones[i] (EulerAngles 0 0 0)
)
)
for t=0 to allFrame do
(
MoveBone FrameBoneLocationArray[t+1] BaseAnimBones t
)
case AixMap of
(
1:(
for t=0 to allFrame do
(
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
)
)
2:(
for t=0 to allFrame do
(
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
)
)
3:(
for t=0 to allFrame do
(
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
)
)
4:(
for t=0 to allFrame do
(
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
)
)
5:(
for t=0 to allFrame do
(
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
)
)
6:(
for t=0 to allFrame do
(
RotationBone 0 0 1 FrameBoneRotationArray[t+1] ZMap BaseAnimBones t
RotationBone 0 1 0 FrameBoneRotationArray[t+1] YMap BaseAnimBones t
RotationBone 1 0 0 FrameBoneRotationArray[t+1] XMap BaseAnimBones t
)
)
)
ExportAnim Anims[index].Address --��������fbx
)
)
rollout AdditiveAnimAmend "AdditiveAnimationAmend" width:200 height:700
(
Group "BaseAnim Import"
(
button 'BtnBase' "BaseAnimation" pos:[50,20] width:100 height:30 toolTip:"SelectBaseAnimation" align:#left
)
Group "AdditiveAnim Import"
(
button 'BtnAdd' "AdditiveAnimation" pos:[50,80] width:100 height:30 toolTip:"SelectAdditiveAnimation" align:#left
listBox 'LstAnims' "Animations:" pos:[10,115] width:180 height:13 align:#left
label 'LblX' "X-Axis:" pos:[30,320] width:40 height:22 align:#left
dropDownList 'DDLX' "" pos:[90,320] width:58 height:22 items:#("X", "Y", "Z", "-X", "-Y", "-Z") selection:1 align:#left
label 'LblY' "Y-Axis:" pos:[30,350] width:40 height:22 align:#left
dropDownList 'DDLY' "" pos:[90,350] width:58 height:22 items:#("X", "Y", "Z", "-X", "-Y", "-Z") selection:2 align:#left
label 'LblZ' "Z-Axis:" pos:[30,380] width:40 height:22 align:#left
dropDownList 'DDLZ' "" pos:[90,380] width:58 height:22 enabled:true items:#("X", "Y", "Z", "-X", "-Y", "-Z") selection:3 align:#left
label 'LblAix' "Order:" pos:[30,410] width:40 height:22 align:#left
dropDownList 'DDLAix' "" pos:[90,410] width:58 height:22 enabled:true items:#("XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX") selection:1 align:#left
label 'LblType' "AdditiveType:" pos:[30,440] width:80 height:22 align:#left
dropDownList 'DDLType' "" pos:[105,440] width:80 height:22 enabled:true items:#("Mesh Space", "Local Space") selection:1 align:#left
-- checkbox 'ChkHaveAnim' " With Anim (Mesh Space)" pos:[30,475] width:150 height:20 toolTip:"Whether the pelvis is included" align:#left checked:g_haveAnim
-- checkbox 'ChkPelvis' " Included Pelvis" pos:[30,505] width:150 height:20 toolTip:"Whether the pelvis is included" align:#left checked:g_pelvis
-- checkbox 'ChkLowerbody' " Included Lower Body" pos:[30,535] width:150 height:20 toolTip:"Whether the lower body is included" align:#left checked:g_lowerBody
-- editText 'EdtName' "First Spine Name:" pos:[30,565] width:160 height:20 align:#left text:g_spineName
button 'BtnExport' "ExportAnimation" pos:[50,475] width:100 height:30 toolTip:"ExportAlterAdditiveAnimation" align:#left
button 'BtnCFG' "Load Batch Config" pos:[50,525] width:100 height:30 toolTip:"SelectAdditiveAnimation" align:#left
)
Group "AdditiveAnim Amend"
(
label 'LblAuthor' "@Author:DontWanna404" pos:[30,590] width:150 height:22 align:#left
label 'LblAuthor2' "Modded by PeterZ" pos:[30,610] width:150 height:22 align:#left
label 'LblVersion' "@Version:1.3a" pos:[30,630] width:100 height:22 align:#left
)
on BtnBase pressed do
(
resetMaxFile #noprompt
local filename = getOpenFileName types:"Base Animation (*.fbx)|*.fbx|All (*.*)|*.*|" filename:g_lastDir1
if filename != undefined then
(
BaseAnimFileName = filename
g_lastDir1 = getFilenamePath BaseAnimFileName
if DoesFileExist BaseAnimFileName then
(
importFile BaseAnimFileName #noPrompt using:Wavefront_Object
local BaseAnimBones = FindAllBones()
-- scale BaseAnimBones[1] [(50.0/127.0),(50.0/127.0),(50.0/127.0)]
)
)
)
on BtnAdd pressed do
(
Anims = #()
if DotNetObject == undefined then
(
local filename = getOpenFileName types:"Additive Anim (*.fbx)|*.fbx|All (*.*)|*.*" filename:g_lastDir2
if filename != undefined then
(
AddAnimFileName = filename
g_lastDir2 = getFilenamePath AddAnimFileName
)
)
else
(
local filenames = getMultiOpenFilenames types:"Additive Anim (*.fbx)|*.fbx|All (*.*)|*.*" filename:g_lastDir2
if filenames != undefined then
(
for filename in filenames do
(
AddAnimFileName = filename
g_lastDir2 = getFilenamePath AddAnimFileName
if DoesFileExist AddAnimFileName then
(
ImportAddAnimFile filename
LstAnims.items = for a in Anims collect (a.Name)
)
)
)
)
)
on BtnCFG pressed do
(
resetMaxFile #noprompt
if DotNetObject == undefined then
(
local filename = getOpenFileName types:"AdditiveCFG (*.cfg)|*.cfg|All (*.*)|*.*" filename:g_lastDir3
if filename != undefined then
(
CfgFileName = filename
g_lastDir3 = getFilenamePath CfgFileName
)
)
else
(
local filenames = getMultiOpenFilenames types:"AdditiveCFG (*.cfg)|*.cfg|All (*.*)|*.*" filename:g_lastDir3
if filenames != undefined then
(
for filename in filenames do
(
CfgFileName = filename
g_lastDir3 = getFilenamePath CfgFileName
if DoesFileExist CfgFileName then
(
local cfgFile = openFile filename
while eof cfgFile == false do(
local line = readline cfgFile
if (line=="") then (
-- print "skip line"
continue
)
local data = filterString line "|" -- [1] = sequencePath, [2] = refSequencePath, [2] = skelAdditiveSpace
sequencePath = data[1]
BaseAnimFileName = data[2]
skelAdditiveSpace= data[3]
format "% % %\n" data[1] data[2] data[3]
-- 导入单个baseanim
resetMaxFile #noprompt
importFile BaseAnimFileName #noPrompt using:Wavefront_Object
local BaseAnimBones = FindAllBones()
scale BaseAnimBones[1] [(50.0/127.0),(50.0/127.0),(50.0/127.0)]
-- 导入单个additive动画
Anims = #()
ImportAddAnimFile sequencePath
LstAnims.items = for a in Anims collect (a.Name)
-- 根据skelAdditiveSpace导出
XMap = DDLX.selection
YMap = DDLY.selection
ZMap = DDLZ.selection
AixMap = DDLAix.selection
boneNum = 1
case skelAdditiveSpace of (
"1":(AddType = 2)
"2":(AddType = 1)
)
for i=1 to LstAnims.items.count do
(
resetMaxFile #noprompt
case AddType of
(
1:(CalculateAddRotation i
)
2:(GetAddRotation i
)
)
)
)
)
)
)
)
)
on BtnExport pressed do
(
BoneRotationArray = #()
if (LstAnims.items.count>0 and BaseAnimFileName != undefined) then
(
XMap = DDLX.selection
YMap = DDLY.selection
ZMap = DDLZ.selection
AixMap = DDLAix.selection
AddType = DDLType.selection
-- if g_pelvis then
-- (
-- boneNum = 1
-- )
-- else boneNum = 2
boneNum = 1
for i=1 to LstAnims.items.count do
(
resetMaxFile #noprompt
case AddType of
(
1:(CalculateAddRotation i)
2:(GetAddRotation i)
)
)
)
)
on ChkHaveAnim changed state do g_haveAnim = state
-- on ChkLowerbody changed state do g_lowerBody = state
-- on ChkPelvis changed state do g_pelvis = state
-- on EdtName changed val do g_spineName = val
)CreateDialog AdditiveAnimAmend width:200 height:720