/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2015 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 ----------------------------------------------------------------------------- */ /*------------------ Delete PlugIT instance -------------------*/ fun deleteOb(inst)= _SetSensorEnable SENSOR_TYPE_LIGHT 0; setPluginInstanceCbScenePreRender inst nil; 0;; fun cbPreRender(inst, sessionstr, etime)= let _GetFloatData SENSOR_TYPE_LIGHT -> proximity in SendPluginEvent inst "Value" ftoa proximity inst.INST_sName; 0;; /*----------------------- Callbacks ------------------------*/ fun cbEnable(inst, from, action, param, rep)= if !(_IsSensorAvailable SENSOR_TYPE_LIGHT) then nil else ( _SetSensorEnable SENSOR_TYPE_LIGHT 1; setPluginInstanceCbScenePreRender inst @cbPreRender; ); 0;; fun cbDisable(inst, from, action, param, rep)= if !(_IsSensorAvailable SENSOR_TYPE_LIGHT) then nil else ( _SetSensorEnable SENSOR_TYPE_LIGHT 0; setPluginInstanceCbScenePreRender inst nil; ); 0;; /*--------------- Create new PlugIT instance ----------------*/ fun newOb(inst)= if !(_IsSensorAvailable SENSOR_TYPE_LIGHT) then ( SendPluginEvent inst "Sensor not found" nil nil; 0; ) else ( _SetSensorEnable SENSOR_TYPE_LIGHT 1; setPluginInstanceCbScenePreRender inst @cbPreRender; PluginRegisterAction inst "Enable" @cbEnable; PluginRegisterAction inst "Disable" @cbDisable; SendPluginEvent inst "Sensor found" nil nil; ); setPluginInstanceCbDel inst @deleteOb; 0;; /*------------------- Initialize PlugIT --------------------*/ fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;