source: OGRE/trunk/ogrenew/Docs/api/html/OgreAxisAlignedBox_8h-source.html @ 657

Revision 657, 34.6 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
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&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;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>
1100002 <span class="comment">-----------------------------------------------------------------------------</span>
1200003 <span class="comment">This source file is part of OGRE</span>
1300004 <span class="comment">    (Object-oriented Graphics Rendering Engine)</span>
1400005 <span class="comment">For the latest info, see http://www.ogre3d.org/</span>
1500006 <span class="comment"></span>
1600007 <span class="comment">Copyright (c) 2000-2005 The OGRE Team</span>
1700008 <span class="comment">Also see acknowledgements in Readme.html</span>
1800009 <span class="comment"></span>
1900010 <span class="comment">This program is free software; you can redistribute it and/or modify it under</span>
2000011 <span class="comment">the terms of the GNU Lesser General Public License as published by the Free Software</span>
2100012 <span class="comment">Foundation; either version 2 of the License, or (at your option) any later</span>
2200013 <span class="comment">version.</span>
2300014 <span class="comment"></span>
2400015 <span class="comment">This program is distributed in the hope that it will be useful, but WITHOUT</span>
2500016 <span class="comment">ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</span>
2600017 <span class="comment">FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</span>
2700018 <span class="comment"></span>
2800019 <span class="comment">You should have received a copy of the GNU Lesser General Public License along with</span>
2900020 <span class="comment">this program; if not, write to the Free Software Foundation, Inc., 59 Temple</span>
3000021 <span class="comment">Place - Suite 330, Boston, MA 02111-1307, USA, or go to</span>
3100022 <span class="comment">http://www.gnu.org/copyleft/lesser.txt.</span>
3200023 <span class="comment">-----------------------------------------------------------------------------</span>
3300024 <span class="comment">*/</span>
3400025 <span class="preprocessor">#ifndef __AxisAlignedBox_H_</span>
3500026 <span class="preprocessor"></span><span class="preprocessor">#define __AxisAlignedBox_H_</span>
3600027 <span class="preprocessor"></span>
3700028 <span class="comment">// Precompiler options</span>
3800029 <span class="preprocessor">#include "<a class="code" href="OgrePrerequisites_8h.html">OgrePrerequisites.h</a>"</span>
3900030
4000031 <span class="preprocessor">#include "<a class="code" href="OgreVector3_8h.html">OgreVector3.h</a>"</span>
4100032 <span class="preprocessor">#include "<a class="code" href="OgreMatrix4_8h.html">OgreMatrix4.h</a>"</span>
4200033
4300034 <span class="keyword">namespace </span>Ogre {
4400035
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
4600046     {
4700047     <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;
5100051
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];
5300053
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>)
5500057         {
5600058             <span class="comment">// The order of these items is, using right-handed co-ordinates:</span>
5700059             <span class="comment">// Minimum Z face, starting with Min(all), then anticlockwise</span>
5800060             <span class="comment">//   around face (looking onto the face)</span>
5900061             <span class="comment">// Maximum Z face, starting with Max(all), then anticlockwise</span>
6000062             <span class="comment">//   around face (looking onto the face)</span>
6100063             mCorners[0] = mMinimum;
6200064             mCorners[1].x = mMinimum.x; mCorners[1].y = mMaximum.y; mCorners[1].z = mMinimum.z;
6300065             mCorners[2].x = mMaximum.x; mCorners[2].y = mMaximum.y; mCorners[2].z = mMinimum.z;
6400066             mCorners[3].x = mMaximum.x; mCorners[3].y = mMinimum.y; mCorners[3].z = mMinimum.z;           
6500067
6600068             mCorners[4] = mMaximum;
6700069             mCorners[5].x = mMinimum.x; mCorners[5].y = mMaximum.y; mCorners[5].z = mMaximum.z;
6800070             mCorners[6].x = mMinimum.x; mCorners[6].y = mMinimum.y; mCorners[6].z = mMaximum.z;
6900071             mCorners[7].x = mMaximum.x; mCorners[7].y = mMinimum.y; mCorners[7].z = mMaximum.z;           
7000072         }       
7100073
7200074     <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()
7400076         {
7500077             <span class="comment">// Default to null box</span>
7600078             setMinimum( -0.5, -0.5, -0.5 );
7700079             setMaximum( 0.5, 0.5, 0.5 );
7800080             mNull = <span class="keyword">true</span>;
7900081         }
8000082
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>&amp; min, <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>&amp; max )
8200084         {
8300085             setExtents( min, max );
8400086         }
8500087
86<a name="l00088"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa2">00088</a>         <span class="keyword">inline</span> AxisAlignedBox(
8700089             <a class="code" href="namespaceOgre.html#a420">Real</a> mx, <a class="code" href="namespaceOgre.html#a420">Real</a> my, <a class="code" href="namespaceOgre.html#a420">Real</a> mz,
8800090             <a class="code" href="namespaceOgre.html#a420">Real</a> Mx, <a class="code" href="namespaceOgre.html#a420">Real</a> My, <a class="code" href="namespaceOgre.html#a420">Real</a> Mz )
8900091         {
9000092             setExtents( mx, my, mz, Mx, My, Mz );
9100093         }
9200094
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>&amp; getMinimum(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
9400098 <span class="keyword">        </span>{
9500099             <span class="keywordflow">return</span> mMinimum;
9600100         }
9700101
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>&amp; getMaximum(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
9900105 <span class="keyword">        </span>{
10000106             <span class="keywordflow">return</span> mMaximum;
10100107         }
10200108
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>&amp; vec )
10400112         {
10500113             mNull = <span class="keyword">false</span>;
10600114             mMinimum = vec;
10700115             updateCorners();
10800116         }
10900117
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#a420">Real</a> x, <a class="code" href="namespaceOgre.html#a420">Real</a> y, <a class="code" href="namespaceOgre.html#a420">Real</a> z )
11100119         {
11200120             mNull = <span class="keyword">false</span>;
11300121             mMinimum.x = x;
11400122             mMinimum.y = y;
11500123             mMinimum.z = z;
11600124             updateCorners();
11700125         }
11800126
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>&amp; vec )
12000130         {
12100131             mNull = <span class="keyword">false</span>;
12200132             mMaximum = vec;
12300133             updateCorners();
12400134         }
12500135
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#a420">Real</a> x, <a class="code" href="namespaceOgre.html#a420">Real</a> y, <a class="code" href="namespaceOgre.html#a420">Real</a> z )
12700137         {
12800138             mNull = <span class="keyword">false</span>;
12900139             mMaximum.x = x;
13000140             mMaximum.y = y;
13100141             mMaximum.z = z;
13200142             updateCorners();
13300143         }
13400144
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>&amp; min, <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>&amp; max )
13600148         {
13700149             mNull = <span class="keyword">false</span>;
13800150             mMinimum = min;
13900151             mMaximum = max;
14000152             updateCorners();
14100153         }
14200154
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(
14400156             <a class="code" href="namespaceOgre.html#a420">Real</a> mx, <a class="code" href="namespaceOgre.html#a420">Real</a> my, <a class="code" href="namespaceOgre.html#a420">Real</a> mz,
14500157             <a class="code" href="namespaceOgre.html#a420">Real</a> Mx, <a class="code" href="namespaceOgre.html#a420">Real</a> My, <a class="code" href="namespaceOgre.html#a420">Real</a> Mz )
14600158         {
14700159             mNull = <span class="keyword">false</span>;
14800160
14900161             mMinimum.x = mx;
15000162             mMinimum.y = my;
15100163             mMinimum.z = mz;
15200164
15300165             mMaximum.x = Mx;
15400166             mMaximum.y = My;
15500167             mMaximum.z = Mz;
15600168
15700169             updateCorners();
15800170         }
15900171
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>
16100196 <span class="keyword">        </span>{
16200197             assert( !mNull &amp;&amp; <span class="stringliteral">"Can't get corners of a null AAB"</span> );
16300198             <span class="keywordflow">return</span> (<span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>*)mCorners;
16400199         }
16500200
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&amp; operator&lt;&lt;( std::ostream&amp; o, AxisAlignedBox aab )
16700202         {
16800203             <span class="keywordflow">if</span> (aab.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa16">isNull</a>())
16900204             {
17000205                 o &lt;&lt; <span class="stringliteral">"AxisAlignedBox(null)"</span>;
17100206             }
17200207             <span class="keywordflow">else</span>
17300208             {
17400209                 o &lt;&lt; <span class="stringliteral">"AxisAlignedBox(min="</span> &lt;&lt; aab.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp0">mMinimum</a> &lt;&lt; <span class="stringliteral">", max="</span> &lt;&lt; aab.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp1">mMaximum</a>;
17500210                 o &lt;&lt; <span class="stringliteral">", corners="</span>;
17600211                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 7; ++i)
17700212                     o &lt;&lt; aab.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp3">mCorners</a>[i] &lt;&lt; <span class="stringliteral">", "</span>;
17800213                 o &lt;&lt; aab.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp3">mCorners</a>[7] &lt;&lt; <span class="stringliteral">")"</span>;
17900214             }
18000215             <span class="keywordflow">return</span> o;
18100216         }
18200217
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&amp; rhs )
18400222         {
18500223             <span class="comment">// Do nothing if rhs null</span>
18600224             <span class="keywordflow">if</span> (rhs.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp2">mNull</a>)
18700225             {
18800226                 <span class="keywordflow">return</span>;
18900227             }
19000228             <span class="comment">// Otherwise if current null, just take rhs</span>
19100229             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mNull)
19200230             {
19300231                 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>);
19400232             }
19500233             <span class="comment">// Otherwise merge</span>
19600234             <span class="keywordflow">else</span>
19700235             {
19800236                 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> min = mMinimum;
19900237                 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> max = mMaximum;
20000238                 max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a33">makeCeil</a>(rhs.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp1">mMaximum</a>);
20100239                 min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a32">makeFloor</a>(rhs.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxp0">mMinimum</a>);
20200240
20300241                 setExtents(min, max);
20400242             }
20500243
20600244         }
20700245         
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>&amp; point )
20900249         {
21000250             <span class="keywordflow">if</span> (mNull){ <span class="comment">// if null, use this point</span>
21100251                 setExtents(point, point);
21200252             } <span class="keywordflow">else</span> {
21300253                 mMaximum.makeCeil(point);
21400254                 mMinimum.makeFloor(point);
21500255                 updateCorners();
21600256             }
21700257         }
21800258
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>&amp; matrix )
22000269         {
22100270             <span class="comment">// Do nothing if current null</span>
22200271             <span class="keywordflow">if</span>( mNull )
22300272                 <span class="keywordflow">return</span>;
22400273
22500274             <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> min, max, temp;
22600275             <span class="keywordtype">bool</span> first = <span class="keyword">true</span>;
22700276             size_t i;
22800277
22900278             <span class="keywordflow">for</span>( i = 0; i &lt; 8; ++i )
23000279             {
23100280                 <span class="comment">// Transform and check extents</span>
23200281                 temp = matrix * mCorners[i];
23300282                 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> &gt; max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> )
23400283                     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>;
23500284                 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> &gt; max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> )
23600285                     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>;
23700286                 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> &gt; max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> )
23800287                     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>;
23900288                 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> &lt; min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> )
24000289                     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>;
24100290                 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> &lt; min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> )
24200291                     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>;
24300292                 <span class="keywordflow">if</span>( first || temp.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> &lt; min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> )
24400293                     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>;
24500294
24600295                 first = <span class="keyword">false</span>;
24700296             }
24800297
24900298             setExtents( min,max );
25000299
25100300         }
25200301
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()
25400305         {
25500306             mNull = <span class="keyword">true</span>;
25600307         }
25700308
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>
25900312 <span class="keyword">        </span>{
26000313             <span class="keywordflow">return</span> mNull;
26100314         }
26200315
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&amp; b2)<span class="keyword"> const</span>
26400318 <span class="keyword">        </span>{
26500319             <span class="comment">// Early-fail for nulls</span>
26600320             <span class="keywordflow">if</span> (this-&gt;isNull() || b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa16">isNull</a>())
26700321                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
26800322
26900323             <span class="comment">// Use up to 6 separating planes</span>
27000324             <span class="keywordflow">if</span> (mMaximum.x &lt; 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>)
27100325                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
27200326             <span class="keywordflow">if</span> (mMaximum.y &lt; 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>)
27300327                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
27400328             <span class="keywordflow">if</span> (mMaximum.z &lt; 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>)
27500329                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
27600330
27700331             <span class="keywordflow">if</span> (mMinimum.x &gt; 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>)
27800332                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
27900333             <span class="keywordflow">if</span> (mMinimum.y &gt; 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>)
28000334                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
28100335             <span class="keywordflow">if</span> (mMinimum.z &gt; 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>)
28200336                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
28300337
28400338             <span class="comment">// otherwise, must be intersecting</span>
28500339             <span class="keywordflow">return</span> <span class="keyword">true</span>;
28600340
28700341         }
28800342
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&amp; b2)<span class="keyword"> const</span>
29000345 <span class="keyword">        </span>{
29100346             <span class="keywordflow">if</span> (!this-&gt;intersects(b2))
29200347             {
29300348                 <span class="keywordflow">return</span> AxisAlignedBox();
29400349             }
29500350             <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> intMin, intMax;
29600351
29700352             <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>&amp; b2max = b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa4">getMaximum</a>();
29800353             <span class="keyword">const</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>&amp; b2min = b2.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa3">getMinimum</a>();
29900354
30000355             <span class="keywordflow">if</span> (b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> &gt; mMaximum.x &amp;&amp; mMaximum.x &gt; b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>)
30100356                 intMax.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = mMaximum.x;
30200357             <span class="keywordflow">else</span>
30300358                 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>;
30400359             <span class="keywordflow">if</span> (b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> &gt; mMaximum.y &amp;&amp; mMaximum.y &gt; b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>)
30500360                 intMax.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = mMaximum.y;
30600361             <span class="keywordflow">else</span>
30700362                 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>;
30800363             <span class="keywordflow">if</span> (b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> &gt; mMaximum.z &amp;&amp; mMaximum.z &gt; b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>)
30900364                 intMax.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = mMaximum.z;
31000365             <span class="keywordflow">else</span>
31100366                 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>;
31200367
31300368             <span class="keywordflow">if</span> (b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> &lt; mMinimum.x &amp;&amp; mMinimum.x &lt; b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a>)
31400369                 intMin.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> = mMinimum.x;
31500370             <span class="keywordflow">else</span>
31600371                 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>;
31700372             <span class="keywordflow">if</span> (b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> &lt; mMinimum.y &amp;&amp; mMinimum.y &lt; b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a>)
31800373                 intMin.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> = mMinimum.y;
31900374             <span class="keywordflow">else</span>
32000375                 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>;
32100376             <span class="keywordflow">if</span> (b2min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> &lt; mMinimum.z &amp;&amp; mMinimum.z &lt; b2max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a>)
32200377                 intMin.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> = mMinimum.z;
32300378             <span class="keywordflow">else</span>
32400379                 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>;
32500380
32600381             <span class="keywordflow">return</span> AxisAlignedBox(intMin, intMax);
32700382
32800383         }
32900384
330<a name="l00386"></a><a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa19">00386</a>         <a class="code" href="namespaceOgre.html#a420">Real</a> volume(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
33100387 <span class="keyword">        </span>{
33200388             <span class="keywordflow">if</span> (mNull)
33300389             {
33400390                 <span class="keywordflow">return</span> 0.0f;
33500391             }
33600392             <span class="keywordflow">else</span>
33700393             {
33800394                 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> diff = mMaximum - mMinimum;
33900395                 <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>;
34000396             }
34100397
34200398         }
34300399
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>&amp; s)
34500402         {
34600403             <span class="comment">// NB assumes centered on origin</span>
34700404             <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> min = mMinimum * s;
34800405             <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> max = mMaximum * s;
34900406             setExtents(min, max);
35000407         }
35100408
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>&amp; s)<span class="keyword"> const</span>
35300411 <span class="keyword">        </span>{
35400412             <span class="keywordflow">return</span> Math::intersects(s, *<span class="keyword">this</span>);
35500413         }
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>&amp; p)<span class="keyword"> const</span>
35700416 <span class="keyword">        </span>{
35800417             <span class="keywordflow">return</span> Math::intersects(p, *<span class="keyword">this</span>);
35900418         }
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>&amp; v)<span class="keyword"> const</span>
36100421 <span class="keyword">        </span>{
36200422             <span class="keywordflow">return</span>(v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> &gt;= mMinimum.x  &amp;&amp;  v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o0">x</a> &lt;= mMaximum.x  &amp;&amp;
36300423                 v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> &gt;= mMinimum.y  &amp;&amp;  v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o1">y</a> &lt;= mMaximum.y  &amp;&amp;
36400424                 v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> &gt;= mMinimum.z  &amp;&amp;  v.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3o2">z</a> &lt;= mMaximum.z);
36500425         }
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>
36700428 <span class="keyword">        </span>{
36800429             <span class="keywordflow">return</span> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>((mMaximum + mMinimum) * 0.5);
36900430         }
37000431
37100432
37200433     };
37300434
37400435 } <span class="comment">// namespace Ogre</span>
37500436
37600437 <span class="preprocessor">#endif</span>
377</pre></div><hr>
378<p>
379Copyright &copy; 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/>
381This 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
389Last modified Sun Feb 12 12:59:41 2006
390</p>
391</body>
392</html>
Note: See TracBrowser for help on using the repository browser.