1 | <html> |
---|
2 | <head> |
---|
3 | <title>OgreAxisAlignedBox.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>OgreAxisAlignedBox.h</h1><a href="OgreAxisAlignedBox_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 __AxisAlignedBox_H_</span> |
---|
35 | 00026 <span class="preprocessor"></span><span class="preprocessor">#define __AxisAlignedBox_H_</span> |
---|
36 | 00027 <span class="preprocessor"></span> |
---|
37 | 00028 <span class="comment">// Precompiler options</span> |
---|
38 | 00029 <span class="preprocessor">#include "<a class="code" href="OgrePrerequisites_8h.html">OgrePrerequisites.h</a>"</span> |
---|
39 | 00030 |
---|
40 | 00031 <span class="preprocessor">#include "<a class="code" href="OgreVector3_8h.html">OgreVector3.h</a>"</span> |
---|
41 | 00032 <span class="preprocessor">#include "<a class="code" href="OgreMatrix4_8h.html">OgreMatrix4.h</a>"</span> |
---|
42 | 00033 |
---|
43 | 00034 <span class="keyword">namespace </span>Ogre { |
---|
44 | 00035 |
---|
45 | <a name="l00045"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html">00045</a> <span class="keyword">class </span><a class="code" href="OgrePlatform_8h.html#a16">_OgreExport</a> AxisAlignedBox |
---|
46 | 00046 { |
---|
47 | 00047 <span class="keyword">protected</span>: |
---|
48 | <a name="l00048"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp0">00048</a> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> mMinimum; |
---|
49 | <a name="l00049"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp1">00049</a> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> mMaximum; |
---|
50 | <a name="l00050"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp2">00050</a> <span class="keywordtype">bool</span> mNull; |
---|
51 | 00051 |
---|
52 | <a name="l00052"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp3">00052</a> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> mCorners[8]; |
---|
53 | 00053 |
---|
54 | <a name="l00056"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxb0">00056</a> <span class="keywordtype">void</span> updateCorners(<span class="keywordtype">void</span>) |
---|
55 | 00057 { |
---|
56 | 00058 <span class="comment">// The order of these items is, using right-handed co-ordinates:</span> |
---|
57 | 00059 <span class="comment">// Minimum Z face, starting with Min(all), then anticlockwise</span> |
---|
58 | 00060 <span class="comment">// around face (looking onto the face)</span> |
---|
59 | 00061 <span class="comment">// Maximum Z face, starting with Max(all), then anticlockwise</span> |
---|
60 | 00062 <span class="comment">// around face (looking onto the face)</span> |
---|
61 | 00063 mCorners[0] = mMinimum; |
---|
62 | 00064 mCorners[1].x = mMinimum.x; mCorners[1].y = mMaximum.y; mCorners[1].z = mMinimum.z; |
---|
63 | 00065 mCorners[2].x = mMaximum.x; mCorners[2].y = mMaximum.y; mCorners[2].z = mMinimum.z; |
---|
64 | 00066 mCorners[3].x = mMaximum.x; mCorners[3].y = mMinimum.y; mCorners[3].z = mMinimum.z; |
---|
65 | 00067 |
---|
66 | 00068 mCorners[4] = mMaximum; |
---|
67 | 00069 mCorners[5].x = mMinimum.x; mCorners[5].y = mMaximum.y; mCorners[5].z = mMaximum.z; |
---|
68 | 00070 mCorners[6].x = mMinimum.x; mCorners[6].y = mMinimum.y; mCorners[6].z = mMaximum.z; |
---|
69 | 00071 mCorners[7].x = mMaximum.x; mCorners[7].y = mMinimum.y; mCorners[7].z = mMaximum.z; |
---|
70 | 00072 } |
---|
71 | 00073 |
---|
72 | 00074 <span class="keyword">public</span>: |
---|
73 | <a name="l00075"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa0">00075</a> <span class="keyword">inline</span> AxisAlignedBox() |
---|
74 | 00076 { |
---|
75 | 00077 <span class="comment">// Default to null box</span> |
---|
76 | 00078 setMinimum( -0.5, -0.5, -0.5 ); |
---|
77 | 00079 setMaximum( 0.5, 0.5, 0.5 ); |
---|
78 | 00080 mNull = <span class="keyword">true</span>; |
---|
79 | 00081 } |
---|
80 | 00082 |
---|
81 | <a name="l00083"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa1">00083</a> <span class="keyword">inline</span> AxisAlignedBox( <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& min, <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& max ) |
---|
82 | 00084 { |
---|
83 | 00085 setExtents( min, max ); |
---|
84 | 00086 } |
---|
85 | 00087 |
---|
86 | <a name="l00088"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa2">00088</a> <span class="keyword">inline</span> AxisAlignedBox( |
---|
87 | 00089 <a class="code" href="namespaceOgre.html#a465">Real</a> mx, <a class="code" href="namespaceOgre.html#a465">Real</a> my, <a class="code" href="namespaceOgre.html#a465">Real</a> mz, |
---|
88 | 00090 <a class="code" href="namespaceOgre.html#a465">Real</a> Mx, <a class="code" href="namespaceOgre.html#a465">Real</a> My, <a class="code" href="namespaceOgre.html#a465">Real</a> Mz ) |
---|
89 | 00091 { |
---|
90 | 00092 setExtents( mx, my, mz, Mx, My, Mz ); |
---|
91 | 00093 } |
---|
92 | 00094 |
---|
93 | <a name="l00097"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa3">00097</a> <span class="keyword">inline</span> <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& getMinimum(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
94 | 00098 <span class="keyword"> </span>{ |
---|
95 | 00099 <span class="keywordflow">return</span> mMinimum; |
---|
96 | 00100 } |
---|
97 | 00101 |
---|
98 | <a name="l00104"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa4">00104</a> <span class="keyword">inline</span> <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& getMaximum(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
99 | 00105 <span class="keyword"> </span>{ |
---|
100 | 00106 <span class="keywordflow">return</span> mMaximum; |
---|
101 | 00107 } |
---|
102 | 00108 |
---|
103 | <a name="l00111"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa5">00111</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> setMinimum( <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& vec ) |
---|
104 | 00112 { |
---|
105 | 00113 mNull = <span class="keyword">false</span>; |
---|
106 | 00114 mMinimum = vec; |
---|
107 | 00115 updateCorners(); |
---|
108 | 00116 } |
---|
109 | 00117 |
---|
110 | <a name="l00118"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa6">00118</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> setMinimum( <a class="code" href="namespaceOgre.html#a465">Real</a> x, <a class="code" href="namespaceOgre.html#a465">Real</a> y, <a class="code" href="namespaceOgre.html#a465">Real</a> z ) |
---|
111 | 00119 { |
---|
112 | 00120 mNull = <span class="keyword">false</span>; |
---|
113 | 00121 mMinimum.x = x; |
---|
114 | 00122 mMinimum.y = y; |
---|
115 | 00123 mMinimum.z = z; |
---|
116 | 00124 updateCorners(); |
---|
117 | 00125 } |
---|
118 | 00126 |
---|
119 | <a name="l00129"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa7">00129</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> setMaximum( <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& vec ) |
---|
120 | 00130 { |
---|
121 | 00131 mNull = <span class="keyword">false</span>; |
---|
122 | 00132 mMaximum = vec; |
---|
123 | 00133 updateCorners(); |
---|
124 | 00134 } |
---|
125 | 00135 |
---|
126 | <a name="l00136"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa8">00136</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> setMaximum( <a class="code" href="namespaceOgre.html#a465">Real</a> x, <a class="code" href="namespaceOgre.html#a465">Real</a> y, <a class="code" href="namespaceOgre.html#a465">Real</a> z ) |
---|
127 | 00137 { |
---|
128 | 00138 mNull = <span class="keyword">false</span>; |
---|
129 | 00139 mMaximum.x = x; |
---|
130 | 00140 mMaximum.y = y; |
---|
131 | 00141 mMaximum.z = z; |
---|
132 | 00142 updateCorners(); |
---|
133 | 00143 } |
---|
134 | 00144 |
---|
135 | <a name="l00147"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa9">00147</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> setExtents( <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& min, <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& max ) |
---|
136 | 00148 { |
---|
137 | 00149 mNull = <span class="keyword">false</span>; |
---|
138 | 00150 mMinimum = min; |
---|
139 | 00151 mMaximum = max; |
---|
140 | 00152 updateCorners(); |
---|
141 | 00153 } |
---|
142 | 00154 |
---|
143 | <a name="l00155"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa10">00155</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> setExtents( |
---|
144 | 00156 <a class="code" href="namespaceOgre.html#a465">Real</a> mx, <a class="code" href="namespaceOgre.html#a465">Real</a> my, <a class="code" href="namespaceOgre.html#a465">Real</a> mz, |
---|
145 | 00157 <a class="code" href="namespaceOgre.html#a465">Real</a> Mx, <a class="code" href="namespaceOgre.html#a465">Real</a> My, <a class="code" href="namespaceOgre.html#a465">Real</a> Mz ) |
---|
146 | 00158 { |
---|
147 | 00159 mNull = <span class="keyword">false</span>; |
---|
148 | 00160 |
---|
149 | 00161 mMinimum.x = mx; |
---|
150 | 00162 mMinimum.y = my; |
---|
151 | 00163 mMinimum.z = mz; |
---|
152 | 00164 |
---|
153 | 00165 mMaximum.x = Mx; |
---|
154 | 00166 mMaximum.y = My; |
---|
155 | 00167 mMaximum.z = Mz; |
---|
156 | 00168 |
---|
157 | 00169 updateCorners(); |
---|
158 | 00170 } |
---|
159 | 00171 |
---|
160 | <a name="l00195"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa11">00195</a> <span class="keyword">inline</span> <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>* getAllCorners(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
161 | 00196 <span class="keyword"> </span>{ |
---|
162 | 00197 assert( !mNull && <span class="stringliteral">"Can't get corners of a null AAB"</span> ); |
---|
163 | 00198 <span class="keywordflow">return</span> (<span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>*)mCorners; |
---|
164 | 00199 } |
---|
165 | 00200 |
---|
166 | <a name="l00201"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxn0">00201</a> <span class="keyword">friend</span> std::ostream& operator<<( std::ostream& o, AxisAlignedBox aab ) |
---|
167 | 00202 { |
---|
168 | 00203 <span class="keywordflow">if</span> (aab.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa16">isNull</a>()) |
---|
169 | 00204 { |
---|
170 | 00205 o << <span class="stringliteral">"AxisAlignedBox(null)"</span>; |
---|
171 | 00206 } |
---|
172 | 00207 <span class="keywordflow">else</span> |
---|
173 | 00208 { |
---|
174 | 00209 o << <span class="stringliteral">"AxisAlignedBox(min="</span> << aab.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp0">mMinimum</a> << <span class="stringliteral">", max="</span> << aab.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp1">mMaximum</a>; |
---|
175 | 00210 o << <span class="stringliteral">", corners="</span>; |
---|
176 | 00211 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < 7; ++i) |
---|
177 | 00212 o << aab.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp3">mCorners</a>[i] << <span class="stringliteral">", "</span>; |
---|
178 | 00213 o << aab.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp3">mCorners</a>[7] << <span class="stringliteral">")"</span>; |
---|
179 | 00214 } |
---|
180 | 00215 <span class="keywordflow">return</span> o; |
---|
181 | 00216 } |
---|
182 | 00217 |
---|
183 | <a name="l00221"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa12">00221</a> <span class="keywordtype">void</span> merge( <span class="keyword">const</span> AxisAlignedBox& rhs ) |
---|
184 | 00222 { |
---|
185 | 00223 <span class="comment">// Do nothing if rhs null</span> |
---|
186 | 00224 <span class="keywordflow">if</span> (rhs.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp2">mNull</a>) |
---|
187 | 00225 { |
---|
188 | 00226 <span class="keywordflow">return</span>; |
---|
189 | 00227 } |
---|
190 | 00228 <span class="comment">// Otherwise if current null, just take rhs</span> |
---|
191 | 00229 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mNull) |
---|
192 | 00230 { |
---|
193 | 00231 setExtents(rhs.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp0">mMinimum</a>, rhs.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp1">mMaximum</a>); |
---|
194 | 00232 } |
---|
195 | 00233 <span class="comment">// Otherwise merge</span> |
---|
196 | 00234 <span class="keywordflow">else</span> |
---|
197 | 00235 { |
---|
198 | 00236 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> min = mMinimum; |
---|
199 | 00237 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> max = mMaximum; |
---|
200 | 00238 max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a37">makeCeil</a>(rhs.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp1">mMaximum</a>); |
---|
201 | 00239 min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a36">makeFloor</a>(rhs.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp0">mMinimum</a>); |
---|
202 | 00240 |
---|
203 | 00241 setExtents(min, max); |
---|
204 | 00242 } |
---|
205 | 00243 |
---|
206 | 00244 } |
---|
207 | 00245 |
---|
208 | <a name="l00248"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa13">00248</a> <span class="keywordtype">void</span> merge( <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& point ) |
---|
209 | 00249 { |
---|
210 | 00250 <span class="keywordflow">if</span> (mNull){ <span class="comment">// if null, use this point</span> |
---|
211 | 00251 setExtents(point, point); |
---|
212 | 00252 } <span class="keywordflow">else</span> { |
---|
213 | 00253 mMaximum.makeCeil(point); |
---|
214 | 00254 mMinimum.makeFloor(point); |
---|
215 | 00255 updateCorners(); |
---|
216 | 00256 } |
---|
217 | 00257 } |
---|
218 | 00258 |
---|
219 | <a name="l00268"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa14">00268</a> <span class="keywordtype">void</span> transform( <span class="keyword">const</span> <a class="code" href="classOgre_1_1Matrix4.html">Matrix4</a>& matrix ) |
---|
220 | 00269 { |
---|
221 | 00270 <span class="comment">// Do nothing if current null</span> |
---|
222 | 00271 <span class="keywordflow">if</span>( mNull ) |
---|
223 | 00272 <span class="keywordflow">return</span>; |
---|
224 | 00273 |
---|
225 | 00274 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> min, max, temp; |
---|
226 | 00275 <span class="keywordtype">bool</span> first = <span class="keyword">true</span>; |
---|
227 | 00276 size_t i; |
---|
228 | 00277 |
---|
229 | 00278 <span class="keywordflow">for</span>( i = 0; i < 8; ++i ) |
---|
230 | 00279 { |
---|
231 | 00280 <span class="comment">// Transform and check extents</span> |
---|
232 | 00281 temp = matrix * mCorners[i]; |
---|
233 | 00282 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> > max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> ) |
---|
234 | 00283 max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
235 | 00284 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> > max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> ) |
---|
236 | 00285 max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
237 | 00286 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> > max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> ) |
---|
238 | 00287 max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
239 | 00288 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> < min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> ) |
---|
240 | 00289 min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
241 | 00290 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> < min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> ) |
---|
242 | 00291 min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
243 | 00292 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> < min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> ) |
---|
244 | 00293 min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
245 | 00294 |
---|
246 | 00295 first = <span class="keyword">false</span>; |
---|
247 | 00296 } |
---|
248 | 00297 |
---|
249 | 00298 setExtents( min,max ); |
---|
250 | 00299 |
---|
251 | 00300 } |
---|
252 | 00301 |
---|
253 | <a name="l00304"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa15">00304</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> setNull() |
---|
254 | 00305 { |
---|
255 | 00306 mNull = <span class="keyword">true</span>; |
---|
256 | 00307 } |
---|
257 | 00308 |
---|
258 | <a name="l00311"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa16">00311</a> <span class="keywordtype">bool</span> isNull(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
259 | 00312 <span class="keyword"> </span>{ |
---|
260 | 00313 <span class="keywordflow">return</span> mNull; |
---|
261 | 00314 } |
---|
262 | 00315 |
---|
263 | <a name="l00317"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa17">00317</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> intersects(<span class="keyword">const</span> AxisAlignedBox& b2)<span class="keyword"> const</span> |
---|
264 | 00318 <span class="keyword"> </span>{ |
---|
265 | 00319 <span class="comment">// Early-fail for nulls</span> |
---|
266 | 00320 <span class="keywordflow">if</span> (this->isNull() || b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa16">isNull</a>()) |
---|
267 | 00321 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
268 | 00322 |
---|
269 | 00323 <span class="comment">// Use up to 6 separating planes</span> |
---|
270 | 00324 <span class="keywordflow">if</span> (mMaximum.x < b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp0">mMinimum</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>) |
---|
271 | 00325 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
272 | 00326 <span class="keywordflow">if</span> (mMaximum.y < b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp0">mMinimum</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>) |
---|
273 | 00327 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
274 | 00328 <span class="keywordflow">if</span> (mMaximum.z < b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp0">mMinimum</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>) |
---|
275 | 00329 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
276 | 00330 |
---|
277 | 00331 <span class="keywordflow">if</span> (mMinimum.x > b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp1">mMaximum</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>) |
---|
278 | 00332 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
279 | 00333 <span class="keywordflow">if</span> (mMinimum.y > b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp1">mMaximum</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>) |
---|
280 | 00334 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
281 | 00335 <span class="keywordflow">if</span> (mMinimum.z > b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp1">mMaximum</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>) |
---|
282 | 00336 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
---|
283 | 00337 |
---|
284 | 00338 <span class="comment">// otherwise, must be intersecting</span> |
---|
285 | 00339 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
---|
286 | 00340 |
---|
287 | 00341 } |
---|
288 | 00342 |
---|
289 | <a name="l00344"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa18">00344</a> <span class="keyword">inline</span> AxisAlignedBox intersection(<span class="keyword">const</span> AxisAlignedBox& b2)<span class="keyword"> const</span> |
---|
290 | 00345 <span class="keyword"> </span>{ |
---|
291 | 00346 <span class="keywordflow">if</span> (!this->intersects(b2)) |
---|
292 | 00347 { |
---|
293 | 00348 <span class="keywordflow">return</span> AxisAlignedBox(); |
---|
294 | 00349 } |
---|
295 | 00350 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> intMin, intMax; |
---|
296 | 00351 |
---|
297 | 00352 <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& b2max = b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa4">getMaximum</a>(); |
---|
298 | 00353 <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& b2min = b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa3">getMinimum</a>(); |
---|
299 | 00354 |
---|
300 | 00355 <span class="keywordflow">if</span> (b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> > mMaximum.x && mMaximum.x > b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>) |
---|
301 | 00356 intMax.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = mMaximum.x; |
---|
302 | 00357 <span class="keywordflow">else</span> |
---|
303 | 00358 intMax.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
304 | 00359 <span class="keywordflow">if</span> (b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> > mMaximum.y && mMaximum.y > b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>) |
---|
305 | 00360 intMax.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = mMaximum.y; |
---|
306 | 00361 <span class="keywordflow">else</span> |
---|
307 | 00362 intMax.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
308 | 00363 <span class="keywordflow">if</span> (b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> > mMaximum.z && mMaximum.z > b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>) |
---|
309 | 00364 intMax.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = mMaximum.z; |
---|
310 | 00365 <span class="keywordflow">else</span> |
---|
311 | 00366 intMax.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
312 | 00367 |
---|
313 | 00368 <span class="keywordflow">if</span> (b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> < mMinimum.x && mMinimum.x < b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>) |
---|
314 | 00369 intMin.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = mMinimum.x; |
---|
315 | 00370 <span class="keywordflow">else</span> |
---|
316 | 00371 intMin.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>= b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>; |
---|
317 | 00372 <span class="keywordflow">if</span> (b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> < mMinimum.y && mMinimum.y < b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>) |
---|
318 | 00373 intMin.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = mMinimum.y; |
---|
319 | 00374 <span class="keywordflow">else</span> |
---|
320 | 00375 intMin.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>= b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>; |
---|
321 | 00376 <span class="keywordflow">if</span> (b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> < mMinimum.z && mMinimum.z < b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>) |
---|
322 | 00377 intMin.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = mMinimum.z; |
---|
323 | 00378 <span class="keywordflow">else</span> |
---|
324 | 00379 intMin.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>= b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
325 | 00380 |
---|
326 | 00381 <span class="keywordflow">return</span> AxisAlignedBox(intMin, intMax); |
---|
327 | 00382 |
---|
328 | 00383 } |
---|
329 | 00384 |
---|
330 | <a name="l00386"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa19">00386</a> <a class="code" href="namespaceOgre.html#a465">Real</a> volume(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
331 | 00387 <span class="keyword"> </span>{ |
---|
332 | 00388 <span class="keywordflow">if</span> (mNull) |
---|
333 | 00389 { |
---|
334 | 00390 <span class="keywordflow">return</span> 0.0f; |
---|
335 | 00391 } |
---|
336 | 00392 <span class="keywordflow">else</span> |
---|
337 | 00393 { |
---|
338 | 00394 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> diff = mMaximum - mMinimum; |
---|
339 | 00395 <span class="keywordflow">return</span> diff.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> * diff.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> * diff.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>; |
---|
340 | 00396 } |
---|
341 | 00397 |
---|
342 | 00398 } |
---|
343 | 00399 |
---|
344 | <a name="l00401"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa20">00401</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> scale(<span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& s) |
---|
345 | 00402 { |
---|
346 | 00403 <span class="comment">// NB assumes centered on origin</span> |
---|
347 | 00404 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> min = mMinimum * s; |
---|
348 | 00405 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> max = mMaximum * s; |
---|
349 | 00406 setExtents(min, max); |
---|
350 | 00407 } |
---|
351 | 00408 |
---|
352 | <a name="l00410"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa21">00410</a> <span class="keywordtype">bool</span> intersects(<span class="keyword">const</span> <a class="code" href="classOgre_1_1Sphere.html">Sphere</a>& s)<span class="keyword"> const</span> |
---|
353 | 00411 <span class="keyword"> </span>{ |
---|
354 | 00412 <span class="keywordflow">return</span> Math::intersects(s, *<span class="keyword">this</span>); |
---|
355 | 00413 } |
---|
356 | <a name="l00415"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa22">00415</a> <span class="keywordtype">bool</span> intersects(<span class="keyword">const</span> <a class="code" href="classOgre_1_1Plane.html">Plane</a>& p)<span class="keyword"> const</span> |
---|
357 | 00416 <span class="keyword"> </span>{ |
---|
358 | 00417 <span class="keywordflow">return</span> Math::intersects(p, *<span class="keyword">this</span>); |
---|
359 | 00418 } |
---|
360 | <a name="l00420"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa23">00420</a> <span class="keywordtype">bool</span> intersects(<span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& v)<span class="keyword"> const</span> |
---|
361 | 00421 <span class="keyword"> </span>{ |
---|
362 | 00422 <span class="keywordflow">return</span>(v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> >= mMinimum.x && v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> <= mMaximum.x && |
---|
363 | 00423 v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> >= mMinimum.y && v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> <= mMaximum.y && |
---|
364 | 00424 v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> >= mMinimum.z && v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> <= mMaximum.z); |
---|
365 | 00425 } |
---|
366 | <a name="l00427"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa24">00427</a> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> getCenter(<span class="keywordtype">void</span>)<span class="keyword"> const</span> |
---|
367 | 00428 <span class="keyword"> </span>{ |
---|
368 | 00429 <span class="keywordflow">return</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>((mMaximum + mMinimum) * 0.5); |
---|
369 | 00430 } |
---|
370 | 00431 |
---|
371 | 00432 |
---|
372 | 00433 }; |
---|
373 | 00434 |
---|
374 | 00435 } <span class="comment">// namespace Ogre</span> |
---|
375 | 00436 |
---|
376 | 00437 <span class="preprocessor">#endif</span> |
---|
377 | </pre></div><hr> |
---|
378 | <p> |
---|
379 | Copyright © 2000-2005 by The OGRE Team<br /> |
---|
380 | <!--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/> |
---|
381 | 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/> |
---|
382 | <!--/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#"> |
---|
383 | <Work rdf:about=""> |
---|
384 | <license rdf:resource="http://creativecommons.org/licenses/by-sa/2.5/" /> |
---|
385 | <dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" /> |
---|
386 | </Work> |
---|
387 | <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> --> |
---|
388 | |
---|
389 | Last modified Sun Mar 12 14:37:37 2006 |
---|
390 | </p> |
---|
391 | </body> |
---|
392 | </html> |
---|