/* ----------------------------------------------------------------------------- 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)= setPluginInstanceCbPreRender inst nil; 0;; fun cbTriggerImpulsePoint(inst, viewstr, p)= let p -> [object iobjmode radius strength continue] in ( let if (iobjmode != 0) then ( let V3DgetDefaultCamera c3dXsession -> curcamera in V3DgetCameraByType c3dXsession curcamera iobjmode; ) else object -> object in if (object == nil) then nil else let SO3ObjectGetGlobalPosition object -> src in SO3WorldApplyImpulsePoint (V3DgetSession c3dXsession) src radius strength; if (continue) then nil else setPluginInstanceCbPreRender inst nil; ); 0;; fun cbTrigger(inst, from, action, param, rep, p)= setPluginInstanceCbPreRender inst mkfun3 @cbTriggerImpulsePoint p; 0;; fun cbStop(inst, from, action, param, rep, p)= setPluginInstanceCbPreRender inst nil; 0;; fun cbSetRadius(inst, from, action, param, rep, p)= if ((atof param) == nil) then nil else mutate p <- [_ _ (atof param) _ _]; 0;; fun cbSetStrength(inst, from, action, param, rep, p)= if ((atof param) == nil) then nil else mutate p <- [_ _ _ (atof param) _]; 0;; fun newOb(inst)= let (getPluginInstanceParam inst "object") -> objname in let atof (getPluginInstanceParam inst "radius") -> radius in let if radius == nil then 1.0 else radius -> radius in let atof (getPluginInstanceParam inst "strength") -> strength in let if strength == nil then 1.0 else strength -> strength in let atoi (getPluginInstanceParam inst "continue") -> continue in let if continue == nil then 0 else continue -> continue in let atoi (getPluginInstanceParam inst "init") -> init in let if init == nil then 0 else init -> init in let V3DgetObjectByName c3dXsession objname -> object in let V3DgetObjectTypeByName objname -> iobjmode in let [object iobjmode radius strength continue] -> p in ( PluginRegisterAction inst "Trigger" mkfun6 @cbTrigger p; PluginRegisterAction inst "Stop" mkfun6 @cbStop p; PluginRegisterAction inst "Set radius" mkfun6 @cbSetRadius p; PluginRegisterAction inst "Set strength" mkfun6 @cbSetStrength p; if (!init) then nil else setPluginInstanceCbPreRender inst mkfun3 @cbTriggerImpulsePoint p; setPluginInstanceCbDel inst @deleteOb; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;