/* ----------------------------------------------------------------------------- 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 -> [ctrlspeed ctrlcamh ctrljump ctrlmass ctrlfov ctrlnclip ctrlfclip ctrlfocalelength ctrlmaxlookup ctrlmaxlookdown ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz ctrlinit ctrlinitcam ctrlflymode ctrldisabledefcontrol] in let getEdCtrlFloatValue ctrlspeed -> speed in let getEdCtrlFloatValue ctrlcamh -> camheight in let getEdCtrlFloatValue ctrljump -> jumpforce in let getEdCtrlFloatValue ctrlmass -> mass 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 ctrlfocalelength -> focalelength in let getEdCtrlFloatValue ctrlmaxlookup -> lookup in let getEdCtrlFloatValue ctrlmaxlookdown -> lookdown in let getEdCtrlCheckState ctrlinit -> init in let getEdCtrlCheckState ctrlinitcam -> initcam in let getEdCtrlCheckState ctrlflymode -> flymode in let getEdCtrlCheckState ctrldisabledefcontrol -> disabledefcontrol in ["speed" ftoa speed]:: ["cameraheight" ftoa camheight]:: ["jumpforce" ftoa jumpforce]:: ["mass" ftoa mass]:: ["fovy" ftoa fovy]:: ["nclip" ftoa nclip]:: ["fclip" ftoa fclip]:: ["focalelength" ftoa focalelength]:: ["posx" ftoa posx]:: ["posy" ftoa posy]:: ["posz" ftoa posz]:: ["angx" ftoa ax]:: ["angy" ftoa ay]:: ["angz" ftoa az]:: ["maxlookup" ftoa lookup]:: ["maxlookdown" ftoa lookdown]:: ["init" itoa init]:: ["initcam" itoa initcam]:: ["flymode" itoa flymode]:: ["disabledefcontrol" itoa disabledefcontrol]:: 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 [420 480] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let atof (getPluginInstanceParam inst "speed") -> speed in let atof (getPluginInstanceParam inst "cameraheight") -> camheight in let atof (getPluginInstanceParam inst "jumpforce") -> jumpforce in let atof (getPluginInstanceParam inst "mass") -> mass 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 "fovy") -> fovy in let atof (getPluginInstanceParam inst "nclip") -> nclip in let atof (getPluginInstanceParam inst "fclip") -> fclip in let atof (getPluginInstanceParam inst "focalelength") -> focalelength in let atof (getPluginInstanceParam inst "maxlookup") -> maxlookup in let atof (getPluginInstanceParam inst "maxlookdown") -> maxlookdown 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 "flymode") -> flymode in let if flymode == nil then 0 else flymode -> flymode in let atoi (getPluginInstanceParam inst "disabledefcontrol") -> disabledefcontrol in let if disabledefcontrol == nil then 0 else disabledefcontrol -> disabledefcontrol in let if speed == nil then 1.0 else speed -> speed in let if camheight == nil then 1.60 else camheight -> camheight in let if jumpforce == nil then 5.0 else jumpforce -> jumpforce in let if mass == nil then 60.0 else mass -> mass 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 fovy == nil then 45.0 else fovy -> fovy in let if nclip == nil then 0.1 else nclip -> nclip in let if fclip == nil then 10000.0 else fclip -> fclip in let if focalelength == nil then 1.0 else focalelength -> focalelength in let if maxlookup == nil then 80.0 else maxlookup -> maxlookup in let if maxlookdown == nil then -.85.0 else maxlookdown -> maxlookdown in let crEdFrameWindowEx _channel ewinstr 0 0 iw 220 EDWIN_RESIZE_MW nil (loc "OS3DBASIC_NAVIGATION_0007") (loc "OS3DBASIC_NAVIGATION_0022") 1 -> winfrm in let crEdWindow _channel winfrm 0 18 iw 180 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 200 20 (loc "OS3DBASIC_NAVIGATION_0002") nil -> labelfov in let crEdCtrlFloat winstr 220 ypos 100 20 fovy 0.0 180.0 1.0 2 nil EDWIN_RESIZE_MW -> ctrlfov in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DBASIC_NAVIGATION_0006") nil -> labelnclip in let crEdCtrlFloat winstr 220 ypos 100 20 nclip 0.0 100000.0 0.001 5 nil EDWIN_RESIZE_MW -> ctrlnclip in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DBASIC_NAVIGATION_0003") nil -> labelfclip in let crEdCtrlFloat winstr 220 ypos 100 20 fclip 0.0 100000.0 0.001 5 nil EDWIN_RESIZE_MW -> ctrlfclip in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DBASIC_NAVIGATION_0004") nil -> labelfocalelength in let crEdCtrlFloat winstr 220 ypos 100 20 focalelength 0.0 100000.0 0.001 5 nil EDWIN_RESIZE_MW -> ctrlfocalelength in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DBASIC_NAVIGATION_0021") nil -> labelmlup in let crEdCtrlFloat winstr 220 ypos 100 20 maxlookup 0.0 180.0 1.0 2 nil EDWIN_RESIZE_MW -> ctrlmaxlookup in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DBASIC_NAVIGATION_0020") nil -> labelmldown in let crEdCtrlFloat winstr 220 ypos 100 20 maxlookdown (-.180.0) 0.0 1.0 2 nil EDWIN_RESIZE_MW -> ctrlmaxlookdown in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DBASIC_NAVIGATION_0005") nil -> labelcamh in let crEdCtrlFloat winstr 220 ypos 100 20 camheight (-.10000.0) 10000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlcamh in let crEdFrameWindow _channel ewinstr 0 0 iw 115 EDWIN_RESIZE_MW nil (loc "OS3DBASIC_NAVIGATION_0026") (loc "OS3DBASIC_NAVIGATION_0022") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 85 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 200 20 (loc "OS3DBASIC_NAVIGATION_0025") nil -> labelmass in let crEdCtrlFloat winstr 220 ypos 100 20 mass 0.0 100000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlmass in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DBASIC_NAVIGATION_0028") nil -> labelspeed in let crEdCtrlFloat winstr 220 ypos 100 20 speed 0.0 1000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlspeed in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DBASIC_NAVIGATION_0019") nil -> labeljump in let crEdCtrlFloat winstr 220 ypos 100 20 jumpforce 0.0 10000.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrljump in let crEdFrameWindow _channel ewinstr 0 0 iw 215 EDWIN_RESIZE_MW nil (loc "OS3DBASIC_NAVIGATION_0027") (loc "OS3DBASIC_NAVIGATION_0022") -> 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 "OS3DBASIC_NAVIGATION_0024") nil -> pickPRSbtn in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 200 20 (loc "OS3DBASIC_NAVIGATION_0016") 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 "OS3DBASIC_NAVIGATION_0017") 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 "OS3DBASIC_NAVIGATION_0018") 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 "OS3DBASIC_NAVIGATION_0013") 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 "OS3DBASIC_NAVIGATION_0014") 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 "OS3DBASIC_NAVIGATION_0015") 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 crEdFrameWindow _channel ewinstr 0 0 iw 125 EDWIN_RESIZE_MW nil (loc "OS3DBASIC_NAVIGATION_0023") (loc "OS3DBASIC_NAVIGATION_0022") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 105 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DBASIC_NAVIGATION_0012") EDWIN_RESIZE_MW -> ctrlflymode in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DBASIC_NAVIGATION_0010") EDWIN_RESIZE_MW -> ctrldisabledefcontrol in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DBASIC_NAVIGATION_0011") EDWIN_RESIZE_MW -> ctrlinit in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DBASIC_NAVIGATION_0001") EDWIN_RESIZE_MW -> ctrlinitcam in ( setEdCtrlCheckState ctrlinit init; setEdCtrlCheckState ctrlinitcam initcam; setEdCtrlCheckState ctrlflymode flymode; setEdCtrlCheckState ctrldisabledefcontrol disabledefcontrol; setEdCtrlButtonCb pickPRSbtn mkfun2 @cbBtnPickObjPRS [inst winstr viewstr ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz]; [mkfun1 @cbCloseEdit [ctrlspeed ctrlcamh ctrljump ctrlmass ctrlfov ctrlnclip ctrlfclip ctrlfocalelength ctrlmaxlookup ctrlmaxlookdown ctrlposx ctrlposy ctrlposz ctrlax ctrlay ctrlaz ctrlinit ctrlinitcam ctrlflymode ctrldisabledefcontrol] nil]; ); );;