/* ----------------------------------------------------------------------------- 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 cbCloseEdit(p)= let p -> [ctrlobjname ctrlparentname ctrlcollide ctrlposmode ctrlposx ctrlposy ctrlposz ctrllimits ctrlconeangle ctrlmintwist ctrlmaxtwist ctrlbreakforce ctrlinit] in let getEdCtrlTextLineValue ctrlobjname -> objname in let getEdCtrlTextLineValue ctrlparentname -> parentname in let getEdCtrlCheckState ctrlcollide -> collide in let getSelectedEdCtrlSelectPos ctrlposmode -> posmode in let getEdCtrlFloatValue ctrlposx -> posx in let getEdCtrlFloatValue ctrlposy -> posy in let getEdCtrlFloatValue ctrlposz -> posz in let getEdCtrlCheckState ctrllimits -> uselimits in let getEdCtrlFloatValue ctrlconeangle -> cone in let getEdCtrlFloatValue ctrlmintwist -> mint in let getEdCtrlFloatValue ctrlmaxtwist -> maxt in let getEdCtrlFloatValue ctrlbreakforce -> breakforce in let getEdCtrlCheckState ctrlinit -> init in ["object" objname]:: ["parent" parentname]:: ["collide" itoa collide]:: ["posmode" itoa posmode]:: ["posx" ftoa posx]:: ["posy" ftoa posy]:: ["posz" ftoa posz]:: ["useLimits" itoa uselimits]:: ["coneangle" ftoa cone]:: ["mintwist" ftoa mint]:: ["maxtwist" ftoa maxt]:: ["breakforce" ftoa breakforce]:: ["init" itoa init]:: nil;; fun cbCloseResPRS(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbSelectObjPRS(val, type, p)= let p -> [inst winstr viewstr ctrlposx ctrlposy ctrlposz] in let V3DgetDefaultSession viewstr -> sessionstr in let if (!strcmpi "Current camera" val) then V3DgetDefaultCamera sessionstr else if (!strcmpi "Current camera shell" val) then (SO3ObjectGetParent (V3DgetDefaultCamera sessionstr)) else SO3SceneGetObject (V3DgetSession sessionstr) val -> obj in if (obj != nil) then ( let SO3ObjectGetGlobalPosition obj -> [x y z] in ( setEdCtrlFloatValue ctrlposx x; setEdCtrlFloatValue ctrlposy y; setEdCtrlFloatValue ctrlposz z; ); ) else nil; 0;; fun cbBtnPickObjPRS(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlposx ctrlposy ctrlposz] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeEntity|iTypeNode|iTypeLight|iTypeCamera|iTypeParticle|iTypeBone|iTypeCubeMap|iTypeReflectionMap nil mkfun3 @cbSelectObjPRS p mkfun1 @cbCloseResPRS ctrlbtn 0; ); 0;; fun cbSelectObj(val, type, p)= let p -> [inst winstr viewstr ctrlobjname] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> obj in if (obj != nil) || (!strcmpi "Current camera" val) || (!strcmpi "Current camera shell" val) then ( setEdCtrlTextLineValue ctrlobjname val; ) else nil; 0;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlobjname objname] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeEntity|iTypeNode|iTypeBone|iTypeLight|iTypeCamera objname mkfun3 @cbSelectObj [inst winstr viewstr ctrlobjname] mkfun1 @cbCloseRes ctrlbtn 0; ); 0;; fun cbRefreshBtn(pickbtn, p)= let p -> [ctrlobjname] in setEdCtrlTextLineValue ctrlobjname ""; 0;; fun cbCheckLimits(ctrl, state, p)= let p -> [ctrlconeangle ctrlmintwist ctrlmaxtwist] in ( setEdCtrlFloatEnable ctrlconeangle state; setEdCtrlFloatEnable ctrlmintwist state; setEdCtrlFloatEnable ctrlmaxtwist state; ); 0;; fun cbPosMode(ctrlstr, pos, elem, p)= let p -> [pickPRSbtn ctrlposx ctrlposy ctrlposz] in let if (pos == 2) then 1 else 0 -> state in ( setEdCtrlButtonEnable pickPRSbtn state; setEdCtrlFloatEnable ctrlposx state; setEdCtrlFloatEnable ctrlposy state; setEdCtrlFloatEnable ctrlposz state; ); 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [420 365] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "object") -> objname in let (getPluginInstanceParam inst "parent") -> parentname in let atoi (getPluginInstanceParam inst "collide") -> collide in let if collide == nil then 0 else collide -> collide in let atoi (getPluginInstanceParam inst "posmode") -> posmode in let if posmode == nil then 0 else posmode -> posmode in let atof (getPluginInstanceParam inst "posx") -> posx in let atof (getPluginInstanceParam inst "posy") -> posy in let atof (getPluginInstanceParam inst "posz") -> posz in let if posx == nil then 0.0 else posx -> posx in let if posy == nil then 0.0 else posy -> posy in let if posz == nil then 0.0 else posz -> posz in let atoi (getPluginInstanceParam inst "useLimits") -> useLimits in let if useLimits == nil then 0 else useLimits -> useLimits in let atof (getPluginInstanceParam inst "coneangle") -> coneangle in let atof (getPluginInstanceParam inst "mintwist") -> mintwist in let atof (getPluginInstanceParam inst "maxtwist") -> maxtwist in let if coneangle == nil then 180.0 else coneangle -> coneangle in let if mintwist == nil then (-.180.0) else mintwist -> mintwist in let if maxtwist == nil then 180.0 else maxtwist -> maxtwist in let atof (getPluginInstanceParam inst "breakforce") -> breakforce in let if breakforce == nil then 0.0 else breakforce -> breakforce in let atoi (getPluginInstanceParam inst "init") -> init in let if init == nil then 1 else init -> init in let if (breakforce >. 0.0) then 1 else 0 -> useBreakForce in ( if !useLimits then nil else set ih = ih + 115; if !useBreakForce then nil else set ih = ih + 35; setEdWindowSize ewinstr iw ih; let crEdFrameWindow _channel ewinstr 0 0 iw 110 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSTRUCTURE_0019") (loc "OS3DPHYSICSTRUCTURE_0015") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 90 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DPHYSICSTRUCTURE_0004") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 140 20 objname nil EDWIN_RESIZE_MW -> ctrlobjname in let crEdCtrlButton winstr 325 ypos 55 20 "..." nil -> pickbtn in let crEdCtrlButton winstr 385 ypos 35 20 "X" nil -> refreshobjname in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSTRUCTURE_0017") nil -> labeltarget in let crEdCtrlTextLine winstr 180 ypos 140 20 parentname nil EDWIN_RESIZE_MW -> ctrlparentname in let crEdCtrlButton winstr 325 ypos 55 20 "..." nil -> pickbtn2 in let crEdCtrlButton winstr 385 ypos 35 20 "X" nil -> refreshparentname in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DPHYSICSTRUCTURE_0010") EDWIN_RESIZE_MW -> ctrlcollide in let crEdFrameWindow _channel ewinstr 0 0 iw 160 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSTRUCTURE_0012") (loc "OS3DPHYSICSTRUCTURE_0015") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 140 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 (set ypos = 10) 160 20 (loc "OS3DPHYSICSTRUCTURE_0024") nil -> labelposmode in let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlposmode in let crEdCtrlButton winstr ((iw / 2) - 100) (set ypos = ypos + 25) 200 20 (loc "OS3DPHYSICSTRUCTURE_0020") nil -> pickPRSbtn in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSTRUCTURE_0021") nil -> labelposx in let crEdCtrlFloat winstr 180 ypos 100 20 posx (-.100000.0) 100000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlposx in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSTRUCTURE_0022") nil -> labelposy in let crEdCtrlFloat winstr 180 ypos 100 20 posy (-.100000.0) 100000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlposy in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSTRUCTURE_0023") nil -> labelposz in let crEdCtrlFloat winstr 180 ypos 100 20 posz (-.100000.0) 100000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlposz in let crEdFrameWindowEx _channel ewinstr 0 0 iw 135 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSTRUCTURE_0001") (loc "OS3DPHYSICSTRUCTURE_0015") !useLimits -> winfrm in let crEdWindow _channel winfrm 0 18 iw 115 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DPHYSICSTRUCTURE_0025") EDWIN_RESIZE_MW -> ctrllimits in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSTRUCTURE_0006") nil -> labelcone in let crEdCtrlFloat winstr 180 ypos 100 20 coneangle (-.180.0) 180.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlconeangle in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSTRUCTURE_0014") nil -> labelmintwist in let crEdCtrlFloat winstr 180 ypos 100 20 mintwist (-.180.0) 180.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlmintwist in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSTRUCTURE_0013") nil -> labelmaxtwist in let crEdCtrlFloat winstr 180 ypos 100 20 maxtwist (-.180.0) 180.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlmaxtwist in let crEdFrameWindowEx _channel ewinstr 0 0 iw 55 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSTRUCTURE_0003") (loc "OS3DPHYSICSTRUCTURE_0015") !useBreakForce -> winfrm in let crEdWindow _channel winfrm 0 18 iw 35 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DPHYSICSTRUCTURE_0002") nil -> labelforce in let crEdCtrlFloat winstr 180 ypos 100 20 breakforce 0.0 100000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlbreakforce in let crEdFrameWindow _channel ewinstr 0 0 iw 55 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSTRUCTURE_0016") (loc "OS3DPHYSICSTRUCTURE_0015") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 35 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DPHYSICSTRUCTURE_0011") EDWIN_RESIZE_MW -> ctrlinit in ( setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlobjname objname]; setEdCtrlButtonCb pickbtn2 mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlparentname parentname]; setEdCtrlButtonCb refreshobjname mkfun2 @cbRefreshBtn [ctrlobjname]; setEdCtrlButtonCb refreshparentname mkfun2 @cbRefreshBtn [ctrlparentname]; fillEdCtrlSelect ctrlposmode (loc "OS3DPHYSICSTRUCTURE_0005")::(loc "OS3DPHYSICSTRUCTURE_0018")::(loc "OS3DPHYSICSTRUCTURE_0009")::nil; selectEdCtrlSelectByPos ctrlposmode posmode; setEdCtrlSelectCb ctrlposmode mkfun4 @cbPosMode [pickPRSbtn ctrlposx ctrlposy ctrlposz]; if (posmode == 2) then nil else ( setEdCtrlButtonEnable pickPRSbtn 0; setEdCtrlFloatEnable ctrlposx 0; setEdCtrlFloatEnable ctrlposy 0; setEdCtrlFloatEnable ctrlposz 0; ); setEdCtrlButtonCb pickPRSbtn mkfun2 @cbBtnPickObjPRS [inst winstr viewstr ctrlposx ctrlposy ctrlposz]; setEdCtrlTextLineEnable ctrlobjname 0; setEdCtrlTextLineEnable ctrlparentname 0; setEdCtrlCheckState ctrlcollide collide; setEdCtrlCheckState ctrllimits useLimits; setEdCtrlCheckState ctrlinit init; if (useLimits) then nil else ( setEdCtrlFloatEnable ctrlconeangle 0; setEdCtrlFloatEnable ctrlmintwist 0; setEdCtrlFloatEnable ctrlmaxtwist 0; ); setEdCtrlCheckCbState ctrllimits mkfun3 @cbCheckLimits [ctrlconeangle ctrlmintwist ctrlmaxtwist]; [mkfun1 @cbCloseEdit [ctrlobjname ctrlparentname ctrlcollide ctrlposmode ctrlposx ctrlposy ctrlposz ctrllimits ctrlconeangle ctrlmintwist ctrlmaxtwist ctrlbreakforce ctrlinit] nil]; ); ); );;