/* ----------------------------------------------------------------------------- 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 getAnimations(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 let strcat "animation_" (itoa i) -> elemname in set ndata = [elemname elem]::ndata; set i = i + 1; ); ndata; );; fun loadAnimations(inst)= let nil -> ndata in let 0 -> i in ( let getPluginInstanceParam inst (strcat "animation_" (itoa i)) -> elem in while (elem != nil) do ( set ndata = if i == 0 then elem::nil else lcat ndata elem::nil; set i = i + 1; set elem = getPluginInstanceParam inst (strcat "animation_" (itoa i)); ); ndata; );; fun cbCloseEdit(p)= let p -> [ctrltransitionspeed ctrlnumanimblended ctrlanimations] in let getEdCtrlListElems ctrlanimations -> lanimations in ["numAnimBlended" (ftoa (getEdCtrlFloatValue ctrlnumanimblended))]:: ["transitionSpeed" (ftoa (getEdCtrlFloatValue ctrltransitionspeed))]:: getAnimations lanimations;; fun cbSelectObj(val, type, p)= let p -> [inst winstr viewstr ctrlanimname] in let V3DgetDefaultSession viewstr -> sessionstr in let V3DgetAnimationByName sessionstr val -> anim in if anim == nil then nil else setEdCtrlTextLineValue ctrlanimname val; 0;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlanimname animname] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeAnim animname mkfun3 @cbSelectObj [inst winstr viewstr ctrlanimname] mkfun1 @cbCloseRes ctrlbtn 0; ); 0;; fun cbAddList(ctrlstr, p)= let p -> [ctrlanimations ctrlselectanimation] in let getEdCtrlTextLineValue ctrlselectanimation -> value in if (value == nil) || (!strcmp "" strtrim value) then nil else let getEdCtrlListElems ctrlanimations -> lelem in ( if (isStringInListi lelem value) then nil else ( addEdCtrlList ctrlanimations value nil nil; ); setEdCtrlTextLineValue ctrlselectanimation nil; ); 0;; fun cbDelList(ctrlstr, p)= let p -> [ctrlanimations ctrlselectanimation] in let getSelectedEdCtrlList ctrlanimations -> [name _ _] in delEdCtrlList ctrlanimations name; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let getPluginInstanceUserEvents inst -> levent in let [400 285] -> [iw ih] in let 10 -> ypos in ( let atof (getPluginInstanceParam inst "transitionSpeed") -> transitionspeed in let if transitionspeed == nil then 200.0 else transitionspeed -> transitionspeed in let atof (getPluginInstanceParam inst "numAnimBlended") -> numanimblended in let if numanimblended == nil then 2.0 else numanimblended -> numanimblended in ( setEdWindowSize ewinstr iw ih; let crEdFrameWindow _channel ewinstr 0 0 iw 90 EDWIN_RESIZE_MW nil (loc "OS3DANIMATIONPOSEBLENDER_0001") (loc "OS3DANIMATIONPOSEBLENDER_0004") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 70 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 (ypos+2) 200 20 (strcat (loc "OS3DANIMATIONPOSEBLENDER_0006") " ") nil -> labeltransitionspeed in let crEdCtrlFloat winstr 210 ypos 80 20 transitionspeed 10.0 10000.0 10.0 0 nil EDWIN_RESIZE_MW -> ctrltransitionspeed in let ypos + 30 -> ypos in let crEdCtrlLabel winstr 10 (ypos+2) 200 20 (strcat (loc "OS3DANIMATIONPOSEBLENDER_0005") " ") nil -> labelnumanimblended in let crEdCtrlFloat winstr 210 ypos 80 20 numanimblended 1.0 100.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlnumanimblended in let crEdFrameWindow _channel ewinstr 0 0 iw 205 EDWIN_RESIZE_MW nil (loc "OS3DANIMATIONPOSEBLENDER_0002") (loc "OS3DANIMATIONPOSEBLENDER_0004") -> winfrm2 in let crEdWindow _channel winfrm2 0 18 iw 185 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr2 in let 5 -> ypos in let crEdCtrlLabel winstr2 10 (ypos + 2) (iw - 20) 20 (loc "OS3DANIMATIONPOSEBLENDER_0003") nil -> labelanimations in let crEdCtrlList winstr2 10 (set ypos = ypos + 25) (iw - 20) 120 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlanimations in let crEdCtrlTextLine winstr2 10 (set ypos = ypos + 125) (iw - 130) 20 nil nil EDWIN_RESIZE_MW -> ctrlselectanimation in let crEdCtrlButton winstr2 (iw - 115) ypos 55 20 "..." nil -> pickbtn in let crEdCtrlButton winstr2 (iw - 55) ypos 20 20 "+" EDWIN_RESIZE_MW -> ctrlbtnadd in let crEdCtrlButton winstr2 (iw - 30) ypos 20 20 "-" EDWIN_RESIZE_MW -> ctrlbtndel in ( setEdCtrlTextLineEnable ctrlselectanimation 0; setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlselectanimation ""]; setEdCtrlButtonCb ctrlbtnadd mkfun2 @cbAddList [ctrlanimations ctrlselectanimation]; setEdCtrlButtonCb ctrlbtndel mkfun2 @cbDelList [ctrlanimations ctrlselectanimation]; fillEdCtrlList ctrlanimations (loadAnimations inst); [mkfun1 @cbCloseEdit [ctrltransitionspeed ctrlnumanimblended ctrlanimations] nil]; ); ); );;