[692] | 1 | <html> |
---|
| 2 | <head> |
---|
| 3 | <title>OgreController.h Source File - OGRE Documentation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
| 4 | <link type="text/css" rel="stylesheet" href="style.css"> |
---|
| 5 | </head> |
---|
| 6 | |
---|
| 7 | <body> |
---|
| 8 | <!-- Generated by Doxygen 1.3.6 --> |
---|
| 9 | <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div> |
---|
| 10 | <h1>OgreController.h</h1><a href="OgreController_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*</span> |
---|
| 11 | 00002 <span class="comment">-----------------------------------------------------------------------------</span> |
---|
| 12 | 00003 <span class="comment">This source file is part of OGRE</span> |
---|
| 13 | 00004 <span class="comment"> (Object-oriented Graphics Rendering Engine)</span> |
---|
| 14 | 00005 <span class="comment">For the latest info, see http://www.ogre3d.org/</span> |
---|
| 15 | 00006 <span class="comment"></span> |
---|
| 16 | 00007 <span class="comment">Copyright (c) 2000-2005 The OGRE Team</span> |
---|
| 17 | 00008 <span class="comment">Also see acknowledgements in Readme.html</span> |
---|
| 18 | 00009 <span class="comment"></span> |
---|
| 19 | 00010 <span class="comment">This program is free software; you can redistribute it and/or modify it under</span> |
---|
| 20 | 00011 <span class="comment">the terms of the GNU Lesser General Public License as published by the Free Software</span> |
---|
| 21 | 00012 <span class="comment">Foundation; either version 2 of the License, or (at your option) any later</span> |
---|
| 22 | 00013 <span class="comment">version.</span> |
---|
| 23 | 00014 <span class="comment"></span> |
---|
| 24 | 00015 <span class="comment">This program is distributed in the hope that it will be useful, but WITHOUT</span> |
---|
| 25 | 00016 <span class="comment">ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</span> |
---|
| 26 | 00017 <span class="comment">FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</span> |
---|
| 27 | 00018 <span class="comment"></span> |
---|
| 28 | 00019 <span class="comment">You should have received a copy of the GNU Lesser General Public License along with</span> |
---|
| 29 | 00020 <span class="comment">this program; if not, write to the Free Software Foundation, Inc., 59 Temple</span> |
---|
| 30 | 00021 <span class="comment">Place - Suite 330, Boston, MA 02111-1307, USA, or go to</span> |
---|
| 31 | 00022 <span class="comment">http://www.gnu.org/copyleft/lesser.txt.</span> |
---|
| 32 | 00023 <span class="comment">-----------------------------------------------------------------------------</span> |
---|
| 33 | 00024 <span class="comment">*/</span> |
---|
| 34 | 00025 <span class="preprocessor">#ifndef __Controller_H__</span> |
---|
| 35 | 00026 <span class="preprocessor"></span><span class="preprocessor">#define __Controller_H__</span> |
---|
| 36 | 00027 <span class="preprocessor"></span> |
---|
| 37 | 00028 <span class="preprocessor">#include "<a class="code" href="OgrePrerequisites_8h.html">OgrePrerequisites.h</a>"</span> |
---|
| 38 | 00029 |
---|
| 39 | 00030 <span class="preprocessor">#include "<a class="code" href="OgreSharedPtr_8h.html">OgreSharedPtr.h</a>"</span> |
---|
| 40 | 00031 |
---|
| 41 | 00032 <span class="keyword">namespace </span>Ogre { |
---|
| 42 | 00033 |
---|
| 43 | 00034 |
---|
| 44 | 00035 |
---|
| 45 | 00036 |
---|
| 46 | 00046 <span class="keyword">template</span> <<span class="keyword">typename</span> T> |
---|
| 47 | <a name="l00047"></a><a class="code" href="classOgre_1_1ControllerFunction.html">00047</a> <span class="keyword">class </span><a class="code" href="classOgre_1_1ControllerFunction.html">ControllerFunction</a> |
---|
| 48 | 00048 { |
---|
| 49 | 00049 <span class="keyword">protected</span>: |
---|
| 50 | <a name="l00051"></a><a class="code" href="classOgre_1_1ControllerFunction.html#Ogre_1_1ControllerFunctionp0">00051</a> <span class="keywordtype">bool</span> mDeltaInput; |
---|
| 51 | <a name="l00052"></a><a class="code" href="classOgre_1_1ControllerFunction.html#Ogre_1_1ControllerFunctionp1">00052</a> T mDeltaCount; |
---|
| 52 | 00053 |
---|
| 53 | <a name="l00056"></a><a class="code" href="classOgre_1_1ControllerFunction.html#Ogre_1_1ControllerFunctionb0">00056</a> T <a class="code" href="classOgre_1_1ControllerFunction.html#Ogre_1_1ControllerFunctionb0">getAdjustedInput</a>(T input) |
---|
| 54 | 00057 { |
---|
| 55 | 00058 <span class="keywordflow">if</span> (mDeltaInput) |
---|
| 56 | 00059 { |
---|
| 57 | 00060 mDeltaCount += input; |
---|
| 58 | 00061 <span class="comment">// Wrap</span> |
---|
| 59 | 00062 <span class="keywordflow">while</span> (mDeltaCount >= 1.0) |
---|
| 60 | 00063 mDeltaCount -= 1.0; |
---|
| 61 | 00064 <span class="keywordflow">while</span> (mDeltaCount < 0.0) |
---|
| 62 | 00065 mDeltaCount += 1.0; |
---|
| 63 | 00066 |
---|
| 64 | 00067 <span class="keywordflow">return</span> mDeltaCount; |
---|
| 65 | 00068 } |
---|
| 66 | 00069 <span class="keywordflow">else</span> |
---|
| 67 | 00070 { |
---|
| 68 | 00071 <span class="keywordflow">return</span> input; |
---|
| 69 | 00072 } |
---|
| 70 | 00073 } |
---|
| 71 | 00074 |
---|
| 72 | 00075 <span class="keyword">public</span>: |
---|
| 73 | <a name="l00081"></a><a class="code" href="classOgre_1_1ControllerFunction.html#Ogre_1_1ControllerFunctiona0">00081</a> <a class="code" href="classOgre_1_1ControllerFunction.html#Ogre_1_1ControllerFunctiona0">ControllerFunction</a>(<span class="keywordtype">bool</span> deltaInput) |
---|
| 74 | 00082 { |
---|
| 75 | 00083 mDeltaInput = deltaInput; |
---|
| 76 | 00084 mDeltaCount = 0; |
---|
| 77 | 00085 } |
---|
| 78 | 00086 |
---|
| 79 | <a name="l00087"></a><a class="code" href="classOgre_1_1ControllerFunction.html#Ogre_1_1ControllerFunctiona1">00087</a> <span class="keyword">virtual</span> <a class="code" href="classOgre_1_1ControllerFunction.html#Ogre_1_1ControllerFunctiona1">~ControllerFunction</a>() {} |
---|
| 80 | 00088 |
---|
| 81 | 00089 <span class="keyword">virtual</span> T <a class="code" href="classOgre_1_1ControllerFunction.html#Ogre_1_1ControllerFunctiona2">calculate</a>(T sourceValue) = 0; |
---|
| 82 | 00090 }; |
---|
| 83 | 00091 |
---|
| 84 | 00092 |
---|
| 85 | 00095 <span class="keyword">template</span> <<span class="keyword">typename</span> T> |
---|
| 86 | <a name="l00096"></a><a class="code" href="classOgre_1_1ControllerValue.html">00096</a> <span class="keyword">class </span><a class="code" href="classOgre_1_1ControllerValue.html">ControllerValue</a> |
---|
| 87 | 00097 { |
---|
| 88 | 00098 |
---|
| 89 | 00099 <span class="keyword">public</span>: |
---|
| 90 | <a name="l00100"></a><a class="code" href="classOgre_1_1ControllerValue.html#Ogre_1_1ControllerValuea0">00100</a> <span class="keyword">virtual</span> <a class="code" href="classOgre_1_1ControllerValue.html#Ogre_1_1ControllerValuea0">~ControllerValue</a>() { } |
---|
| 91 | 00101 <span class="keyword">virtual</span> T <a class="code" href="classOgre_1_1ControllerValue.html#Ogre_1_1ControllerValuea1">getValue</a>(<span class="keywordtype">void</span>) <span class="keyword">const</span> = 0; |
---|
| 92 | 00102 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classOgre_1_1ControllerValue.html#Ogre_1_1ControllerValuea2">setValue</a>(T value) = 0; |
---|
| 93 | 00103 |
---|
| 94 | 00104 }; |
---|
| 95 | 00105 |
---|
| 96 | 00126 <span class="keyword">template</span> <<span class="keyword">typename</span> T> |
---|
| 97 | <a name="l00127"></a><a class="code" href="classOgre_1_1Controller.html">00127</a> <span class="keyword">class </span><a class="code" href="classOgre_1_1Controller.html">Controller</a> |
---|
| 98 | 00128 { |
---|
| 99 | 00129 <span class="keyword">protected</span>: |
---|
| 100 | <a name="l00131"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllerp0">00131</a> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr< ControllerValue<T></a> > mSource; |
---|
| 101 | <a name="l00133"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllerp1">00133</a> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr< ControllerValue<T></a> > mDest; |
---|
| 102 | <a name="l00135"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllerp2">00135</a> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr< ControllerFunction<T></a> > mFunc; |
---|
| 103 | <a name="l00137"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllerp3">00137</a> <span class="keywordtype">bool</span> mEnabled; |
---|
| 104 | 00138 |
---|
| 105 | 00139 |
---|
| 106 | 00140 <span class="keyword">public</span>: |
---|
| 107 | 00141 |
---|
| 108 | <a name="l00147"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera0">00147</a> <a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera0">Controller</a>(<span class="keyword">const</span> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr</a>< <a class="code" href="classOgre_1_1ControllerValue.html">ControllerValue<T></a> >& src, |
---|
| 109 | 00148 <span class="keyword">const</span> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr</a>< <a class="code" href="classOgre_1_1ControllerValue.html">ControllerValue<T></a> >& dest, <span class="keyword">const</span> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr</a>< <a class="code" href="classOgre_1_1ControllerFunction.html">ControllerFunction<T></a> >& func) |
---|
| 110 | 00149 : mSource(src), mDest(dest), mFunc(func) |
---|
| 111 | 00150 { |
---|
| 112 | 00151 mEnabled = <span class="keyword">true</span>; |
---|
| 113 | 00152 } |
---|
| 114 | 00153 |
---|
| 115 | <a name="l00156"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera1">00156</a> <span class="keyword">virtual</span> <a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera1">~Controller</a>() {} |
---|
| 116 | 00157 |
---|
| 117 | 00158 |
---|
| 118 | <a name="l00160"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera2">00160</a> <span class="keywordtype">void</span> <a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera2">setSource</a>(<span class="keyword">const</span> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr</a>< <a class="code" href="classOgre_1_1ControllerValue.html">ControllerValue<T></a> >& src) |
---|
| 119 | 00161 { |
---|
| 120 | 00162 mSource = src; |
---|
| 121 | 00163 } |
---|
| 122 | <a name="l00165"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera3">00165</a> <span class="keyword">const</span> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr< ControllerValue<T></a> >& <a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera3">getSource</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
| 123 | 00166 <span class="keyword"> </span>{ |
---|
| 124 | 00167 <span class="keywordflow">return</span> mSource; |
---|
| 125 | 00168 } |
---|
| 126 | <a name="l00170"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera4">00170</a> <span class="keywordtype">void</span> <a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera4">setDestination</a>(<span class="keyword">const</span> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr</a>< <a class="code" href="classOgre_1_1ControllerValue.html">ControllerValue<T></a> >& dest) |
---|
| 127 | 00171 { |
---|
| 128 | 00172 mDest = dest; |
---|
| 129 | 00173 } |
---|
| 130 | 00174 |
---|
| 131 | <a name="l00176"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera5">00176</a> <span class="keyword">const</span> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr< ControllerValue<T></a> >& <a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera5">getDestination</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
| 132 | 00177 <span class="keyword"> </span>{ |
---|
| 133 | 00178 <span class="keywordflow">return</span> mDest; |
---|
| 134 | 00179 } |
---|
| 135 | 00180 |
---|
| 136 | <a name="l00182"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera6">00182</a> <span class="keywordtype">bool</span> <a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera6">getEnabled</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
| 137 | 00183 <span class="keyword"> </span>{ |
---|
| 138 | 00184 <span class="keywordflow">return</span> mEnabled; |
---|
| 139 | 00185 } |
---|
| 140 | 00186 |
---|
| 141 | <a name="l00188"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera7">00188</a> <span class="keywordtype">void</span> <a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera7">setEnabled</a>(<span class="keywordtype">bool</span> enabled) |
---|
| 142 | 00189 { |
---|
| 143 | 00190 mEnabled = enabled; |
---|
| 144 | 00191 } |
---|
| 145 | 00192 |
---|
| 146 | <a name="l00195"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera8">00195</a> <span class="keywordtype">void</span> <a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera8">setFunction</a>(<span class="keyword">const</span> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr</a>< <a class="code" href="classOgre_1_1ControllerFunction.html">ControllerFunction<T></a> >& func) |
---|
| 147 | 00196 { |
---|
| 148 | 00197 mFunc = func; |
---|
| 149 | 00198 } |
---|
| 150 | 00199 |
---|
| 151 | <a name="l00202"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera9">00202</a> <span class="keyword">const</span> <a class="code" href="classOgre_1_1SharedPtr.html">SharedPtr< ControllerFunction<T></a> >& <a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera9">getFunction</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
| 152 | 00203 <span class="keyword"> </span>{ |
---|
| 153 | 00204 <span class="keywordflow">return</span> mFunc; |
---|
| 154 | 00205 } |
---|
| 155 | 00206 |
---|
| 156 | <a name="l00212"></a><a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera10">00212</a> <span class="keywordtype">void</span> <a class="code" href="classOgre_1_1Controller.html#Ogre_1_1Controllera10">update</a>(<span class="keywordtype">void</span>) |
---|
| 157 | 00213 { |
---|
| 158 | 00214 <span class="keywordflow">if</span>(mEnabled) |
---|
| 159 | 00215 mDest->setValue(mFunc->calculate(mSource->getValue())); |
---|
| 160 | 00216 } |
---|
| 161 | 00217 |
---|
| 162 | 00218 }; |
---|
| 163 | 00219 |
---|
| 164 | 00220 |
---|
| 165 | 00221 } |
---|
| 166 | 00222 |
---|
| 167 | 00223 <span class="preprocessor">#endif</span> |
---|
| 168 | </pre></div><hr> |
---|
| 169 | <p> |
---|
| 170 | Copyright © 2000-2005 by The OGRE Team<br /> |
---|
| 171 | <!--Creative Commons License--><a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.png"/></a><br/> |
---|
| 172 | This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/">Creative Commons Attribution-ShareAlike 2.5 License</a>.<br/> |
---|
| 173 | <!--/Creative Commons License--><!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> |
---|
| 174 | <Work rdf:about=""> |
---|
| 175 | <license rdf:resource="http://creativecommons.org/licenses/by-sa/2.5/" /> |
---|
| 176 | <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" /> |
---|
| 177 | </Work> |
---|
| 178 | <License rdf:about="http://creativecommons.org/licenses/by-sa/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/><permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/><requires rdf:resource="http://web.resource.org/cc/Attribution"/><permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/><requires rdf:resource="http://web.resource.org/cc/ShareAlike"/></License></rdf:RDF> --> |
---|
| 179 | |
---|
| 180 | Last modified Sun Mar 12 14:37:39 2006 |
---|
| 181 | </p> |
---|
| 182 | </body> |
---|
| 183 | </html> |
---|