-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmain.agc
2698 lines (2020 loc) · 74.4 KB
/
main.agc
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
InitFirstOpening() // in init.agc
#include "include/include.agc"
// Init the Interface (Ui, menu, gadgets...), options...
InitGeneral() // in init.agc
FoldStart // define Some parameters for the visual editor
action = C_ACTIONSELECT
Obj$ = "Box,Sphere,Capsule,Cone,Cylinder,Plane,Object3D"
ObjTyp$ = GetStringToken(Obj$,",",ObjTyp+1)
CreateText(1, Info$)
SetTextPosition(1,PaneLW+20,65)
SetTextSize(1,15)
SetTextDepth(1,20)
SetTextMaxWidth(1,G_width-2*(PaneLW+20))
Event_Menu = -1
Event_Gadget = 0
id = -1
LAG_v_MenuItemId = -1
MX as float
MY as float
Dc as float
Dc = Options.Camera.Speed
CamOrtho as integer
SetCameraRotation(1,30,0,0)
SetCubeViewTocamera(1)
// for transformation of object
ux as float
uy as float
uz as float
// SetPhysicsDebugOn()
IF use_Lag = 1
SetTool(Event_Gadget)
LAG_SetGadgetState(C_Gad_PreviewModel,UiObjImg[0])
LAG_Message("Info","Please, note that this visual editor isn't finished at all, it's a wip version, so some features aren't available and it's possible there's still some bugs. Maybe, some features will changed in a next version.","")
endif
FoldEnd
SetCameraRange(1,1,10000)
Options.Camera.Far = 10000
/*
SetCameraRotation(1,60,0,0)
SetCAmeraPosition(1,0,150,-50)
SetCameraFOV(1,70)
w1 = 600 // size of the ground
global TheGourndZ = 192
CreateObjectPlane(TheGourndZ,w1,w1)
SetObjectRotation(TheGourndZ,90,0,0)
// SetObjectCullMode(1,1)
SetObjectColor(TheGourndZ,150,150,150,255)
SetObjectImage(TheGourndZ,iLightmap,0)
SetObjectPosition(TheGourndZ,0,0,0)
For i =0 to 10
x = random(-100,100)
y = random(-10,50)
z = random(-100,100)
AddObjet(x,y,z,"")
next
ObjId = TheGourndZ
*/
// For the lightmap
Global TheGourndZ = -1 // the ground
Global TheObjectLightMap = -1
Active_Gadget = -1
GetScreenBoundEditor()
// temporary !!, to see the lightmap image
/*
CreateSprite(1,1)
SetSpriteSize(1,128,128)
SetSpritePosition(1,-2300,80)
SetSpriteImage(1,iLightmap)
SetSpriteDepth(1, 0)
*/
//SetGenerateMipmaps(0)
//********************* MAIN LOOP **********************//
do
MX = getpointerX()
MY = getPointerY()
// print(str(Getspritex(C_Gad_TB))+"/"+str(GetspriteY(C_Gad_TB)))
FoldStart //Debug
if Options.Debug = 1
Info$ = "FPS : "+str(ScreenFPS())+Chr(10)
//Info$ = Info$ + "Mouse : "+str(Get3DVectorXFromScreen(mx,my)*10,2)+"/"+str(Get3DVectorYFromScreen(mx,my)*10,2)+"/"+str(Get3DVectorZFromScreen(mx,my)*10,2)+Chr(10)
Info$ = Info$ +"Obj Id : "+str(ObjId)+Chr(10)
Info$ = Info$ +"Physics : "+ str(Options.physicOn)+Chr(10)
Info$ = Info$ +"Active Obj Physics : "+ str(Get3DPhysicsActiveObjects() )+Chr(10)
Info$ = Info$ +"Obj Physics : "+ str(Get3DPhysicsTotalObjects())+Chr(10)
/*
if objid > -1 and objid<= object.length
if assettyp =C_ASSETOBJ
Info$ = Info$ +"W : "+str(GetObjectWidth(ObjId))+" / H : "+str(GetObjectHeight(ObjId))+" / L : "+str(GetObjectLength(ObjId))+chr(10)
Info$ = Info$ +"Hmin : "+str(GetObjectSizeMinY(object[ObjId].obj))+" / Hmax : "+str(GetObjectSizeMaxY(object[ObjId].obj))+chr(10)
endif
endif
*/
// info$ = info$ + "Cubeview : "+str(GetObjectAngleX(CubeView))+"/"+str(GetObjectAngleY(CubeView))+"/"+str(GetObjectAngleZ(CubeView))
// Info$ = Info$ + str(x)+"|"+str(y)+"|"+str(z)
SetTextString(1,info$)
// Print(Str(mx)+"/"+str(my))
endif
Foldend
//Print("Min/max "+str(Options.Minx)+"/"+str(Options.MaxX)+" | "+str(Options.MinY)+"/"+str(Options.MaxY)+" | "+str(Options.MinZ)+"/"+str(Options.MaxZ)+"/")
if Action = C_ACTIONPLAY // play
ScreenGame() // in ScreenGame.agc
else
foldstart //************* autosave
IF autosave>=0
dec autosave
else
autosave = 3600
if object.length >=0
olddoc$ = doc.FileName$
if AutosaveDoc$ = ""
AutosaveDoc$ = "autosave\Autosave"+str(random(0,100000))+"_"+GetCurrentDate()+".age"
endif
Doc.Filename$ = AutosaveDoc$
SaveDoc(0)
Doc.FileName$ = olddoc$
endif
endif
foldend
GetScreenBoundEditor() // in editor.agc
FoldStart //************* Mouse Event & Gadget/Menu
// LAG_EventWindow()
LAG_EventType()
// verification for editbox
FoldStart // Active gadget (for editbox)
if Active_Gadget > -1
If Lag_GetGadgetType(Active_Gadget) = LAG_C_TYPSTRING
if Lag_event_type = LAG_C_EVENTTYPEKEYRELEASED or Lag_event_type = LAG_C_EVENTTYPEKEYPRESSED
// print("ok key !!!!!!!!!!!")
Keypressed = 1
endif
if GetEditBoxHasFocus(LAG_D_Gadget[Active_Gadget].EditBoxId) = 0
Active_Gadget = -1
endif
endif
else
if Event_Gadget> -1
If Lag_GetGadgetType(Event_Gadget) = LAG_C_TYPSTRING
if GetEditBoxHasFocus(LAG_D_Gadget[Event_Gadget].EditBoxId) <> 0
Active_Gadget = Event_Gadget
endif
endif
endif
endif
Foldend
if options.HideLag = 0 and ((Mx<= PanelW+GameProp.BoundLeft or Mx >= GameProp.BoundRight-PanelW or MY<=60+GameProp.BoundTop or LAG_v_MenuItemId <> -1))
FoldStart // Menu & gadgets
IF use_Lag = 1
ToolTipsEvent(getpointerX(),getpointerY())
Keypressed = 0
FoldStart // using LAG ui (Menu & gadgets)
if GetRawMouseRightReleased() // or (GetRawMouseLeftPressed()
LAG_CloseMenu()
else
Event_Menu = LAG_EventMenu()
// verify the event for menu and gadget, if LeftClic or keyboard event
if Event_Menu <> -1
FoldStart // menu
If Event_Menu <= C_MENU_QUIT
Select Event_Menu // FILE
// files
case C_MENU_NEW
NewDoc(0)
endcase
case C_MENU_OPEN
OpenDoc(0)
endcase
case C_MENU_MERGE
OpenDoc(1)
endcase
case C_MENU_SAVEAS
SaveDoc(1)
endcase
case C_MENU_EXPORT
ExportForAGK(0, 0)
endcase
case C_MENU_SAVE
SaveDoc(0)
endcase
case C_MENU_QUIT
LAG_message("Quit","Bye ;)","")
Event_Gadget = 0
end
endcase
endselect
elseIf Event_Menu <= C_MENU_SETOBJPARAM // edit
Select Event_menu
// EDIT
Case C_MENU_HIDE
For i=0 to object.length
if Object[i].Selected = 1
SetObjectvisible(Object[i].Obj,0)
SetSpriteVisible(Object[i].Spr,0)
Object[i].Hide = 0
endif
next
EndCase
Case C_MENU_FREEZE
For i=0 to object.length
if Object[i].Selected = 1
Object[i].Locked = 1
endif
next
EndCase
Case C_MENU_COPY
CopyObject()
endcase
Case C_MENU_CLONE
CopyObject()
PasteObject()
Endcase
Case C_MENU_PASTE
PasteObject()
endcase
case C_MENU_SETOBJPARAM
OpenWindowObjParam() // in object.agc
endcase
Endselect
elseIf Event_Menu <= C_MENU_USERTLM // view
Select Event_menu
// view
case C_MENU_VIEWRESET
SetView(2)
endcase
case C_MENU_VIEWSELECTED
SetView(1)
Endcase
case C_MENU_VIEWCENTER
SetView(0)
Endcase
case C_MENU_DEBUG
Options.Debug = 1-Options.Debug
if Options.Debug =0
SetTextString(1,"")
endif
Endcase
case C_MENU_USEWATER
Options.ShowWater = 1-Options.ShowWater
Endcase
case C_MENU_GRID
Options.ShowGrid = 1-Options.ShowGrid
SetObjectVisible(Grid,Options.ShowGrid)
Endcase
case C_MENU_USERTLM
Options.ShowLMRT = 1-Options.ShowLMRT
endcase
case C_MENU_SHOWCENTER
Options.ShowCenter = 1-Options.ShowCenter
UpdateAllCenter()
SetAllCenterVisible()
endcase
/*
case C_MENU_SUN
Options.ShowSun = 1-Options.ShowSun
SetSunActive(Options.ShowSun)
Endcase
case C_MENU_SKYBOX
Options.ShowSkyBox = 1-Options.ShowSkyBox
SetSkyBoxSunVisible(Options.ShowSkyBox)
Endcase
case C_MENU_FOG
Options.ShowFog = 1-Options.ShowFog
SetFogMode(Options.ShowFog)
Endcase
*/
Endselect
elseIf Event_Menu <= C_MENU_CreateLightMAp // Add
Select Event_menu
case C_MENU_ADDOBJ
AssetTyp = C_ASSETOBJ
CreateNewObject(1) // in editor.agc
endcase
case C_MENU_ADDLIGHT
AssetTyp = C_ASSETLIGHT
AddLight(0,20,0,150,255,255,255,-1,1)
//LAG_Message("Light",Help$,"")
Endcase
case C_MENU_ADDCAMERA
AssetTyp = C_ASSETCAMERA
AddCamera(0,20,0,0,0,0,1,1000,70)
endcase
case C_MENU_CHANGETYP
inc ObjTyp
if ObjTyp>C_OBJBANK
ObjTyp = 0
endif
ObjTyp$ = GetStringToken(Obj$,",",ObjTyp+1)
endcase
case C_MENU_CHANGEIMG
/*
inc TextureID
if TextureID>texture.length
TextureID = 0
endif
LAG_SetGadgetState(C_Gad_BankImg,Texture[textureId].img)
*/
endcase
Case C_MENU_ADDWATER
// ! <----------------------- !!!! TODO : Créer une interface avec gestion de la création de l'asset Water ou load/save preset
wat = Options.WaterImageSize
AddWater(-2,wat,wat,wat,wat,0)
endcase
Case C_MENU_ADDTERRAIN
OpenWindowTerrain()
endcase
Case C_MENU_CreateLightMAp
// CreateLightMap()
if ObjId >-1 and ObjId <= Object.length
TheObjectLightMAp = ObjId
Object[ObjId].LightMapID = 1
SyncShadow()
SaveImage(iLightmap,"lightmap.jpg")
else
LAG_message("Info","Please, select the ground which receive the lightmap first","")
endif
endcase
endselect
elseIf Event_Menu <= C_MENU_UPDATE // HElp
Select Event_menu
case C_MENU_ABOUT
LAG_message("Info","AGE (Agk Game Editor) is a visual 3D editor for AGK (and made in AGK), to help you to create 3D level, add gameplay, shader, image...."+chr(10)+"Version : "+C_VERSION+chr(10)+"Date : "+C_DATE+chr(10)+"Dev : Blendman","")
endcase
case C_MENU_HELP
LAG_Message("Help",Help$,"")
endCase
case C_MENU_INFO
ViewFile("doc/age3D.rtf")
endcase
case C_MENU_RELEASE
ViewFile("doc/releaseLog.rtf")
endcase
endselect
elseIf Event_Menu <= C_MENU_SELECTBYNAME // selection
Select Event_menu
// Select
case C_MENU_SELECTBYGROUP
Name$ = Lag_InputRequester("Select Object by group","")
if name$ <> ""
moveobj=0
For i=0 to object.length
Object[i].Selected = 0
SetObjectColorEmissive(Object[i].Obj,Object[i].r,Object[i].g,Object[i].b)
next
For i=0 to object.length
for j =0 to Object[i].Group.Length
if object[i].group[j] = name$
objId = i
Object[i].Selected = 1
SetObjectColorEmissive(Object[i].Obj,50,0,0)
moveobj=1
GetObjProp()
exit
endif
next
next
if moveobj = 0
endif
endif
Endcase
case C_MENU_SelectByName
Name$ = Lag_InputRequester("Select Object by name","")
if name$ <> ""
moveobj=0
For i=0 to object.length
Object[i].Selected = 0
SetObjectColorEmissive(Object[i].Obj,Object[i].r,Object[i].g,Object[i].b)
next
For i=0 to object.length
if object[i].name$ = name$
objId = i
Object[i].Selected = 1
SetObjectColorEmissive(Object[i].Obj,50,0,0)
moveobj=1
GetObjProp()
exit
endif
next
if moveobj = 0
endif
endif
Endcase
case C_MENU_SELECTALL
if assetTyp = C_ASSETOBJ
For i=0 to object.length
Object[i].Selected = 1
SetObjectColorEmissive(Object[i].Obj,50,0,0)
next
endif
Endcase
Endselect
else
txt$ = LAG_GetMenuItemText(0,Event_Menu)
LAG_message("Info",txt$+" : not implemented","")
endif
Foldend
elseif LAG_v_MenuItemId = -1 and Options.MenuOpen = 0
FoldStart // event_gadget
Event_Gadget = LAG_EventGadget()
// print("EventGadget : "+str(Event_Gadget))
if Event_Gadget < 0 or Event_Gadget > C_Gad_Last or My <= 30+Options.Y+GameProp.BoundTop
FreeToolTips()
// Active_Gadget = -1
elseif Event_Gadget > 0 and Event_Gadget <= C_Gad_Last
// main window
CreateToolTips(getPointerX(),getPointerY(),Event_Gadget)
if Lag_event_type = LAG_c_EventTypeMousePressed
if Active_Gadget = -1
If Lag_GetGadgetType(Event_Gadget) = LAG_C_TYPSTRING
Active_Gadget = Event_Gadget
endif
else
If Lag_GetGadgetType(Active_Gadget) = LAG_C_TYPSTRING
if GetEditBoxActive(LAG_D_Gadget[Active_Gadget].EditBoxId) = 0
Active_Gadget = -1
endif
endif
endif
endif
// toolbar
if Event_gadget >= C_GAD_TBNEW and Event_gadget<= C_Gad_TBDEL
if event_Gadget >= C_Gad_TBViewPan and event_Gadget <= C_Gad_TBViewZoom
Select event_Gadget
case C_Gad_TBViewPan
ActionView = 1
endcase
case C_Gad_TBViewRot
ActionView = 2
endcase
case C_Gad_TBViewZoom
ActionView = 3
endcase
endselect
else
ActionView = 0
IF GetRawMouseLeftPressed() or LAG_Event_Type = LAG_c_EventTypeMousePressed
Action$ = SetTool(Event_Gadget)
endif
endif
else
FoldStart // others gadgets
// Windows prop ( anim, shader...)
if Event_Gadget >= C_Gad_WinObjBehavior and Event_Gadget<C_Gad_NameObj
Select Event_Gadget // Windows prop ( anim, shader...)
case C_Gad_WinObjBehavior
if LAG_event_Type = LAG_C_EVENTTYPEMOUSERELEASED //GetRawMouseLeftReleased()
OpenWindowBehavior()
endif
Endcase
case C_Gad_WinObjPhysic
if LAG_event_Type = LAG_C_EVENTTYPEMOUSERELEASED //GetRawMouseLeftReleased()
OpenWindowObjPhysics()
endif
Endcase
case C_GAD_LoadPartsys
if LAG_event_Type = LAG_C_EVENTTYPEMOUSERELEASED
If ObjId >- 1 and ObjId<= Object.length
if Object[objID].typ= C_OBJPARTSYS
LoadParticleSystemPreset("",0)
endif
endif
endif
Endcase
case C_GAD_SavePartsys
if LAG_event_Type = LAG_C_EVENTTYPEMOUSERELEASED
If ObjId >- 1 and ObjId<= Object.length
if Object[objID].typ= C_OBJPARTSYS
SaveParticleSystemPreset("", 0)
endif
endif
endif
Endcase
case C_Gad_WinObjShader
if LAG_event_Type = LAG_C_EVENTTYPEMOUSERELEASED //GetRawMouseLeftReleased()
OpenWindowShader()
endif
Endcase
endselect
// Obj prop
elseif Event_Gadget >= C_Gad_NameObj and Event_Gadget<=C_Gad_AnimSpeed
FoldStart // Object properties
if Event_Gadget >= C_Gad_lock_X and Event_Gadget <= C_Gad_lock_SZ
SetObjectLock()
else
Select Event_Gadget
case C_Gad_X,C_Gad_Size,C_Gad_Y,C_Gad_Z,C_Gad_Rx,C_Gad_Ry,C_Gad_RZ,C_Gad_Sx,C_Gad_Sy,C_Gad_Sz,C_Gad_NameObj,C_Gad_Param1,C_Gad_Param2
SetAssetProp(C_SETOBJPROP_GEN)
// = -> SetObjProp(mode) dans object.agc
endcase
case C_Gad_Shado, C_Gad_ShadoCast,C_Gad_ShadoRec, C_Gad_ObjFog, C_Gad_ObjLight, C_Gad_ObjVisible, C_Gad_Hide,C_Gad_Lock
if LAG_event_Type = LAG_c_EventTypeMousePressed
SetAssetProp(C_SETOBJPROP_GEN) // = -> SetObjProp(mode) dans object.agc
endif
endcase
case C_Gad_BM
if LAG_event_Type = LAG_c_EventTypeMousePressed
if AssetTyp = C_ASSETOBJ
if Objid>-1 and objID <= object.length
inc Object[ObjId].BM
if Object[ObjId].BM > 4
Object[ObjId].BM = 0
endif
bm$ = "Normal,add,mult,sub,other,"
LAg_SetGadgetText(C_Gad_BM, GetStringToken(bm$, ",", Object[ObjId].BM+1))
SetAssetProp(C_SETOBJPROP_COL)
endif
endif
endif
endcase
case C_Gad_Tra
if LAG_event_Type = LAG_c_EventTypeMousePressed
if AssetTyp = C_ASSETOBJ
if Objid>-1 and objID <= object.length
inc Object[ObjId].tra
if Object[ObjId].tra > 2
Object[ObjId].tra = 0
endif
bm$ = "Opaque,Transp,Custom,"
LAg_SetGadgetText(C_Gad_tra, GetStringToken(bm$, ",", Object[ObjId].tra+1))
SetAssetProp(C_SETOBJPROP_COL)
endif
endif
endif
endcase
case C_gad_alpha, C_Gad_B, C_Gad_G, C_Gad_R
SetAssetProp(C_SETOBJPROP_COL)
endcase
case C_Gad_uvx, C_Gad_uvy, C_Gad_uvw, C_Gad_uvh, C_Gad_SetShader
SetAssetProp(C_SETOBJPROP_UV)
endcase
case C_Gad_SetStage
SetAssetProp(C_SETOBJPROP_STAGEImg)
endcase
case C_Gad_Physic
//if LAG_event_Type = LAG_C_EVENTTYPEMOUSERELEASED
if LAG_event_Type = LAG_c_EventTypeMousePressed
if ObjID>-1 and ObjId <= object.length
i=ObjId
// Object[i].Physic = val(LAG_GetGadgetText(C_Gad_Physic))
inc Object[i].Physic
if Object[i].Physic>4
Object[i].Physic =0
endif
Txt$ ="No Physic/Static/Dynamic/Kinematic/Character"
LAG_SetGadgetText(C_Gad_Physic, GetStringToken(Txt$,"/",Object[i].Physic+1))
SetPhysicToObject(i,0)
// OpenWindowObjPhysic()
endif
endif
endcase
case C_Gad_PlayAnim
IF GetRawMouseLeftPressed() or LAG_Event_Type = LAG_c_EventTypeMousePressed
play = LAG_GetGadgetState(C_Gad_PlayAnim)
Speed# = Valfloat(LAG_GetGadgettext(C_Gad_AnimSpeed))
FrSt# = Valfloat(LAG_GetGadgettext(C_Gad_AnimStart))
FRend# = Valfloat(LAG_GetGadgettext(C_Gad_AnimEnd))
SetObjectAnimation(play, speed#, FrSt#, FrEnd#)
endif
endcase
case C_Gad_AnimSpeed, C_Gad_AnimStart, C_Gad_AnimEnd
if Lag_event_type = LAG_C_EVENTTYPEKEYRELEASED
play = LAG_GetGadgetState(C_Gad_PlayAnim)
Speed# = Valfloat(LAG_GetGadgettext(C_Gad_AnimSpeed))
FrSt# = Valfloat(LAG_GetGadgettext(C_Gad_AnimStart))
FRend# = Valfloat(LAG_GetGadgettext(C_Gad_AnimEnd))
SetObjectAnimation(play, speed#, FrSt#, FrEnd#)
endif
endcase
case C_Gad_Type
if LAG_event_Type = LAG_c_EventTypeMousereleased
typ$ = GetObjTypFromFile("")
maxtyp = CountStringTokens(typ$, ",")
inc ZeTyp
if ZeTyp >= maxtyp
ZeTyp = 0
endif
LAg_SetGadgetText(C_Gad_Type, GetStringToken(typ$, ",",1+zetyp))
Select AssetTyp
case C_ASSETOBJ
if ObjID > -1 and objID <= object.length
Object[objid].ObjTyp = Zetyp
endif
endcase
endselect
t$ = GetStringToken(typ$, ",",1+zetyp)
subtyp$ = GetObjTypFromFile(t$)
LAg_SetGadgetText(C_Gad_subType, GetStringToken(Subtyp$, ",",1))
endif
endcase
case C_Gad_SubType
if LAG_event_Type = LAG_c_EventTypeMousereleased
typ$ = Lag_GetGadgetText(C_Gad_Type)
subtyp$ = GetObjTypFromFile(typ$)
maxtyp = CountStringTokens(subtyp$, ",")
inc ZesubTyp
if ZesubTyp >= maxtyp
ZesubTyp = 0
endif
LAg_SetGadgetText(C_Gad_subType, GetStringToken(Subtyp$, ",",1+ZesubTyp))
Select AssetTyp
case C_ASSETOBJ
if ObjID > -1 and objID <= object.length
Object[objid].SubTyp = ZesubTyp
endif
endcase
endselect
endif
endcase
endselect
endif
Foldend
// options
elseif Event_Gadget >= C_Gad_SnapX and Event_Gadget <= C_Gad_SelectList
FoldStart // options
if Event_Gadget >= C_Gad_CamPresetList and Event_Gadget <=C_Gad_CamOrtW
if Event_Gadget = C_Gad_CamPresetList
else
if Lag_event_type = LAG_C_EVENTTYPEKEYRELEASED
//case C_Gad_CamFar, C_Gad_CamFov, C_Gad_CamNear, C_Gad_CamOrtW
Options.Camera.X = val(LAG_GetGadgetText(C_Gad_CamX))
Options.Camera.Y = val(LAG_GetGadgetText(C_Gad_CamY))
Options.Camera.Z = val(LAG_GetGadgetText(C_Gad_CamZ))
CamX = Options.Camera.X
CamY = Options.Camera.Y
CamZ = Options.Camera.Z
Options.Camera.RX = val(LAG_GetGadgetText(C_Gad_CamRX))
Options.Camera.RY = val(LAG_GetGadgetText(C_Gad_CamRY))
Options.Camera.RZ = val(LAG_GetGadgetText(C_Gad_CamRZ))
Options.Camera.Far = val(LAG_GetGadgetText(C_Gad_CamFar))
Options.Camera.Fov = val(LAG_GetGadgetText(C_Gad_CamFov))
Options.Camera.Near = valfloat(LAG_GetGadgetText(C_Gad_CamNear))
Options.Camera.OrthoW = valFloat(LAG_GetGadgetText(C_Gad_CamOrtW))
SetCamera()
SaveOptions()
endif
//Endcase
endif
else
select Event_Gadget
case C_Gad_Snap, C_Gad_SnapX, C_Gad_SnapY, C_Gad_SnapZ
Snap = LAG_GetGadgetState(C_Gad_Snap)
SnapX = val(LAG_GetGadgetTExt(C_Gad_SnapX))
SnapY = val(LAG_GetGadgetTExt(C_Gad_Snapy))
SnapZ = val(LAG_GetGadgetTExt(C_Gad_SnapZ))
Options.Snap = Snap
SaveOptions()
endcase
case C_Gad_LockX, C_Gad_LockY, C_Gad_LockZ
select action
case C_ACTIONMOVE
Options.LockX = LAG_GetGadgetState(C_Gad_LockX)
Options.LockY = LAG_GetGadgetState(C_Gad_LockY)
Options.LockZ = LAG_GetGadgetState(C_Gad_LockZ)
endcase
case C_ACTIONROTATE
Options.LockRX = LAG_GetGadgetState(C_Gad_LockX)
Options.LockRY = LAG_GetGadgetState(C_Gad_LockY)
Options.LockRZ = LAG_GetGadgetState(C_Gad_LockZ)
endcase
case C_ACTIONSCALE
Options.LockSX = LAG_GetGadgetState(C_Gad_LockX)
Options.LockSY = LAG_GetGadgetState(C_Gad_LockY)
Options.LockSZ = LAG_GetGadgetState(C_Gad_LockZ)
endcase
endselect
SaveOptions()
endcase
case C_Gad_SelectList
IF GetRawMouseLeftPressed() or LAG_Event_Type = LAG_c_EventTypeMousePressed
j = LAG_GetGadgetState(C_Gad_SelectList)
assetTyp = LAG_GetGadgetItemAttribute(C_Gad_SelectList,j)
select assettyp
case C_ASSETLIGHT
if j <= light.length and j>=0
if light[j].hide = 0
objId = j
Name$ = LAg_GetGadgetItemText(C_Gad_SelectList, ObjId)
SelectObject(-1)
endif
endif
endcase
case C_ASSETOBJ
if j <= Object.length and j>=0
if object[j].hide = 0
objId = j
Name$ = LAg_GetGadgetItemText(C_Gad_SelectList, ObjId)
SelectObject(-1)
endif
endif
endcase
case C_ASSETMESH
Meshid = j+1
endcase
case C_ASSETCAMERA
if j <= camera.length and j>=0
if camera[j].hide = 0
objId = j
Name$ = LAg_GetGadgetItemText(C_Gad_SelectList, ObjId)
SelectObject(-1)
endif
endif
endcase
endselect
endif
endcase
case C_Gad_BtnSelectTyp
IF GetRawMouseLeftPressed() or LAG_Event_Type = LAG_c_EventTypeMousePressed
inc assetTyp
if assetTyp > C_ASSETMax
assetTyp = C_ASSETOBJ
endif
Lag_FreeallGadgetItemByGadget(C_Gad_SelectList)
CreateAllGadgetItem()
endif
endcase
endselect
endif
foldend
// sky
elseif Event_Gadget >= C_Gad_SkyOk and Event_Gadget<=C_Gad_SHADO_SizeH
select Event_Gadget // sky & atmosphere
case C_GAD_AtmSave
IF LAG_Event_Type = LAG_C_EVENTTYPEMOUSERELEASED
SaveAtmosphere("",0,0)
endif
endcase
case C_GAD_AtmLoad
IF LAG_Event_Type = LAG_C_EVENTTYPEMOUSERELEASED
LoadAtmosphere("",0,0)
endif
endcase
case C_Gad_AmbInt, C_Gad_SunInt
if keypressed or LAG_Event_Type = LAG_C_EVENTTYPEKEYPRESSED
UpdateSky()
endif
endcase
case C_Gad_SkyHR,C_Gad_SkyHG,C_Gad_SkyHB,C_Gad_SkyR,C_Gad_SkyG,C_Gad_SkyB,C_Gad_SunR,C_Gad_SunX,C_Gad_SunY,C_Gad_SunZ,C_Gad_SunG,C_Gad_SunB,C_Gad_FogR,C_Gad_FogG,C_Gad_FogB,C_Gad_FogMax,C_Gad_FogMin,C_Gad_AmbR,C_Gad_AmbG,C_Gad_AmbB
//If LAG_Event_Type = LAG_C_EVENTTYPEMOUSEMOVE
UpdateSky()
//endif
endcase
case C_Gad_SkyOk, C_Gad_SunOk, C_Gad_FogOk, C_Gad_SHADO_RT, C_Gad_AmbOk
IF GetRawMouseLeftPressed() or LAG_Event_Type = LAG_C_EVENTTYPEMOUSEPRESSED
UpdateSky()
endif
endcase
case C_Gad_SHADO_Bias, C_Gad_SHADO_Smooth, C_Gad_SHADO_Type,C_Gad_SHADO_SizeW, C_Gad_SHADO_SizeH
UpdateSky()
endcase
endselect
// image bank & Object
elseif Event_Gadget >= C_Gad_BankImg and Event_Gadget<=C_Gad_ShaderFolder
// Create, Object & image bank
select Event_Gadget
// change asset size
case C_Gad_AssetSize, C_Gad_AssetW, C_Gad_AssetL, C_Gad_AssetL
if LAG_Event_Type = LAG_C_EVENTTYPEKEYPRESSED
Options.Asset.Size = valfloat(LAG_GetGadgetText(C_Gad_AssetSize))
Options.Asset.W = valfloat(LAG_GetGadgetText(C_Gad_AssetW))
Options.Asset.H = valfloat(LAG_GetGadgetText(C_Gad_AssetH))
Options.Asset.L = valfloat(LAG_GetGadgetText(C_Gad_AssetL))
SaveOptions()
endif
endcase
case C_Gad_AssetProp
IF GetRawMouseLeftReleased() or LAG_Event_Type = LAG_C_EVENTTYPEMOUSERELEASED
OpenWindowAssetCreate()
SaveOptions()
endif
endcase
// Change Object 3D
case C_Gad_BankPrevM
If GetRawMouseLeftPressed() or LAG_event_Type = LAG_C_EVENTTYPEMOUSERELEASED
dec ObjTyp
if ObjTyp < 0
ObjTyp = C_OBJBANK
endif
LAG_SetGadgetState(C_Gad_PreviewModel,UiObjImg[ObjTyp]) // change the image
SetObjectPanel()
endif
endcase
case C_Gad_BankNextM
If GetRawMouseLeftPressed() or LAG_event_Type = LAG_C_EVENTTYPEMOUSERELEASED
inc ObjTyp
if ObjTyp > C_OBJBANK
ObjTyp = 0
endif
LAG_SetGadgetState(C_Gad_PreviewModel,UiObjImg[ObjTyp]) // change the image
SetObjectPanel()
endif
endcase
Case C_Gad_BankMeshSet
if LAG_Event_Type = LAG_C_EVENTTYPEMOUSEreleased
SetObjectMesh()
endif
endcase