-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCRPlugins.ms
More file actions
2759 lines (2498 loc) · 99.6 KB
/
Copy pathCRPlugins.ms
File metadata and controls
2759 lines (2498 loc) · 99.6 KB
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
if ImportCNT==undefined then
(
fn ImportCNT = ()
)
fn IsObjectAJoint obj =
(
(classof obj) == CarmaHelper_JointHelper
)
polymesh = mesh
plugin simpleObject CarmaHelper_JointHelper
Name: "Joint"
classID: #(0x6d1e792f, 0x4883ec71)
category: "Carmageddon: Reincarnation"
version:1
(
local lastMinLimit, lastMaxLimit, lastMinLimit2, lastMaxLimit2, lastMinTwist, lastMaxTwist, lastJointType, lastLimit1Start, lastLimit2Start, lastTwistStart, meshObj, thisNode
parameters jointParamBlock rollout:jointParams
(
NodeStorage type:#maxObject
JointType type:#integer animatable:false default:1 ui:rad_JointType
JointType_Hinge type:#boolean animatable:false default:true
JointType_Ball type:#boolean animatable:false default:false
JointType_UJ type:#boolean animatable:false default:false
JointType_Slide type:#boolean animatable:false default:false
AxisIsSet type:#boolean default:false
JointAxis type:#point3 animatable:false default:[1,0,0]
JointNormal type:#point3 animatable:false default:[0,0,1]
Weakness type:#float animatable:false ui:spn_Weakness
UseLimit type:#boolean default:false ui:chk_UseLimit
MinLimit type:#float animatable:false ui:spn_MinLimit
MaxLimit type:#float animatable:false ui:spn_MaxLimit
UseLimit2 type:#boolean default:false ui:chk_UseLimit2
MinLimit2 type:#float animatable:false ui:spn_MinLimit2
MaxLimit2 type:#float animatable:false ui:spn_MaxLimit2
UseTwist type:#boolean default:false ui:chk_UseTwist
MinTwist type:#float animatable:false ui:spn_MinTwist
MaxTwist type:#float animatable:false ui:spn_MaxTwist
FlapSprings type:#point3Tab tabSizeVariable:true
UseLocation type:#boolean ui:chk_UseLocation
UseNormal type:#boolean ui:chk_UseNormal
)
parameters visualSettingsBlock rollout:jointVisualSettings
(
Limit1Start type:#float animatable:false ui:spn_Limit1Start
Limit2Start type:#float animatable:false ui:spn_Limit2Start
TwistStart type:#float animatable:false ui:spn_TwistStart
)
rollout jointParams "Joint"
(
radiobuttons rad_JointType "Joint Type" columns:2 labels:#("Hinge", "Ball","UJ","Slide")
spinner spn_Weakness "Weakness" fieldwidth:40 range:[-100000,100000,0]
checkbox chk_UseLimit "Limit"
spinner spn_MinLimit "" fieldwidth:40 across:2 range:[-360,360,0]
spinner spn_MaxLimit "" fieldwidth:40 across:2 range:[-360,360,15]
checkbox chk_UseLimit2 "Limit 2"
spinner spn_MinLimit2 "" fieldwidth:40 across:2 range:[-360,360,0]
spinner spn_MaxLimit2 "" fieldwidth:40 across:2 range:[-360,360,15]
checkbox chk_UseTwist "Twist"
spinner spn_MinTwist "" fieldwidth:40 across:2 range:[-360,360,0]
spinner spn_MaxTwist "" fieldwidth:40 across:2 range:[-360,360,15]
checkbox chk_UseLocation "Use Location"
checkbox chk_UseNormal "Use Joint Normal"
group "Flap Springs"
(
spinner spn_FlapSpring1 "" type:#worldunits range:[-10000, 10000, 0] across:3 fieldwidth:30
spinner spn_FlapSpring2 "" type:#worldunits range:[-10000, 10000, 0] across:3 fieldwidth:30
button but_AddFlapSpring "Add" across:3
dotnetcontrol lv_FlapSprings "listview" height: 100
button but_DelFlapSpring "Delete"
)
on jointParams open do
(
lv_FlapSprings.view = (dotnetclass "view").details
lv_FlapSprings.fullrowselect= true
lv_FlapSprings.gridlines = true
lv_FlapSprings.multiselect =false
lv_FlapSprings.columns.add "Spring 1" 55
lv_FlapSprings.columns.add "Spring 2" 55
for i=1 to FlapSprings.count do
(
lvItem = dotnetobject "listviewitem" (FlapSprings[i].x as string)
lvitem.subitems.add (FlapSprings[i].y as string)
lv_FlapSprings.Items.add lvitem
)
)
on but_DelFlapSpring pressed do
(
if lv_FlapSprings.SelectedIndices.count > 0 then
(
selectedIndex = lv_FlapSprings.SelectedIndices.Item[0]
lv_FlapSprings.Items.removeat selectedIndex
deleteItem FlapSprings (selectedIndex+1)
)
)
on but_AddFlapSpring pressed do
(
lvItem = dotnetobject "listviewitem" (spn_FlapSpring1.value as string)
lvitem.subitems.add (spn_FlapSpring2.value as string)
lv_FlapSprings.Items.add lvitem
append FlapSprings [spn_FlapSpring1.value, spn_FlapSpring2.value, 0]
)
on rad_JointType changed index do
(
JointType_Hinge = false
JointType_Ball = false
JointType_UJ =false
JointType_Slide =false
case index of
(
1: JointType_Hinge=true
2: JointType_Ball=true
3: JointType_UJ=true
4: JointType_Slide=true
)
--format "JointType: %\nHinge: %\n Ball: %\n Slide: %\n" JointType JointType_Hinge JointType_Ball JointType_UJ JointType_Slide
)
on chk_UseTwist changed state do
(
if state then
(
spn_MinTwist.enabled=true
spn_MaxTwist.enabled=true
)
else
(
spn_MinTwist.enabled=false
spn_MaxTwist.enabled=false
)
)
/*on chk_UseLimit changed state do
(
if state then
(
spn_MinLimit.enabled=true
spn_MaxLimit.enabled=true
)
else
(
spn_MinLimit.enabled=false
spn_MaxLimit.enabled=false
)
)*/
on chk_UseLimit2 changed state do
(
if state then
(
spn_MinLimit2.enabled=true
spn_MaxLimit2.enabled=true
)
else
(
spn_MinLimit2.enabled=false
spn_MaxLimit2.enabled=false
)
)
)
rollout jointVisualSettings "Visualisation Settings"
(
spinner spn_Limit1Start "Limit 1 Start Position" fieldwidth:40 range:[-360,360,0] labelOnTop:true
spinner spn_Limit2Start "Limit 2 Start Position" fieldwidth:40 range:[-360,360,0] labelOnTop:true
spinner spn_TwistStart "Twist Start Position" fieldwidth:40 range:[-360,360,0] labelOnTop:true
)
fn SetTransformFromAxisAndNormal = (
trans = thisNode.transform
transRow1 = JointAxis
--format "transRow1 = %\n" transRow1
if UseNormal then
(
transRow2 = cross JointNormal JointAxis
--format "transRow2 = %\n" transRow2
transRow3 = JointNormal
--format "transRow3 = %\n" transRow3
)
else
(
if JointAxis == [0,0,-1] then
(
--format "Axis is facing down\n"
transRow2 = cross [1,0,0] JointAxis
--format "transRow3 = %\n" transRow3
transRow3 = cross JointAxis transRow2
--format "transRow2 = %\n" transRow2
transRow2 = cross JointAxis transRow3
--format "transRow3 = %\n" transRow3
)
else if JointAxis == [0,0,1] then
(
--format "Axis is facing up\n"
transRow2 = cross [-1,0,0] JointAxis
--format "transRow3 = %\n" transRow3
transRow3 = cross transRow2 JointAxis
--format "transRow2 = %\n" transRow2
transRow2 = cross JointAxis transRow3
--format "transRow3 = %\n" transRow3
)
else
(
--format "Axis is not facing backwards\n"
transRow2 = cross JointAxis [0,0,-1]
--format "transRow3 = %\n" transRow3
transRow3 = cross JointAxis transRow2
--format "transRow2 = %\n" transRow2
transRow2 = cross JointAxis transRow3
--format "transRow3 = %\n" transRow3
)
trans.row2 = transRow2
trans.row3 = transRow3
)
thisNode.transform = matrix3 transRow1 transRow2 transRow3 trans.row4
)
on postload do
(
thisNode = NodeStorage.node
)
on load do
(
thisNode = NodeStorage.node
)
on attachedToNode nodeVar do
(
thisNode = nodeVar
NodeStorage = nodeTransformMonitor node:nodeVar forwardTransformChangeMsgs:false
)
on buildmesh do
(
if meshObj == undefined or lastJointType != jointType or lastMinTwist != minTwist or lastMaxTwist != maxTwist or lastMinLimit != minLimit or lastMaxLimit != maxLimit or lastMinLimit2 != minLimit2 or lastMaxLimit2 != maxLimit2 or lastLimit1Start != Limit1Start or lastLimit2Start != Limit2Start or lastTwistStart != TwistStart then
(
verts =#(
[0,0,0],
[0.5,0,0],
[0,0,0.25]
)
faces = #(
[1, 2, 3]
)
vertCount=3
faceVis = #(#(true,false, true))
if JointType_Slide then
(
if maxLimit != minLimit then
(
if minLimit > maxLimit then
(
tmp = maxLimit
thismaxLimit = minLimit
thisminLimit = tmp
)
else
(
thismaxlimit= maxlimit
thisminlimit =minlimit
)
midPoint = (thisMaxLimit+thisMinLimit)*0.5
if thisMaxLimit - ((thisMaxLimit+thisMinLimit)*0.5) > 0.75 then midPoint = thisMaxLimit - 0.75
v1 = [-thisMinLimit, 0.25,0.0]
v2 = [-thisMinLimit, -0.25,0.0]
v3 = [-midpoint, 0.25,0.0]
v4 = [-midpoint, -0.25,0.0]
v5 = [-thisMaxLimit, 0,0.0]
v6 = [-midpoint, -0.75,0.0]
v7 = [-midpoint, 0.75,0.0]
append verts v1
append verts v2
append verts v3
append verts v4
append verts v5
append verts v6
append verts v7
append faces [vertCount+1,vertCount+3,vertCount+2]
append faces [vertCount+2,vertCount+3,vertCount+4]
append faces [vertCount+5,vertCount+6,vertCount+4]
append faces [vertCount+5,vertCount+3,vertCount+7]
append faces [vertCount+5,vertCount+4,vertCount+3]
append faceVis #(true, false, true)
append faceVis #(false, false, true)
append faceVis #(true, true, false)
append faceVis #(false, true, true)
append faceVis #(false, false, false)
vertCount += 4
)
)
else if JointType_Hinge or JointType_UJ or JointType_Ball then
(
if maxLimit != minLimit then
(
if minLimit > maxLimit then
(
tmp = maxLimit
thismaxLimit = minLimit
thisminLimit = tmp
)
else
(
thismaxlimit= maxlimit
thisminlimit =minlimit
)
steps = (thismaxLimit - thisminLimit)/512
width = steps/2
radius1=0.75
radius2=0.45
radiusSteps = ((radius1 - radius2) * 0.5)/512
heightSteps = ((thismaxLimit - thisminLimit)/360)*0.0001
height=0
for a = thisminLimit + Limit1Start to thismaxLimit + Limit1Start by steps do
(
v1 = [height, radius1*cos(a+width),radius1*sin(a+width)]
v2 = [height+heightSteps, radius1*cos(a-width),radius1*sin(a-width)]
v3 = [height, radius2*cos(a+width),radius2*sin(a+width)]
v4 = [height+heightSteps, radius2*cos(a-width),radius2*sin(a-width)]
radius1 -= radiusSteps
radius2 += radiusSteps
append verts v1
append verts v2
append verts v3
append verts v4
height += heightSteps
append faces [vertCount+1,vertCount+3,vertCount+2]
append faces [vertCount+2,vertCount+3,vertCount+4]
if a== thisminLimit then
(
append faceVis #(true, false, true)
append faceVis #(true, true, false)
)
else if a+ steps >= thismaxLimit then
(
append faceVis #(false, true, true)
append faceVis #(false, true, true)
)
else
(
append faceVis #(false, false, true)
append faceVis #(false, true, false)
)
vertCount += 4
)
)
)
if JointType_UJ or JointType_Ball then
(
if maxLimit2 != minLimit2 then
(
if minLimit2 > maxLimit2 then
(
tmp = maxLimit2
thismaxLimit2 = minLimit2
thisminLimit2 = tmp
)
else
(
thismaxlimit2= maxlimit2
thisminlimit2 =minlimit2
)
steps = (thismaxlimit2 - thisminlimit2)/512
width = steps/2
radius1=0.75
radius2=0.45
radiusSteps = ((radius1 - radius2) * 0.5)/512
heightSteps = ((thismaxlimit2 - thisminlimit2)/360)*0.0001
height=0.0
sideways = 0
for a = thisminlimit2 + Limit2Start to thismaxlimit2 + Limit2Start by steps do
(
v1 = [ radius1*cos(a+width)+sideways,height,radius1*sin(a+width)]
v2 = [radius1*cos(a-width)+sideways,height+heightSteps, radius1*sin(a-width)]
v3 = [radius2*cos(a+width)+sideways,height,radius2*sin(a+width)]
v4 = [radius2*cos(a-width)+sideways,height+heightSteps, radius2*sin(a-width)]
radius1 -= radiusSteps
radius2 += radiusSteps
append verts v1
append verts v2
append verts v3
append verts v4
height += heightSteps
append faces [vertCount+1,vertCount+3,vertCount+2]
append faces [vertCount+2,vertCount+3,vertCount+4]
if a== thisminlimit2 then
(
append faceVis #(true, false, true)
append faceVis #(true, true, false)
)
else if a+ steps >= thismaxlimit2 then
(
append faceVis #(false, true, true)
append faceVis #(false, true, true)
)
else
(
append faceVis #(false, false, true)
append faceVis #(false, true, false)
)
vertCount += 4
)
)
)
if JointType_Ball then
(
if maxTwist != minTwist then
(
if minTwist > maxTwist then
(
tmp = maxTwist
thismaxTwist = minTwist
thisminTwist = tmp
)
else
(
thismaxTwist= maxTwist
thisminTwist =minTwist
)
steps = (thismaxTwist - thisminTwist)/512
width = steps/2
radius1=0.75
radius2=0.45
radiusSteps = ((radius1 - radius2) * 0.5)/512
heightSteps = ((thismaxTwist - thisminTwist)/360)*0.0001
height=0.0
sideways = 0
for a = thisminTwist + TwistStart to thismaxTwist + TwistStart by steps do
(
v1 = [-radius1*cos(a+width)+sideways,radius1*sin(a+width),height]
v2 = [-radius1*cos(a-width)+sideways, radius1*sin(a-width),height+heightSteps]
v3 = [-radius2*cos(a+width)+sideways,radius2*sin(a+width),height]
v4 = [-radius2*cos(a-width)+sideways, radius2*sin(a-width),height+heightSteps]
append verts v1
append verts v2
append verts v3
append verts v4
radius1 -= radiusSteps
radius2 += radiusSteps
height += heightSteps
append faces [vertCount+1,vertCount+3,vertCount+2]
append faces [vertCount+2,vertCount+3,vertCount+4]
if a== thisminTwist then
(
append faceVis #(true, false, true)
append faceVis #(true, true, false)
)
else if a+ steps >= thismaxTwist then
(
append faceVis #(false, true, true)
append faceVis #(false, true, true)
)
else
(
append faceVis #(false, false, true)
append faceVis #(false, true, false)
)
vertCount += 4
)
)
)
tmpmeshObj = polymesh vertices:verts faces:faces
for i = 1 to faceVis.count do
(
setEdgeVis tmpmeshObj i 1 faceVis[i][1]
setEdgeVis tmpmeshObj i 2 faceVis[i][2]
setEdgeVis tmpmeshObj i 3 faceVis[i][3]
)
lastJointType = jointType
lastMinTwist = minTwist
lastMaxTwist = maxTwist
lastMinLimit = minLimit
lastMaxLimit = maxLimit
lastMinLimit2 = minLimit2
lastMaxLimit2 = maxLimit2
lastLimit1Start = Limit1Start
lastLimit2Start = Limit2Start
lastTwistStart = TwistStart
meshObj = copy tmpMeshObj.mesh
delete tmpmeshobj
)
setmesh mesh meshObj
)
tool create
(
on mousePoint click do
(
case click of
(
1:
(
coordsys grid (nodeTM.translation = gridPoint)
)
2: #stop
)
)
on mouseMove click do
(
case click of
(
2: #stop
)
)
)
)
format "CREATING CarmaHelper_WheelPlaceholder!!!!\n\n"
CarmaHelper_WheelType = #("Wheel_FR","Wheel_FL","Wheel_RR","Wheel_RL","WheelRL_001","WheelRR_001","WheelRL_002","WheelRR_002","WheelRL_003","WheelRR_003","WheelRL_004","WheelRR_004")
plugin simpleObject CarmaHelper_WheelPlaceholder
Name:"Wheel"
classID:#(0x4892a691, 0x7b9572bb)
category:"Carmageddon: Reincarnation"
version:2
(
local usingMesh, actualMeshObj, actualMeshMat, placeholderMeshObj, lastWheelName, lastWheelFilename, thisNode, oldWheelFileName
parameters wheelParamBlock rollout:wheelParams
(
NodeStorage type:#maxObject
wheelType type:#string animatable:false default:CarmaHelper_WheelType[1]
wheelTypeID type:#integer animatable:false default:1
wheelFileName type:#string animatable:false ui:txt_wheelFileName
wheelName type:#string animatable:false ui:txt_wheelName
previewWheel type:#boolean animatable:false ui:chk_PreviewWheel
forceRefresh type:#boolean default:false
)
fn combineWheelMeshes obj doDelete:false =
(
outMesh = undefined
if IsObjectACNT obj and obj.modifiers["CNT Hierarchy"].NodeType=="MODL" then
(
outMesh = copy obj
convertTo outMesh Editable_Poly
ResetXForm outMesh
)
for child in obj.children do
(
childIsModl = childmesh !=undefined and childmesh.modifiers != undefined and IsObjectACNT childmesh and childmesh.modifiers["CNT Hierarchy"].NodeType=="MODL"
childMesh = combineWheelMeshes child
if outMesh == undefined then
(
outMesh = childmesh
)
else if childmesh !=undefined then --and childmesh.modifiers != undefined and IsObjectACNT childmesh and childmesh.modifiers["CNT Hierarchy"].NodeType=="MODL" then
(
/*oldMeshNumVerts = getNumVerts outMesh
numVerts = getNumVerts childMesh
numFaces = getNumFaces childMesh
setNumVerts outMesh (oldMeshNumVerts+numVerts)
for i = 1 to numVerts do
(
setVert outMesh (oldMeshNumVerts+i) (getVert childMesh i)
)*/
polyop.attach outMesh childMesh
)
)
delete obj
outMesh
)
fn loadWheelMesh cnt_name =
(
--format "======================\nLoading wheelmesh %\n==================\n" cnt_name
rimMesh = ImportCNT cnt_name importTextures:true forcePREP:true useTriStrips:false
tyreMesh = ImportCNT ((getFilenamePath cnt_name)+"Tyre.cnt") importTextures:true forcePREP:true useTriStrips:false
append rimMesh.children tyreMesh
combinedMesh = combineWheelMeshes rimMesh
actualMeshObj = copy combinedMesh.mesh
actualMeshMat =combinedMesh.material
delete combinedMesh
oldWheelFileName = cnt_name
wheelFileName = cnt_name
splitPath = filterstring (getFileNamePath cnt_name) "/\\"
wheelName = splitPath[splitPath.count]
)
rollout wheelParams "Wheel Parameters"
(
dropdownlist dpdn_wheelType "Wheel Type" items:CarmaHelper_WheelType selection:wheelTypeID
edittext txt_wheelName "Wheel Name" labelOnTop:true
edittext txt_wheelFileName "Wheel Folder" labelOnTop:true
button but_loadWheel "Load Wheel"
checkbox chk_PreviewWheel "Preview Wheel"
on dpdn_wheelType selected i do
(
wheelTypeID = dpdn_wheelType.selection
wheelType = dpdn_wheelType.items[i]
thisNode.name = wheelType
forceRefresh= true
)
on chk_PreviewWheel checked value do (
forceRefresh= value == false
)
on but_loadWheel pressed do
(
cnt_name = GetOpenFileName caption:"Open Rim.CNT File" types:"Rim.CNT(Rim.CNT)|rim.cnt"
if cnt_name != undefined then
(
loadWheelMesh cnt_name
)
this.forceRefresh = this.previewWheel == false
)
on wheelParams open do
(
)
)
on postLoad do
(
thisNode = NodeStorage.node
oldWheelFilename=""
usingMesh = undefined
placeholderMeshObj = undefined
actualMeshObj = undefined
this.forceRefresh = this.previewWheel == false
)
on load do (
thisNode = NodeStorage.node
oldWheelFilename=""
usingMesh = undefined
placeholderMeshObj = undefined
actualMeshObj = undefined
)
on attachedToNode nodeVar do
(
thisNode = nodeVar
NodeStorage = nodeTransformMonitor node:nodeVar forwardTransformChangeMsgs:false
)
on buildmesh do
(
if placeholderMeshObj == undefined then
(
tmpmesh = polymesh vertices:#([-0.163197, 0.0, -0.316496],[-0.163197, 0.108248, -0.297409],[-0.163198, 0.20344, -0.24245],[-0.163198, 0.274093, -0.158248],[-0.163198, 0.311688, -0.0549589],[-0.163198, 0.311688, 0.0549589],[-0.163198, 0.274093, 0.158248],[-0.163198, 0.20344, 0.24245],[-0.163198, 0.108248, 0.297409],[-0.163198, 0.0, 0.316496],[-0.163198, -0.108248, 0.297409],[-0.163198, -0.20344, 0.24245],[-0.163198, -0.274093, 0.158248],[-0.163198, -0.311687, 0.054959],[-0.163198, -0.311688, -0.0549588],[-0.163198, -0.274093, -0.158248],[-0.163198, -0.20344, -0.24245],[-0.163198, -0.108248, -0.297409],[0.0, 0.122818, -0.33744],[0.0, 0.230822, -0.275083],[0.0, 0.310986, -0.179548],[0.0, 0.35364, -0.0623563],[0.0, 0.35364, 0.0623563],[0.0, 0.310986, 0.179548],[0.0, 0.230822, 0.275083],[0.0, 0.122818, 0.33744],[0.0, 0.0, 0.359096],[0.0, -0.122818, 0.33744],[0.0, -0.230822, 0.275083],[0.0, -0.310986, 0.179548],[0.0, -0.35364, 0.0623564],[0.0, -0.35364, -0.0623562],[0.0, -0.310986, -0.179548],[0.0, -0.230822, -0.275083],[0.0, -0.122818, -0.33744],[0.0, 0.0, -0.359096],[0.163197, 0.0, -0.316496],[0.163197, 0.108248, -0.297409],[0.163197, 0.20344, -0.24245],[0.163197, 0.274093, -0.158248],[0.163197, 0.311688, -0.0549589],[0.163197, 0.311688, 0.0549589],[0.163197, 0.274093, 0.158248],[0.163197, 0.20344, 0.24245],[0.163197, 0.108248, 0.297409],[0.163197, 0.0, 0.316496],[0.163197, -0.108248, 0.297409],[0.163197, -0.20344, 0.24245],[0.163197, -0.274093, 0.158248],[0.163197, -0.311687, 0.054959],[0.163197, -0.311688, -0.0549588],[0.163197, -0.274093, -0.158248],[0.163197, -0.20344, -0.24245],[0.163197, -0.108248, -0.297409],[0.163197, 0.0, -0.275879],[0.163197, 0.0943561, -0.259241],[0.163197, 0.177331, -0.211335],[0.163197, 0.238918, -0.137939],[0.163197, 0.271688, -0.0479058],[0.163197, 0.271688, 0.0479059],[0.163197, 0.238918, 0.137939],[0.163197, 0.177331, 0.211335],[0.163197, 0.0943561, 0.259241],[0.163197, 0.0, 0.275879],[0.163197, -0.094356, 0.259241],[0.163197, -0.177331, 0.211335],[0.163197, -0.238918, 0.137939],[0.163197, -0.271687, 0.0479059],[0.163197, -0.271688, -0.0479057],[0.163197, -0.238918, -0.137939],[0.163197, -0.177332, -0.211335],[0.163197, -0.0943563, -0.259241],[-0.0768025, 0.0, -0.275879],[-0.0768025, 0.0943561, -0.259241],[-0.0768026, 0.177331, -0.211335],[-0.0768026, 0.238918, -0.137939],[-0.0768026, 0.271688, -0.0479059],[-0.0768025, 0.271688, 0.0479058],[-0.0768026, 0.238918, 0.137939],[-0.0768026, 0.177331, 0.211335],[-0.0768026, 0.0943561, 0.259241],[-0.0768026, 0.0, 0.275879],[-0.0768025, -0.094356, 0.259241],[-0.0768026, -0.177331, 0.211335],[-0.0768026, -0.238918, 0.137939],[-0.0768025, -0.271687, 0.0479059],[-0.0768025, -0.271688, -0.0479057],[-0.0768026, -0.238918, -0.137939],[-0.0768026, -0.177332, -0.211335],[-0.0768025, -0.0943563, -0.259241]) faces:#([1.0, 2.0, 19.0],[19.0, 36.0, 1.0],[2.0, 3.0, 20.0],[20.0, 19.0, 2.0],[3.0, 4.0, 21.0],[21.0, 20.0, 3.0],[4.0, 5.0, 22.0],[22.0, 21.0, 4.0],[5.0, 6.0, 23.0],[23.0, 22.0, 5.0],[6.0, 7.0, 24.0],[24.0, 23.0, 6.0],[7.0, 8.0, 25.0],[25.0, 24.0, 7.0],[8.0, 9.0, 26.0],[26.0, 25.0, 8.0],[9.0, 10.0, 27.0],[27.0, 26.0, 9.0],[10.0, 11.0, 28.0],[28.0, 27.0, 10.0],[11.0, 12.0, 29.0],[29.0, 28.0, 11.0],[12.0, 13.0, 30.0],[30.0, 29.0, 12.0],[13.0, 14.0, 31.0],[31.0, 30.0, 13.0],[14.0, 15.0, 32.0],[32.0, 31.0, 14.0],[15.0, 16.0, 33.0],[33.0, 32.0, 15.0],[16.0, 17.0, 34.0],[34.0, 33.0, 16.0],[17.0, 18.0, 35.0],[35.0, 34.0, 17.0],[18.0, 1.0, 36.0],[36.0, 35.0, 18.0],[36.0, 19.0, 38.0],[38.0, 37.0, 36.0],[19.0, 20.0, 39.0],[39.0, 38.0, 19.0],[20.0, 21.0, 40.0],[40.0, 39.0, 20.0],[21.0, 22.0, 41.0],[41.0, 40.0, 21.0],[22.0, 23.0, 42.0],[42.0, 41.0, 22.0],[23.0, 24.0, 43.0],[43.0, 42.0, 23.0],[24.0, 25.0, 44.0],[44.0, 43.0, 24.0],[25.0, 26.0, 45.0],[45.0, 44.0, 25.0],[26.0, 27.0, 46.0],[46.0, 45.0, 26.0],[27.0, 28.0, 47.0],[47.0, 46.0, 27.0],[28.0, 29.0, 48.0],[48.0, 47.0, 28.0],[29.0, 30.0, 49.0],[49.0, 48.0, 29.0],[30.0, 31.0, 50.0],[50.0, 49.0, 30.0],[31.0, 32.0, 51.0],[51.0, 50.0, 31.0],[32.0, 33.0, 52.0],[52.0, 51.0, 32.0],[33.0, 34.0, 53.0],[53.0, 52.0, 33.0],[34.0, 35.0, 54.0],[54.0, 53.0, 34.0],[35.0, 36.0, 37.0],[37.0, 54.0, 35.0],[17.0, 16.0, 15.0],[15.0, 14.0, 13.0],[13.0, 12.0, 11.0],[15.0, 13.0, 11.0],[11.0, 10.0, 9.0],[9.0, 8.0, 7.0],[11.0, 9.0, 7.0],[7.0, 6.0, 5.0],[5.0, 4.0, 3.0],[7.0, 5.0, 3.0],[11.0, 7.0, 3.0],[15.0, 11.0, 3.0],[3.0, 2.0, 1.0],[15.0, 3.0, 1.0],[17.0, 15.0, 1.0],[18.0, 17.0, 1.0],[74.0, 75.0, 76.0],[76.0, 77.0, 78.0],[78.0, 79.0, 80.0],[76.0, 78.0, 80.0],[80.0, 81.0, 82.0],[82.0, 83.0, 84.0],[80.0, 82.0, 84.0],[84.0, 85.0, 86.0],[86.0, 87.0, 88.0],[84.0, 86.0, 88.0],[80.0, 84.0, 88.0],[76.0, 80.0, 88.0],[88.0, 89.0, 90.0],[76.0, 88.0, 90.0],[74.0, 76.0, 90.0],[73.0, 74.0, 90.0],[37.0, 38.0, 56.0],[56.0, 55.0, 37.0],[38.0, 39.0, 57.0],[57.0, 56.0, 38.0],[39.0, 40.0, 58.0],[58.0, 57.0, 39.0],[40.0, 41.0, 59.0],[59.0, 58.0, 40.0],[41.0, 42.0, 60.0],[60.0, 59.0, 41.0],[42.0, 43.0, 61.0],[61.0, 60.0, 42.0],[43.0, 44.0, 62.0],[62.0, 61.0, 43.0],[44.0, 45.0, 63.0],[63.0, 62.0, 44.0],[45.0, 46.0, 64.0],[64.0, 63.0, 45.0],[46.0, 47.0, 65.0],[65.0, 64.0, 46.0],[47.0, 48.0, 66.0],[66.0, 65.0, 47.0],[48.0, 49.0, 67.0],[67.0, 66.0, 48.0],[49.0, 50.0, 68.0],[68.0, 67.0, 49.0],[50.0, 51.0, 69.0],[69.0, 68.0, 50.0],[51.0, 52.0, 70.0],[70.0, 69.0, 51.0],[52.0, 53.0, 71.0],[71.0, 70.0, 52.0],[53.0, 54.0, 72.0],[72.0, 71.0, 53.0],[54.0, 37.0, 55.0],[55.0, 72.0, 54.0],[55.0, 56.0, 74.0],[74.0, 73.0, 55.0],[56.0, 57.0, 75.0],[75.0, 74.0, 56.0],[57.0, 58.0, 76.0],[76.0, 75.0, 57.0],[58.0, 59.0, 77.0],[77.0, 76.0, 58.0],[59.0, 60.0, 78.0],[78.0, 77.0, 59.0],[60.0, 61.0, 79.0],[79.0, 78.0, 60.0],[61.0, 62.0, 80.0],[80.0, 79.0, 61.0],[62.0, 63.0, 81.0],[81.0, 80.0, 62.0],[63.0, 64.0, 82.0],[82.0, 81.0, 63.0],[64.0, 65.0, 83.0],[83.0, 82.0, 64.0],[65.0, 66.0, 84.0],[84.0, 83.0, 65.0],[66.0, 67.0, 85.0],[85.0, 84.0, 66.0],[67.0, 68.0, 86.0],[86.0, 85.0, 67.0],[68.0, 69.0, 87.0],[87.0, 86.0, 68.0],[69.0, 70.0, 88.0],[88.0, 87.0, 69.0],[70.0, 71.0, 89.0],[89.0, 88.0, 70.0],[71.0, 72.0, 90.0],[90.0, 89.0, 71.0],[72.0, 55.0, 73.0],[73.0, 90.0, 72.0])
placeholderMeshObj = copy tmpmesh.mesh
delete tmpmesh
--placeholderMeshObj.name = wheelType
for i=1 to (GetNumFaces placeholderMeshObj) do
(
setFaceSmoothGroup placeholderMeshObj i 1
)
)
if oldWheelFilename != wheelFileName and wheelFileName!= "" then
(
loadWheelMesh wheelFileName
)
--if actualMeshObj == undefined then format "Actual Mesh undefined\n"
--else format "Actual mesh is there yay!\n"
if this.previewWheel and actualMeshObj!=undefined then
(
--format "Setting model to tire\n"
thisNode.material = actualMeshMat
setmesh thisNode.mesh actualMeshObj
usingMesh = copy actualMeshObj
--format "Using Preview Wheel with % verts\n" (getNumVerts actualMeshObj)
--format "Usingmesh with % verts\n" (getNumVerts usingMesh)
)
else
(
--format "Setting model to placeholder\n"
thisNode.material=undefined
setmesh thisNode.mesh placeholderMeshObj
usingMesh = copy placeholderMeshObj
if forceRefresh then forceRefresh = false
--format "Using Placeholder Wheel with % verts\n" (getNumVerts placeholderMeshObj)
--format "Usingmesh with % verts\n" (getNumVerts usingMesh)
)
if this.forceRefresh != this.previewWheel then this.forceRefresh = this.previewWheel
--setmesh mesh undefined
-- CompleteRedraw()
setmesh mesh usingMesh
--CompleteRedraw()
--setMesh -- mesh vertices:#([-0.163197, 0.0, -0.316496],[-0.163197, 0.108248, -0.297409],[-0.163198, 0.20344, -0.24245],[-0.163198, 0.274093, -0.158248],[-0.163198, 0.311688, -0.0549589],[-0.163198, 0.311688, 0.0549589],[-0.163198, 0.274093, 0.158248],[-0.163198, 0.20344, 0.24245],[-0.163198, 0.108248, 0.297409],[-0.163198, 0.0, 0.316496],[-0.163198, -0.108248, 0.297409],[-0.163198, -0.20344, 0.24245],[-0.163198, -0.274093, 0.158248],[-0.163198, -0.311687, 0.054959],[-0.163198, -0.311688, -0.0549588],[-0.163198, -0.274093, -0.158248],[-0.163198, -0.20344, -0.24245],[-0.163198, -0.108248, -0.297409],[0.0, 0.122818, -0.33744],[0.0, 0.230822, -0.275083],[0.0, 0.310986, -0.179548],[0.0, 0.35364, -0.0623563],[0.0, 0.35364, 0.0623563],[0.0, 0.310986, 0.179548],[0.0, 0.230822, 0.275083],[0.0, 0.122818, 0.33744],[0.0, 0.0, 0.359096],[0.0, -0.122818, 0.33744],[0.0, -0.230822, 0.275083],[0.0, -0.310986, 0.179548],[0.0, -0.35364, 0.0623564],[0.0, -0.35364, -0.0623562],[0.0, -0.310986, -0.179548],[0.0, -0.230822, -0.275083],[0.0, -0.122818, -0.33744],[0.0, 0.0, -0.359096],[0.163197, 0.0, -0.316496],[0.163197, 0.108248, -0.297409],[0.163197, 0.20344, -0.24245],[0.163197, 0.274093, -0.158248],[0.163197, 0.311688, -0.0549589],[0.163197, 0.311688, 0.0549589],[0.163197, 0.274093, 0.158248],[0.163197, 0.20344, 0.24245],[0.163197, 0.108248, 0.297409],[0.163197, 0.0, 0.316496],[0.163197, -0.108248, 0.297409],[0.163197, -0.20344, 0.24245],[0.163197, -0.274093, 0.158248],[0.163197, -0.311687, 0.054959],[0.163197, -0.311688, -0.0549588],[0.163197, -0.274093, -0.158248],[0.163197, -0.20344, -0.24245],[0.163197, -0.108248, -0.297409],[0.163197, 0.0, -0.275879],[0.163197, 0.0943561, -0.259241],[0.163197, 0.177331, -0.211335],[0.163197, 0.238918, -0.137939],[0.163197, 0.271688, -0.0479058],[0.163197, 0.271688, 0.0479059],[0.163197, 0.238918, 0.137939],[0.163197, 0.177331, 0.211335],[0.163197, 0.0943561, 0.259241],[0.163197, 0.0, 0.275879],[0.163197, -0.094356, 0.259241],[0.163197, -0.177331, 0.211335],[0.163197, -0.238918, 0.137939],[0.163197, -0.271687, 0.0479059],[0.163197, -0.271688, -0.0479057],[0.163197, -0.238918, -0.137939],[0.163197, -0.177332, -0.211335],[0.163197, -0.0943563, -0.259241],[-0.0768025, 0.0, -0.275879],[-0.0768025, 0.0943561, -0.259241],[-0.0768026, 0.177331, -0.211335],[-0.0768026, 0.238918, -0.137939],[-0.0768026, 0.271688, -0.0479059],[-0.0768025, 0.271688, 0.0479058],[-0.0768026, 0.238918, 0.137939],[-0.0768026, 0.177331, 0.211335],[-0.0768026, 0.0943561, 0.259241],[-0.0768026, 0.0, 0.275879],[-0.0768025, -0.094356, 0.259241],[-0.0768026, -0.177331, 0.211335],[-0.0768026, -0.238918, 0.137939],[-0.0768025, -0.271687, 0.0479059],[-0.0768025, -0.271688, -0.0479057],[-0.0768026, -0.238918, -0.137939],[-0.0768026, -0.177332, -0.211335],[-0.0768025, -0.0943563, -0.259241]) faces:#([1.0, 2.0, 19.0],[19.0, 36.0, 1.0],[2.0, 3.0, 20.0],[20.0, 19.0, 2.0],[3.0, 4.0, 21.0],[21.0, 20.0, 3.0],[4.0, 5.0, 22.0],[22.0, 21.0, 4.0],[5.0, 6.0, 23.0],[23.0, 22.0, 5.0],[6.0, 7.0, 24.0],[24.0, 23.0, 6.0],[7.0, 8.0, 25.0],[25.0, 24.0, 7.0],[8.0, 9.0, 26.0],[26.0, 25.0, 8.0],[9.0, 10.0, 27.0],[27.0, 26.0, 9.0],[10.0, 11.0, 28.0],[28.0, 27.0, 10.0],[11.0, 12.0, 29.0],[29.0, 28.0, 11.0],[12.0, 13.0, 30.0],[30.0, 29.0, 12.0],[13.0, 14.0, 31.0],[31.0, 30.0, 13.0],[14.0, 15.0, 32.0],[32.0, 31.0, 14.0],[15.0, 16.0, 33.0],[33.0, 32.0, 15.0],[16.0, 17.0, 34.0],[34.0, 33.0, 16.0],[17.0, 18.0, 35.0],[35.0, 34.0, 17.0],[18.0, 1.0, 36.0],[36.0, 35.0, 18.0],[36.0, 19.0, 38.0],[38.0, 37.0, 36.0],[19.0, 20.0, 39.0],[39.0, 38.0, 19.0],[20.0, 21.0, 40.0],[40.0, 39.0, 20.0],[21.0, 22.0, 41.0],[41.0, 40.0, 21.0],[22.0, 23.0, 42.0],[42.0, 41.0, 22.0],[23.0, 24.0, 43.0],[43.0, 42.0, 23.0],[24.0, 25.0, 44.0],[44.0, 43.0, 24.0],[25.0, 26.0, 45.0],[45.0, 44.0, 25.0],[26.0, 27.0, 46.0],[46.0, 45.0, 26.0],[27.0, 28.0, 47.0],[47.0, 46.0, 27.0],[28.0, 29.0, 48.0],[48.0, 47.0, 28.0],[29.0, 30.0, 49.0],[49.0, 48.0, 29.0],[30.0, 31.0, 50.0],[50.0, 49.0, 30.0],[31.0, 32.0, 51.0],[51.0, 50.0, 31.0],[32.0, 33.0, 52.0],[52.0, 51.0, 32.0],[33.0, 34.0, 53.0],[53.0, 52.0, 33.0],[34.0, 35.0, 54.0],[54.0, 53.0, 34.0],[35.0, 36.0, 37.0],[37.0, 54.0, 35.0],[17.0, 16.0, 15.0],[15.0, 14.0, 13.0],[13.0, 12.0, 11.0],[15.0, 13.0, 11.0],[11.0, 10.0, 9.0],[9.0, 8.0, 7.0],[11.0, 9.0, 7.0],[7.0, 6.0, 5.0],[5.0, 4.0, 3.0],[7.0, 5.0, 3.0],[11.0, 7.0, 3.0],[15.0, 11.0, 3.0],[3.0, 2.0, 1.0],[15.0, 3.0, 1.0],[17.0, 15.0, 1.0],[18.0, 17.0, 1.0],[74.0, 75.0, 76.0],[76.0, 77.0, 78.0],[78.0, 79.0, 80.0],[76.0, 78.0, 80.0],[80.0, 81.0, 82.0],[82.0, 83.0, 84.0],[80.0, 82.0, 84.0],[84.0, 85.0, 86.0],[86.0, 87.0, 88.0],[84.0, 86.0, 88.0],[80.0, 84.0, 88.0],[76.0, 80.0, 88.0],[88.0, 89.0, 90.0],[76.0, 88.0, 90.0],[74.0, 76.0, 90.0],[73.0, 74.0, 90.0],[37.0, 38.0, 56.0],[56.0, 55.0, 37.0],[38.0, 39.0, 57.0],[57.0, 56.0, 38.0],[39.0, 40.0, 58.0],[58.0, 57.0, 39.0],[40.0, 41.0, 59.0],[59.0, 58.0, 40.0],[41.0, 42.0, 60.0],[60.0, 59.0, 41.0],[42.0, 43.0, 61.0],[61.0, 60.0, 42.0],[43.0, 44.0, 62.0],[62.0, 61.0, 43.0],[44.0, 45.0, 63.0],[63.0, 62.0, 44.0],[45.0, 46.0, 64.0],[64.0, 63.0, 45.0],[46.0, 47.0, 65.0],[65.0, 64.0, 46.0],[47.0, 48.0, 66.0],[66.0, 65.0, 47.0],[48.0, 49.0, 67.0],[67.0, 66.0, 48.0],[49.0, 50.0, 68.0],[68.0, 67.0, 49.0],[50.0, 51.0, 69.0],[69.0, 68.0, 50.0],[51.0, 52.0, 70.0],[70.0, 69.0, 51.0],[52.0, 53.0, 71.0],[71.0, 70.0, 52.0],[53.0, 54.0, 72.0],[72.0, 71.0, 53.0],[54.0, 37.0, 55.0],[55.0, 72.0, 54.0],[55.0, 56.0, 74.0],[74.0, 73.0, 55.0],[56.0, 57.0, 75.0],[75.0, 74.0, 56.0],[57.0, 58.0, 76.0],[76.0, 75.0, 57.0],[58.0, 59.0, 77.0],[77.0, 76.0, 58.0],[59.0, 60.0, 78.0],[78.0, 77.0, 59.0],[60.0, 61.0, 79.0],[79.0, 78.0, 60.0],[61.0, 62.0, 80.0],[80.0, 79.0, 61.0],[62.0, 63.0, 81.0],[81.0, 80.0, 62.0],[63.0, 64.0, 82.0],[82.0, 81.0, 63.0],[64.0, 65.0, 83.0],[83.0, 82.0, 64.0],[65.0, 66.0, 84.0],[84.0, 83.0, 65.0],[66.0, 67.0, 85.0],[85.0, 84.0, 66.0],[67.0, 68.0, 86.0],[86.0, 85.0, 67.0],[68.0, 69.0, 87.0],[87.0, 86.0, 68.0],[69.0, 70.0, 88.0],[88.0, 87.0, 69.0],[70.0, 71.0, 89.0],[89.0, 88.0, 70.0],[71.0, 72.0, 90.0],[90.0, 89.0, 71.0],[72.0, 55.0, 73.0],[73.0, 90.0, 72.0])
)
tool create
(
on mousePoint click do
(
case click of
(
1:
(
thisNode.name = wheelType
coordsys grid (nodeTM.translation = gridPoint)
)
2: #stop
)
)
on mouseMove click do
(
case click of
(
2: #stop
)
)
)
)
struct AccessoryItemEntry (AccessoryMesh, AccessoryMaterial)
struct AccessoryManager (
ExistingAccessoryTypes = #(),
ExistingAccessoryMeshes = #(),
fn loadAccessoryMesh cnt_name =
(
accessoryMesh = ImportCNT cnt_name importTextures:true forcePREP:true useTriStrips:false mergeMDLs:true
actualMeshObj = copy accessoryMesh.mesh
actualMeshMat =accessoryMesh.material
delete accessoryMesh
entry = AccessoryItemEntry()
entry.AccessoryMesh = actualMeshObj
entry.AccessoryMaterial = actualMeshMat
entry
),
fn GetAccessory cnt_name =
(
splitPath = filterstring (getFileNamePath cnt_name) "/\\"
accessoryType = splitPath[splitPath.count]
result = undefined
accessoryExists = finditem ExistingAccessoryTypes accessoryType
if accessoryExists > 0 then
(
result = ExistingAccessoryMeshes[accessoryExists]
)
else
(
loadedMesh = loadAccessoryMesh cnt_name
append ExistingAccessoryTypes accessoryType
append ExistingAccessoryMeshes loadedMesh
result = loadedMesh
)
result
),
fn ClearAccessories =
(
delete ExistingAccessoryTypes
delete ExistingAccessoryMeshes
ExistingAccessoryTypes = #()
ExistingAccessoryMeshes = #()
)
)
AccessoryMan = AccessoryManager()
plugin simpleObject CarmaHelper_AccessoryPlaceholder
Name:"Level Accessory"
classID:#(0x40f1d017, 0x25af9649)
category:"Carmageddon: Reincarnation"
version:1
(
local usingMesh, actualMeshObj, actualMeshMat, placeholderMeshObj, lastAccessoryName, lastAccessoryFilename, thisNode, oldAccessoryFileName
parameters accessoryParamBlock rollout:accessoryParams
(
NodeStorage type:#maxObject
accessoryFileName type:#string animatable:false ui:txt_accessoryFileName
accessoryType type:#string animatable:false ui:txt_accessoryType
accessoryName type:#string animatable:false ui:txt_accessoryName
accessoryID type:#string animatable:false ui:txt_accessoryID
accessoryColour type:#color animatable:false ui:colpick_accessoryColour default:(color 255 255 255)
isPowerup type:#boolean animatable:false ui:chk_isPowerup
)
fn loadAccessoryMesh cnt_name =
(
/*
accessoryMesh = ImportCNT cnt_name importTextures:true forcePREP:false useTriStrips:false mergeMDLs:true
actualMeshObj = copy accessoryMesh.mesh
actualMeshMat =accessoryMesh.material
delete accessoryMesh*/
global AccessoryMan
accessoryEntry = AccessoryMan.GetAccessory cnt_name
actualMeshObj = accessoryEntry.AccessoryMesh
actualMeshMat = accessoryEntry.AccessoryMaterial
oldAccessoryFileName = cnt_name
accessoryFileName = cnt_name
splitPath = filterstring (getFileNamePath cnt_name) "/\\"
accessoryType = splitPath[splitPath.count]
)
rollout accessoryParams "Accessory Parameters"
(
edittext txt_accessoryID "Accessory Unique ID" labelOnTop:true
edittext txt_accessoryName "Accessory Name" labelOnTop:true
edittext txt_accessoryType "Accessory Type" labelOnTop:true
edittext txt_accessoryFileName "Accessory Folder" labelOnTop:true
colorpicker colpick_AccessoryColour "Accessory Colour"
button but_loadAccessory "Load Accessory"
checkbox chk_isPowerup "Is Powerup"
on but_loadAccessory pressed do
(
cnt_name = GetOpenFileName caption:"Open accessory.CNT File" types:"accessory.CNT(accessory.CNT)|accessory.cnt"
if cnt_name != undefined then
(
loadAccessoryMesh cnt_name
)
)
on accessoryParams open do
(
)
)
on postLoad do
(
thisNode = NodeStorage.node
oldAccessoryFilename=""
usingMesh = undefined
placeholderMeshObj = undefined
actualMeshObj = undefined
)
on load do (
thisNode = NodeStorage.node
oldAccessoryFilename=""
usingMesh = undefined
placeholderMeshObj = undefined
actualMeshObj = undefined
)
on attachedToNode nodeVar do
(
thisNode = nodeVar
NodeStorage = nodeTransformMonitor node:nodeVar forwardTransformChangeMsgs:false
)
on buildmesh do
(
if thisNode == undefined and NodeStorage != undefined and NodeStorage.node != undefined then (
thisNode = NodeStorage.node
)
if thisNode != undefined then (
if placeholderMeshObj == undefined then
(
tmpmesh = polymesh vertices:#([-0.00750644, -0.292164, -0.0157009],[0.00750644, -0.292164, -0.0157009],[-0.0225933, -0.022668, -0.0224066],[0.0225186, -0.0225186, -0.0224066],[-0.00750644, -0.292164, -0.000688014],[0.00750644, -0.292164, -0.000688014],[-0.0225933, -0.022668, 0.0224065],[0.0225186, -0.0225186, 0.0224065],[0.292164, -0.00750644, -0.00750644],[0.292164, 0.00750644, -0.00750644],[0.292164, -0.00750644, 0.00750644],[0.292164, 0.00750644, 0.00750644],[-0.0225933, 0.0225933, -0.0224065],[-0.00750644, 0.00750644, 0.27705],[0.00750644, 0.00750644, 0.27705],[0.022668, 0.0225933, -0.0224065],[0.00750644, -0.00750645, 0.27705],[-0.00750644, -0.00750645, 0.27705],[0.022668, 0.0225933, 0.0224065],[-0.0225933, 0.0225933, 0.0224065]) faces:#([1.0, 3.0, 4.0],[4.0, 2.0, 1.0],[5.0, 6.0, 8.0],[8.0, 7.0, 5.0],[1.0, 2.0, 6.0],[6.0, 5.0, 1.0],[2.0, 4.0, 8.0],[8.0, 6.0, 2.0],[3.0, 1.0, 5.0],[5.0, 7.0, 3.0],[9.0, 4.0, 16.0],[16.0, 10.0, 9.0],[11.0, 12.0, 19.0],[19.0, 8.0, 11.0],[9.0, 10.0, 12.0],[12.0, 11.0, 9.0],[10.0, 16.0, 19.0],[19.0, 12.0, 10.0],[4.0, 9.0, 11.0],[11.0, 8.0, 4.0],[13.0, 19.0, 16.0],[13.0, 4.0, 3.0],[15.0, 14.0, 18.0],[18.0, 17.0, 15.0],[20.0, 7.0, 18.0],[18.0, 14.0, 20.0],[14.0, 15.0, 19.0],[19.0, 20.0, 14.0],[17.0, 18.0, 7.0],[7.0, 8.0, 17.0],[15.0, 17.0, 8.0],[8.0, 19.0, 15.0],[20.0, 13.0, 7.0],[13.0, 20.0, 19.0],[13.0, 16.0, 4.0],[13.0, 3.0, 7.0])
placeholderMeshObj = copy tmpmesh.mesh
delete tmpmesh
--placeholderMeshObj.name = wheelType
for i=1 to (GetNumFaces placeholderMeshObj) do
(
setFaceSmoothGroup placeholderMeshObj i 1
)
)
if oldAccessoryFilename != accessoryFileName and accessoryFileName!= "" then
(
loadAccessoryMesh accessoryFileName
)
if actualMeshObj!=undefined then
(
thisNode.material = actualMeshMat
setmesh mesh actualMeshObj
usingMesh = actualMeshObj
--format "Using Preview Wheel with % verts\n" (getNumVerts actualMeshObj)
--format "Usingmesh with % verts\n" (getNumVerts usingMesh)
)
else
(
thisNode.material=undefined
--setmesh mesh placeholderMeshObj
usingMesh = placeholderMeshObj
--format "Using Placeholder Wheel with % verts\n" (getNumVerts placeholderMeshObj)
--format "Usingmesh with % verts\n" (getNumVerts usingMesh)
)
setmesh mesh usingMesh
--setMesh -- mesh vertices:#([-0.163197, 0.0, -0.316496],[-0.163197, 0.108248, -0.297409],[-0.163198, 0.20344, -0.24245],[-0.163198, 0.274093, -0.158248],[-0.163198, 0.311688, -0.0549589],[-0.163198, 0.311688, 0.0549589],[-0.163198, 0.274093, 0.158248],[-0.163198, 0.20344, 0.24245],[-0.163198, 0.108248, 0.297409],[-0.163198, 0.0, 0.316496],[-0.163198, -0.108248, 0.297409],[-0.163198, -0.20344, 0.24245],[-0.163198, -0.274093, 0.158248],[-0.163198, -0.311687, 0.054959],[-0.163198, -0.311688, -0.0549588],[-0.163198, -0.274093, -0.158248],[-0.163198, -0.20344, -0.24245],[-0.163198, -0.108248, -0.297409],[0.0, 0.122818, -0.33744],[0.0, 0.230822, -0.275083],[0.0, 0.310986, -0.179548],[0.0, 0.35364, -0.0623563],[0.0, 0.35364, 0.0623563],[0.0, 0.310986, 0.179548],[0.0, 0.230822, 0.275083],[0.0, 0.122818, 0.33744],[0.0, 0.0, 0.359096],[0.0, -0.122818, 0.33744],[0.0, -0.230822, 0.275083],[0.0, -0.310986, 0.179548],[0.0, -0.35364, 0.0623564],[0.0, -0.35364, -0.0623562],[0.0, -0.310986, -0.179548],[0.0, -0.230822, -0.275083],[0.0, -0.122818, -0.33744],[0.0, 0.0, -0.359096],[0.163197, 0.0, -0.316496],[0.163197, 0.108248, -0.297409],[0.163197, 0.20344, -0.24245],[0.163197, 0.274093, -0.158248],[0.163197, 0.311688, -0.0549589],[0.163197, 0.311688, 0.0549589],[0.163197, 0.274093, 0.158248],[0.163197, 0.20344, 0.24245],[0.163197, 0.108248, 0.297409],[0.163197, 0.0, 0.316496],[0.163197, -0.108248, 0.297409],[0.163197, -0.20344, 0.24245],[0.163197, -0.274093, 0.158248],[0.163197, -0.311687, 0.054959],[0.163197, -0.311688, -0.0549588],[0.163197, -0.274093, -0.158248],[0.163197, -0.20344, -0.24245],[0.163197, -0.108248, -0.297409],[0.163197, 0.0, -0.275879],[0.163197, 0.0943561, -0.259241],[0.163197, 0.177331, -0.211335],[0.163197, 0.238918, -0.137939],[0.163197, 0.271688, -0.0479058],[0.163197, 0.271688, 0.0479059],[0.163197, 0.238918, 0.137939],[0.163197, 0.177331, 0.211335],[0.163197, 0.0943561, 0.259241],[0.163197, 0.0, 0.275879],[0.163197, -0.094356, 0.259241],[0.163197, -0.177331, 0.211335],[0.163197, -0.238918, 0.137939],[0.163197, -0.271687, 0.0479059],[0.163197, -0.271688, -0.0479057],[0.163197, -0.238918, -0.137939],[0.163197, -0.177332, -0.211335],[0.163197, -0.0943563, -0.259241],[-0.0768025, 0.0, -0.275879],[-0.0768025, 0.0943561, -0.259241],[-0.0768026, 0.177331, -0.211335],[-0.0768026, 0.238918, -0.137939],[-0.0768026, 0.271688, -0.0479059],[-0.0768025, 0.271688, 0.0479058],[-0.0768026, 0.238918, 0.137939],[-0.0768026, 0.177331, 0.211335],[-0.0768026, 0.0943561, 0.259241],[-0.0768026, 0.0, 0.275879],[-0.0768025, -0.094356, 0.259241],[-0.0768026, -0.177331, 0.211335],[-0.0768026, -0.238918, 0.137939],[-0.0768025, -0.271687, 0.0479059],[-0.0768025, -0.271688, -0.0479057],[-0.0768026, -0.238918, -0.137939],[-0.0768026, -0.177332, -0.211335],[-0.0768025, -0.0943563, -0.259241]) faces:#([1.0, 2.0, 19.0],[19.0, 36.0, 1.0],[2.0, 3.0, 20.0],[20.0, 19.0, 2.0],[3.0, 4.0, 21.0],[21.0, 20.0, 3.0],[4.0, 5.0, 22.0],[22.0, 21.0, 4.0],[5.0, 6.0, 23.0],[23.0, 22.0, 5.0],[6.0, 7.0, 24.0],[24.0, 23.0, 6.0],[7.0, 8.0, 25.0],[25.0, 24.0, 7.0],[8.0, 9.0, 26.0],[26.0, 25.0, 8.0],[9.0, 10.0, 27.0],[27.0, 26.0, 9.0],[10.0, 11.0, 28.0],[28.0, 27.0, 10.0],[11.0, 12.0, 29.0],[29.0, 28.0, 11.0],[12.0, 13.0, 30.0],[30.0, 29.0, 12.0],[13.0, 14.0, 31.0],[31.0, 30.0, 13.0],[14.0, 15.0, 32.0],[32.0, 31.0, 14.0],[15.0, 16.0, 33.0],[33.0, 32.0, 15.0],[16.0, 17.0, 34.0],[34.0, 33.0, 16.0],[17.0, 18.0, 35.0],[35.0, 34.0, 17.0],[18.0, 1.0, 36.0],[36.0, 35.0, 18.0],[36.0, 19.0, 38.0],[38.0, 37.0, 36.0],[19.0, 20.0, 39.0],[39.0, 38.0, 19.0],[20.0, 21.0, 40.0],[40.0, 39.0, 20.0],[21.0, 22.0, 41.0],[41.0, 40.0, 21.0],[22.0, 23.0, 42.0],[42.0, 41.0, 22.0],[23.0, 24.0, 43.0],[43.0, 42.0, 23.0],[24.0, 25.0, 44.0],[44.0, 43.0, 24.0],[25.0, 26.0, 45.0],[45.0, 44.0, 25.0],[26.0, 27.0, 46.0],[46.0, 45.0, 26.0],[27.0, 28.0, 47.0],[47.0, 46.0, 27.0],[28.0, 29.0, 48.0],[48.0, 47.0, 28.0],[29.0, 30.0, 49.0],[49.0, 48.0, 29.0],[30.0, 31.0, 50.0],[50.0, 49.0, 30.0],[31.0, 32.0, 51.0],[51.0, 50.0, 31.0],[32.0, 33.0, 52.0],[52.0, 51.0, 32.0],[33.0, 34.0, 53.0],[53.0, 52.0, 33.0],[34.0, 35.0, 54.0],[54.0, 53.0, 34.0],[35.0, 36.0, 37.0],[37.0, 54.0, 35.0],[17.0, 16.0, 15.0],[15.0, 14.0, 13.0],[13.0, 12.0, 11.0],[15.0, 13.0, 11.0],[11.0, 10.0, 9.0],[9.0, 8.0, 7.0],[11.0, 9.0, 7.0],[7.0, 6.0, 5.0],[5.0, 4.0, 3.0],[7.0, 5.0, 3.0],[11.0, 7.0, 3.0],[15.0, 11.0, 3.0],[3.0, 2.0, 1.0],[15.0, 3.0, 1.0],[17.0, 15.0, 1.0],[18.0, 17.0, 1.0],[74.0, 75.0, 76.0],[76.0, 77.0, 78.0],[78.0, 79.0, 80.0],[76.0, 78.0, 80.0],[80.0, 81.0, 82.0],[82.0, 83.0, 84.0],[80.0, 82.0, 84.0],[84.0, 85.0, 86.0],[86.0, 87.0, 88.0],[84.0, 86.0, 88.0],[80.0, 84.0, 88.0],[76.0, 80.0, 88.0],[88.0, 89.0, 90.0],[76.0, 88.0, 90.0],[74.0, 76.0, 90.0],[73.0, 74.0, 90.0],[37.0, 38.0, 56.0],[56.0, 55.0, 37.0],[38.0, 39.0, 57.0],[57.0, 56.0, 38.0],[39.0, 40.0, 58.0],[58.0, 57.0, 39.0],[40.0, 41.0, 59.0],[59.0, 58.0, 40.0],[41.0, 42.0, 60.0],[60.0, 59.0, 41.0],[42.0, 43.0, 61.0],[61.0, 60.0, 42.0],[43.0, 44.0, 62.0],[62.0, 61.0, 43.0],[44.0, 45.0, 63.0],[63.0, 62.0, 44.0],[45.0, 46.0, 64.0],[64.0, 63.0, 45.0],[46.0, 47.0, 65.0],[65.0, 64.0, 46.0],[47.0, 48.0, 66.0],[66.0, 65.0, 47.0],[48.0, 49.0, 67.0],[67.0, 66.0, 48.0],[49.0, 50.0, 68.0],[68.0, 67.0, 49.0],[50.0, 51.0, 69.0],[69.0, 68.0, 50.0],[51.0, 52.0, 70.0],[70.0, 69.0, 51.0],[52.0, 53.0, 71.0],[71.0, 70.0, 52.0],[53.0, 54.0, 72.0],[72.0, 71.0, 53.0],[54.0, 37.0, 55.0],[55.0, 72.0, 54.0],[55.0, 56.0, 74.0],[74.0, 73.0, 55.0],[56.0, 57.0, 75.0],[75.0, 74.0, 56.0],[57.0, 58.0, 76.0],[76.0, 75.0, 57.0],[58.0, 59.0, 77.0],[77.0, 76.0, 58.0],[59.0, 60.0, 78.0],[78.0, 77.0, 59.0],[60.0, 61.0, 79.0],[79.0, 78.0, 60.0],[61.0, 62.0, 80.0],[80.0, 79.0, 61.0],[62.0, 63.0, 81.0],[81.0, 80.0, 62.0],[63.0, 64.0, 82.0],[82.0, 81.0, 63.0],[64.0, 65.0, 83.0],[83.0, 82.0, 64.0],[65.0, 66.0, 84.0],[84.0, 83.0, 65.0],[66.0, 67.0, 85.0],[85.0, 84.0, 66.0],[67.0, 68.0, 86.0],[86.0, 85.0, 67.0],[68.0, 69.0, 87.0],[87.0, 86.0, 68.0],[69.0, 70.0, 88.0],[88.0, 87.0, 69.0],[70.0, 71.0, 89.0],[89.0, 88.0, 70.0],[71.0, 72.0, 90.0],[90.0, 89.0, 71.0],[72.0, 55.0, 73.0],[73.0, 90.0, 72.0])
)
)
tool create
(
on mousePoint click do
(
case click of
(
1:
(
if accessoryType as string != "" then
(
thisNode.name = accessoryType as string
)
else thisNode.name = "Accessory"
coordsys grid (nodeTM.translation = gridPoint)
)
2: #stop
)
)
on mouseMove click do
(
case click of
(
2: #stop
)
)
)
)
--struct AINode (Index, Type, Radius, Position, RaceLine, RaceLineOffset)
--struct AILink (Node1, Node2, Width, Type, OneWay, Interior, Loop)
LinkMatLibrary = undefined
struct LinkMatTextureDetails (
OneWayTexture,
MaskTex1,
MaskTex2
)
UIIconPath = getFileNamePath (getThisScriptFilename())
LinkMatTextures = LinkMatTextureDetails OneWayTexture:(bitmaptexture hasAlpha:true filename:(UIIconPath+"UI/OneWayIcon.png")) MaskTex1:(bitmaptexture filename:(UIIconPath+"UI/LinkMask.png")) MaskTex2:(bitmaptexture filename:(UIIconPath+"UI/LinkMask2.png"))
fn CreateLinkMaterial name:"AILinkMat" isoneWay:false isWater:false isloop:false isinterior:false isTrack:false isShortcut:false = (
mat = DXMaterial()
mat.effectFile =UIIconPath+"Shaders\\AIPathShader.fx"
mat.masktex1 =LinkMatTextures.MaskTex1.bitmap
mat.masktex2 =LinkMatTextures.MaskTex2.bitmap
mat.onewaytex =LinkMatTextures.OneWayTexture.bitmap
mat.isoneway =isoneWay
mat.iswater = isWater
mat.isloop = isloop
mat.isinterior = isinterior
mat.isTrack = isTrack
mat.isShortcut = isShortcut
showTextureMap mat on
mat
)
struct LinkMatLibraryDetails (
linkMatNormal,
linkMatWater,
linkMatLoop,
linkMatInterior,
linkMatShortcut,
linkMatTrack,
linkMatOneWayNormal,
linkMatOneWayWater,
linkMatOneWayLoop,
linkMatOneWayInterior,
linkMatOneWayShortcut,
linkMatOneWayTrack,
linkMatWaterLoop,
linkMatWaterInterior,
linkMatWaterShortcut,
linkMatWaterTrack,
linkMatLoopInterior,
linkMatLoopShortcut,
linkMatLoopTrack,
linkMatInteriorShortcut,
linkMatInteriorTrack,
linkMatWaterLoopInterior,
linkMatWaterLoopShortcut,
linkMatWaterLoopTrack,
linkMatWaterInteriorShortcut,
linkMatWaterInteriorTrack,
linkMatLoopInteriorShortcut,
linkMatLoopInteriorTrack,
linkMatWaterLoopInteriorShortcut,
linkMatWaterLoopInteriorTrack,
linkMatOneWayWaterLoop,
linkMatOneWayWaterInterior,
linkMatOneWayWaterShortcut,
linkMatOneWayWaterTrack,
linkMatOneWayLoopInterior,
linkMatOneWayLoopShortcut,
linkMatOneWayLoopTrack,
linkMatOneWayInteriorShortcut,