/* ----------------------------------------------------------------------------- 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 ctrllimits ctrlminangle ctrlmaxangle 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 getEdCtrlCheckState ctrllimits -> uselimits in let getEdCtrlFloatValue ctrlminangle -> mint in let getEdCtrlFloatValue ctrlmaxangle -> maxt 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]:: ["useLimits" itoa uselimits]:: ["minangle" ftoa mint]:: ["maxangle" ftoa maxt]:: ["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 cbCheckLimits(ctrl, state, p)= let p -> [ctrlminangle ctrlmaxangle] in ( setEdCtrlFloatEnable ctrlminangle state; setEdCtrlFloatEnable ctrlmaxangle state; ); 0;; fun cbCheckMotor(ctrl, state, ctrlmotor)= setEdCtrlFloatEnable ctrlmotor 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 495] -> [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 atoi (getPluginInstanceParam inst "useLimits") -> useLimits in let if useLimits == nil then 0 else useLimits -> useLimits in let atof (getPluginInstanceParam inst "minangle") -> minangle in let atof (getPluginInstanceParam inst "maxangle") -> maxangle in let if minangle == nil then 0.0 else minangle -> minangle in let if maxangle == nil then 180.0 else maxangle -> maxangle 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 !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 "OS3DPHYSICHINGE_0023") (loc "OS3DPHYSICHINGE_0018") -> 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 "OS3DPHYSICHINGE_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 "OS3DPHYSICHINGE_0021") 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 "OS3DPHYSICHINGE_0012") EDWIN_RESIZE_MW -> ctrlcollide in let crEdFrameWindow _channel ewinstr 0 0 iw 160 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICHINGE_0015") (loc "OS3DPHYSICHINGE_0018") -> 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 "OS3DPHYSICHINGE_0028") 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 "OS3DPHYSICHINGE_0024") nil -> pickPRSbtn in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICHINGE_0025") 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 "OS3DPHYSICHINGE_0026") 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 "OS3DPHYSICHINGE_0027") 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 "OS3DPHYSICHINGE_0014") (loc "OS3DPHYSICHINGE_0018") -> 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 "OS3DPHYSICHINGE_0009") 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 "OS3DPHYSICHINGE_0010") 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 "OS3DPHYSICHINGE_0011") 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 crEdFrameWindowEx _channel ewinstr 0 0 iw 110 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICHINGE_0001") (loc "OS3DPHYSICHINGE_0018") !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 "OS3DPHYSICHINGE_0029") EDWIN_RESIZE_MW -> ctrllimits in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICHINGE_0017") nil -> labelminangle in let crEdCtrlFloat winstr 180 ypos 100 20 minangle (-.180.0) 180.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlminangle in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICHINGE_0016") nil -> labelmaxangle in let crEdCtrlFloat winstr 180 ypos 100 20 maxangle (-.180.0) 180.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlmaxangle in let crEdFrameWindowEx _channel ewinstr 0 0 iw 55 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICHINGE_0003") (loc "OS3DPHYSICHINGE_0018") !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 "OS3DPHYSICHINGE_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 crEdFrameWindowEx _channel ewinstr 0 0 iw 80 EDWIN_RESIZE_MW nil (loc "OS3DPHYSICHINGE_0020") (loc "OS3DPHYSICHINGE_0018") !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 "OS3DPHYSICHINGE_0030") EDWIN_RESIZE_MW -> ctrlusemotor in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DPHYSICHINGE_0020") 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 "OS3DPHYSICHINGE_0019") (loc "OS3DPHYSICHINGE_0018") -> 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 "OS3DPHYSICHINGE_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 "OS3DPHYSICHINGE_0005")::(loc "OS3DPHYSICHINGE_0022")::(loc "OS3DPHYSICHINGE_0008")::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 ctrlusemotor usemotor; setEdCtrlCheckState ctrlinit init; if (useLimits) then nil else ( setEdCtrlFloatEnable ctrlminangle 0; setEdCtrlFloatEnable ctrlmaxangle 0; ); if (usemotor) then nil else setEdCtrlFloatEnable ctrlmotor 0; setEdCtrlCheckCbState ctrllimits mkfun3 @cbCheckLimits [ctrlminangle ctrlmaxangle]; setEdCtrlCheckCbState ctrlusemotor mkfun3 @cbCheckMotor ctrlmotor; [mkfun1 @cbCloseEdit [ctrlobjname ctrlparentname ctrlcollide ctrlposmode ctrlposx ctrlposy ctrlposz ctrldirx ctrldiry ctrldirz ctrllimits ctrlminangle ctrlmaxangle ctrlbreakforce ctrlusemotor ctrlmotor ctrlinit] nil]; ); ); );;