/* ----------------------------------------------------------------------------- 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 cbDestroyEdit()= 0;; fun cbCloseEdit(p)= let p -> [ctrlobjname ctrllocal ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz ctrlinit] in let getEdCtrlTextLineValue ctrlobjname -> objname in let getEdCtrlCheckState ctrllocal -> local in let getEdCtrlFloatValue ctrlposx -> posx in let getEdCtrlFloatValue ctrlposy -> posy in let getEdCtrlFloatValue ctrlposz -> posz in let getEdCtrlFloatValue ctrlax -> ax in let getEdCtrlFloatValue ctrlay -> ay in let getEdCtrlFloatValue ctrlaz -> az in let getEdCtrlCheckState ctrlinit -> init in ["object" objname]:: ["local" itoa local]:: ["posx" ftoa posx]:: ["posy" ftoa posy]:: ["posz" ftoa posz]:: ["angx" ftoa ax]:: ["angy" ftoa ay]:: ["angz" ftoa az]:: ["init" itoa init]:: nil;; fun cbSelectObj(val, type, p)= let p -> [inst winstr viewstr ctrlobjname [ctrllocal ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz]] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> obj in let getEdCtrlCheckState ctrllocal -> local in if (obj != nil) || (!strcmpi "Current camera" val) || (!strcmpi "Current camera shell" val) then ( setEdCtrlTextLineValue ctrlobjname val; if (!strcmpi "Current camera" val) || (!strcmpi "Current camera shell" val) then nil else let if local then SO3ObjectGetPosition obj else SO3ObjectGetGlobalPosition obj -> [x y z] in let if local then V3DgetObjectOrientationDeg obj else V3DgetObjectGlobalOrientationDeg obj -> [ax ay az] in ( setEdCtrlFloatValue ctrlposx x; setEdCtrlFloatValue ctrlposy y; setEdCtrlFloatValue ctrlposz z; setEdCtrlFloatValue ctrlax ax; setEdCtrlFloatValue ctrlay ay; setEdCtrlFloatValue ctrlaz az; ); ) else nil; 0;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlobjname objname prs] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeGroup|iTypeEntity|iTypeNode|iTypeLight|iTypeCamera|iTypeParticle|iTypeBone|iTypeCubeMap objname mkfun3 @cbSelectObj [inst winstr viewstr ctrlobjname prs] mkfun1 @cbCloseRes ctrlbtn 0; ); 0;; fun cbSelectObjPRS(val, type, p)= let p -> [inst winstr viewstr ctrlobjname ctrllocal ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz] in let getEdCtrlCheckState ctrllocal -> local 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 -> obj1 in let SO3ObjectGetParent (SO3SceneGetObject (V3DgetSession sessionstr) (getEdCtrlTextLineValue ctrlobjname)) -> obj2 in if (obj1 != nil) then ( let if (obj2 == nil) || (!local) then SO3ObjectGetGlobalPosition obj1 else SO3ObjectGetPositionInObjectRef obj1 obj2 -> [x y z] in let if (obj2 == nil) || (!local) then SO3MathsQuatToEulerPYR SO3ObjectGetGlobalOrientation obj1 else SO3MathsQuatToEulerPYR SO3ObjectGetOrientationInObjectRef obj1 obj2 -> [ax ay az] in let [(SO3MathsRadianToDegree ax) (SO3MathsRadianToDegree ay) (SO3MathsRadianToDegree az)] -> [ax ay az] in ( setEdCtrlFloatValue ctrlposx x; setEdCtrlFloatValue ctrlposy y; setEdCtrlFloatValue ctrlposz z; setEdCtrlFloatValue ctrlax ax; setEdCtrlFloatValue ctrlay ay; setEdCtrlFloatValue ctrlaz az; ); ) else nil; 0;; fun cbCloseResPRS(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbBtnPickObjPRS(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlobjname ctrllocal ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeGroup|iTypeEntity|iTypeNode|iTypeLight|iTypeCamera|iTypeParticle|iTypeBone|iTypeCubeMap|iTypeReflectionMap nil mkfun3 @cbSelectObjPRS p mkfun1 @cbCloseResPRS ctrlbtn 0; ); 0;; fun cbRefreshBtn(pickbtn, p)= let p -> [ctrlobjname] in setEdCtrlTextLineValue ctrlobjname ""; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [420 300] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "object") -> objname in //for compatibility let if (atoi (getPluginInstanceParam inst "iscamera")) == 1 then "Current camera" else objname -> objname in let atoi (getPluginInstanceParam inst "local") -> local in let if (local == nil) then 1 else local -> local in let atof (getPluginInstanceParam inst "posx") -> posx in let atof (getPluginInstanceParam inst "posy") -> posy in let atof (getPluginInstanceParam inst "posz") -> posz in let atof (getPluginInstanceParam inst "angx") -> ax in let atof (getPluginInstanceParam inst "angy") -> ay in let atof (getPluginInstanceParam inst "angz") -> az 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 if ax == nil then 0.0 else ax -> ax in let if ay == nil then 0.0 else ay -> ay in let if az == nil then 0.0 else az -> az in let atoi (getPluginInstanceParam inst "init") -> init in let if (init == nil) then 1 else init -> init in let crEdFrameWindow _channel ewinstr 0 0 iw 290 EDWIN_RESIZE_MW nil (loc "OS3DOBJECTPOSITION_0008") (loc "OS3DOBJECTPOSITION_0006") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 265 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DOBJECTPOSITION_0007") 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 crEdCtrlCheck winstr 10 (set ypos = ypos + 25) (iw - 20) 20 (loc "OS3DOBJECTPOSITION_0014") EDWIN_RESIZE_MW -> ctrllocal in let crEdCtrlButton winstr ((iw / 2) - 100) (set ypos = ypos + 35) 200 20 (loc "OS3DOBJECTPOSITION_0009") nil -> pickPRSbtn in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DOBJECTPOSITION_0010") nil -> labelposx in let crEdCtrlFloat winstr 180 ypos 100 20 posx (-.100000.0) 100000.0 0.1 5 nil EDWIN_RESIZE_MW -> ctrlposx in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DOBJECTPOSITION_0011") nil -> labelposy in let crEdCtrlFloat winstr 180 ypos 100 20 posy (-.100000.0) 100000.0 0.1 5 nil EDWIN_RESIZE_MW -> ctrlposy in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DOBJECTPOSITION_0012") nil -> labelposz in let crEdCtrlFloat winstr 180 ypos 100 20 posz (-.100000.0) 100000.0 0.1 5 nil EDWIN_RESIZE_MW -> ctrlposz in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DOBJECTPOSITION_0001") nil -> labelax in let crEdCtrlFloat winstr 180 ypos 100 20 ax (-.720.0) 720.0 1.0 5 nil EDWIN_RESIZE_MW -> ctrlax in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DOBJECTPOSITION_0002") nil -> labelay in let crEdCtrlFloat winstr 180 ypos 100 20 ay (-.720.0) 720.0 1.0 5 nil EDWIN_RESIZE_MW -> ctrlay in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DOBJECTPOSITION_0003") nil -> labelaz in let crEdCtrlFloat winstr 180 ypos 100 20 az (-.720.0) 720.0 1.0 5 nil EDWIN_RESIZE_MW -> ctrlaz in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) (iw - 20) 20 (loc "OS3DOBJECTPOSITION_0013") EDWIN_RESIZE_MW -> ctrlinit in ( setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlobjname objname [ctrllocal ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz]]; setEdCtrlButtonCb pickPRSbtn mkfun2 @cbBtnPickObjPRS [inst winstr viewstr ctrlobjname ctrllocal ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz]; setEdCtrlTextLineEnable ctrlobjname 0; setEdCtrlButtonCb refreshobjname mkfun2 @cbRefreshBtn [ctrlobjname]; setEdCtrlCheckState ctrllocal local; setEdCtrlCheckState ctrlinit init; [(mkfun1 @cbCloseEdit [ctrlobjname ctrllocal ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz ctrlinit]) @cbDestroyEdit]; ); );;