/* ----------------------------------------------------------------------------- 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 -> [ctrlfov ctrlnclip ctrlfclip ctrlxoff ctrlxoffmode ctrlyoff ctrlyoffmode ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz ctrlpan ctrlinertia ctrlspeed ctrldist ctrlmindist ctrlmaxdist ctrlmaxleft ctrlmaxright ctrlmaxup ctrlmaxdown ctrluselimits ctrlreverty ctrlshowunit ctrlinit ctrlinitcam] 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 getEdCtrlFloatValue ctrlfov -> fovy in let getEdCtrlFloatValue ctrlnclip -> nclip in let getEdCtrlFloatValue ctrlfclip -> fclip in let getEdCtrlFloatValue ctrlxoff -> xoff in let getSelectedEdCtrlSelectPos ctrlxoffmode -> xoffmode in let getEdCtrlFloatValue ctrlyoff -> yoff in let getSelectedEdCtrlSelectPos ctrlyoffmode -> yoffmode in let getEdCtrlFloatValue ctrldist -> dist in let getEdCtrlFloatValue ctrlmindist -> mindist in let getEdCtrlFloatValue ctrlmaxdist -> maxdist in let getEdCtrlFloatValue ctrlmaxleft -> maxleft in let getEdCtrlFloatValue ctrlmaxright -> maxright in let getEdCtrlFloatValue ctrlmaxup -> maxup in let getEdCtrlFloatValue ctrlmaxdown -> maxdown in let getEdCtrlFloatValue ctrlinertia -> inertia in let getEdCtrlFloatValue ctrlspeed -> speed in let getEdCtrlCheckState ctrluselimits -> uselimits in let getEdCtrlCheckState ctrlreverty -> reverty in let getEdCtrlCheckState ctrlshowunit -> showunit in let getEdCtrlCheckState ctrlpan -> pan in let getEdCtrlCheckState ctrlinit -> init in let getEdCtrlCheckState ctrlinitcam -> initcam in ["fovy" ftoa fovy]:: ["nclip" ftoa nclip]:: ["fclip" ftoa fclip]:: ["xoff" ftoa xoff]:: ["xoffmode" itoa xoffmode]:: ["yoff" ftoa yoff]:: ["yoffmode" itoa yoffmode]:: ["posx" ftoa posx]:: ["posy" ftoa posy]:: ["posz" ftoa posz]:: ["angx" ftoa ax]:: ["angy" ftoa ay]:: ["angz" ftoa az]:: ["pan" itoa pan]:: ["dist" ftoa dist]:: ["mindist" ftoa mindist]:: ["maxdist" ftoa maxdist]:: ["miny" ftoa maxleft]:: ["maxy" ftoa maxright]:: ["minp" ftoa maxdown]:: ["maxp" ftoa maxup]:: ["inertia" ftoa inertia]:: ["speed" ftoa speed]:: ["uselimits" itoa uselimits]:: ["reverty" itoa reverty]:: ["showunitscale" itoa showunit]:: ["init" itoa init]:: ["initcam" itoa initcam]:: nil;; fun cbSelectObjPRS(val, type, p)= let p -> [inst winstr viewstr ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz] 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 let SO3MathsQuatToEulerPYR SO3ObjectGetGlobalOrientation obj -> [ax ay az] in // invert X / Y for camera orientation 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 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 dynamicedit(ewinstr, inst, viewstr, applybtn)= let [360 590] -> [iw ih] in let 10 -> ypos 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 atof (getPluginInstanceParam inst "minp") -> minp in let atof (getPluginInstanceParam inst "maxp") -> maxp in let atof (getPluginInstanceParam inst "miny") -> miny in let atof (getPluginInstanceParam inst "maxy") -> maxy in let atof (getPluginInstanceParam inst "nclip") -> nclip in let atof (getPluginInstanceParam inst "fclip") -> fclip in let atof (getPluginInstanceParam inst "fovy") -> fovy in let atof (getPluginInstanceParam inst "xoff") -> xoff in let atoi (getPluginInstanceParam inst "xoffmode") -> xoffmode in let atof (getPluginInstanceParam inst "yoff") -> yoff in let atoi (getPluginInstanceParam inst "yoffmode") -> yoffmode in let atof (getPluginInstanceParam inst "dist") -> dist in let atof (getPluginInstanceParam inst "mindist") -> mindist in let atof (getPluginInstanceParam inst "maxdist") -> maxdist in let atoi (getPluginInstanceParam inst "pan") -> pan in let atof (getPluginInstanceParam inst "inertia") -> inertia in let atof (getPluginInstanceParam inst "speed") -> speed in let atoi (getPluginInstanceParam inst "showunitscale") -> showunit in let if showunit == nil then 1 else showunit -> showunit in let atoi (getPluginInstanceParam inst "reverty") -> reverty in let if reverty == nil then 0 else reverty -> reverty in let atoi (getPluginInstanceParam inst "init") -> init in let if init == nil then 1 else init -> init in let atoi (getPluginInstanceParam inst "initcam") -> initcam in let if initcam == nil then 1 else initcam -> initcam in let atoi (getPluginInstanceParam inst "uselimits") -> uselimits in let if uselimits == nil then 1 else uselimits -> uselimits 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 if minp == nil then 180.0 else minp -> minp in let if maxp == nil then 180.0 else maxp -> maxp in let if miny == nil then 180.0 else miny -> miny in let if maxy == nil then 180.0 else maxy -> maxy in let if fovy == nil then 45.0 else fovy -> fovy in let if xoff == nil then 0.0 else xoff -> xoff in let if xoffmode == nil then 0 else xoffmode -> xoffmode in let if yoff == nil then 0.0 else yoff -> yoff in let if yoffmode == nil then 0 else yoffmode -> yoffmode in let if nclip == nil then 0.01 else nclip -> nclip in let if fclip == nil then 10000.0 else fclip -> fclip in let if dist == nil then 5.0 else dist -> dist in let if mindist == nil then 0.0 else mindist -> mindist in let if maxdist == nil then 100000.0 else maxdist -> maxdist in let if inertia == nil then 0.0 else inertia -> inertia in let if speed == nil then 1.0 else speed -> speed in let if ((fovy != 45.0) || (xoff != 0.0) || (yoff != 0.0) || (nclip != 0.01) || (fclip != 10000.0)) then 1 else 0 -> hascamparams in ( if !hascamparams then nil else set ih = ih + 140; setEdWindowSize ewinstr iw ih; let crEdFrameWindowEx _channel ewinstr 0 0 iw 160 EDWIN_RESIZE_MW nil (loc "OS3DVIEWER_NAVIGATION_0005") (loc "OS3DVIEWER_NAVIGATION_0024") !hascamparams -> 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) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0002") nil -> labelfov in let crEdCtrlFloat winstr 220 ypos 100 20 fovy 0.0 90.0 1.0 2 nil EDWIN_RESIZE_MW -> ctrlfov in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0004") nil -> labelnclip in let crEdCtrlFloat winstr 220 ypos 100 20 nclip 0.001 100000.0 0.001 5 nil EDWIN_RESIZE_MW -> ctrlnclip in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0003") nil -> labelfclip in let crEdCtrlFloat winstr 220 ypos 100 20 fclip 0.001 100000.0 0.001 5 nil EDWIN_RESIZE_MW -> ctrlfclip in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 90 20 (loc "OS3DVIEWER_NAVIGATION_0033") nil -> labelxoff in let crEdCtrlFloat winstr 220 ypos 100 20 xoff (-.10000.0) 10000.0 1.0 2 nil EDWIN_RESIZE_MW -> ctrlxoff in let crEdCtrlSelect winstr 325 ypos 35 120 EDWIN_RESIZE_MW -> ctrlxoffmode in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 90 20 (loc "OS3DVIEWER_NAVIGATION_0034") nil -> labelyoff in let crEdCtrlFloat winstr 220 ypos 100 20 yoff (-.10000.0) 10000.0 1.0 2 nil EDWIN_RESIZE_MW -> ctrlyoff in let crEdCtrlSelect winstr 325 ypos 35 120 EDWIN_RESIZE_MW -> ctrlyoffmode in let crEdFrameWindow _channel ewinstr 0 0 iw 335 EDWIN_RESIZE_MW nil (loc "OS3DVIEWER_NAVIGATION_0026") (loc "OS3DVIEWER_NAVIGATION_0024") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 310 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0011") nil -> labeldist in let crEdCtrlFloat winstr 220 ypos 100 20 dist 0.0 100000.0 0.01 4 nil EDWIN_RESIZE_MW -> ctrldist in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0023") nil -> labelmindist in let crEdCtrlFloat winstr 220 ypos 100 20 mindist 0.0 100000.0 0.01 4 nil EDWIN_RESIZE_MW -> ctrlmindist in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0018") nil -> labelmaxdist in let crEdCtrlFloat winstr 220 ypos 100 20 maxdist 0.0 100000.0 0.01 4 nil EDWIN_RESIZE_MW -> ctrlmaxdist in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0020") nil -> labelmlleft in let crEdCtrlFloat winstr 220 ypos 100 20 miny 0.0 180.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlmaxleft in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0021") nil -> labelmlright in let crEdCtrlFloat winstr 220 ypos 100 20 maxy (-.180.0) 180.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlmaxright in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0022") nil -> labelmlup in let crEdCtrlFloat winstr 220 ypos 100 20 maxp (-.180.0) 180.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlmaxup in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0019") nil -> labelmldown in let crEdCtrlFloat winstr 220 ypos 100 20 minp (-.180.0) 180.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlmaxdown in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0030") nil -> labelspeed in let crEdCtrlFloat winstr 220 ypos 100 20 speed 0.0 100000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlspeed in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0010") nil -> labelinertia in let crEdCtrlFloat winstr 220 ypos 100 20 inertia 0.0 100.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlinertia in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DVIEWER_NAVIGATION_0032") EDWIN_RESIZE_MW -> ctrluselimits in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DVIEWER_NAVIGATION_0008") EDWIN_RESIZE_MW -> ctrlpan in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DVIEWER_NAVIGATION_0029") EDWIN_RESIZE_MW -> ctrlreverty in let crEdFrameWindow _channel ewinstr 0 0 iw 215 EDWIN_RESIZE_MW nil (loc "OS3DVIEWER_NAVIGATION_0028") (loc "OS3DVIEWER_NAVIGATION_0024") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 185 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlButton winstr ((iw / 2) - 100) (set ypos = 10) 200 20 (loc "OS3DVIEWER_NAVIGATION_0027") nil -> pickPRSbtn in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0015") nil -> labelposx in let crEdCtrlFloat winstr 220 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) 200 20 (loc "OS3DVIEWER_NAVIGATION_0016") nil -> labelposy in let crEdCtrlFloat winstr 220 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) 200 20 (loc "OS3DVIEWER_NAVIGATION_0017") nil -> labelposz in let crEdCtrlFloat winstr 220 ypos 100 20 posz (-.100000.0) 100000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlposz in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0012") nil -> labelax in let crEdCtrlFloat winstr 220 ypos 100 20 ax (-.720.0) 720.0 1.0 2 nil EDWIN_RESIZE_MW -> ctrlax in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0013") nil -> labelay in let crEdCtrlFloat winstr 220 ypos 100 20 ay (-.720.0) 720.0 1.0 2 nil EDWIN_RESIZE_MW -> ctrlay in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DVIEWER_NAVIGATION_0014") nil -> labelaz in let crEdCtrlFloat winstr 220 ypos 100 20 az (-.720.0) 720.0 1.0 2 nil EDWIN_RESIZE_MW -> ctrlaz in let crEdFrameWindowEx _channel ewinstr 0 0 iw 100 EDWIN_RESIZE_MW nil (loc "OS3DVIEWER_NAVIGATION_0025") (loc "OS3DVIEWER_NAVIGATION_0024") 1 -> winfrm in let crEdWindow _channel winfrm 0 18 iw 80 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DVIEWER_NAVIGATION_0031") EDWIN_RESIZE_MW -> ctrlshowunit in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DVIEWER_NAVIGATION_0009") EDWIN_RESIZE_MW -> ctrlinit in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DVIEWER_NAVIGATION_0001") EDWIN_RESIZE_MW -> ctrlinitcam in ( fillEdCtrlSelect ctrlxoffmode "px"::"%"::nil; selectEdCtrlSelectByPos ctrlxoffmode xoffmode; fillEdCtrlSelect ctrlyoffmode "px"::"%"::nil; selectEdCtrlSelectByPos ctrlyoffmode yoffmode; setEdCtrlCheckState ctrlpan pan; setEdCtrlCheckState ctrlinit init; setEdCtrlCheckState ctrlinitcam initcam; setEdCtrlCheckState ctrlreverty reverty; setEdCtrlCheckState ctrlshowunit showunit; setEdCtrlCheckState ctrluselimits uselimits; setEdCtrlButtonCb pickPRSbtn mkfun2 @cbBtnPickObjPRS [inst winstr viewstr ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz]; [mkfun1 @cbCloseEdit [ctrlfov ctrlnclip ctrlfclip ctrlxoff ctrlxoffmode ctrlyoff ctrlyoffmode ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz ctrlpan ctrlinertia ctrlspeed ctrldist ctrlmindist ctrlmaxdist ctrlmaxleft ctrlmaxright ctrlmaxup ctrlmaxdown ctrluselimits ctrlreverty ctrlshowunit ctrlinit ctrlinitcam] nil]; ); ); );;