/* ----------------------------------------------------------------------------- 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 deleteOb(inst, p)= let p -> [preset quality] in let V3DgetSession c3dXsession -> scene in ( SO3SceneSetShadowPreset scene preset; SO3SceneSetShadowQuality scene quality; ); 0;; fun cbSetFarDistance(inst, from, action, param, reply)= let atof param -> dist in if (param == nil || (!strcmp param "") || dist <=. 0.0) then nil else SO3SceneSetShadowFarDistance (V3DgetSession c3dXsession) dist; 0;; fun cbDisable (inst, from, action, param, reply, p)= let p -> [preset state] in if (!state) then nil else ( mutate p <- [_ 0]; SO3SceneSetShadowPreset (V3DgetSession c3dXsession) SO3_SHADOWS_PRESET_NONE; SendPluginEvent inst "Disabled" nil nil; ); 0;; fun cbEnable (inst, from, action, param, reply, p)= let p -> [preset state] in if (state) then nil else ( mutate p <- [_ 1]; SO3SceneSetShadowPreset (V3DgetSession c3dXsession) preset; SendPluginEvent inst "Enabled" nil nil; ); 0;; fun cbSetState(inst, from, action, param, reply, p)= if (param == nil) || (!strcmp param "") then nil else ( if (atoi param) <= 0 then cbDisable inst from action param reply p else cbEnable inst from action param reply p; ); 0;; fun getShadowTypeByName(param)= if (!strcmpi param "LISPSM") then 0 else if (!strcmpi param "PSSM") then 1 else if (!strcmpi param "CSM") then 2 else nil ;; fun getShadowTypeyByIndex(ival)= if (ival == 0) then SO3_SHADOWS_PRESET_LISPSM else if (ival == 1) then SO3_SHADOWS_PRESET_PSSM else if (ival == 2) then SO3_SHADOWS_PRESET_CSM else nil ;; fun cbSetType(inst, from, action, param, reply, p)= let p -> [_ state] in if (param == nil) || (!strcmp param "") then nil else ( let getShadowTypeByName param -> tval in let atoi param -> ival in let if (tval != nil) then getShadowTypeyByIndex tval else getShadowTypeyByIndex ival -> preset in if (preset == nil) then nil else ( mutate p <- [preset _]; if (!state) then nil else SO3SceneSetShadowPreset (V3DgetSession c3dXsession) preset; ); ); 0;; fun getShadowQualityByName(param)= if (!strcmpi param "VERYLOW") then 0 else if (!strcmpi param "LOW") then 1 else if (!strcmpi param "MEDIUM") then 2 else if (!strcmpi param "HIGH") then 3 else if (!strcmpi param "VERYHIGH") then 4 else nil ;; fun getShadowQualityByIndex(ival)= if (ival == 0) then SO3_SHADOWS_QUALITY_VERYLOW else if (ival == 1) then SO3_SHADOWS_QUALITY_LOW else if (ival == 2) then SO3_SHADOWS_QUALITY_MEDIUM else if (ival == 3) then SO3_SHADOWS_QUALITY_HIGH else if (ival == 4) then SO3_SHADOWS_QUALITY_VERYHIGH else SO3_SHADOWS_QUALITY_MEDIUM ;; fun cbSetQuality(inst, from, action, param, reply, p)= let p -> [_ state] in if (param == nil) || (!strcmpi param "") then nil else ( let getShadowQualityByName param -> tval in let atoi param -> ival in let if (tval != nil) then getShadowQualityByIndex tval else getShadowQualityByIndex ival -> quality in SO3SceneSetShadowQuality (V3DgetSession c3dXsession) quality; ); 0;; fun newOb(inst)= let atoi (getPluginInstanceParam inst "init") -> init in let if (init == nil) then 1 else init -> init in let V3DgetSessionView c3dXsession -> viewstr in let V3DgetDefaultViewport viewstr -> viewportstr in let V3DgetSession c3dXsession -> scene in let SO3SceneGetShadowPreset scene -> preset in let SO3SceneGetShadowQuality scene -> quality in let [preset init] -> p in ( if init then SO3SceneSetShadowPreset scene preset else SO3SceneSetShadowPreset scene SO3_SHADOWS_PRESET_NONE; //SO3ViewportSetShadowEnabled viewportstr.V3D_viewport init; PluginRegisterAction inst "Enable" mkfun6 @cbEnable p; PluginRegisterAction inst "Disable" mkfun6 @cbDisable p; PluginRegisterAction inst "Set state" mkfun6 @cbSetState p; PluginRegisterAction inst "Set type" mkfun6 @cbSetType p; PluginRegisterAction inst "Set quality" mkfun6 @cbSetQuality p; PluginRegisterAction inst "Set far distance" @cbSetFarDistance; setPluginInstanceCbDel inst mkfun2 @deleteOb [preset quality]; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;