/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ fun getEvents(l)= let sizelist l -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list l i -> elem in set ndata = ["EVENT" elem]::ndata; set i = i + 1; ); ndata; );; fun cbCloseEdit(p)= let p -> [ctrlanimname ctrlweight ctrlspeed ctrlstpos ctrlendpos ctrlloop ctrlskipframe ctrlenable ctrlevent] in let getEdCtrlTextLineValue ctrlanimname -> animname in let getEdCtrlFloatValue ctrlweight -> weight in let getEdCtrlFloatValue ctrlspeed -> speed in let getEdCtrlFloatValue ctrlstpos -> startpos in let getEdCtrlFloatValue ctrlendpos -> endpos in let getEdCtrlCheckState ctrlloop -> loop in let getEdCtrlCheckState ctrlskipframe -> skipframe in let getEdCtrlCheckState ctrlenable -> enable in let getEdCtrlListElems ctrlevent -> levent in ["anim" animname]:: ["weight" ftoa weight]:: ["speed" ftoa speed]:: ["startpos" ftoa startpos]:: ["endpos" ftoa endpos]:: ["loop" itoa loop]:: ["skipframe" itoa skipframe]:: ["enable" itoa enable]:: (getEvents levent);; fun cbSelectObj(val, type, p)= let p -> [inst winstr viewstr ctrlanimname ctrlendpos ctrladdpos] in let V3DgetDefaultSession viewstr -> sessionstr in let V3DgetAnimationByName sessionstr val -> anim in if anim == nil then nil else ( setEdCtrlTextLineValue ctrlanimname val; let V3DgetAnimationByName c3dXsession val -> animstr in let V3DgetAnimationLength animstr -> length in let if length == 0.0 then 0.00001 else length -> length in ( setEdCtrlFloatValue ctrlendpos length; setEdCtrlFloatMaxValue ctrladdpos length; ); ); 0;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlanimname animname ctrlendpos ctrladdpos] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeAnim animname mkfun3 @cbSelectObj [inst winstr viewstr ctrlanimname ctrlendpos ctrladdpos] mkfun1 @cbCloseRes ctrlbtn 0; ); 0;; fun cbAddActEvnt(ctrlstr, value, p)= let p -> [liststr ctrladdpos ctrladdevent] in if (value == nil) || (!strcmp "" strtrim value) then nil else let getEdCtrlListElems liststr -> lelem in let ftoa (getEdCtrlFloatValue ctrladdpos) -> fpos in if (isStringInListi lelem (strcatn fpos::" "::value::nil)) then nil else ( addEdCtrlList liststr (strcatn fpos::" "::value::nil) nil nil; setEdCtrlTextLineValue ctrlstr nil; ); 0;; fun cbAddList(ctrlstr, p)= let p -> [liststr ctrladdpos ctrladdevent] in let getEdCtrlTextLineValue ctrladdevent -> value in if (value == nil) || (!strcmp "" strtrim value) then nil else let ftoa (getEdCtrlFloatValue ctrladdpos) -> fpos in let getEdCtrlListElems liststr -> lelem in if (isStringInListi lelem (strcatn fpos::" "::value::nil)) then nil else ( addEdCtrlList liststr (strcatn fpos::" "::value::nil) nil nil; setEdCtrlTextLineValue ctrladdevent nil; ); 0;; fun cbDelList(ctrlstr, p)= let p -> [liststr ctrladdpos ctrladdevent] in let getSelectedEdCtrlList liststr -> [name _ _] in delEdCtrlList liststr name; 0;; fun cbRefreshBtn(pickbtn, p)= let p -> [ctrlobjname] in setEdCtrlTextLineValue ctrlobjname ""; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let getPluginInstanceUserEvents inst -> levent in let [420 355] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "anim") -> animname in let if animname == nil then nil else V3DgetAnimationByName c3dXsession animname -> animstr in let if animstr == nil then 1.0 else V3DgetAnimationLength animstr -> length in let if length == 0.0 then 0.00001 else length -> length in let atof (getPluginInstanceParam inst "weight") -> weight in let if weight == nil then 1.0 else weight -> weight in let atof (getPluginInstanceParam inst "speed") -> speed in let if speed == nil then 1.0 else speed -> speed in let atof (getPluginInstanceParam inst "startpos") -> startpos in let if startpos == nil then 0.0 else startpos -> startpos in let atof (getPluginInstanceParam inst "endpos") -> endpos in let if endpos == nil then length else endpos -> endpos in let atoi (getPluginInstanceParam inst "loop") -> loop in let if loop == nil then 0 else loop -> loop in let atoi (getPluginInstanceParam inst "skipframe") -> skipframe in let if skipframe == nil then 1 else skipframe -> skipframe in let atoi (getPluginInstanceParam inst "enable") -> enable in let if enable == nil then 0 else enable -> enable in let crEdFrameWindow _channel ewinstr 0 0 iw 225 EDWIN_RESIZE_MW nil (loc "OS3DANIMATION_0002") (loc "OS3DANIMATION_0006") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 210 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DANIMATION_0001") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 140 20 animname nil EDWIN_RESIZE_MW -> ctrlanimname in let crEdCtrlButton winstr 325 ypos 55 20 "..." nil -> pickbtn in let crEdCtrlButton winstr 385 ypos 35 20 "X" nil -> refreshanimname in let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DANIMATION_0011") nil -> labelweight in let crEdCtrlFloat winstr 180 ypos 100 20 weight 0.0 1.0 0.01 6 nil EDWIN_RESIZE_MW -> ctrlweight in let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DANIMATION_0009") nil -> labelspeed in let crEdCtrlFloat winstr 180 ypos 100 20 speed (-.100000.0) 100000.0 0.1 6 nil EDWIN_RESIZE_MW -> ctrlspeed in let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DANIMATION_0010") nil -> labelstpos in let crEdCtrlFloat winstr 180 ypos 100 20 startpos 0.0 100000.0 0.01 6 nil EDWIN_RESIZE_MW -> ctrlstpos in let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DANIMATION_0004") nil -> labelendpos in let crEdCtrlFloat winstr 180 ypos 100 20 endpos 0.0 100000.0 0.01 6 nil EDWIN_RESIZE_MW -> ctrlendpos in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DANIMATION_0005") EDWIN_RESIZE_MW -> ctrlloop in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DANIMATION_0008") EDWIN_RESIZE_MW -> ctrlskipframe in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DANIMATION_0007") EDWIN_RESIZE_MW -> ctrlenable in let crEdFrameWindow _channel ewinstr 0 0 iw 155 EDWIN_RESIZE_MW nil (loc "OS3DANIMATION_0003") (loc "OS3DANIMATION_0006") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 135 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlList winstr 10 (set ypos = 10) (iw - 20) 60 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlevent in let crEdCtrlFloat winstr 10 (set ypos = ypos + 65) 100 20 0.0 0.0 length 0.01 6 nil EDWIN_RESIZE_MW -> ctrladdpos in let crEdCtrlTextLine winstr 115 ypos (iw - 175) 20 nil nil EDWIN_RESIZE_MW -> ctrladdevent in let crEdCtrlButton winstr (iw - 55) ypos 20 20 "+" EDWIN_RESIZE_MW -> ctrlbtnadd1 in let crEdCtrlButton winstr (iw - 30) ypos 20 20 "-" EDWIN_RESIZE_MW -> ctrlbtndel1 in ( fillEdCtrlList ctrlevent levent; setEdCtrlCheckState ctrlenable enable; setEdCtrlCheckState ctrlloop loop; setEdCtrlCheckState ctrlskipframe skipframe; setEdCtrlButtonCb ctrlbtnadd1 mkfun2 @cbAddList [ctrlevent ctrladdpos ctrladdevent]; setEdCtrlButtonCb ctrlbtndel1 mkfun2 @cbDelList [ctrlevent ctrladdpos ctrladdevent]; setEdCtrlTextLineCbValidate ctrladdevent mkfun3 @cbAddActEvnt [ctrlevent ctrladdpos ctrladdevent]; setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlanimname animname ctrlendpos ctrladdpos]; setEdCtrlTextLineEnable ctrlanimname 0; setEdCtrlButtonCb refreshanimname mkfun2 @cbRefreshBtn [ctrlanimname]; [mkfun1 @cbCloseEdit [ctrlanimname ctrlweight ctrlspeed ctrlstpos ctrlendpos ctrlloop ctrlskipframe ctrlenable ctrlevent] nil]; ); );;