00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://ogre.sourceforge.net/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #ifndef __Controller_H__ 00026 #define __Controller_H__ 00027 00028 #include "OgrePrerequisites.h" 00029 00030 #include "OgreFrameListener.h" 00031 00032 namespace Ogre { 00033 00043 class _OgreExport ControllerFunction 00044 { 00045 protected: 00047 bool mDeltaInput; 00048 Real mDeltaCount; 00049 00052 Real getAdjustedInput(Real input) 00053 { 00054 if (mDeltaInput) 00055 { 00056 mDeltaCount += input; 00057 // Wrap 00058 while (mDeltaCount >= 1.0) 00059 mDeltaCount -= 1.0; 00060 00061 return mDeltaCount; 00062 } 00063 else 00064 { 00065 return input; 00066 } 00067 } 00068 00069 public: 00075 ControllerFunction(bool deltaInput) 00076 { 00077 mDeltaInput = deltaInput; 00078 mDeltaCount = 0; 00079 } 00080 00081 virtual Real calculate(Real sourceValue) = 0; 00082 }; 00083 00084 00087 class _OgreExport ControllerValue 00088 { 00089 00090 public: 00091 virtual Real getValue(void) = 0; 00092 virtual void setValue(Real value) = 0; 00093 00094 }; 00095 00116 class _OgreExport Controller 00117 { 00118 protected: 00120 ControllerValue *mSource; 00122 ControllerValue *mDest; 00124 ControllerFunction* mFunc; 00126 bool mEnabled; 00127 00128 00129 public: 00130 00139 Controller(ControllerValue* src, ControllerValue* dest, ControllerFunction* func); 00140 00143 virtual ~Controller(); 00144 00145 void setSource(ControllerValue* src); 00146 ControllerValue* getSource(void); 00147 void setDestination(ControllerValue* dest); 00148 ControllerValue* getDestination(void); 00149 00151 bool getEnabled(void) const; 00153 void setEnabled(bool enabled); 00154 00155 00158 void setFunction(ControllerFunction* func); 00159 00162 ControllerFunction* getFunction(void); 00163 00164 void update(void); 00165 }; 00166 00167 00168 } 00169 00170 #endif
Copyright © 2002 by The OGRE Team