/* ----------------------------------------------------------------------------- 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 -> [light initstate] in V3DenableLight light initstate; 0;; fun enableLight(inst, from, action, param, rep, p) = let p -> [[light _] state] in ( V3DenableLight light state; SendPluginEvent inst if (state) then "On" else "Off" nil nil; ); 0;; fun setDiffuse(inst, from, action, param, rep, p) = let p -> [light _] in if (htoi param) == nil then nil else SO3LightSetDiffuseColor light (htoi param); 0;; fun setSpecular(inst, from, action, param, rep, p) = let p -> [light _] in if (htoi param) == nil then nil else SO3LightSetSpecularColor light (htoi param); 0;; fun setSpotAngle(inst, from, action, param, rep, p) = let p -> [light _] in let hd (strextr param) -> lp in let atof (hd lp) -> inner in let atof (hd tl lp) -> outer in ( if inner == nil then nil else SO3LightSetSpotInnerAngle light SO3MathsDegreeToRadian inner; if outer == nil then nil else SO3LightSetSpotOuterAngle light SO3MathsDegreeToRadian outer; ); 0;; fun setRange(inst, from, action, param, rep, p) = let p -> [light _] in if (atof param) == nil then nil else SO3LightSetAttenuationAuto light (atof param); 0;; fun setPower(inst, from, action, param, rep, p) = let p -> [light _] in if (atof param) == nil then nil else SO3LightSetPowerScale light (atof param); 0;; fun newOb(inst)= let (getPluginInstanceParam inst "light") -> lightname in let atoi (getPluginInstanceParam inst "enable") -> enable in let SO3SceneGetObject (V3DgetSession c3dXsession) lightname -> light in let SO3LightGetVisible light -> initstate in let [light initstate] -> p in ( V3DenableLight light enable; PluginRegisterAction inst "On" mkfun6 @enableLight [p 1]; PluginRegisterAction inst "Off" mkfun6 @enableLight [p 0]; PluginRegisterAction inst "Set diffuse" mkfun6 @setDiffuse p; PluginRegisterAction inst "Set specular" mkfun6 @setSpecular p; PluginRegisterAction inst "Set spot angle" mkfun6 @setSpotAngle p; PluginRegisterAction inst "Set range" mkfun6 @setRange p; PluginRegisterAction inst "Set power" mkfun6 @setPower p; setPluginInstanceCbDel inst mkfun2 @deleteOb p; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;