/* ----------------------------------------------------------------------------- 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 ctrldirx ctrldiry ctrldirz ctrlfriction ctrllimits ctrlmindist ctrlmaxdist ctrlspring ctrlspstrength ctrlspdamping ctrlbreakforce ctrlusemotor ctrlmotor 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 getEdCtrlFloatValue ctrldirx -> dirx in let getEdCtrlFloatValue ctrldiry -> diry in let getEdCtrlFloatValue ctrldirz -> dirz in let getEdCtrlFloatValue ctrlfriction -> friction in let getEdCtrlCheckState ctrllimits -> uselimits in let getEdCtrlFloatValue ctrlmindist -> mint in let getEdCtrlFloatValue ctrlmaxdist -> maxt in let getEdCtrlCheckState ctrlspring -> usespring in let getEdCtrlFloatValue ctrlspstrength -> spstrength in let getEdCtrlFloatValue ctrlspdamping -> spdamping in let getEdCtrlFloatValue ctrlbreakforce -> breakforce in let getEdCtrlCheckState ctrlusemotor -> usemotor in let getEdCtrlFloatValue ctrlmotor -> motor 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]:: ["dirx" ftoa dirx]:: ["diry" ftoa diry]:: ["dirz" ftoa dirz]:: ["friction" ftoa friction]:: ["useLimits" itoa uselimits]:: ["mindist" ftoa mint]:: ["maxdist" ftoa maxt]:: ["useSpring" itoa usespring]:: ["spstrength" ftoa spstrength]:: ["spdamping" ftoa spdamping]:: ["breakforce" ftoa breakforce]:: ["useMotor" itoa usemotor]:: ["motor" ftoa motor]:: ["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 cbCheckMotor(ctrl, state, ctrlmotor)= setEdCtrlFloatEnable ctrlmotor state; 0;; fun cbCheckLimits(ctrl, state, p)= let p -> [ctrlmindist ctrlmaxdist] in ( setEdCtrlFloatEnable ctrlmindist state; setEdCtrlFloatEnable ctrlmaxdist 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 570] -> [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 atof (getPluginInstanceParam inst "dirx") -> dirx in let atof (getPluginInstanceParam inst "diry") -> diry in let atof (getPluginInstanceParam inst "dirz") -> dirz in let if dirx == nil then 0.0 else dirx -> dirx in let if diry == nil then 1.0 else diry -> diry in let if dirz == nil then 0.0 else dirz -> dirz in let atof (getPluginInstanceParam inst "friction") -> friction in let if friction == nil then 0.0 else friction -> friction in let atoi (getPluginInstanceParam inst "useLimits") -> useLimits in let if useLimits == nil then 0 else useLimits -> useLimits in let atof (getPluginInstanceParam inst "mindist") -> mindist in let atof (getPluginInstanceParam inst "maxdist") -> maxdist in let if mindist == nil then 0.0 else mindist -> mindist in let if maxdist == nil then 1.0 else maxdist -> maxdist in let atoi (getPluginInstanceParam inst "useSpring") -> useSpring in let if useSpring == nil then 0 else useSpring -> useSpring in let atof (getPluginInstanceParam inst "spstrength") -> spstrength in let atof (getPluginInstanceParam inst "spdamping") -> spdamping in let if spstrength == nil then 50.0 else spstrength -> spstrength in let if spdamping == nil then 1.0 else spdamping -> spdamping in let atof (getPluginInstanceParam inst "breakforce") -> breakforce in let if breakforce == nil then 0.0 else breakforce -> breakforce in let atoi (getPluginInstanceParam inst "useMotor") -> usemotor in let if usemotor == nil then 0 else usemotor -> usemotor in let atof (getPluginInstanceParam inst "motor") -> motor in let if motor == nil then 0.0 else motor -> motor 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 + 90; if !useSpring then nil else set ih = ih + 90; if !useBreakForce then nil else set ih = ih + 35; if !usemotor then nil else set ih = ih + 60; setEdWindowSize ewinstr iw ih; let crEdFrameWindow _channel ewinstr 0 0 iw 110 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSLIDER_0024") (loc "OS3DPHYSICSLIDER_0019") -> 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 "OS3DPHYSICSLIDER_0003") 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 "OS3DPHYSICSLIDER_0022") 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 "OS3DPHYSICSLIDER_0012") EDWIN_RESIZE_MW -> ctrlcollide in let crEdFrameWindow _channel ewinstr 0 0 iw 160 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSLIDER_0016") (loc "OS3DPHYSICSLIDER_0019") -> 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 "OS3DPHYSICSLIDER_0029") 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 "OS3DPHYSICSLIDER_0025") nil -> pickPRSbtn in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSLIDER_0026") 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 "OS3DPHYSICSLIDER_0027") 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 "OS3DPHYSICSLIDER_0028") 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 crEdFrameWindow _channel ewinstr 0 0 iw 110 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSLIDER_0015") (loc "OS3DPHYSICSLIDER_0019") -> 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 "OS3DPHYSICSLIDER_0008") nil -> labelposx in let crEdCtrlFloat winstr 180 ypos 100 20 dirx (-.1.0) 1.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrldirx in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSLIDER_0009") nil -> labelposy in let crEdCtrlFloat winstr 180 ypos 100 20 diry (-.1.0) 1.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrldiry in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSLIDER_0010") nil -> labelposz in let crEdCtrlFloat winstr 180 ypos 100 20 dirz (-.1.0) 1.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrldirz in let crEdFrameWindow _channel ewinstr 0 0 iw 55 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSLIDER_0014") (loc "OS3DPHYSICSLIDER_0019") -> 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 "OS3DPHYSICSLIDER_0014") nil -> labelfriction in let crEdCtrlFloat winstr 180 ypos 100 20 friction 0.0 1000000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlfriction in let crEdFrameWindowEx _channel ewinstr 0 0 iw 110 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSLIDER_0011") (loc "OS3DPHYSICSLIDER_0019") !useLimits -> winfrm in let crEdWindow _channel winfrm 0 18 iw 90 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DPHYSICSLIDER_0035") EDWIN_RESIZE_MW -> ctrllimits in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSLIDER_0018") nil -> labelmindist in let crEdCtrlFloat winstr 180 ypos 100 20 mindist (-.1000000.0) 1000000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlmindist in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSLIDER_0017") nil -> labelmaxdist in let crEdCtrlFloat winstr 180 ypos 100 20 maxdist (-.1000000.0) 1000000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlmaxdist in let crEdFrameWindowEx _channel ewinstr 0 0 iw 110 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSLIDER_0031") (loc "OS3DPHYSICSLIDER_0019") !useSpring -> winfrm in let crEdWindow _channel winfrm 0 18 iw 90 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DPHYSICSLIDER_0034") EDWIN_RESIZE_MW -> ctrlspring in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSLIDER_0032") nil -> labelspstrength in let crEdCtrlFloat winstr 180 ypos 100 20 spstrength 0.0 1000000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlspstrength in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSLIDER_0030") nil -> labelspdamping in let crEdCtrlFloat winstr 180 ypos 100 20 spdamping 0.0 1000000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlspdamping in let crEdFrameWindowEx _channel ewinstr 0 0 iw 55 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSLIDER_0002") (loc "OS3DPHYSICSLIDER_0019") !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 "OS3DPHYSICSLIDER_0001") 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 crEdFrameWindowEx _channel ewinstr 0 0 iw 80 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSLIDER_0021") (loc "OS3DPHYSICSLIDER_0019") !usemotor -> winfrm in let crEdWindow _channel winfrm 0 18 iw 60 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DPHYSICSLIDER_0033") EDWIN_RESIZE_MW -> ctrlusemotor in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICSLIDER_0021") nil -> labelforce in let crEdCtrlFloat winstr 180 ypos 100 20 motor (-.100000.0) 100000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlmotor in let crEdFrameWindow _channel ewinstr 0 0 iw 55 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICSLIDER_0020") (loc "OS3DPHYSICSLIDER_0019") -> 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 "OS3DPHYSICSLIDER_0013") 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 "OS3DPHYSICSLIDER_0004")::(loc "OS3DPHYSICSLIDER_0023")::(loc "OS3DPHYSICSLIDER_0007")::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 ctrlspring useSpring; setEdCtrlCheckState ctrlusemotor usemotor; setEdCtrlCheckState ctrlinit init; if (useLimits) then nil else ( setEdCtrlFloatEnable ctrlmindist 0; setEdCtrlFloatEnable ctrlmaxdist 0; ); if (useSpring) then nil else ( setEdCtrlFloatEnable ctrlspstrength 0; setEdCtrlFloatEnable ctrlspdamping 0; ); setEdCtrlCheckCbState ctrllimits mkfun3 @cbCheckLimits [ctrlmindist ctrlmaxdist]; setEdCtrlCheckCbState ctrlspring mkfun3 @cbCheckLimits [ctrlspstrength ctrlspdamping]; setEdCtrlCheckCbState ctrlusemotor mkfun3 @cbCheckMotor ctrlmotor; [mkfun1 @cbCloseEdit [ctrlobjname ctrlparentname ctrlcollide ctrlposmode ctrlposx ctrlposy ctrlposz ctrldirx ctrldiry ctrldirz ctrlfriction ctrllimits ctrlmindist ctrlmaxdist ctrlspring ctrlspstrength ctrlspdamping ctrlbreakforce ctrlusemotor ctrlmotor ctrlinit] nil]; ); ); );;