/* ----------------------------------------------------------------------------- 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)= 0;; fun cbRandom(inst, from, action, param, reply, p)= let p -> [x1 y1 z1 x2 y2 z2 xr yr zr] in let let nil -> r in ( while (r == nil) do ( let rand -> rd in if (rd == xr) then nil else set r = rd; ); r ) -> xr in let let nil -> r in ( while (r == nil) do ( let rand -> rd in if (rd == yr) then nil else set r = rd; ); r ) -> yr in let let nil -> r in ( while (r == nil) do ( let rand -> rd in if (rd == zr) then nil else set r = rd; ); r ) -> zr in let absf if (x2 >. x1) then (x1 -. x2) else (x2 -. x1) -> mx in let if (mx >. 100.0) then 10.0 else if (mx >. 10.0) then 100.0 else 1000.0 -> div in let x1 +. (absf ((itof (mod xr (ftoi (mx *. div)) + 1)) /. div)) -> x in let absf if (y2 >. y1) then (y1 -. y2) else (y2 -. y1) -> my in let if (my >. 100.0) then 10.0 else if (my >. 10.0) then 100.0 else 1000.0 -> div in let y1 +. (absf ((itof (mod yr (ftoi (my *. div)) + 1)) /. div)) -> y in let absf if (z2 >. z1) then (z1 -. z2) else (z2 -. z1) -> mz in let if (mz >. 100.0) then 10.0 else if (mz >. 10.0) then 100.0 else 1000.0 -> div in let z1 +. (absf ((itof (mod zr (ftoi (mz *. div)) + 1)) /. div)) -> z in ( mutate p <- [_ _ _ _ _ _ xr yr zr]; SendPluginEvent inst "Vector" (strcatnSep (ftoa x)::(ftoa y)::(ftoa z)::nil " ") nil; ); 0;; fun newOb(inst)= let atof (getPluginInstanceParam inst "x1") -> x1 in let atof (getPluginInstanceParam inst "y1") -> y1 in let atof (getPluginInstanceParam inst "z1") -> z1 in let atof (getPluginInstanceParam inst "x2") -> x2 in let atof (getPluginInstanceParam inst "y2") -> y2 in let atof (getPluginInstanceParam inst "z2") -> z2 in PluginRegisterAction inst "Get" mkfun6 @cbRandom [x1 y1 z1 x2 y2 z2 nil nil nil]; setPluginInstanceCbDel inst @deleteOb; 0;; fun IniPlug(file)= srand time; PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;