/* ----------------------------------------------------------------------------- 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 -> [camera fov near far] in ( V3DchangeCameraViewport c3dXsession (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) (V3DgetDefaultCamera c3dXsession); SO3CameraSetFOVy camera fov; SO3CameraSetNearClipDistance camera near; SO3CameraSetFarClipDistance camera far; ); 0;; fun cbSetCamera(inst, from, action, param, rep, camera) = V3DchangeCameraViewport c3dXsession (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) camera; SendPluginEvent inst "Activated" param nil; 0;; fun cbRestaureCamera(inst, from, action, param, rep) = V3DchangeCameraViewport c3dXsession (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) (V3DgetDefaultCamera c3dXsession); SendPluginEvent inst "Deactivated" param nil; 0;; fun cbInitPlugs(inst, camera)= cbSetCamera inst nil nil nil nil camera; 0;; fun cbCameraFov(inst, from, action, param, reply, camera)= if ((atof param) == nil) then nil else ( SO3CameraSetFOVy camera SO3MathsDegreeToRadian (atof param); ); 0;; fun cbCameraClipping(inst, from, action, param, reply, camera)= if ((atof param) == nil) then nil else let hd strextr param -> l in let atof (hd l) -> near in let atof (hd tl l) -> far in ( SO3CameraSetNearClipDistance camera near; SO3CameraSetFarClipDistance camera far; ); 0;; fun newOb(inst)= let (getPluginInstanceParam inst "camera") -> camname in let atoi (getPluginInstanceParam inst "init") -> init in let V3DgetObjectByName c3dXsession camname -> camera in let SO3CameraGetNearClipDistance camera -> near in let SO3CameraGetFarClipDistance camera -> far in let SO3CameraGetFOVy camera -> fov in ( PluginRegisterAction inst "SetCamera" mkfun6 @cbSetCamera camera; PluginRegisterAction inst "RestaureCamera" @cbRestaureCamera; PluginRegisterAction inst "Set camera FOV" mkfun6 @cbCameraFov camera; PluginRegisterAction inst "Set camera clipping" mkfun6 @cbCameraClipping camera; if !init then nil else if inst.INST_groupstr.GRP_project.PRJ_bPluginsLoaded then ( cbSetCamera inst nil nil nil nil camera; 0; ) else ( setPluginInstanceCbAllPluginsLoaded inst mkfun2 @cbInitPlugs camera; 0; ); setPluginInstanceCbDel inst mkfun2 @deleteOb [camera fov near far]; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;