/* PNJ Dyneditor Plugin - DMS - junary 2008 - by Bastien BOURINEAU */ /*************************************************************************** Variables *******************************************************************************/ // TCB var fDefCamFov = 10.01;; var iDefFps = 30;; var iDefKps = 30;; var iDefNbkey = 100;; var iWinW = 640;; var iWinH = 480;; var iBackColor = 0x000000;; var iDotColor = 0x0000ff;; var iDotSelectColor = 0xffffff;; var iCurveColor = 0xffffff;; var iPreviewColor = 0xffffff;; var iPreviewRadius = 10;; var iDotRadius = 5;; var iDotBorder = 1;; struct TCBeditor = [ TCB_name : S, TCB_win : ObjWin, TCB_winP : ObjWin, TCB_iCursorX : I, TCB_iCursorY : I, TCB_surface : ObjSurface, TCB_shell : H3d, TCB_cam : H3d, TCB_fCamfov : F, TCB_iCamClip : I, TCB_font : ObjFont, TCB_txtFps : ObjText, TCB_txtNbKey : ObjText, TCB_txtX : ObjText, TCB_txtY : ObjText, TCB_txtZ : ObjText, TCB_txtAX : ObjText, TCB_txtAY : ObjText, TCB_txtAZ : ObjText, TCB_chkLoop : ObjCheck, TCB_chkInit : ObjCheck, TCB_sldT : ObjSlider, TCB_sldC : ObjSlider, TCB_sldB : ObjSlider, TCB_sldDotTime : ObjSlider, TCB_sldClip : ObjSlider, TCB_sldTime : ObjSlider, TCB_sldFov : ObjSlider, TCB_lDots : [[[F F] [F F F] [F F F] [F F F] F] r1], TCB_iSelected : I, TCB_iNbkey : I, TCB_iKps : I, TCB_fPreview : F, TCB_iTick : I, TCB_iPreview : I, TCB_iLoop : I, TCB_iInit : I, TCB_iViewMode : I, // 0 top 1 front 2 left 3 pos TCB_timer : Timer ] mkTCBeditor;; typeof strCurveEditor = TCBeditor;; var sCamFile = "camera camera { 0 0 0 0 0 0 300 300 800 600 1 30000 50000 } ";; var sPath = "/";; typeof sClass = S;; typeof sInstName = S;; typeof ed = PluginEditor;; typeof winEdt = ObjWin;; /* Editor's window */ typeof txtM3D = ObjText;; /* Text and EditLine objects for the different */ typeof edtM3D = ObjText;; typeof btnBrowseM3d = ObjButton;; typeof txtAFR = ObjText;; /* Text and EditLine objects for the animations' */ typeof edtAFR = ObjText;; /* framerate */ typeof lAnimlist = [[I [S r1]] r1];; typeof txtAnims = ObjText;; typeof listAnims = ObjList;; typeof edtAnim = ObjText;; typeof chkLoopAnim = ObjCheck;; typeof chkStartAnim = ObjCheck;; typeof btnBrowseAnim = ObjButton;; typeof btnAddAnim = ObjButton;; typeof btnRemoveAnim = ObjButton;; typeof lSoundlist = [[I [S r1]] r1];; typeof txtSound = ObjText;; typeof listSound = ObjList;; typeof edtSound = ObjText;; typeof txtMaxSound = ObjText;; typeof txtMinSound = ObjText;; typeof edtMinSound = ObjText;; typeof edtMaxSound = ObjText;; typeof chkLoopSound = ObjCheck;; typeof chkStartSound = ObjCheck;; typeof btnBrowseSound = ObjButton;; typeof btnAddSound = ObjButton;; typeof btnRemoveSound = ObjButton;; typeof lTranslist = [[I [S r1]] r1];; typeof txtTrans = ObjText;; typeof listTrans = ObjList;; typeof txtNameTrans = ObjText;; typeof edtNameTrans = ObjText;; typeof btnEndPosTrans = ObjButton;; typeof btnCancelPosTrans = ObjButton;; typeof btnAddTrans = ObjButton;; typeof btnRemoveTrans = ObjButton;; typeof lScriptlist = [[I [S r1]] r1];; typeof btnEditScript = ObjButton;; typeof winScriptEditor = ObjWin;; typeof listScript = ObjList;; typeof txtEvent = ObjText;; typeof txtAction = ObjText;; typeof cmbScriptInType = ObjBox;; typeof cmbScriptInName = ObjBox;; typeof cmbScriptInParam = ObjBox;; typeof cmbScriptOutType = ObjBox;; typeof cmbScriptOutName = ObjBox;; typeof cmbScriptOutParam = ObjBox;; typeof btnAddScript = ObjButton;; typeof btnRemoveScript = ObjButton;; typeof btnCloseScript = ObjButton;; typeof btnExportScript = ObjButton;; typeof btnImportScript = ObjButton;; /******************************************************************************* Functions *******************************************************************************/ fun convertDegFAngToRad(ang)= ((2.0 *. PIf) *. ang) /. 360.0;; fun convertDegVecAngToRad(ang)= let ang -> [a b c] in [(convertDegFAngToRad -. a) (convertDegFAngToRad b +. 180.0) (convertDegFAngToRad -. c)];; fun permutXYvec(vec)= let vec -> [x y z] in [y x z];; fun addVectorsF(vec1, vec2)= let vec1 -> [x1 y1 z1] in let vec2 -> [x2 y2 z2] in [(x1 +. x2) (y1 +. y2) (z1 +. z2)] ;; fun soustractVectorsF(vec1, vec2)= let vec1 -> [x1 y1 z1] in let vec2 -> [x2 y2 z2] in [(x1 -. x2) (y1 -. y2) (z1 -. z2)] ;; fun absVectorF(vec1)= let vec1 -> [x1 y1 z1] in [absf x1 absf y1 absf z1] ;; fun getListParam(data)= let sizelist data -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list data i -> [_ elem] in set ndata = listcat ndata elem::nil; set i = i + 1; ); ndata; );; fun getElemFromPos(l, pos)= if l == nil then nil else ( let hd l -> [eltpos lp] in if eltpos == pos then lp else getElemFromPos tl l pos; );; fun remove_string_from_pos_list(l, pos)= if l==nil then nil else let hd l -> [eltpos _] in if eltpos == pos then tl l else (hd l)::remove_string_from_pos_list tl l pos ;; fun getElemPosFromListByName(data, string)= let sizelist data -> size in let nil -> pos in let 0 -> i in ( while i < size && pos == nil do ( let nth_list data i -> [cpos elem] in if !strcmp (hd elem) string then set pos = cpos else nil; set i = i + 1; ); pos; );; fun cb_fin_upload(state, p)= let p -> [path edttxt addbtn nbdl] in ( if state == 0 then ( _DLGMessageBox _channel nil "ATTENTION !" "un fichier n'est pas uploadé ! " 0; _SETtext edttxt "Error ..."; 0; ) else ( if nbdl > 0 then nil else _SETtext edttxt path; 0; ); _ENbutton addbtn 1; ); 0;; fun getTransByName(name)= let sizelist lTranslist -> size in let nil -> ndata in let 0 -> i in ( while i < size && ndata == nil do ( let nth_list lTranslist i -> [_ elem] in if !strcmp name hd elem then set ndata = elem else nil; set i = i + 1; ); ndata; );; /* ********************************************************************************************* / TCB EDITOR / ********************************************************************************************* */ /******************************************************************************* OptSingleAngle() - Optimizing single position's angle p -> I : Source angle q -> I : Destination original angle <- I : Optimized destination angle *******************************************************************************/ fun OptSingleAngle(p, q) = let (absf (q -. p)) -> path1 in let (absf (q +. (2.0 *. PIf) -. p)) -> path2 in let (absf (q -. (2.0 *. PIf) -. p)) -> path3 in let min ftoi path1 min ftoi path2 ftoi path3 -> minpath in if (minpath == ftoi path1) then q else if (minpath == ftoi path2) then (q +. (2.0 *. PIf)) else (q -. (2.0 *. PIf));; /******************************************************************************* OptimizeDestinationOrientation() - Optimizing position orientation ap -> I : Source angle a aq -> I : Destination original angle a bp -> I : Source angle b bq -> I : Destination original angle b cp -> I : Source angle c cq -> I : Destination original angle c <- [I I I] : Optimized destination orientation *******************************************************************************/ fun OptimizeDestinationOrientation(ap, aq, bp, bq, cp, cq) = [(OptSingleAngle ap aq) (OptSingleAngle bp bq) (OptSingleAngle cp cq)];; // TCB ********************************************************************************************* // 2t3 - 3t2 + 1 fun H1(coef)= (2.0 *. (pow coef 3.0)) -. (3.0 *. (pow coef 2.0)) +. 1.0;; // -2t3 + 3t2 fun H2(coef)= (-. 2.0 *. (pow coef 3.0)) +. (3.0 *. (pow coef 2.0));; // t3 - 2t2 +t fun H3(coef)= (pow coef 3.0) -. (2.0 *. (pow coef 2.0)) +. coef;; // t3 - t2 fun H4(coef)= (pow coef 3.0) -. (pow coef 2.0);; fun getInterpolateCurve(vec1, vec2, ang1, ang2, coef)= let vec1 -> [x1 y1] in let vec2 -> [x2 y2] in let ang1 -> [ax1 ay1] in let ang2 -> [ax2 ay2] in let ftoi (((H1 coef) *. x1) +. ((H2 coef) *. x2) +. ((H3 coef) *. ax1) +. ((H4 coef) *. ax2)) -> x in let ftoi (((H1 coef) *. y1) +. ((H2 coef) *. y2) +. ((H3 coef) *. ay1) +. ((H4 coef) *. ay2)) -> y in [x y];; fun getInterpolate3DCurve(vec1, vec2, ang1, ang2, coef)= let vec1 -> [x1 y1 z1] in let vec2 -> [x2 y2 z2] in let ang1 -> [ax1 ay1 az1] in let ang2 -> [ax2 ay2 az2] in let ((H1 coef) *. x1) +. ((H2 coef) *. x2) +. ((H3 coef) *. ax1) +. ((H4 coef) *. ax2) -> x in let ((H1 coef) *. y1) +. ((H2 coef) *. y2) +. ((H3 coef) *. ay1) +. ((H4 coef) *. ay2) -> y in let ((H1 coef) *. z1) +. ((H2 coef) *. z2) +. ((H3 coef) *. az1) +. ((H4 coef) *. az2) -> z in [x y z];; fun getPosTime(pos)= let pos -> [vec _ ang tcb ti] in ti;; fun getPosTension(pos)= let pos -> [vec _ ang tcb ti] in let tcb -> [t c b] in t;; fun getPosContinuity(pos)= let pos -> [vec _ ang tcb ti] in let tcb -> [t c b] in c;; fun getPosBias(pos)= let pos -> [vec _ ang tcb ti] in let tcb -> [t c b] in b;; fun getPosX(pos)= let pos -> [vec _ ang tcb ti] in let vec -> [x y] in x;; fun getPosY(pos)= let pos -> [vec _ ang tcb ti] in let vec -> [x y] in y;; fun getPos3DX(pos)= let pos -> [_ vec ang tcb ti] in let vec -> [x y z] in x;; fun getPos3DY(pos)= let pos -> [_ vec ang tcb ti] in let vec -> [x y z] in y;; fun getPos3DZ(pos)= let pos -> [_ vec ang tcb ti] in let vec -> [x y z] in z;; fun getPosXY(pos)= let pos -> [vec _ ang tcb ti] in let vec -> [x y] in [x y];; fun getPos3DXYZ(pos)= let pos -> [_ vec ang tcb ti] in let vec -> [x y z] in [x y z];; fun getInterpolateTCB(lpos, t)= let sizelist lpos -> size in let size - 1 -> sizeminus in let 0 -> i in let nil -> out in ( while i < size && out == nil do ( let nth_list lpos i -> nextpos in if t <. (getPosTime nextpos) then ( let if i == 0 then nth_list lpos (sizeminus - 1) else nth_list lpos (i - 1) -> curpos in let if i == 0 then nth_list lpos (sizeminus - 2) else if i == 1 then nth_list lpos (sizeminus - 1) else nth_list lpos (i - 2) -> prevpos in let if i == sizeminus then nth_list lpos 0 else nth_list lpos (i + 1) -> nextnextpos in let ((t -. (getPosTime curpos)) /. ((getPosTime nextpos) -. (getPosTime curpos))) -> coef in //Update values from TCB let (1.0 -. (getPosTension curpos)) -> OneMinusTension in let (1.0 -. (getPosContinuity curpos)) -> OneMinusContinuity in let (1.0 +. (getPosContinuity curpos)) -> OnePlusContinuity in let (1.0 -. (getPosBias curpos)) -> OneMinusBias in let (1.0 +. (getPosBias curpos)) -> OnePlusBias in let 0.5 *. ((OneMinusTension *. OneMinusContinuity *. OneMinusBias *. ((getPosX nextpos) -. (getPosX curpos) )) +. (OneMinusTension *. OnePlusContinuity *. OnePlusBias *. ( (getPosX curpos) -. (getPosX prevpos) ))) -> tancurposx in let 0.5 *. ((OneMinusTension *. OneMinusContinuity *. OneMinusBias *. ((getPosY nextpos) -. (getPosY curpos) )) +. (OneMinusTension *. OnePlusContinuity *. OnePlusBias *. ( (getPosY curpos) -. (getPosY prevpos) ))) -> tancurposy in let 0.5 *. ((OneMinusTension *. OnePlusContinuity *. OneMinusBias *. ((getPosX nextpos) -. (getPosX curpos) )) +. (OneMinusTension *. OneMinusContinuity *. OnePlusBias *. ( (getPosX nextnextpos) -. (getPosX nextpos) ))) -> tannextposx in let 0.5 *. ((OneMinusTension *. OnePlusContinuity *. OneMinusBias *. ((getPosY nextpos) -. (getPosY curpos) )) +. (OneMinusTension *. OneMinusContinuity *. OnePlusBias *. ( (getPosY nextnextpos) -. (getPosY nextpos) ))) -> tannextposy in let getInterpolateCurve (getPosXY curpos) (getPosXY nextpos) [tancurposx tancurposy] [tannextposx tannextposy] coef -> [x y] in set out = [i x y]; 0; ) else nil; set i = i + 1; ); out; );; fun getInterpolateTCB3D(lpos, t)= let sizelist lpos -> size in let size - 1 -> sizeminus in let 0 -> i in let nil -> outvec in ( while i < size && outvec == nil do ( let nth_list lpos i -> nextpos in if t <. (getPosTime nextpos) then ( let if i == 0 then nth_list lpos (sizeminus - 1) else nth_list lpos (i - 1) -> curpos in let if i == 0 then nth_list lpos (sizeminus - 2) else if i == 1 then nth_list lpos (sizeminus - 1) else nth_list lpos (i - 2) -> prevpos in let if i == sizeminus then nth_list lpos 0 else nth_list lpos (i + 1) -> nextnextpos in let ((t -. (getPosTime curpos)) /. ((getPosTime nextpos) -. (getPosTime curpos))) -> coef in //Update values from TCB let (1.0 -. (getPosTension curpos)) -> OneMinusTension in let (1.0 -. (getPosContinuity curpos)) -> OneMinusContinuity in let (1.0 +. (getPosContinuity curpos)) -> OnePlusContinuity in let (1.0 -. (getPosBias curpos)) -> OneMinusBias in let (1.0 +. (getPosBias curpos)) -> OnePlusBias in let 0.5 *. ((OneMinusTension *. OneMinusContinuity *. OneMinusBias *. ((getPos3DX nextpos) -. (getPos3DX curpos) )) +. (OneMinusTension *. OnePlusContinuity *. OnePlusBias *. ( (getPos3DX curpos) -. (getPos3DX prevpos) ))) -> tancurposx in let 0.5 *. ((OneMinusTension *. OneMinusContinuity *. OneMinusBias *. ((getPos3DY nextpos) -. (getPos3DY curpos) )) +. (OneMinusTension *. OnePlusContinuity *. OnePlusBias *. ( (getPos3DY curpos) -. (getPos3DY prevpos) ))) -> tancurposy in let 0.5 *. ((OneMinusTension *. OneMinusContinuity *. OneMinusBias *. ((getPos3DZ nextpos) -. (getPos3DZ curpos) )) +. (OneMinusTension *. OnePlusContinuity *. OnePlusBias *. ( (getPos3DZ curpos) -. (getPos3DZ prevpos) ))) -> tancurposz in let 0.5 *. ((OneMinusTension *. OnePlusContinuity *. OneMinusBias *. ((getPos3DX nextpos) -. (getPos3DX curpos) )) +. (OneMinusTension *. OneMinusContinuity *. OnePlusBias *. ( (getPos3DX nextnextpos) -. (getPos3DX nextpos) ))) -> tannextposx in let 0.5 *. ((OneMinusTension *. OnePlusContinuity *. OneMinusBias *. ((getPos3DY nextpos) -. (getPos3DY curpos) )) +. (OneMinusTension *. OneMinusContinuity *. OnePlusBias *. ( (getPos3DY nextnextpos) -. (getPos3DY nextpos) ))) -> tannextposy in let 0.5 *. ((OneMinusTension *. OnePlusContinuity *. OneMinusBias *. ((getPos3DZ nextpos) -. (getPos3DZ curpos) )) +. (OneMinusTension *. OneMinusContinuity *. OnePlusBias *. ( (getPos3DZ nextnextpos) -. (getPos3DZ nextpos) ))) -> tannextposz in let getInterpolate3DCurve (getPos3DXYZ curpos) (getPos3DXYZ nextpos) [tancurposx tancurposy tancurposz] [tannextposx tannextposy tannextposz] coef -> [x y z] in set outvec = [i [x y z]]; 0; ) else nil; set i = i + 1; ); outvec; );; fun setPosTime(lpos)= let sizelist lpos -> size in if !size then nil else ( let 1.0 /. (itof size) -> step in let 0 -> i in while i < size do ( let nth_list lpos i -> elt in let if i == 0 then 0.0 else (step *. (itof i + 1)) -> ts in mutate elt <- [_ _ _ _ ts]; set i = i + 1; ); ); lpos;; fun refreshDots(tcbstr)= let sizelist tcbstr.TCB_lDots -> size in let 0 -> i in ( while i < size do ( let nth_list tcbstr.TCB_lDots i -> pos in let pos -> [_ vec ang tcb ts] in let ang -> [ax ay az] in let if tcbstr.TCB_iViewMode == 0 then [ax az ay] else if tcbstr.TCB_iViewMode == 1 then [ax ay az] else [az ay ax] -> [ax ay az] in let az *. (2.0 *. PIf) /. 360.0 -> azr in let (az +. 90.0) *. (2.0 *. PIf) /. 360.0 -> azr2 in let M3getObjVecF session tcbstr.TCB_shell -> cvec in let absVectorF soustractVectorsF vec cvec -> [dx dy dz] in let if tcbstr.TCB_iViewMode == 0 then dy else if tcbstr.TCB_iViewMode == 1 then dz else dx -> dist in let vec -> [dcx dcy dcz] in let cvec -> [ctx cty ctz] in let [-.(ctx -. dcx) (cty -. dcy) (ctz -. dcz)] -> [vx vy vz] in let if tcbstr.TCB_iViewMode == 0 then vx else if tcbstr.TCB_iViewMode == 1 then vx else vz -> xdot in let if tcbstr.TCB_iViewMode == 0 then vz else if tcbstr.TCB_iViewMode == 1 then vy else vy -> ydot in let tcbstr.TCB_fCamfov /. 57.29 -> d in let (itof iWinW) /. (itof iWinH) -> wx in let ((dist *. (tan d)) *. 2.0) -> iw in let iw /. wx -> ih in let (iWinW / 2) + (ftoi (xdot *. ((itof iWinW) /. iw))) -> x in let (iWinH / 2) + (ftoi (ydot *. ((itof iWinH) /. ih))) -> y in ( let 30.0 *. (cos azr) -> lx1 in let 30.0 *. (sin azr) -> ly1 in let 30.0 *. (cos azr2) -> lx2 in let 30.0 *. (sin azr2) -> ly2 in ( _SDRAWline tcbstr.TCB_surface x y (ftoi ((itof x) +. lx1)) (ftoi ((itof y) -. ly1)) DRAW_SOLID 1 0xff0000; _SDRAWline tcbstr.TCB_surface x y (ftoi ((itof x) +. lx2)) (ftoi ((itof y) -. ly2)) DRAW_SOLID 1 0x00ff00; ); mutate pos <- [[(itof x) (itof y)] _ _ _ _]; ); set i = i + 1; ); let (1.0 /. (itof tcbstr.TCB_iNbkey)) -> stp in let stp -> t in while (t <. 1.0) do ( let getInterpolateTCB tcbstr.TCB_lDots t -> interp in if interp == nil then nil else let interp -> [_ x y] in //_SDRAWcircle tcbstr.TCB_surface x y 1 DRAW_SOLID 0 iCurveColor DRAW_SOLID iCurveColor; _SDRAWpoint tcbstr.TCB_surface x y iCurveColor; set t = t +. stp; ); let sizelist tcbstr.TCB_lDots -> size in let 0 -> i in while i < size do ( let nth_list tcbstr.TCB_lDots i -> [[x y] _ _ _ _] in let if i == tcbstr.TCB_iSelected then iDotSelectColor else iDotColor -> dcolor in _SDRAWcircle tcbstr.TCB_surface (ftoi x) (ftoi y) iDotRadius DRAW_SOLID iDotBorder dcolor DRAW_SOLID iDotColor; set i = i + 1; ); ); if (tcbstr.TCB_fPreview == nil) || (tcbstr.TCB_lDots == nil) then nil else ( let getInterpolateTCB tcbstr.TCB_lDots tcbstr.TCB_fPreview -> interp in if interp == nil then nil else let interp -> [_ x y] in _SDRAWcircle tcbstr.TCB_surface x y iPreviewRadius DRAW_SOLID 0 iPreviewColor DRAW_SOLID iPreviewColor; ); 0;; fun setCameraParams(tcbstr)= let M3getObjVec session tcbstr.TCB_shell -> [x y z] in let if tcbstr.TCB_iViewMode == 0 then ((abs y) - tcbstr.TCB_iCamClip) else if tcbstr.TCB_iViewMode == 1 then ((abs z) - tcbstr.TCB_iCamClip) else if tcbstr.TCB_iViewMode == 2 then ((abs x) - tcbstr.TCB_iCamClip) else 1 -> clip in let M3getCamera session tcbstr.TCB_cam -> [ [dx dy] [sx sy] [_ _ zmax] ] in M3setCamera session tcbstr.TCB_cam [[dx dy] [iWinW/2 iWinH/2] [clip 90000000 90000000]]; let (if tcbstr.TCB_iViewMode == 3 then 29.7 else tcbstr.TCB_fCamfov) /. 57.29 -> d in let M3getCamera session tcbstr.TCB_cam ->[_ [sx sy] z] in let ftoi (itof sx)/. tan d -> dx in M3setCamera session tcbstr.TCB_cam [[dx dx] [sx sy] z]; 0;; fun getDotParams(tcbstr)= if tcbstr.TCB_iSelected == nil then ( _SHOWwindow tcbstr.TCB_winP WINDOW_HIDDEN; 0; ) else ( let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> [_ [x y z] [ax ay az] [t c b] ts] in ( _SETtext tcbstr.TCB_txtX ftoa x; _SETtext tcbstr.TCB_txtY ftoa y; _SETtext tcbstr.TCB_txtZ ftoa z; _SETtext tcbstr.TCB_txtAX ftoa ax; _SETtext tcbstr.TCB_txtAY ftoa ay; _SETtext tcbstr.TCB_txtAZ ftoa az; _SETsliderLeft tcbstr.TCB_sldT t; _SETsliderLeft tcbstr.TCB_sldC c; _SETsliderLeft tcbstr.TCB_sldB b; let nth_list tcbstr.TCB_lDots (tcbstr.TCB_iSelected - 1) -> [_ _ _ _ tmin] in let nth_list tcbstr.TCB_lDots (tcbstr.TCB_iSelected + 1) -> [_ _ _ _ tmax] in let if tmin == nil then 0.0 else (tmin +. 0.01) -> tcmin in let if tmin == nil then 0.0001 else if tmax == nil then 1.0 else (tmax -. 0.01) -> tcmax in ( _SETsliderMin tcbstr.TCB_sldDotTime tcmin; _SETsliderMax tcbstr.TCB_sldDotTime tcmax; _SETsliderLeft tcbstr.TCB_sldDotTime ts; ); _SHOWwindow tcbstr.TCB_winP WINDOW_UNHIDDEN; 0; ); ); 0;; fun addDot(tcbstr, cx, cy)= let M3getObjVecF session tcbstr.TCB_shell -> cvec in let cvec -> [vx vy vz] in let if tcbstr.TCB_iViewMode == 0 then vy else if tcbstr.TCB_iViewMode == 1 then vz else vx -> dist in let if tcbstr.TCB_iViewMode == 0 then vx else if tcbstr.TCB_iViewMode == 1 then vx else vz -> xdot in let if tcbstr.TCB_iViewMode == 0 then vz else if tcbstr.TCB_iViewMode == 1 then vy else vy -> ydot in let tcbstr.TCB_fCamfov /. 57.29 -> d in let (itof iWinW) /. (itof iWinH) -> wx in let ((dist *. (tan d)) *. 2.0) -> iw in let iw /. wx -> ih in let ((itof (cx - (iWinW / 2))) *. (iw /. (itof iWinW))) -> x in let ((itof (cy - (iWinH / 2))) *. (ih /. (itof iWinH))) -> z in let if tcbstr.TCB_iViewMode == 0 then [nil [(xdot +. x) 0.0 (ydot -. z)] [0.0 0.0 0.0] [0.0 0.0 0.0] 0.0] else if tcbstr.TCB_iViewMode == 1 then [nil [(xdot -. x) (ydot +. z) 0.0] [0.0 0.0 0.0] [0.0 0.0 0.0] 0.0] else [nil [0.0 (ydot +. z) (xdot +. x)] [0.0 0.0 0.0] [0.0 0.0 0.0] 0.0] -> npos in ( let 0.001 -> stp in let stp -> t in let nil -> ipos in ( while (t <. 1.0) do ( let getInterpolateTCB tcbstr.TCB_lDots t -> interp in if interp == nil then nil else let interp -> [li tx ty] in let abs (cx - tx) -> xd in let abs (cy - ty) -> yd in if xd <= iDotRadius && yd <= iDotRadius then set ipos = li else nil; set t = t +. stp; ); if ipos == nil then set tcbstr.TCB_lDots = setPosTime (listcat tcbstr.TCB_lDots npos::nil) else set tcbstr.TCB_lDots = setPosTime (add_nth_in_list tcbstr.TCB_lDots ipos npos); ); ); set tcbstr.TCB_iSelected = (sizelist tcbstr.TCB_lDots) - 1; getDotParams tcbstr; 0;; fun delDot(tcbstr)= if tcbstr.TCB_iSelected == nil then nil else set tcbstr.TCB_lDots = setPosTime remove_nth_from_list tcbstr.TCB_lDots tcbstr.TCB_iSelected; 0;; fun selectDot(tcbstr, cx, cy)= set tcbstr.TCB_iSelected = nil; let sizelist tcbstr.TCB_lDots -> size in let 0 -> i in while i < size do ( let nth_list tcbstr.TCB_lDots i -> [[x y] _ ang tcb ts] in let abs (cx - (ftoi x)) -> xd in let abs (cy - (ftoi y)) -> yd in if xd <= iDotRadius && yd <= iDotRadius then set tcbstr.TCB_iSelected = i else nil; set i = i + 1; ); getDotParams tcbstr; 0;; // 2D callbacks ************************************************************************************ fun cbWinPaint(win, p) = 0;; fun cbWinClick(win, tcbstr, x, y, btn)= if tcbstr.TCB_iViewMode == 3 then nil else if btn == 2 then ( addDot tcbstr x y; ) else ( selectDot tcbstr x y; ); 0;; fun cbWinCursorMove(win, tcbstr, x, y, btn)= _SETfocus win; if tcbstr.TCB_iViewMode == 3 then nil else if btn & 1 then ( let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> dot in if dot == nil then nil else let dot -> [[px py] vec ang tcb ts] in if btn & 4 then ( let ang -> [a b c] in ( let (itof (x - tcbstr.TCB_iCursorX)) -> rt in let if (tcbstr.TCB_iViewMode == 2) then if ((a +. rt) >=. 180.0) then 180.0 else if ((a +. rt) <=. -.180.0) then -.180.0 else (a +. rt) else a -> a in let if (tcbstr.TCB_iViewMode == 0) then if ((b +. rt) >=. 180.0) then 180.0 else if ((b +. rt) <=. -.180.0) then -.180.0 else (b +. rt) else b -> b in let if (tcbstr.TCB_iViewMode == 1) then if ((c +. rt) >=. 180.0) then 180.0 else if ((c +. rt) <=. -.180.0) then -.180.0 else (c +. rt) else c -> c in ( mutate dot <- [_ _ [a b c] _ _]; ); ); ) else ( let M3getObjVecF session tcbstr.TCB_shell -> cvec in let absVectorF soustractVectorsF vec cvec -> [dx dy dz] in let if tcbstr.TCB_iViewMode == 0 then dy else if tcbstr.TCB_iViewMode == 1 then dz else dx -> dist in let vec -> [dcx dcy dcz] in let cvec -> [vx vy vz] in let if tcbstr.TCB_iViewMode == 0 then vx else if tcbstr.TCB_iViewMode == 1 then vx else vz -> xdot in let if tcbstr.TCB_iViewMode == 0 then vz else if tcbstr.TCB_iViewMode == 1 then vy else vy -> ydot in let tcbstr.TCB_fCamfov /. 57.29 -> d in let (itof iWinW) /. (itof iWinH) -> wx in let ((dist *. (tan d)) *. 2.0) -> iw in let iw /. wx -> ih in let ((itof (x - (iWinW / 2))) *. (iw /. (itof iWinW))) -> x in let ((itof (y - (iWinH / 2))) *. (ih /. (itof iWinH))) -> z in if tcbstr.TCB_iViewMode == 0 then mutate dot <- [_ [(xdot +. x) dcy (ydot -. z)] _ _ _] else if tcbstr.TCB_iViewMode == 1 then mutate dot <- [_ [(xdot +. x) (ydot -. z) dcz] _ _ _] else mutate dot <- [_ [dcx (ydot -. z) (xdot -. x)] _ _ _] ); getDotParams tcbstr; 0; ) else if btn == 16 then ( M3movObj session tcbstr.TCB_shell [-(x - tcbstr.TCB_iCursorX) (y - tcbstr.TCB_iCursorY) 0]; 0; ) else nil; set tcbstr.TCB_iCursorX = x; set tcbstr.TCB_iCursorY = y; 0;; fun cbViewPos(tcbstr)= if tcbstr.TCB_lDots == nil then nil else let if tcbstr.TCB_iSelected == nil then 0 else tcbstr.TCB_iSelected -> select in let nth_list tcbstr.TCB_lDots select -> dot in let dot -> [_ vec ang _ _] in ( set tcbstr.TCB_iViewMode = 3; M3setObjVecF session tcbstr.TCB_shell vec; M3setObjAngF session tcbstr.TCB_shell (permutXYvec (convertDegVecAngToRad ang)); ); setCameraParams tcbstr; 0;; fun cbEndColor(c, tcbstr)= set iCurveColor = make_rgb (c>>16)&255 (c>>8)&255 c&255; 0;; fun cbViewColor(btn, tcbstr)= GD_CRcolorMap _channel tcbstr.TCB_win 100 100 "Choose Font Color" mkfun2 @cbEndColor tcbstr make_rgb (iCurveColor>>16)&255 (iCurveColor>>8)&255 iCurveColor&255; 0;; fun cbViewMode(btn, tcbstr, mode)= if mode == 0 then // T ( set tcbstr.TCB_iViewMode = 0; M3setObjVec session tcbstr.TCB_shell [0 5000 0]; M3setObjAng session tcbstr.TCB_shell [0 (-16384) 0]; setCameraParams tcbstr; 0; ) else if mode == 1 then // F ( set tcbstr.TCB_iViewMode = 1; M3setObjVec session tcbstr.TCB_shell [0 0 (-5000)]; M3setObjAng session tcbstr.TCB_shell [0 0 0]; setCameraParams tcbstr; 0; ) else if mode == 2 then // L ( set tcbstr.TCB_iViewMode = 2; M3setObjVec session tcbstr.TCB_shell [(-5000) 0 0]; M3setObjAng session tcbstr.TCB_shell [(-16384) 0 0]; setCameraParams tcbstr; 0; ) else if mode == 3 then // P ( cbViewPos tcbstr; 0; ) else nil; 0;; fun cbPreview(btn, tcbstr)= if tcbstr.TCB_lDots == nil then nil else if tcbstr.TCB_iPreview == 1 then ( set tcbstr.TCB_iPreview = 0; ) else ( if tcbstr.TCB_fPreview != 1.0 && tcbstr.TCB_fPreview != nil then nil else set tcbstr.TCB_fPreview = 0.0; set tcbstr.TCB_iPreview = 1; set tcbstr.TCB_iTick = _tickcount; ); _SETfocus tcbstr.TCB_win; 0;; fun cbWinKeyUp(win, tcbstr, key)= if key == 339 then // DEL ( if tcbstr.TCB_iSelected == nil then nil else ( delDot tcbstr; set tcbstr.TCB_iSelected = nil; getDotParams tcbstr; ); ) else nil; 0;; fun cbWinKeyDown(win, tcbstr, key, asc)= if key == 20 then // T ( set tcbstr.TCB_iViewMode = 0; M3setObjVec session tcbstr.TCB_shell [0 5000 0]; M3setObjAng session tcbstr.TCB_shell [0 (-16384) 0]; setCameraParams tcbstr; 0; ) else if key == 33 then // F ( set tcbstr.TCB_iViewMode = 1; M3setObjVec session tcbstr.TCB_shell [0 0 (-5000)]; M3setObjAng session tcbstr.TCB_shell [0 0 0]; setCameraParams tcbstr; 0; ) else if key == 38 then // L ( set tcbstr.TCB_iViewMode = 2; M3setObjVec session tcbstr.TCB_shell [(-5000) 0 0]; M3setObjAng session tcbstr.TCB_shell [(-16384) 0 0]; setCameraParams tcbstr; 0; ) else if key == 25 then // P ( cbViewPos tcbstr; 0; ) else if key == 57 then // SPACE ( cbPreview nil tcbstr; 0; ) else nil; 0;; fun closeCurveEditor(tcbstr)= _DSwindow tcbstr.TCB_win; _DStext tcbstr.TCB_txtX; _DStext tcbstr.TCB_txtY; _DStext tcbstr.TCB_txtZ; _DStext tcbstr.TCB_txtAX; _DStext tcbstr.TCB_txtAY; _DStext tcbstr.TCB_txtAZ; _DSslider tcbstr.TCB_sldT; _DSslider tcbstr.TCB_sldC; _DSslider tcbstr.TCB_sldB; _DSslider tcbstr.TCB_sldDotTime; _DSslider tcbstr.TCB_sldTime; _DSslider tcbstr.TCB_sldClip; _DSslider tcbstr.TCB_sldFov; _DSfont tcbstr.TCB_font; M3delObj session tcbstr.TCB_cam; M3delObj session tcbstr.TCB_shell; _DSsurface tcbstr.TCB_surface; _deltimer tcbstr.TCB_timer; _DScheck tcbstr.TCB_chkLoop; _DScheck tcbstr.TCB_chkInit; set tcbstr.TCB_win = nil; set tcbstr.TCB_txtX = nil; set tcbstr.TCB_txtY = nil; set tcbstr.TCB_txtZ = nil; set tcbstr.TCB_txtAX = nil; set tcbstr.TCB_txtAY = nil; set tcbstr.TCB_txtAZ = nil; set tcbstr.TCB_sldT = nil; set tcbstr.TCB_sldC = nil; set tcbstr.TCB_sldB = nil; set tcbstr.TCB_sldDotTime = nil; set tcbstr.TCB_sldTime = nil; set tcbstr.TCB_sldClip = nil; set tcbstr.TCB_sldFov = nil; set tcbstr.TCB_font = nil; set tcbstr.TCB_cam = nil; set tcbstr.TCB_shell = nil; set tcbstr.TCB_surface = nil; set tcbstr.TCB_timer = nil; set tcbstr.TCB_chkLoop = nil; set tcbstr.TCB_chkInit = nil; set strCurveEditor = nil; 0;; fun cbWinDestroy(win, tcbstr, edttxt)= closeCurveEditor tcbstr; _SETtext edttxt nil; _SELlist listTrans nil; 0;; fun cbWinWheel(win, tcbstr, posx, posy, delta, but)= if tcbstr.TCB_iViewMode == 3 then nil else ( let M3getObjVec session tcbstr.TCB_shell -> [x y z] in let if tcbstr.TCB_iViewMode == 0 then abs y else if tcbstr.TCB_iViewMode == 1 then abs z else abs x -> coef in let if coef == 0 then 1 else coef -> coef in M3movObj session tcbstr.TCB_shell [0 0 (delta * (coef / 50))]; let M3getObjVec session tcbstr.TCB_shell -> [x y z] in let if tcbstr.TCB_iViewMode == 0 then abs y else if tcbstr.TCB_iViewMode == 1 then abs z else abs x -> coef in ( let _GETsliderLeft tcbstr.TCB_sldClip -> lf in _SETsliderMax tcbstr.TCB_sldClip itof coef; let M3getCamera session tcbstr.TCB_cam -> [ [dx dy] [sx sy] [_ _ zmax] ] in M3setCamera session tcbstr.TCB_cam [[dx dy] [iWinW/2 iWinH/2] [(coef - tcbstr.TCB_iCamClip) 90000000 90000000]]; let tcbstr.TCB_fCamfov /. 57.29 -> d in let M3getCamera session tcbstr.TCB_cam ->[_ [sx sy] z] in let ftoi (itof sx)/. tan d -> dx in M3setCamera session tcbstr.TCB_cam [[dx dx] [sx sy] z]; ); ); 0;; fun cbTimeSlider(sld, af, bf, tcbstr)= set tcbstr.TCB_fPreview = af; 0;; fun cbTSlider(sld, af, bf, tcbstr)= if tcbstr.TCB_iSelected == nil then nil else let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> dot in let dot -> [_ _ _ [t c b] _] in mutate dot <- [_ _ _ [af c b] _]; 0;; fun cbCSlider(sld, af, bf, tcbstr)= if tcbstr.TCB_iSelected == nil then nil else let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> dot in let dot -> [_ _ _ [t c b] _] in mutate dot <- [_ _ _ [t af b] _]; 0;; fun cbBSlider(sld, af, bf, tcbstr)= if tcbstr.TCB_iSelected == nil then nil else let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> dot in let dot -> [_ _ _ [t c b] _] in mutate dot <- [_ _ _ [t c af] _]; 0;; fun cbDotTimeSlider(sld, af, bf, tcbstr)= if tcbstr.TCB_iSelected == nil then nil else let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> dot in mutate dot <- [_ _ _ _ af]; 0;; fun cbFovSlider(sld, af, bf, tcbstr)= set tcbstr.TCB_fCamfov = af; setCameraParams tcbstr; 0;; fun cbClipSlider(sld, af, bf, tcbstr)= set tcbstr.TCB_iCamClip = ftoi af; setCameraParams tcbstr; 0;; fun cbAXchange(txt, tcbstr)= if tcbstr.TCB_iSelected == nil then nil else ( let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> dot in let dot -> [_ _ [a b c] _ _] in ( mutate dot <- [_ _ [atof (_GETtext txt) b c] _ _]; if tcbstr.TCB_iViewMode != 3 then nil else M3setObjAngF session tcbstr.TCB_shell permutXYvec convertDegVecAngToRad [atof (_GETtext txt) b c]; ); ); 0;; fun cbAYchange(txt, tcbstr)= if tcbstr.TCB_iSelected == nil then nil else ( let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> dot in let dot -> [_ _ [a b c] _ _] in ( mutate dot <- [_ _ [a atof (_GETtext txt) c] _ _]; if tcbstr.TCB_iViewMode != 3 then nil else M3setObjAngF session tcbstr.TCB_shell permutXYvec convertDegVecAngToRad [a atof (_GETtext txt) c]; ); ); 0;; fun cbAZchange(txt, tcbstr)= if tcbstr.TCB_iSelected == nil then nil else ( let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> dot in let dot -> [_ _ [a b c] _ _] in ( mutate dot <- [_ _ [a b atof (_GETtext txt)] _ _]; if tcbstr.TCB_iViewMode != 3 then nil else M3setObjAngF session tcbstr.TCB_shell permutXYvec convertDegVecAngToRad [a b atof (_GETtext txt)]; ); ); 0;; fun cbVXchange(txt, tcbstr)= if tcbstr.TCB_iSelected == nil then nil else ( let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> dot in let dot -> [_ [x y z] _ _ _] in ( mutate dot <- [_ [atof (_GETtext txt) x y] _ _ _]; if tcbstr.TCB_iViewMode != 3 then nil else M3setObjVecF session tcbstr.TCB_shell [atof (_GETtext txt) x y]; ); ); 0;; fun cbVYchange(txt, tcbstr)= if tcbstr.TCB_iSelected == nil then nil else ( let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> dot in let dot -> [_ [x y z] _ _ _] in ( mutate dot <- [_ [x atof (_GETtext txt) z] _ _ _]; if tcbstr.TCB_iViewMode != 3 then nil else M3setObjVecF session tcbstr.TCB_shell [x atof (_GETtext txt) z]; ); ); 0;; fun cbVZchange(txt, tcbstr)= if tcbstr.TCB_iSelected == nil then nil else ( let nth_list tcbstr.TCB_lDots tcbstr.TCB_iSelected -> dot in let dot -> [_ [x y z] _ _ _] in ( mutate dot <- [_ [x y atof (_GETtext txt)] _ _ _]; if tcbstr.TCB_iViewMode != 3 then nil else M3setObjVecF session tcbstr.TCB_shell [x y atof (_GETtext txt)]; ); ); 0;; fun cbFpsChange(txt, tcbstr)= set tcbstr.TCB_iPreview = 0; let atoi (_GETtext txt) -> fps in set tcbstr.TCB_iKps = if fps == nil || fps == 0 then 1 else fps; 0;; fun cbNbkeyChange(txt, tcbstr)= set tcbstr.TCB_iPreview = 0; let atoi (_GETtext txt) -> nbkeys in set tcbstr.TCB_iNbkey = if nbkeys == nil || nbkeys == 0 then 1 else nbkeys; 0;; fun setCameraPos(tcbstr, coef)= let getInterpolateTCB3D tcbstr.TCB_lDots coef -> [index tvec] in let nth_list tcbstr.TCB_lDots (index - 1) -> [_ spos sang _ t1] in let nth_list tcbstr.TCB_lDots index -> [_ dpos dang _ t2] in if tvec == nil then ( let if tcbstr.TCB_iSelected == nil then 0 else tcbstr.TCB_iSelected -> select in let nth_list tcbstr.TCB_lDots select -> [_ vec ang _ _] in ( M3setObjVecF session tcbstr.TCB_shell vec; M3setObjAngF session tcbstr.TCB_shell (permutXYvec (convertDegVecAngToRad ang)); 0; ); ) else ( let (if t1 == nil then 0.0 else t1) -> t1 in let (if t2 == nil then 1.0 else t2) -> t2 in let t2 -. t1 -> lenght in let lenght /. (1.0 /. (itof tcbstr.TCB_iNbkey)) -> nbk in let 1.0 /. nbk -> angstep in let ((lenght -. (t2 -. coef)) /. (lenght /. nbk)) *. angstep -> angcoef in let (permutXYvec (convertDegVecAngToRad sang)) -> [ax ay az] in let (permutXYvec (convertDegVecAngToRad dang)) -> [tx ty tz] in let OptimizeDestinationOrientation ax tx ay ty az tz -> oang in let M3interpVecF [ax ay az] oang angcoef -> tang in M3setObjAngF session tcbstr.TCB_shell tang; M3setObjVecF session tcbstr.TCB_shell tvec; 0; ); 0;; fun playPreview(tcbstr)= let (tcbstr.TCB_iKps * (_tickcount - tcbstr.TCB_iTick)) / 1000 -> ntick in if (ntick < 1) || (tcbstr.TCB_lDots == nil) then nil else ( if (tcbstr.TCB_fPreview >=. 1.0) then ( set tcbstr.TCB_fPreview = 1.0; set tcbstr.TCB_iPreview = 0; ) else ( let (itof ntick) *. (1.0 /. (itof tcbstr.TCB_iNbkey)) -> nstep in set tcbstr.TCB_fPreview = if (tcbstr.TCB_fPreview +. nstep) >. 1.0 then 1.0 else tcbstr.TCB_fPreview +. nstep; if tcbstr.TCB_iViewMode != 3 then nil else setCameraPos tcbstr tcbstr.TCB_fPreview; _SETsliderLeft tcbstr.TCB_sldTime tcbstr.TCB_fPreview; 0; ); set tcbstr.TCB_iTick = _tickcount; ); 0;; fun cbErender(trm, tcbstr)= if tcbstr.TCB_iPreview != 1 then nil else playPreview tcbstr; MX3render session tcbstr.TCB_surface tcbstr.TCB_cam 0 0 0; if tcbstr.TCB_iViewMode == 3 then nil else refreshDots tcbstr; let if tcbstr.TCB_iViewMode == 0 then "TOP" else if tcbstr.TCB_iViewMode == 1 then "FRONT" else if tcbstr.TCB_iViewMode == 2 then "LEFT" else "POS" -> txt in _SDRAWtext tcbstr.TCB_surface tcbstr.TCB_font 5 5 0xffffff TD_LEFT txt; _BLTsurface tcbstr.TCB_win 0 0 tcbstr.TCB_surface 0 0 iWinW iWinH; 0;; fun getStringDots(ldots)= let sizelist ldots -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list ldots i -> dot in let nth_list dot 0 -> x in let nth_list dot 1 -> y in let nth_list dot 2 -> z in let nth_list dot 3 -> ax in let nth_list dot 4 -> ay in let nth_list dot 5 -> az in let nth_list dot 6 -> t in let nth_list dot 7 -> c in let nth_list dot 8 -> b in let nth_list dot 9 -> ts in set ndata = listcat ndata [[0.0 0.0] [(atof x) (atof y) (atof z)] [(atof ax) (atof ay) (atof az)] [(atof t) (atof c) (atof b)] (atof ts)]::nil; set i = i + 1; ); ndata; );; fun getDotsToString(ldots)= let sizelist ldots -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list ldots i -> [_ [x y z] [ax ay az] [t c b] ts] in set ndata = listcat ndata ((ftoa x)::(ftoa y)::(ftoa z)::(ftoa ax)::(ftoa ay)::(ftoa az)::(ftoa t)::(ftoa c)::(ftoa b)::(ftoa ts)::nil)::nil; set i = i + 1; ); strbuild ndata; );; fun cbBtnEndTrans(btn, tcbstr, edttxt)= if (tcbstr.TCB_name == nil) || (!strcmp tcbstr.TCB_name "") then nil else let _GETtext tcbstr.TCB_txtNbKey -> nbk in let _GETtext tcbstr.TCB_txtFps -> kps in let itoa (_GETcheck tcbstr.TCB_chkLoop) -> loop in let itoa (_GETcheck tcbstr.TCB_chkInit) -> init in let strcatn tcbstr.TCB_name::" "::nbk::" "::kps::" "::loop::" "::init::nil -> transp in let tcbstr.TCB_name::nbk::kps::loop::init::(getDotsToString tcbstr.TCB_lDots)::nil -> transfullp in ( let getElemPosFromListByName lTranslist tcbstr.TCB_name -> pos in if pos == nil then nil else ( _DELlist listTrans pos; set lTranslist = remove_string_from_pos_list lTranslist pos; let sizelist lTranslist -> size in let 0 -> i in while i < size do ( let nth_list lTranslist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); ); let (_GETlistCount listTrans) -> pos in ( _ADDlist listTrans pos transp; set lTranslist = listcat lTranslist [pos transfullp]::nil; ); closeCurveEditor tcbstr; _SETtext edttxt nil; _SELlist listTrans nil; ); 0;; fun cbBtnCancelTrans(btn, tcbstr, edttxt)= closeCurveEditor tcbstr; _SETtext edttxt nil; _SELlist listTrans nil; 0;; fun initCurveEditor(tcbstr, win, edttxt) = if tcbstr.TCB_win != nil then ( _SETfocus tcbstr.TCB_win; 0; ) else let _GETscreenSize -> [w h] in ( set tcbstr.TCB_win = _CRwindow _channel win ((w-iWinW)/2) ((h-iWinH)/2) iWinW + 180 iWinH + 40 WN_MENU|WN_NOBORDER|WN_NOSCOL "TCB Editor"; set tcbstr.TCB_shell = M3createShell session; set tcbstr.TCB_iViewMode = 0; set tcbstr.TCB_font = _CRfont _channel 18 0 FF_PIXEL "Arial"; set tcbstr.TCB_fPreview = nil; set tcbstr.TCB_iTick = nil; set tcbstr.TCB_iPreview = 0; set tcbstr.TCB_iSelected = nil; M3loadString session sCamFile tcbstr.TCB_shell; M3setObjVec session tcbstr.TCB_shell [0 5000 0]; M3setObjAng session tcbstr.TCB_shell [0 (-16384) 0]; M3link session tcbstr.TCB_shell shell; set tcbstr.TCB_cam = M3getFirstSon session tcbstr.TCB_shell; set tcbstr.TCB_surface = _CRsurface _channel iWinW iWinH; setCameraParams tcbstr; _CBwinWheel tcbstr.TCB_win @cbWinWheel tcbstr; _CBcursorMove tcbstr.TCB_win @cbWinCursorMove tcbstr; _CBwinClick tcbstr.TCB_win @cbWinClick tcbstr; _CBwinKeydown tcbstr.TCB_win @cbWinKeyDown tcbstr; _CBwinDestroy tcbstr.TCB_win mkfun3 @cbWinDestroy edttxt tcbstr; _CBwinPaint tcbstr.TCB_win @cbWinPaint tcbstr; _CBwinKeyup tcbstr.TCB_win @cbWinKeyUp tcbstr; _CBwinClose tcbstr.TCB_win mkfun3 @cbWinDestroy edttxt tcbstr; let _CRwindow _channel tcbstr.TCB_win iWinW 0 180 iWinH WN_NOBORDER|WN_CHILDINSIDE "" -> twin in let _CRwindow _channel tcbstr.TCB_win 0 iWinH iWinW 40 WN_NOBORDER|WN_CHILDINSIDE "" -> ewin in let _CRwindow _channel twin 5 5 170 185 WN_CHILDINSIDE "" -> cwin in let _CRwindow _channel twin 5 190 170 270 WN_CHILDINSIDE|WINDOW_HIDDEN "" -> pwin in ( _SHOWwindow pwin WINDOW_HIDDEN; set tcbstr.TCB_winP = pwin; _CBbutton _CRbutton _channel cwin 5 5 20 20 nil "T" mkfun3 @cbViewMode 0 tcbstr; _CBbutton _CRbutton _channel cwin 30 5 20 20 nil "F" mkfun3 @cbViewMode 1 tcbstr; _CBbutton _CRbutton _channel cwin 55 5 20 20 nil "L" mkfun3 @cbViewMode 2 tcbstr; _CBbutton _CRbutton _channel cwin 80 5 20 20 nil "P" mkfun3 @cbViewMode 3 tcbstr; _CBbutton _CRbutton _channel cwin 105 5 30 20 nil "Color" @cbViewColor tcbstr; _CRtext _channel cwin 5 30 70 20 ET_ALIGN_LEFT "Focale :"; set tcbstr.TCB_sldFov = _CRslider _channel cwin nil 80 30 80 20 0xff0000 0.1 100.0 0.0 0.0 mkfun4 @cbFovSlider tcbstr SLIDER_INTER_FIXED; _SETsliderPrecisionStep tcbstr.TCB_sldFov 0.1; _SETsliderPrecisionMark tcbstr.TCB_sldFov 3; _SETsliderLeft tcbstr.TCB_sldFov tcbstr.TCB_fCamfov; _CRtext _channel cwin 5 55 70 20 ET_ALIGN_LEFT "Clip :"; set tcbstr.TCB_sldClip = _CRslider _channel cwin nil 80 55 80 20 0xff0000 0.0 5000.0 0.0 0.0 mkfun4 @cbClipSlider tcbstr SLIDER_INTER_FIXED; _SETsliderPrecisionStep tcbstr.TCB_sldClip 1.0; _SETsliderPrecisionMark tcbstr.TCB_sldClip 3; _SETsliderLeft tcbstr.TCB_sldClip itof tcbstr.TCB_iCamClip; _CRtext _channel cwin 5 85 70 20 ET_ALIGN_LEFT "Keys / sec :"; set tcbstr.TCB_txtFps = _CBtext _CReditLine _channel cwin 80 85 80 20 ET_BORDER (itoa tcbstr.TCB_iKps) @cbFpsChange tcbstr; _CRtext _channel cwin 5 110 70 20 ET_ALIGN_LEFT "Total keys :"; set tcbstr.TCB_txtNbKey = _CBtext _CReditLine _channel cwin 80 110 80 20 ET_BORDER (itoa tcbstr.TCB_iNbkey) @cbNbkeyChange tcbstr; set tcbstr.TCB_chkLoop = _SETcheck _CRcheck _channel cwin 5 135 155 20 CH_TABFOCUS "Loop" tcbstr.TCB_iLoop; set tcbstr.TCB_chkInit = _SETcheck _CRcheck _channel cwin 5 160 155 20 CH_TABFOCUS "On start" tcbstr.TCB_iInit; _CRtext _channel pwin 5 5 70 20 ET_ALIGN_LEFT "Pos. X :"; set tcbstr.TCB_txtX = _CBtext _CReditLine _channel pwin 80 5 80 20 ET_BORDER "" @cbVXchange tcbstr; _CRtext _channel pwin 5 30 70 20 ET_ALIGN_LEFT "Pos. Y :"; set tcbstr.TCB_txtY = _CBtext _CReditLine _channel pwin 80 30 80 20 ET_BORDER "" @cbVYchange tcbstr; _CRtext _channel pwin 5 55 70 20 ET_ALIGN_LEFT "Pos. Z :"; set tcbstr.TCB_txtZ = _CBtext _CReditLine _channel pwin 80 55 80 20 ET_BORDER "" @cbVZchange tcbstr; _CRtext _channel pwin 5 85 70 20 ET_ALIGN_LEFT "Ang. X :"; set tcbstr.TCB_txtAX = _CBtext _CReditLine _channel pwin 80 85 80 20 ET_BORDER "" @cbAXchange tcbstr; _CRtext _channel pwin 5 110 70 20 ET_ALIGN_LEFT "Ang. Y :"; set tcbstr.TCB_txtAY = _CBtext _CReditLine _channel pwin 80 110 80 20 ET_BORDER "" @cbAYchange tcbstr; _CRtext _channel pwin 5 135 70 20 ET_ALIGN_LEFT "Ang. Z :"; set tcbstr.TCB_txtAZ = _CBtext _CReditLine _channel pwin 80 135 80 20 ET_BORDER "" @cbAZchange tcbstr; _CRtext _channel pwin 5 165 70 20 ET_ALIGN_LEFT "Curve T :"; set tcbstr.TCB_sldT = _CRslider _channel pwin nil 80 165 80 20 0xff0000 (-. 1.0) 1.0 0.0 0.0 mkfun4 @cbTSlider tcbstr SLIDER_INTER_FIXED; _SETsliderPrecisionStep tcbstr.TCB_sldT 0.01; _SETsliderPrecisionMark tcbstr.TCB_sldT 3; _CRtext _channel pwin 5 190 70 20 ET_ALIGN_LEFT "Curve C :"; set tcbstr.TCB_sldC = _CRslider _channel pwin nil 80 190 80 20 0xff0000 (-. 1.0) 1.0 0.0 0.0 mkfun4 @cbCSlider tcbstr SLIDER_INTER_FIXED; _SETsliderPrecisionStep tcbstr.TCB_sldC 0.01; _SETsliderPrecisionMark tcbstr.TCB_sldC 3; _CRtext _channel pwin 5 215 70 20 ET_ALIGN_LEFT "Curve B :"; set tcbstr.TCB_sldB = _CRslider _channel pwin nil 80 215 80 20 0xff0000 (-. 1.0) 1.0 0.0 0.0 mkfun4 @cbBSlider tcbstr SLIDER_INTER_FIXED; _SETsliderPrecisionStep tcbstr.TCB_sldB 0.01; _SETsliderPrecisionMark tcbstr.TCB_sldB 3; _CRtext _channel pwin 5 245 70 20 ET_ALIGN_LEFT "Dot time :"; set tcbstr.TCB_sldDotTime = _CRslider _channel pwin nil 80 245 80 20 0xff0000 0.0 1.0 0.0 0.0 mkfun4 @cbDotTimeSlider tcbstr SLIDER_INTER_FIXED; _SETsliderPrecisionStep tcbstr.TCB_sldDotTime 0.001; _SETsliderPrecisionMark tcbstr.TCB_sldDotTime 3; _SETsliderLeft tcbstr.TCB_sldDotTime 0.0; set tcbstr.TCB_sldTime = _CRslider _channel ewin nil 10 2 (iWinW - 20) 16 0xff0000 0.0 1.0 0.0 0.0 mkfun4 @cbTimeSlider tcbstr SLIDER_INTER_FIXED; _SETsliderPrecisionStep tcbstr.TCB_sldTime (1.0 /. (itof tcbstr.TCB_iNbkey)); _SETsliderPrecisionMark tcbstr.TCB_sldTime 3; _CBbutton _CRbutton _channel ewin 10 20 (iWinW - 20) 20 nil "Preview" @cbPreview tcbstr; _CBbutton _CRbutton _channel tcbstr.TCB_win (iWinW + 10) (iWinH + 10) 75 20 nil "Ok" mkfun3 @cbBtnEndTrans edttxt tcbstr; _CBbutton _CRbutton _channel tcbstr.TCB_win (iWinW + 100) (iWinH + 10) 75 20 nil "Cancel" mkfun3 @cbBtnCancelTrans edttxt tcbstr; ); _PAINTwindow tcbstr.TCB_win; set tcbstr.TCB_timer = _rfltimer _starttimer _channel 1000/iDefFps @cbErender tcbstr; 0; );; fun cbOpenCurveEditor(btn, win, edttxt)= if ((_GETtext edttxt) == nil) || (!strcmp (_GETtext edttxt) "") then nil else ( if strCurveEditor == nil then nil else closeCurveEditor strCurveEditor; let mkTCBeditor [nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] -> tcbstr in ( set tcbstr.TCB_iKps = iDefKps; set tcbstr.TCB_iNbkey = iDefNbkey; set tcbstr.TCB_fCamfov = fDefCamFov; set tcbstr.TCB_iLoop = 0; set tcbstr.TCB_iInit = 0; set tcbstr.TCB_iCamClip = 5000; set strCurveEditor = tcbstr; set tcbstr.TCB_name = (_GETtext edttxt); let getElemPosFromListByName lTranslist tcbstr.TCB_name -> pos in if pos == nil then nil else ( let getElemFromPos lTranslist pos -> trans in let atoi nth_list trans 1 -> nbk in let atoi nth_list trans 2 -> kps in let atoi nth_list trans 3 -> loop in let atoi nth_list trans 4 -> init in let nth_list trans 5 -> dots in ( set tcbstr.TCB_lDots = getStringDots strextr dots; set tcbstr.TCB_iKps = if kps == nil then iDefKps else kps; set tcbstr.TCB_iNbkey = if nbk == nil then iDefNbkey else nbk; set tcbstr.TCB_iLoop = loop; set tcbstr.TCB_iInit = init; ); ); initCurveEditor tcbstr win edttxt; ); ); 0;; /***************************************** Fonction qui renvoie l'indice du dernier % dans la chaine s *****************************************/ fun search_last_percent(s)= let strlen s -> l in let 1 -> i in (while i i in substr filename i+1 1000 else filename -> filetex in ( set l = filetex::l; ); let if (nth_char filenamebis 0)=='% then let search_last_percent filenamebis -> i in substr filenamebis i+1 1000 else filenamebis -> filetexbis in ( set l = filetexbis::l; ); let if posbis == nil then substr newMapo pos+1 (strlen mapo)-(pos+1) else substr newMapobis posbis+1 (strlen mapo)-(posbis+1) -> nextfile in registerTextures nextfile l /* 1 = strlen "\n" */ ); l;; fun brwSearchLastpoint(s)= if s == nil then nil else let (strlen s) - 1 -> i in ( while (i >= 0) && ((nth_char s i) != '.) do ( set i = i - 1; ); i );; fun getFileWithoutExtension(file)= let brwSearchLastpoint file -> i in substr file 0 i;; fun getPathFile (longfile, file)= if (longfile==nil) || (strlen longfile)==0 || (nth_char longfile ((strlen longfile)-1)) == '/ then [longfile file] else getPathFile substr longfile 0 (strlen longfile)-1 strcat substr longfile ((strlen longfile)-1) 1 file;; fun getFileNameFromPath(path)= if path == nil then nil else let strlen path -> size in let 0 -> pos in let 0 -> prevpos in ( while pos != nil && pos < size do ( set prevpos = pos; let strfind "/" path pos -> npos in set pos = if npos != nil then npos + 1 else nil; ); substr path prevpos (size - prevpos); );; /******************************************************************************* Functions: Freeing Editor's resources *******************************************************************************/ /******************************************************************************* cbDestroyWin() win -> ObjWin : Plugin Editor window p -> u0 : Not used <- I : Not used Callback function activated when the plugin Editor window is destroyed. Resources allocated in cbOpenEdit should be freed here. Checking the real allocation prevents corruptions in Voyager's data structures. *******************************************************************************/ fun cbDestroyWin(win, p) = if (txtM3D != nil) then (_DStext txtM3D; set txtM3D = nil; 0;) else 0; if (edtM3D != nil) then (_DStext edtM3D; set edtM3D = nil; 0;) else 0; if (txtAFR != nil) then (_DStext txtAFR; set txtAFR = nil; 0;) else 0; if (edtAFR != nil) then (_DStext edtAFR; set edtAFR = nil; 0;) else 0; if (edtAnim != nil) then (_DStext edtAnim; set edtAnim = nil; 0;) else 0; if (txtAnims != nil) then (_DStext txtAnims; set txtAnims = nil; 0;) else 0; if (listAnims != nil) then (_DSlist listAnims; set listAnims = nil; 0;) else 0; if (btnAddAnim != nil) then (_DSbutton btnAddAnim; set btnAddAnim = nil; 0;) else 0; if (btnRemoveAnim != nil) then (_DSbutton btnRemoveAnim; set btnRemoveAnim = nil; 0;) else 0; if (btnBrowseAnim != nil) then (_DSbutton btnBrowseAnim; set btnBrowseAnim = nil; 0;) else 0; if (btnBrowseM3d != nil) then (_DSbutton btnBrowseM3d; set btnBrowseM3d = nil; 0;) else 0; set lAnimlist = nil; 0;; /******************************************************************************* Functions: Saving plugin's DMI information *******************************************************************************/ fun uploadFilesList(l, path, p, nbdl)= if l == nil then nil else let p -> [edttxt addbtn] in ( let _getpack _checkpack hd l -> contenu in _DMSupload this hd l contenu mkfun2 @cb_fin_upload [path edttxt addbtn nbdl]; uploadFilesList tl l path p nbdl - 1; ); 0;; fun cbBrowseM3d(dlg, p, file)= let _PtoScol file -> name in if name == nil then nil else let p -> [edttxt addbtn] in ( let getPathFile name nil -> [path _] in set sPath = path; _ENbutton addbtn 0; _SETtext edttxt "Uploading ..."; // chercher les textures let registerTextures _getpack _checkpack name nil -> ltexturepath in ( uploadFilesList name::ltexturepath name p ((sizelist (name::ltexturepath)) - 1); ); ); 0;; fun cbBtnBrowseM3d(btn, p)= _DLGrflopen _DLGOpenFile _channel winEdt sPath nil "M3D\0*.m3d\0\0" @cbBrowseM3d p; 0;; fun cbBtnAddAnim(btn, p)= let p -> [edttxt chkp1 chkp2] in let _GETtext edttxt -> name in if (name == nil) || (!strcmp name "") then nil else ( let getElemPosFromListByName lAnimlist name -> pos in if pos != nil then nil else ( _DELlist listAnims pos; set lAnimlist = remove_string_from_pos_list lAnimlist pos; let sizelist lAnimlist -> size in let 0 -> i in while i < size do ( let nth_list lAnimlist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); let (_GETlistCount listAnims) -> pos in ( _ADDlist listAnims pos strcatn name::" "::(itoa _GETcheck chkp1)::" "::(itoa _GETcheck chkp2)::nil; _SELlist listAnims pos; set lAnimlist = listcat lAnimlist [pos (name::(itoa _GETcheck chkp1)::(itoa _GETcheck chkp2)::nil)] ::nil; ); _SETcheck chkp1 0; _SETcheck chkp2 0; _SETtext edttxt nil; ); ); 0;; fun cbLoopAnim(chk, edttxt, state)= let _GETtext edttxt -> name in if (name == nil) || (!strcmp name "") then nil else ( let getElemPosFromListByName lAnimlist name -> pos in if pos == nil then nil else let switch lAnimlist pos -> anim in let hd anim -> name in let hd tl anim -> loop in let hd tl tl anim -> astart in ( _DELlist listAnims pos; set lAnimlist = remove_string_from_pos_list lAnimlist pos; let sizelist lAnimlist -> size in let 0 -> i in while i < size do ( let nth_list lAnimlist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); let (_GETlistCount listAnims) -> pos in ( _ADDlist listAnims pos strcatn name::" "::(itoa _GETcheck chk)::" "::astart::nil; _SELlist listAnims pos; set lAnimlist = listcat lAnimlist [pos (name::(itoa _GETcheck chk)::astart::nil)] ::nil; ); ); ); 0;; fun cbStartAnim(chk, edttxt, state)= let _GETtext edttxt -> name in if (name == nil) || (!strcmp name "") then nil else ( let getElemPosFromListByName lAnimlist name -> pos in if pos == nil then nil else let switch lAnimlist pos -> anim in let hd anim -> name in let hd tl anim -> aloop in ( _DELlist listAnims pos; set lAnimlist = remove_string_from_pos_list lAnimlist pos; let sizelist lAnimlist -> size in let 0 -> i in while i < size do ( let nth_list lAnimlist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); let (_GETlistCount listAnims) -> pos in ( _ADDlist listAnims pos strcatn name::" "::aloop::" "::(itoa _GETcheck chk)::nil; _SELlist listAnims pos; set lAnimlist = listcat lAnimlist [pos (name::aloop::(itoa _GETcheck chk)::nil)] ::nil; ); ); ); 0;; fun cbBtnRemoveAnim(btn, p)= let _GETlist listAnims -> [pos name] in if pos == nil then nil else ( _DELlist listAnims pos; set lAnimlist = remove_string_from_pos_list lAnimlist pos; let sizelist lAnimlist -> size in let 0 -> i in while i < size do ( let nth_list lAnimlist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); _SETcheck chkLoopAnim 0; _SETcheck chkStartAnim 0; _SETtext edtAnim nil; ); 0;; fun cbListAnimSelect(lst, p, pos, elt)= let getElemFromPos lAnimlist pos -> anim in ( _SETtext edtAnim hd anim; _SETcheck chkLoopAnim atoi(hd tl anim); _SETcheck chkStartAnim atoi(hd tl tl anim); ); 0;; fun fillAnimList(anims)= let strextr anims -> l in let sizelist l -> size in let 0 -> i in while i < size do ( let nth_list l i -> elem in ( let (_GETlistCount listAnims) -> pos in ( _ADDlist listAnims pos strcatn (hd elem)::" "::(hd tl elem)::" "::(hd tl tl elem)::nil; set lAnimlist = listcat lAnimlist [pos elem]::nil; ); ); set i = i + 1; );; fun cbBrowseSound(dlg, p, file)= let _PtoScol file -> name in if name == nil then nil else let p -> [edttxt addbtn] in ( let getPathFile name nil -> [path _] in set sPath = path; _ENbutton addbtn 0; _SETtext edttxt "Uploading ..."; uploadFilesList name::nil name p ((sizelist (name::nil)) - 1); ); 0;; fun cbBtnBrowseSound(btn, p)= _DLGrflopen _DLGOpenFile _channel winEdt sPath nil "MP3\0*.mp3\0WAV\0*.wav\0\0" @cbBrowseSound p; 0;; fun cbBtnAddSound(btn, p)= let p -> [edttxt edtp1 edtp2 edtp3 edtp4] in let _GETtext edttxt -> name in if (name == nil) || (!strcmp name "") then nil else ( let getElemPosFromListByName lSoundlist name -> pos in if pos != nil then nil else ( _DELlist listSound pos; set lSoundlist = remove_string_from_pos_list lSoundlist pos; let sizelist lSoundlist -> size in let 0 -> i in while i < size do ( let nth_list lSoundlist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); let if (_GETtext edtp1) == nil || !strcmp (_GETtext edtp1) "" then "0" else (_GETtext edtp1) -> mindist in let if (_GETtext edtp2) == nil || !strcmp (_GETtext edtp2) "" then "0" else (_GETtext edtp2) -> maxdist in let strcatn name::" "::mindist::" "::maxdist::" "::(itoa (_GETcheck edtp3))::" "::(itoa (_GETcheck edtp4))::nil -> soundp in ( let (_GETlistCount listSound) -> pos in ( _ADDlist listSound pos soundp; _SELlist listSound pos; set lSoundlist = listcat lSoundlist [pos (name::mindist::maxdist::(itoa (_GETcheck edtp3))::(itoa (_GETcheck edtp4))::nil)]::nil; ); _SETtext edttxt nil; _SETtext edtp1 nil; _SETtext edtp2 nil; _SETcheck edtp3 0; _SETcheck edtp4 0; ); ); ); 0;; fun cbLoopSound(chk, edttxt, state)= let _GETtext edttxt -> name in if (name == nil) || (!strcmp name "") then nil else ( let getElemPosFromListByName lSoundlist name -> pos in if pos == nil then nil else let switch lSoundlist pos -> snd in let hd snd -> name in let hd tl snd -> mdist in let hd tl tl snd -> mxdist in let hd tl tl tl snd -> aloop in let hd tl tl tl tl snd -> astart in ( _DELlist listSound pos; set lSoundlist = remove_string_from_pos_list lSoundlist pos; let sizelist lSoundlist -> size in let 0 -> i in while i < size do ( let nth_list lSoundlist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); let if mdist == nil || !strcmp mdist "" then "0" else mdist -> mindist in let if mxdist == nil || !strcmp mxdist "" then "0" else mxdist -> maxdist in let strcatn name::" "::mindist::" "::maxdist::" "::(itoa (_GETcheck chk))::" "::astart::nil -> soundp in let (_GETlistCount listSound) -> pos in ( _ADDlist listSound pos soundp; _SELlist listSound pos; set lSoundlist = listcat lSoundlist [pos (name::mindist::maxdist::(itoa (_GETcheck chk))::astart::nil)]::nil; ); ); ); 0;; fun cbStartSound(chk, edttxt, state)= let _GETtext edttxt -> name in if (name == nil) || (!strcmp name "") then nil else ( let getElemPosFromListByName lSoundlist name -> pos in if pos == nil then nil else let switch lSoundlist pos -> snd in let hd snd -> name in let hd tl snd -> mdist in let hd tl tl snd -> mxdist in let hd tl tl tl snd -> aloop in let hd tl tl tl tl snd -> astart in ( _DELlist listSound pos; set lSoundlist = remove_string_from_pos_list lSoundlist pos; let sizelist lSoundlist -> size in let 0 -> i in while i < size do ( let nth_list lSoundlist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); let if mdist == nil || !strcmp mdist "" then "0" else mdist -> mindist in let if mxdist == nil || !strcmp mxdist "" then "0" else mxdist -> maxdist in let strcatn name::" "::mindist::" "::maxdist::" "::aloop::" "::(itoa (_GETcheck chk))::nil -> soundp in let (_GETlistCount listSound) -> pos in ( _ADDlist listSound pos soundp; _SELlist listSound pos; set lSoundlist = listcat lSoundlist [pos (name::mindist::maxdist::aloop::(itoa (_GETcheck chk))::nil)]::nil; ); ); ); 0;; fun cbMinSound(txt, edttxt)= let _GETtext edttxt -> name in if (name == nil) || (!strcmp name "") then nil else ( let getElemPosFromListByName lSoundlist name -> pos in if pos == nil then nil else let switch lSoundlist pos -> snd in let hd snd -> name in let _GETtext txt -> mdist in let hd tl tl snd -> mxdist in let hd tl tl tl snd -> aloop in let hd tl tl tl tl snd -> astart in ( _DELlist listSound pos; set lSoundlist = remove_string_from_pos_list lSoundlist pos; let sizelist lSoundlist -> size in let 0 -> i in while i < size do ( let nth_list lSoundlist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); let if mdist == nil || !strcmp mdist "" then "0" else mdist -> mindist in let if mxdist == nil || !strcmp mxdist "" then "0" else mxdist -> maxdist in let strcatn name::" "::mindist::" "::maxdist::" "::aloop::" "::astart::nil -> soundp in let (_GETlistCount listSound) -> pos in ( _ADDlist listSound pos soundp; _SELlist listSound pos; set lSoundlist = listcat lSoundlist [pos (name::mindist::maxdist::aloop::astart::nil)]::nil; ); ); ); 0;; fun cbMaxSound(txt, edttxt)= let _GETtext edttxt -> name in if (name == nil) || (!strcmp name "") then nil else ( let getElemPosFromListByName lSoundlist name -> pos in if pos == nil then nil else let switch lSoundlist pos -> snd in let hd snd -> name in let hd tl snd -> mdist in let _GETtext txt -> mxdist in let hd tl tl tl snd -> aloop in let hd tl tl tl tl snd -> astart in ( _DELlist listSound pos; set lSoundlist = remove_string_from_pos_list lSoundlist pos; let sizelist lSoundlist -> size in let 0 -> i in while i < size do ( let nth_list lSoundlist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); let if mdist == nil || !strcmp mdist "" then "0" else mdist -> mindist in let if mxdist == nil || !strcmp mxdist "" then "0" else mxdist -> maxdist in let strcatn name::" "::mindist::" "::maxdist::" "::aloop::" "::astart::nil -> soundp in let (_GETlistCount listSound) -> pos in ( _ADDlist listSound pos soundp; _SELlist listSound pos; set lSoundlist = listcat lSoundlist [pos (name::mindist::maxdist::aloop::astart::nil)]::nil; ); ); ); 0;; fun cbBtnRemoveSound(btn, p)= let _GETlist listSound -> [pos name] in if pos == nil then nil else ( _DELlist listSound pos; set lSoundlist = remove_string_from_pos_list lSoundlist pos; let sizelist lSoundlist -> size in let 0 -> i in while i < size do ( let nth_list lSoundlist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); _SETtext edtSound nil; _SETtext edtMinSound nil; _SETtext edtMaxSound nil; _SETcheck chkLoopSound 0; _SETcheck chkStartSound 0; ); 0;; fun cbListSoundSelect(lst, p, pos, elt)= let getElemFromPos lSoundlist pos -> sound in ( _SETtext edtSound hd sound; _SETtext edtMinSound (hd tl sound); _SETtext edtMaxSound (hd tl tl sound); _SETcheck chkLoopSound atoi(hd tl tl tl sound); _SETcheck chkStartSound atoi(hd tl tl tl tl sound); ); 0;; fun fillSoundList(sounds)= let strextr sounds -> l in let sizelist l -> size in let 0 -> i in while i < size do ( let nth_list l i -> elem in let nth_list elem 0 -> name in let nth_list elem 1 -> smin in let nth_list elem 2 -> smax in let nth_list elem 3 -> sloop in let nth_list elem 4 -> sstart in ( let (_GETlistCount listSound) -> pos in ( _ADDlist listSound pos strcatn name::" "::smin::" "::smax::" "::sloop::" "::sstart::nil; set lSoundlist = listcat lSoundlist [pos elem]::nil; ); ); set i = i + 1; );; fun cbBtnRemoveTrans(btn, p)= let _GETlist listTrans -> [pos _] in ( _DELlist listTrans pos; set lTranslist = remove_string_from_pos_list lTranslist pos; let sizelist lTranslist -> size in let 0 -> i in while i < size do ( let nth_list lTranslist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); _SETtext edtNameTrans nil; ); 0;; fun cbListTransSelect(lst, p, pos, elt)= let getElemFromPos lTranslist pos -> trans in ( _SETtext edtNameTrans hd trans; ); 0;; fun fillTransList(trans)= let strextr trans -> l in let sizelist l -> size in let 0 -> i in while i < size do ( let nth_list l i -> elem in ( let nth_list elem 0 -> name in let nth_list elem 1 -> nbk in let nth_list elem 2 -> kps in let nth_list elem 3 -> loop in let nth_list elem 4 -> init in let (_GETlistCount listTrans) -> pos in ( _ADDlist listTrans pos strcatn name::" "::nbk::" "::kps::" "::loop::" "::init::nil; set lTranslist = listcat lTranslist [pos elem]::nil; ); ); set i = i + 1; );; fun fillScriptList()= _RSTlist listScript; let sizelist lScriptlist -> size in let 0 -> i in while i < size do ( let nth_list lScriptlist i -> [pos elem] in ( let hd elem -> intype in let nth_list elem 1 -> inname in let nth_list elem 2 -> inparam in let nth_list elem 3 -> outtype in let nth_list elem 4 -> outname in let nth_list elem 5 -> outparam in _ADDlist listScript pos strcatn intype::" "::inname::" "::inparam::" -> "::outtype::" "::outname::" "::outparam::nil; ); set i = i + 1; );; fun closeScriptEditor()= _DSwindow winScriptEditor; set winScriptEditor = nil; _DStext txtEvent; _DStext txtAction; _DSlist listScript; _DScombo cmbScriptInType; _DScombo cmbScriptInName; _DScombo cmbScriptInParam; _DScombo cmbScriptOutType; _DScombo cmbScriptOutName; _DScombo cmbScriptOutParam; _DSbutton btnAddScript; _DSbutton btnRemoveScript; _DSbutton btnCloseScript; _DSbutton btnExportScript; _DSbutton btnImportScript; 0;; fun cbWinScriptDestroy(win, p)= closeScriptEditor; 0;; fun cbBtnCloseScript(btn, p)= closeScriptEditor; 0;; fun cbBtnAddScript(btn, p)= let _GETcombo cmbScriptInType -> [_ intype] in let _GETcombo cmbScriptInName -> [_ inname] in let _GETcombo cmbScriptInParam -> [_ inparam] in let _GETcombo cmbScriptOutType -> [_ outtype] in let _GETcombo cmbScriptOutName -> [_ outname] in let _GETcombo cmbScriptOutParam -> [_ outparam] in let intype::inname::(if (!strcmp inparam "") || (inparam == nil) then "_" else inparam)::outtype::outname::outparam::nil -> newscript in let strcatn intype::" "::inname::" "::(if (!strcmp inparam "") || (inparam == nil) then "_" else inparam)::" -> "::outtype::" "::outname::" "::outparam::nil -> newlscript in ( let (_GETlistCount listScript) -> pos in ( _ADDlist listScript pos newlscript; set lScriptlist = listcat lScriptlist [pos newscript]::nil; ); ); 0;; fun cbBtnRemoveScript(btn, p)= let _GETlist listScript -> [pos name] in ( _DELlist listScript pos; set lScriptlist = remove_string_from_pos_list lScriptlist pos; let sizelist lScriptlist -> size in let 0 -> i in while i < size do ( let nth_list lScriptlist i -> elem in let elem -> [cpos _] in if cpos <= pos then nil else mutate elem <- [(cpos - 1) _]; set i = i + 1; ); ); 0;; fun cbImportScript(dlg, p, file)= if file == nil then nil else ( set lScriptlist = nil; let strextr _getpack file -> lscript in let sizelist lscript -> size in let 0 -> i in while i < size do ( let nth_list lscript i -> elem in let nth_list elem 0 -> intype in let nth_list elem 1 -> inname in let nth_list elem 2 -> inparam in let nth_list elem 4 -> outtype in let nth_list elem 5 -> outname in let nth_list elem 6 -> outparam in set lScriptlist = listcat lScriptlist [i (intype::inname::inparam::outtype::outname::outparam::nil)]::nil; set i = i + 1; ); fillScriptList; ); 0;; fun cbBtnImportScript(btn, p)= _DLGrflopen _DLGOpenFile _channel winScriptEditor nil nil "script\0*.psc\0\0" @cbImportScript nil; 0;; fun cbExportScript(dlg, p, file)= if file == nil then nil else ( let sizelist lScriptlist -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list lScriptlist i -> [_ elem] in let nth_list elem 0 -> intype in let nth_list elem 1 -> inname in let nth_list elem 2 -> inparam in let nth_list elem 3 -> outtype in let nth_list elem 4 -> outname in let nth_list elem 5 -> outparam in set ndata = listcat ndata (intype::inname::inparam::"->"::outtype::outname::outparam::nil)::nil; set i = i + 1; ); _createpack strbuild ndata file; ); ); 0;; fun cbBtnExportScript(btn, p)= _DLGrflsave _DLGSaveFile _channel winScriptEditor nil "script.psc" "script\0*.psc\0\0" @cbExportScript nil; 0;; fun fillComboScriptType(cmb, mode)= if mode then ( _ADDcombo cmb 0 "Anim"; _ADDcombo cmb 1 "Sound"; _ADDcombo cmb 2 "Trans"; _ADDcombo cmb 3 "Radar"; _ADDcombo cmb 4 "Click"; _SELcombo cmb 0; ) else ( _ADDcombo cmb 0 "Anim"; _ADDcombo cmb 1 "Sound"; _ADDcombo cmb 2 "Trans"; _SELcombo cmb 0; ); 0;; fun getAnimLenghtByName(name)= let sizelist lAnimlist -> size in let nil -> ndata in let 0 -> i in ( while i < size && ndata == nil do ( let nth_list lAnimlist i -> [_ elem] in if !strcmp name getFileWithoutExtension getFileNameFromPath (hd elem) then ( let strextr _getpack _checkpack hd elem -> lfile in let atoi getInfo lfile "length" -> animsize in set ndata = animsize; ) else nil; set i = i + 1; ); ndata; );; fun fillComboScriptName(cmb, type)= if !strcmpi type "Anim" then ( _RSTcombo cmb; let sizelist lAnimlist -> size in let 0 -> i in while i < size do ( let nth_list lAnimlist i -> [_ elem] in _ADDcombo cmb _GETcomboCount cmb getFileWithoutExtension getFileNameFromPath (hd elem); set i = i + 1; ); ) else if !strcmpi type "Sound" then ( _RSTcombo cmb; let sizelist lSoundlist -> size in let 0 -> i in while i < size do ( let nth_list lSoundlist i -> [_ elem] in _ADDcombo cmb _GETcomboCount cmb getFileWithoutExtension getFileNameFromPath (hd elem); set i = i + 1; ); ) else if !strcmpi type "Trans" then ( _RSTcombo cmb; let sizelist lTranslist -> size in let 0 -> i in while i < size do ( let nth_list lTranslist i -> [_ elem] in _ADDcombo cmb _GETcomboCount cmb (hd elem); set i = i + 1; ); ) else if !strcmpi type "Radar" then ( _RSTcombo cmb; _ADDcombo cmb 0 "In"; _ADDcombo cmb 1 "Out"; 0; ) else if !strcmpi type "Click" then ( _RSTcombo cmb; _ADDcombo cmb 0 "Left"; _ADDcombo cmb 1 "Right"; 0; ) else nil; _SELcombo cmb 0; 0;; fun fillComboScriptParam(cmb, type, mode)= if !strcmpi type "Anim" then ( _RSTcombo cmb; if mode then ( let _GETcombo cmbScriptInName -> [_ name] in let getAnimLenghtByName name -> animsize in let if animsize == nil then 100 else animsize -> size in let 0 -> i in while i <= size do ( _ADDcombo cmb _GETcomboCount cmb itoa i; set i = i + 1; ); 0 ) else ( _ADDcombo cmb 0 "Play"; _ADDcombo cmb 1 "Stop"; 0; ); ) else if !strcmpi type "Sound" then ( _RSTcombo cmb; if mode then ( _ADDcombo cmb 0 "End"; 0 ) else ( _ADDcombo cmb 0 "Play"; _ADDcombo cmb 1 "Stop"; 0; ); ) else if !strcmpi type "Trans" then ( _RSTcombo cmb; if mode then ( let _GETcombo cmbScriptInName -> [_ name] in let getStringDots (strextr (nth_list (getTransByName name) 5)) -> poslist in let sizelist poslist -> size in let 0 -> i in while i < size do ( _ADDcombo cmb _GETcomboCount cmb itoa i; set i = i + 1; ); 0 ) else ( _ADDcombo cmb 0 "Play"; _ADDcombo cmb 1 "Pause"; _ADDcombo cmb 2 "Stop"; 0; ); ) else if !strcmpi type "Radar" then ( _RSTcombo cmb; let 10000 -> size in let 0 -> i in while i <= size do ( _ADDcombo cmb _GETcomboCount cmb itoa i; set i = i + 100; ); ) else nil; if !strcmpi type "Click" then ( _RSTcombo cmb; _ENcombo cmb 0; ) else ( _ENcombo cmb 1; ); _SELcombo cmb 0; 0;; fun cbTypeComboInChoice(cmb, p, pos, sel)= fillComboScriptName cmbScriptInName sel; fillComboScriptParam cmbScriptInParam sel 1; 0;; fun cbTypeComboOutChoice(cmb, p, pos, sel)= fillComboScriptName cmbScriptOutName sel; fillComboScriptParam cmbScriptOutParam sel 0; 0;; fun cbTypeComboInName(cmb, p, pos, sel)= let _GETcombo cmbScriptInType -> [_ name] in fillComboScriptParam cmbScriptInParam name 1; 0;; // Interface d'edition de script fun cbBtnEditScript(btn, p)= let 450 -> w in let 250 -> h in let _GETscreenSize -> [scrw scrh] in if winScriptEditor != nil then nil else ( set winScriptEditor = _CBwinDestroy _CRwindow _channel winEdt ((scrw / 2) - (w / 2)) ((scrh / 2) - (h / 2)) w h WN_MENU _loc this "KW_SCRIPTWIN" nil @cbWinScriptDestroy nil; set listScript = _CRlist _channel winScriptEditor 5 5 (w - 10) 100 LB_DOWN|LB_VSCROLL; set txtEvent = _CRtext _channel winScriptEditor 5 110 (w - 60) 20 ET_ALIGN_LEFT _loc this "KW_ACTION" nil; set btnAddScript = _CBbutton _CRbutton _channel winScriptEditor (w - 50) 107 20 20 PB_TABFOCUS "+" @cbBtnAddScript nil; set btnRemoveScript = _CBbutton _CRbutton _channel winScriptEditor (w - 25) 107 20 20 PB_TABFOCUS "-" @cbBtnRemoveScript nil; set cmbScriptInType = _CBcombo _CRcombo _channel winScriptEditor 5 130 ((w / 3) - 10) 100 CB_NOEDIT nil @cbTypeComboInChoice nil; fillComboScriptType cmbScriptInType 1; set cmbScriptInName = _CBcombo _CRcombo _channel winScriptEditor ((w / 3) + 5) 130 ((w / 3) - 10) 100 nil nil @cbTypeComboInName nil; fillComboScriptName cmbScriptInName "Anim"; set cmbScriptInParam = _CRcombo _channel winScriptEditor (((w / 3) * 2) + 5) 130 ((w / 3) - 10) 100 nil nil; fillComboScriptParam cmbScriptInParam "Anim" 1; set txtAction = _CRtext _channel winScriptEditor 5 165 (w - 10) 20 ET_ALIGN_LEFT _loc this "KW_EVENT" nil; set cmbScriptOutType = _CBcombo _CRcombo _channel winScriptEditor 5 185 ((w / 3) - 10) 100 CB_NOEDIT nil @cbTypeComboOutChoice nil; fillComboScriptType cmbScriptOutType 0; set cmbScriptOutName = _CRcombo _channel winScriptEditor ((w / 3) + 5) 185 ((w / 3) - 10) 100 nil nil; fillComboScriptName cmbScriptOutName "Anim"; set cmbScriptOutParam = _CRcombo _channel winScriptEditor (((w / 3) * 2) + 5) 185 ((w / 3) - 10) 100 nil nil; fillComboScriptParam cmbScriptOutParam "Anim" 0; set btnCloseScript = _CBbutton _CRbutton _channel winScriptEditor (w - 65) (h - 25) 60 20 PB_TABFOCUS _loc this "KW_CLOSE" nil @cbBtnCloseScript nil; set btnImportScript = _CBbutton _CRbutton _channel winScriptEditor 5 (h - 25) 60 20 PB_TABFOCUS _loc this "KW_IMPORT" nil @cbBtnImportScript nil; set btnExportScript = _CBbutton _CRbutton _channel winScriptEditor 75 (h - 25) 60 20 PB_TABFOCUS _loc this "KW_EXPORT" nil @cbBtnExportScript nil; fillScriptList; ); 0;; fun loadScript(data)= set lScriptlist = nil; let sizelist data -> size in let 0 -> i in while i < size do ( let nth_list data i -> elem in set lScriptlist = listcat lScriptlist [i elem]::nil; set i = i + 1; ); 0;; /******************************************************************************* Functions: Opening Plugin's Editor *******************************************************************************/ /******************************************************************************* cbOpenEdit() win -> ObjWin : Plugin's Editor father window params -> S : "strbuilded" list of plugin's instance's parameters and params' values <- I : Not used Callback function called when the Editor of the plugin is opened. Caution! Resources allocated here will not be destroyed until the cbDestroyWin callback is triggered and if you destroy them in this function. Multiple openings of the plugin Editor should thus consume a lot of resources if resources are not properly handled. *******************************************************************************/ fun cbOpenEdit(win, params)= let strextr params -> l in let _GETwindowSizePosition win -> [w h x y] in ( set sClass = getInfo l "ClassName"; set sInstName = getInfo l "ObName"; set winEdt = win; set txtM3D = _CRtext _channel winEdt 5 5 100 20 ET_ALIGN_LEFT _loc this "KW_DIRM3D" nil; set edtM3D = _ENtext _CReditLine _channel winEdt 105 5 (w - 105 - 30) 20 ET_AHSCROLL|ET_BORDER "" 0; set btnBrowseM3d = _CBbutton _CRbutton _channel winEdt (w - 25) 5 20 20 PB_DEFAULT "..." @cbBtnBrowseM3d [edtM3D nil]; set txtAFR = _CRtext _channel winEdt 5 35 100 20 ET_ALIGN_LEFT _loc this "KW_FRAMERATE" nil; set edtAFR = _CReditLine _channel winEdt 105 35 30 20 ET_AHSCROLL|ET_BORDER|ET_NUMBER ""; set txtAnims = _CRtext _channel winEdt 5 65 (w - 10) 20 ET_ALIGN_LEFT _loc this "KW_ANIM" nil; set listAnims = _CBlistClick _CRlist _channel winEdt 5 85 (w - 10) 60 LB_DOWN|LB_VSCROLL @cbListAnimSelect nil; set edtAnim = _ENtext _CReditLine _channel winEdt 5 175 (w - 85) 20 ET_AHSCROLL|ET_BORDER "" 0; set chkLoopAnim = _CBcheck _CRcheck _channel winEdt 5 150 ((w - 15) / 2) 20 CH_TABFOCUS _loc this "KW_SOUNDLOOP" nil @cbLoopAnim edtAnim; set chkStartAnim = _CBcheck _CRcheck _channel winEdt (((w - 15) / 2) + 10) 150 ((w - 15) / 2) 20 CH_TABFOCUS _loc this "KW_SOUNDSTART" nil @cbStartAnim edtAnim; set btnAddAnim = _CBbutton _CRbutton _channel winEdt (w - 50) 175 20 20 PB_TABFOCUS "+" @cbBtnAddAnim [edtAnim chkLoopAnim chkStartAnim]; set btnRemoveAnim = _CBbutton _CRbutton _channel winEdt (w - 25) 175 20 20 PB_TABFOCUS "-" @cbBtnRemoveAnim nil; set btnBrowseAnim = _CBbutton _CRbutton _channel winEdt (w - 75) 175 20 20 PB_TABFOCUS "..." @cbBtnBrowseM3d [edtAnim btnAddAnim]; set txtSound = _CRtext _channel winEdt 5 205 (w - 10) 20 ET_ALIGN_LEFT _loc this "KW_SOUND" nil; set listSound = _CBlistClick _CRlist _channel winEdt 5 225 (w - 10) 60 LB_DOWN|LB_VSCROLL @cbListSoundSelect nil; set edtSound = _ENtext _CReditLine _channel winEdt 5 340 (w - 85) 20 ET_AHSCROLL|ET_BORDER "" 0; set txtMinSound = _CRtext _channel winEdt 5 290 80 20 ET_ALIGN_LEFT _loc this "KW_SOUNDMIN" nil; set edtMinSound = _CBtext _CReditLine _channel winEdt 85 290 40 20 ET_AHSCROLL|ET_BORDER|ET_NUMBER "" @cbMinSound edtSound; set txtMaxSound = _CRtext _channel winEdt 130 290 35 20 ET_ALIGN_LEFT _loc this "KW_SOUNDMAX" nil; set edtMaxSound = _CBtext _CReditLine _channel winEdt 170 290 40 20 ET_AHSCROLL|ET_BORDER|ET_NUMBER "" @cbMaxSound edtSound; set chkLoopSound = _CBcheck _CRcheck _channel winEdt 5 315 ((w - 15) / 2) 20 CH_TABFOCUS _loc this "KW_SOUNDLOOP" nil @cbLoopSound edtSound; set chkStartSound = _CBcheck _CRcheck _channel winEdt (((w - 15) / 2) + 10) 315 ((w - 15) / 2) 20 CH_TABFOCUS _loc this "KW_SOUNDSTART" nil @cbStartSound edtSound; set btnAddSound = _CBbutton _CRbutton _channel winEdt (w - 50) 340 20 20 PB_TABFOCUS "+" @cbBtnAddSound [edtSound edtMinSound edtMaxSound chkLoopSound chkStartSound]; set btnRemoveSound = _CBbutton _CRbutton _channel winEdt (w - 25) 340 20 20 PB_TABFOCUS "-" @cbBtnRemoveSound nil; set btnBrowseSound = _CBbutton _CRbutton _channel winEdt (w - 75) 340 20 20 PB_TABFOCUS "..." @cbBtnBrowseSound [edtSound btnAddSound]; set txtTrans = _CRtext _channel winEdt 5 370 (w - 10) 20 ET_ALIGN_LEFT _loc this "KW_TRANS" nil; set listTrans = _CBlistClick _CRlist _channel winEdt 5 390 (w - 10) 60 LB_DOWN|LB_VSCROLL @cbListTransSelect nil; set txtNameTrans = _CRtext _channel winEdt 5 455 40 20 ET_ALIGN_LEFT _loc this "KW_TRANSNAME" nil; set edtNameTrans = _CReditLine _channel winEdt 50 455 (w - 105) 20 ET_AHSCROLL|ET_BORDER ""; set btnAddTrans = _CBbutton _CRbutton _channel winEdt (w - 50) 455 20 20 PB_TABFOCUS ">" mkfun3 @cbOpenCurveEditor edtNameTrans win; //set btnAddTrans = _CBbutton _CRbutton _channel winEdt (w - 50) 455 20 20 PB_TABFOCUS ">" @cbBtnAddTrans edtNameTrans; set btnRemoveTrans = _CBbutton _CRbutton _channel winEdt (w - 25) 455 20 20 PB_TABFOCUS "-" @cbBtnRemoveTrans nil; set btnEditScript = _CBbutton _CRbutton _channel winEdt ((w / 2) - 45) 485 90 20 PB_TABFOCUS _loc this "KW_SCRIPTEDIT" nil @cbBtnEditScript nil; _SETtext edtM3D getInfo l "m3dpath"; fillAnimList getInfo l "anims"; fillSoundList getInfo l "sounds"; fillTransList getInfo l "trans"; loadScript strextr getInfo l "script"; if (getInfo l "frameR") != nil then _SETtext edtAFR (getInfo l "frameR") else _SETtext edtAFR "30"; _CBwinDestroy win @cbDestroyWin nil; ); 0;; /******************************************************************************* Functions: Quitting Plugin's Editor *******************************************************************************/ /******************************************************************************* SaveBasicActionsAndEvents() name -> S : Instance name <- [[S r1] r1] : Basic actions and events of the plugin Saves basic actions and events of the plugin *******************************************************************************/ fun SaveActionsAndEvents(l, type) = let nil -> extented in let sizelist l -> size in let 0 -> i in ( while i < size do ( if !strcmpi type "trans" then ( let hd (nth_list l i) -> elem in set extented = listcat extented ("actionC"::(strcatn sInstName::"."::type::"_"::elem::".play"::nil)::nil)::("actionC"::(strcatn sInstName::"."::type::"_"::elem::".stop"::nil)::nil)::nil; ) else ( let getFileWithoutExtension getFileNameFromPath hd (nth_list l i) -> elem in set extented = listcat extented ("actionC"::(strcatn sInstName::"."::type::"_"::elem::".play"::nil)::nil)::("actionC"::(strcatn sInstName::"."::type::"_"::elem::".stop"::nil)::nil)::nil; ); set i = i + 1; ); extented; );; /******************************************************************************* SaveDMI() l -> [Inst r1] : List of plugin's instances <- [[S r1] r1] : DMI informations Saves supplementary DMI information *******************************************************************************/ fun SaveDMI() = let ("eventC"::(strcat sInstName ".in")::nil):: ("eventC"::(strcat sInstName ".entering")::nil):: ("eventC"::(strcat sInstName ".leftClick")::nil):: ("eventC"::(strcat sInstName ".rightClick")::nil):: nil -> basics in listcat listcat listcat basics (SaveActionsAndEvents (getListParam lAnimlist) "anim") (SaveActionsAndEvents (getListParam lSoundlist) "sound") (SaveActionsAndEvents (getListParam lTranslist) "trans") ;; /******************************************************************************* SaveBasicParameters() <- [[S r1] r1] : Plugin basic parameters Saves the basic parameters of the plugin: files' pathes & framerate *******************************************************************************/ fun SaveBasicParameters() = ("m3dpath"::(_GETtext edtM3D)::nil):: ("frameR"::(_GETtext edtAFR)::nil):: ("anims"::(strbuild (getListParam lAnimlist))::nil):: ("sounds"::(strbuild (getListParam lSoundlist))::nil):: ("trans"::(strbuild (getListParam lTranslist))::nil):: ("script"::(strbuild (getListParam lScriptlist))::nil):: ("DMIparams"::(strbuild SaveDMI)::nil):: nil;; /******************************************************************************* cbCloseEdit() <- S : "strbuilded" list of plugin's instance's parameters and params' values Callback function called when you click on the OK button of the plugin Editor. The Cancel button doesn't call this callback, nor any other one. *******************************************************************************/ fun cbCloseEdit() = closeCurveEditor strCurveEditor; closeScriptEditor; strbuild SaveBasicParameters;; /******************************************************************************* Functions: Plugin's Editor initialization *******************************************************************************/ /******************************************************************************* Init_2DAPI_Objects() <- I : Not used Initializes all 2D Objects to nil value *******************************************************************************/ fun Init_2DAPI_Objects() = set txtM3D = nil; set edtM3D = nil; set txtAFR = nil; set edtAFR = nil; set edtAnim = nil; set txtAnims = nil; set listAnims = nil; set lAnimlist = nil; set btnAddAnim = nil; set chkLoopAnim = nil; set chkStartAnim = nil; set btnRemoveAnim = nil; set btnBrowseAnim = nil; set btnBrowseM3d = nil; set edtSound = nil; set txtMinSound = nil; set txtMaxSound = nil; set edtMinSound = nil; set edtMaxSound = nil; set chkLoopSound = nil; set chkStartSound = nil; set txtSound = nil; set listSound = nil; set lSoundlist = nil; set btnAddSound = nil; set btnRemoveSound = nil; set btnBrowseSound = nil; set lTranslist = nil; set txtTrans = nil; set listTrans = nil; set txtNameTrans = nil; set edtNameTrans = nil; set btnEndPosTrans = nil; set btnCancelPosTrans = nil; set btnAddTrans = nil; set btnRemoveTrans = nil; set lScriptlist = nil; set btnEditScript = nil; set winScriptEditor = nil; set listScript = nil; set txtEvent = nil; set txtAction = nil; set cmbScriptInType = nil; set cmbScriptInName = nil; set cmbScriptInParam = nil; set cmbScriptOutType = nil; set cmbScriptOutName = nil; set cmbScriptOutParam = nil; set btnAddScript = nil; set btnRemoveScript = nil; set btnCloseScript = nil; set btnExportScript = nil; set btnImportScript = nil; 0;; /******************************************************************************* IniPlug() file -> S : '*.plug' file name <- I : Not used Standard function. Plugin initialisation, the PlugRegister function has to be called at the end. This function is called when you open the C3D3 Editor. *******************************************************************************/ fun dynamicedit(win, obj, mat, param) = Init_2DAPI_Objects; cbOpenEdit win param; @cbCloseEdit;;