/* ----------------------------------------------------------------------------- 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 ctrlmatname ctrlmattech ctrlmatpass ctrlallmat ctrlambient ctrldiffuse ctrlspecular ctrlselfillumination ctrlinit] in let getEdCtrlTextLineValue ctrlobjname -> objname in let getSelectedEdCtrlSelect ctrlmatname -> matname in let getSelectedEdCtrlSelectPos ctrlmattech -> technique in let getSelectedEdCtrlSelectPos ctrlmatpass -> pass in let getEdCtrlCheckState ctrlallmat -> allmat in let getEdCtrlColorButtonColor ctrlambient -> ambient in let getEdCtrlColorButtonColor ctrldiffuse -> diffuse in let getEdCtrlColorButtonColor ctrlspecular -> specular in let getEdCtrlColorButtonColor ctrlselfillumination -> selfillumination in let getEdCtrlCheckState ctrlinit -> init in ["object" objname]:: ["material" matname]:: ["technique" itoa technique]:: ["pass" itoa pass]:: ["allmat" itoa allmat]:: ["ambient" itoa ambient]:: ["diffuse" itoa diffuse]:: ["specular" itoa specular]:: ["selfillumination" itoa selfillumination]:: ["init" itoa init]:: nil;; fun fillMaterialPassSelector(viewstr, p, mat, tech)= let p -> [ctrlselect ctrlmatname ctrlmattech] in if mat == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3MaterialNumberOfPassesByTechnique mat tech -> size in let 0 -> i in let nil -> lmatname in ( while i < size do ( let SO3MaterialPassGetNameByIndex mat tech i -> matname in let if (!strcmp matname "") then (itoa i) else matname -> matname in set lmatname = lcat lmatname matname::nil; set i = i + 1; ); fillEdCtrlSelect ctrlselect lmatname; ); 0;; fun cbMatTechniqueName(ctrlstr, pos, elem, p)= let p -> [inst viewstr group ctrlmatname ctrlmatpass] in let getSelectedEdCtrlSelect ctrlmatname -> matname in let V3DgetDefaultSession viewstr -> sessionstr in let if matname != nil then SO3SceneGetMaterial (V3DgetSession sessionstr) group matname else nil -> mat in fillMaterialPassSelector viewstr [ctrlmatpass ctrlmatname ctrlstr] mat pos; 0;; fun fillMaterialTechSelector(viewstr, p, mat)= let p -> [ctrlselect ctrlmatname ctrlmatpass] in if mat == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3MaterialNumberOfTechniques mat -> size in let 0 -> i in let nil -> lmatname in ( while i < size do ( let SO3MaterialTechniqueGetNameByIndex mat i -> matname in set lmatname = lcat lmatname matname::nil; set i = i + 1; ); fillEdCtrlSelect ctrlselect lmatname; fillMaterialPassSelector viewstr [ctrlmatpass ctrlmatname ctrlselect] mat 0; ); 0;; fun cbMatName(ctrlstr, pos, elem, p)= let p -> [inst viewstr group ctrlmattech ctrlmatpass] in let V3DgetDefaultSession viewstr -> sessionstr in let if elem != nil then SO3SceneGetMaterial (V3DgetSession sessionstr) group elem else nil -> mat in fillMaterialTechSelector viewstr [ctrlmattech ctrlstr ctrlmatpass] mat; 0;; fun fillMaterialSelector(viewstr, p, objname)= let p -> [inst ctrlselect ctrlmattech ctrlmatpass] in if objname == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) objname -> obj in let SO3EntityGetResourceGroup obj -> group in let SO3EntityMaterialList obj -> lmat in let nil -> lmatname in ( setEdCtrlSelectCb ctrlselect mkfun4 @cbMatName [inst viewstr group ctrlmattech ctrlmatpass]; setEdCtrlSelectCb ctrlmattech mkfun4 @cbMatTechniqueName [inst viewstr group ctrlselect ctrlmatpass]; let sizelist lmat -> size in let 0 -> i in while i < size do ( let nth_list lmat i -> mat in let SO3MaterialGetName mat -> matname in set lmatname = lcat lmatname matname::nil; set i = i + 1; ); fillEdCtrlSelect ctrlselect lmatname; fillMaterialTechSelector viewstr [ctrlmattech ctrlselect ctrlmatpass] (SO3SceneGetMaterial (V3DgetSession sessionstr) group (hd lmatname)); ); 0;; fun cbSelectObj(val, type, p)= let p -> [inst winstr viewstr ctrlobjname ctrlmatname ctrlmattech ctrlmatpass] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> obj in if obj == nil then nil else ( setEdCtrlTextLineValue ctrlobjname val; fillMaterialSelector viewstr [inst ctrlmatname ctrlmattech ctrlmatpass] val; ); 0;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlobjname ctrlmatname ctrlmattech ctrlmatpass objname] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeEntity objname mkfun3 @cbSelectObj [inst winstr viewstr ctrlobjname ctrlmatname ctrlmattech ctrlmatpass] mkfun1 @cbCloseRes ctrlbtn 0; ); 0;; fun cbCheckAllmat(ctrl, state, p)= let p -> [ctrlmattech ctrlmatpass] in ( setEdCtrlSelectEnable ctrlmattech !state; setEdCtrlSelectEnable ctrlmatpass !state; ); 0;; fun cbRefreshBtnSpec(pickbtn, p)= let p -> [ctrlobjname ctrlmatname ctrlmattech ctrlmatpass] in ( setEdCtrlTextLineValue ctrlobjname ""; fillEdCtrlSelect ctrlmatname nil; fillEdCtrlSelect ctrlmattech nil; fillEdCtrlSelect ctrlmatpass nil; ); 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [455 335] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "object") -> objname in let (getPluginInstanceParam inst "material") -> matname in let atoi (getPluginInstanceParam inst "technique") -> technique in let if technique == nil then 0 else technique -> technique in let atoi (getPluginInstanceParam inst "pass") -> pass in let if pass == nil then 0 else pass -> pass in let atoi (getPluginInstanceParam inst "allmat") -> allmat in let if allmat == nil then 1 else allmat -> allmat in let atoi (getPluginInstanceParam inst "ambient") -> ambient in let if ambient == nil then (make_rgba 0 0 0 255) else ambient -> ambient in let atoi (getPluginInstanceParam inst "diffuse") -> diffuse in let if diffuse == nil then (make_rgba 250 250 250 255) else diffuse -> diffuse in let atoi (getPluginInstanceParam inst "specular") -> specular in let if specular == nil then (make_rgba 255 255 255 255) else specular -> specular in let atoi (getPluginInstanceParam inst "selfillumination") -> selfillumination in let if selfillumination == nil then (make_rgba 0 0 0 255) else selfillumination -> selfillumination in let atoi (getPluginInstanceParam inst "init") -> init in let if init == nil then 0 else init -> init in let crEdFrameWindow _channel ewinstr 0 0 iw 155 EDWIN_RESIZE_MW nil (loc "OS3DMATCOLOR_0007") (loc "OS3DMATCOLOR_0009") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 145 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 (ypos + 2) 170 20 (loc "OS3DMATCOLOR_0011") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 170 20 objname nil EDWIN_RESIZE_MW -> ctrlobjname in let crEdCtrlButton winstr 360 ypos 55 20 "..." nil -> pickbtn in let crEdCtrlButton winstr 420 ypos 35 20 "X" nil -> refreshobjname in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DMATCOLOR_0006") nil -> labelmat in let crEdCtrlSelect winstr 180 ypos (iw - 180) 120 EDWIN_RESIZE_MW -> ctrlmatname in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DMATCOLOR_0008") nil -> labeltech in let crEdCtrlSelect winstr 180 ypos (iw - 180) 120 EDWIN_RESIZE_MW -> ctrlmattech in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DMATCOLOR_0014") nil -> labelpass in let crEdCtrlSelect winstr 180 ypos (iw - 180) 120 EDWIN_RESIZE_MW -> ctrlmatpass in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DMATCOLOR_0002") EDWIN_RESIZE_MW -> ctrlallmat in let crEdFrameWindow _channel ewinstr 0 0 iw 130 EDWIN_RESIZE_MW nil (loc "OS3DMATCOLOR_0004") (loc "OS3DMATCOLOR_0009") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 120 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DMATCOLOR_0001") nil -> labelambient in let crEdCtrlColorButton winstr 180 ypos 100 20 ambient 1 EDWIN_RESIZE_MW nil -> ctrlambient in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DMATCOLOR_0005") nil -> labeldiffuse in let crEdCtrlColorButton winstr 180 ypos 100 20 diffuse 1 EDWIN_RESIZE_MW nil -> ctrldiffuse in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DMATCOLOR_0013") nil -> labelspecular in let crEdCtrlColorButton winstr 180 ypos 100 20 specular 1 EDWIN_RESIZE_MW nil -> ctrlspecular in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DMATCOLOR_0012") nil -> labelselfcolor in let crEdCtrlColorButton winstr 180 ypos 100 20 selfillumination 1 EDWIN_RESIZE_MW nil -> ctrlselfillumination in let crEdFrameWindow _channel ewinstr 0 0 iw 60 EDWIN_RESIZE_MW nil (loc "OS3DMATCOLOR_0010") (loc "OS3DMATCOLOR_0009") -> 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 "OS3DMATCOLOR_0003") EDWIN_RESIZE_MW -> ctrlinit in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) objname -> obj in let SO3EntityGetResourceGroup obj -> group in ( setEdCtrlCheckState ctrlinit init; setEdCtrlCheckState ctrlallmat allmat; setEdCtrlCheckCbState ctrlallmat mkfun3 @cbCheckAllmat [ctrlmattech ctrlmatpass]; if (!allmat) then nil else ( setEdCtrlSelectEnable ctrlmattech 0; setEdCtrlSelectEnable ctrlmatpass 0; ); setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlobjname ctrlmatname ctrlmattech ctrlmatpass objname]; setEdCtrlTextLineEnable ctrlobjname 0; setEdCtrlButtonCb refreshobjname mkfun2 @cbRefreshBtnSpec [ctrlobjname ctrlmatname ctrlmattech ctrlmatpass]; fillMaterialSelector viewstr [inst ctrlmatname ctrlmattech ctrlmatpass] objname; selectEdCtrlSelect ctrlmatname matname; let SO3SceneGetMaterial (V3DgetSession sessionstr) group matname -> mat in if mat == nil then nil else ( fillMaterialTechSelector viewstr [ctrlmattech ctrlmatname ctrlmatpass] mat; selectEdCtrlSelectByPos ctrlmattech technique; fillMaterialPassSelector viewstr [ctrlmatpass ctrlmatname ctrlmattech] mat technique; selectEdCtrlSelectByPos ctrlmatpass pass; ); [mkfun1 @cbCloseEdit [ctrlobjname ctrlmatname ctrlmattech ctrlmatpass ctrlallmat ctrlambient ctrldiffuse ctrlspecular ctrlselfillumination ctrlinit] nil]; ); );;