/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2021 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 ----------------------------------------------------------------------------- */ struct ObjLODbias = [ LODB_inst : PInstance, LODB_camera : SO3_OBJECT, LODB_fBias : F, LODB_bState : I ]mkObjLODbias;; fun deleteOb(inst, obstr)= SO3CameraSetLODbias obstr.LODB_camera nil; 0;; fun cbSetLODbias(inst, from, action, param, reply, obstr)= let atof param -> bias in if (bias == nil) then nil else ( set obstr.LODB_fBias = bias; SO3CameraSetLODbias obstr.LODB_camera bias; ); 0;; fun cbEnable(inst, from, action, param, reply, obstr)= SO3CameraSetLODbias obstr.LODB_camera obstr.LODB_fBias; set obstr.LODB_bState = 1; 0;; fun cbDisable(inst, from, action, param, reply, obstr)= SO3CameraSetLODbias obstr.LODB_camera nil; set obstr.LODB_bState = 0; 0;; fun cbChangeCamera(inst, viewstr, sessionstr, camera, obstr)= if (!obstr.LODB_bState) then nil else ( SO3CameraSetLODbias obstr.LODB_camera nil; SO3CameraSetLODbias camera obstr.LODB_fBias; ); set obstr.LODB_camera = camera; 0;; fun newOb(inst)= let (getPluginInstanceParam inst "camera") -> camname in let atof (getPluginInstanceParam inst "bias") -> bias in let if bias == nil then 1.0 else bias -> bias in let atoi (getPluginInstanceParam inst "init") -> init in let V3DgetObjectByName c3dXsession camname -> camera in let mkObjLODbias [inst camera bias init] -> obstr in ( PluginRegisterAction inst "Set LOD bias" mkfun6 @cbSetLODbias obstr; PluginRegisterAction inst "Enable" mkfun6 @cbEnable obstr; PluginRegisterAction inst "Disable" mkfun6 @cbDisable obstr; setPluginInstanceCbCameraChange inst mkfun5 @cbChangeCamera obstr; if !init then nil else SO3CameraSetLODbias obstr.LODB_camera obstr.LODB_fBias; setPluginInstanceCbDel inst mkfun2 @deleteOb obstr; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;