<html> <head> <title>OgreOctreeSceneManager.cpp Source File - OGRE Documentation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link type="text/css" rel="stylesheet" href="style.css"> </head> <body> <!-- Generated by Doxygen 1.2.16 --> <center> <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">Compound 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">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> </center> <hr><h1>OgreOctreeSceneManager.cpp</h1><a href="OgreOctreeSceneManager_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/***************************************************************************</font> 00002 <font class="comment">octreescenemanager.cpp - description</font> 00003 <font class="comment">-------------------</font> 00004 <font class="comment">begin : Fri Sep 27 2002</font> 00005 <font class="comment">copyright : (C) 2002 by Jon Anderson</font> 00006 <font class="comment">email : janders@users.sf.net</font> 00007 <font class="comment">***************************************************************************/</font> 00008 00009 <font class="comment">/***************************************************************************</font> 00010 <font class="comment">* *</font> 00011 <font class="comment">* This program is free software; you can redistribute it and/or modify *</font> 00012 <font class="comment">* it under the terms of the GNU Lesser General Public License as *</font> 00013 <font class="comment">* published by the Free Software Foundation; either version 2 of the * </font> 00014 <font class="comment">* License, or (at your option) any later version. *</font> 00015 <font class="comment">* *</font> 00016 <font class="comment">***************************************************************************/</font> 00017 00018 <font class="preprocessor">#include <<a class="code" href="OgreOctreeSceneManager_8h.html">OgreOctreeSceneManager.h</a>></font> 00019 <font class="preprocessor">#include <<a class="code" href="OgreOctreeNode_8h.html">OgreOctreeNode.h</a>></font> 00020 <font class="preprocessor">#include <<a class="code" href="OgreOctreeCamera_8h.html">OgreOctreeCamera.h</a>></font> 00021 <font class="preprocessor">#include <<a class="code" href="OgreRenderSystem_8h.html">OgreRenderSystem.h</a>></font> 00022 00023 00024 <font class="keyword">extern</font> <font class="stringliteral">"C"</font> 00025 { <a name="l00026"></a><a class="code" href="OgreOctreeSceneManager_8cpp.html#a0">00026</a> <font class="keywordtype">void</font> <a class="code" href="OgreOctreeSceneManager_8cpp.html#a0">findNodesInBox</a>( <a class="code" href="classOgre_1_1SceneManager.html">Ogre::SceneManager</a> *sm, 00027 <font class="keyword">const</font> <a class="code" href="classOgre_1_1AxisAlignedBox.html">Ogre::AxisAlignedBox</a> &box, 00028 std::list < Ogre::SceneNode * > &list, 00029 <a class="code" href="classOgre_1_1SceneNode.html">Ogre::SceneNode</a> *exclude ) 00030 { 00031 static_cast<Ogre::OctreeSceneManager*>( sm ) -> findNodesIn( box, list, exclude ); 00032 } <a name="l00033"></a><a class="code" href="OgreOctreeSceneManager_8cpp.html#a1">00033</a> <font class="keywordtype">void</font> <a class="code" href="OgreOctreeSceneManager_8cpp.html#a1">findNodesInSphere</a>( <a class="code" href="classOgre_1_1SceneManager.html">Ogre::SceneManager</a> *sm, 00034 <font class="keyword">const</font> <a class="code" href="classOgre_1_1Sphere.html">Ogre::Sphere</a> &sphere, 00035 std::list < Ogre::SceneNode * > &list, 00036 <a class="code" href="classOgre_1_1SceneNode.html">Ogre::SceneNode</a> *exclude ) 00037 { 00038 static_cast<Ogre::OctreeSceneManager*>( sm ) -> findNodesIn( sphere, list, exclude ); 00039 } 00040 } 00041 00042 <font class="keyword">namespace </font>Ogre 00043 { <a name="l00044"></a><a class="code" href="namespaceOgre.html#a649">00044</a> <font class="keyword">enum</font> <a class="code" href="namespaceOgre.html#a649">Intersection</a> 00045 { 00046 <a class="code" href="namespaceOgre.html#a649a479">OUTSIDE</a>=0, 00047 <a class="code" href="namespaceOgre.html#a649a480">INSIDE</a>=1, 00048 <a class="code" href="namespaceOgre.html#a649a481">INTERSECT</a>=2 00049 }; <a name="l00050"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagerp0">00050</a> <font class="keywordtype">int</font> OctreeSceneManager::intersect_call = 0; 00051 00052 00053 <a name="l00056"></a><a class="code" href="namespaceOgre.html#a581">00056</a> <a class="code" href="namespaceOgre.html#a649">Intersection</a> <a class="code" href="namespaceOgre.html#a581">intersect</a>( <font class="keyword">const</font> <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> &one, <font class="keyword">const</font> <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> &two ) 00057 { 00058 OctreeSceneManager::intersect_call++; 00059 <font class="keyword">const</font> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> * outside = one.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa11">getAllCorners</a>(); 00060 <font class="keyword">const</font> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> *inside = two.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa11">getAllCorners</a>(); 00061 00062 <font class="keywordflow">if</font> ( inside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> < outside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> || 00063 inside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> < outside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> || 00064 inside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> < outside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> || 00065 inside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> > outside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> || 00066 inside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> > outside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> || 00067 inside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> > outside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> ) 00068 { 00069 <font class="keywordflow">return</font> <a class="code" href="namespaceOgre.html#a649a479">OUTSIDE</a>; 00070 } 00071 00072 <font class="keywordtype">bool</font> full = ( inside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> > outside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> && 00073 inside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> > outside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> && 00074 inside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> > outside[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> && 00075 inside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> < outside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> && 00076 inside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> < outside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> && 00077 inside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> < outside[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> ); 00078 00079 <font class="keywordflow">if</font> ( full ) 00080 <font class="keywordflow">return</font> <a class="code" href="namespaceOgre.html#a649a480">INSIDE</a>; 00081 <font class="keywordflow">else</font> 00082 <font class="keywordflow">return</font> <a class="code" href="namespaceOgre.html#a649a481">INTERSECT</a>; 00083 00084 } 00085 <a name="l00088"></a><a class="code" href="namespaceOgre.html#a582">00088</a> <a class="code" href="namespaceOgre.html#a649">Intersection</a> <a class="code" href="namespaceOgre.html#a581">intersect</a>( <font class="keyword">const</font> <a class="code" href="classOgre_1_1Sphere.html">Sphere</a> &one, <font class="keyword">const</font> <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> &two ) 00089 { 00090 OctreeSceneManager::intersect_call++; 00091 <font class="keywordtype">float</font> sradius = one.<a class="code" href="classOgre_1_1Sphere.html#Ogre_1_1Spherea2">getRadius</a>(); 00092 00093 sradius *= sradius; 00094 00095 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> scenter = one.<a class="code" href="classOgre_1_1Sphere.html#Ogre_1_1Spherea4">getCenter</a>(); 00096 00097 <font class="keyword">const</font> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> *corners = two.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa11">getAllCorners</a>(); 00098 00099 <font class="keywordtype">float</font> s, d = 0; 00100 00101 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> mndistance = ( corners[ 0 ] - scenter ); 00102 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> mxdistance = ( corners[ 4 ] - scenter ); 00103 00104 <font class="keywordflow">if</font> ( mndistance.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a22">squaredLength</a>() < sradius && 00105 mxdistance.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a22">squaredLength</a>() < sradius ) 00106 { 00107 <font class="keywordflow">return</font> <a class="code" href="namespaceOgre.html#a649a480">INSIDE</a>; 00108 } 00109 00110 <font class="comment">//find the square of the distance</font> 00111 <font class="comment">//from the sphere to the box</font> 00112 <font class="keywordflow">for</font> ( <font class="keywordtype">int</font> i = 0 ; i < 3 ; i++ ) 00113 { 00114 <font class="keywordflow">if</font> ( scenter[ i ] < corners[ 0 ][ i ] ) 00115 { 00116 s = scenter[ i ] - corners[ 0 ][ i ]; 00117 d += s * s; 00118 } 00119 00120 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( scenter[ i ] > corners[ 4 ][ i ] ) 00121 { 00122 s = scenter[ i ] - corners[ 4 ][ i ]; 00123 d += s * s; 00124 } 00125 00126 } 00127 00128 <font class="keywordtype">bool</font> partial = ( d <= sradius ); 00129 00130 <font class="keywordflow">if</font> ( !partial ) 00131 { 00132 <font class="keywordflow">return</font> <a class="code" href="namespaceOgre.html#a649a479">OUTSIDE</a>; 00133 } 00134 00135 <font class="keywordflow">else</font> 00136 { 00137 <font class="keywordflow">return</font> <a class="code" href="namespaceOgre.html#a649a481">INTERSECT</a>; 00138 } 00139 00140 00141 } 00142 <a name="l00143"></a><a class="code" href="namespaceOgre.html#a478">00143</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> <a class="code" href="namespaceOgre.html#a478">white</a> = 0xFFFFFFFF; 00144 <a name="l00145"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagerq1">00145</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> OctreeSceneManager::mIndexes[ 24 ] = {0, 1, 1, 2, 2, 3, 3, 0, <font class="comment">//back</font> 00146 0, 6, 6, 5, 5, 1, <font class="comment">//left</font> 00147 3, 7, 7, 4, 4, 2, <font class="comment">//right</font> 00148 6, 7, 5, 4 }; <font class="comment">//front</font> <a name="l00149"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagerq0">00149</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> OctreeSceneManager::mColors[ 8 ] = {<a class="code" href="namespaceOgre.html#a478">white</a>, <a class="code" href="namespaceOgre.html#a478">white</a>, <a class="code" href="namespaceOgre.html#a478">white</a>, <a class="code" href="namespaceOgre.html#a478">white</a>, <a class="code" href="namespaceOgre.html#a478">white</a>, <a class="code" href="namespaceOgre.html#a478">white</a>, <a class="code" href="namespaceOgre.html#a478">white</a>, <a class="code" href="namespaceOgre.html#a478">white</a> }; 00150 00151 <a name="l00152"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1OctreeSceneManagera0">00152</a> OctreeSceneManager::OctreeSceneManager( ) : <a class="code" href="classOgre_1_1SceneManager.html">SceneManager</a>() 00153 { 00154 <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> b( -500, -500, -500, 500, 500, 500 ); 00155 <font class="keywordtype">int</font> depth = 5; 00156 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> = 0; 00157 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera10">init</a>( b, depth ); 00158 } 00159 <a name="l00160"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1OctreeSceneManagera1">00160</a> OctreeSceneManager::OctreeSceneManager( <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> &box, <font class="keywordtype">int</font> max_depth ) : <a class="code" href="classOgre_1_1SceneManager.html">SceneManager</a>() 00161 { 00162 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> = 0; 00163 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera10">init</a>( box, max_depth ); 00164 } 00165 <a name="l00166"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera10">00166</a> <font class="keywordtype">void</font> OctreeSceneManager::init( <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> &box, <font class="keywordtype">int</font> depth ) 00167 { 00168 <font class="keyword">delete</font> <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagern27">mSceneRoot</a>; <font class="comment">//get rid of old root.</font> 00169 00170 <font class="comment">// -- Changes by Steve</font> 00171 <font class="comment">// Don't do it this way, it will add it to the mSceneNodes which we don't want</font> 00172 <font class="comment">//mSceneRoot = createSceneNode( "SceneRoot" );</font> 00173 <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagern27">mSceneRoot</a> = <font class="keyword">new</font> <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a>( <font class="keyword">this</font>, <font class="stringliteral">"SceneRoot"</font> ); 00174 <font class="comment">// -- End changes by Steve</font> 00175 00176 <font class="keywordflow">if</font> ( <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> != 0 ) 00177 <font class="keyword">delete</font> <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>; 00178 00179 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> = <font class="keyword">new</font> <a class="code" href="classOgre_1_1Octree.html">Octree</a>( 0 ); 00180 00181 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern12">mMaxDepth</a> = depth; 00182 00183 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> -> mBox = box; 00184 00185 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> min = box.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa3">getMinimum</a>(); 00186 00187 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> max = box.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa4">getMaximum</a>(); 00188 00189 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> -> mHalfSize = ( max - min ) / 2; 00190 00191 00192 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern13">mShowBoxes</a> = <font class="keyword">false</font>; 00193 00194 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern14">mCullCamera</a> = <font class="keyword">false</font>; 00195 00196 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern11">mNumObjects</a> = 0; 00197 00198 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> v( 1.5, 1.5, 1.5 ); 00199 00200 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern17">mScaleFactor</a>.<a class="code" href="classOgre_1_1Matrix4.html#Ogre_1_1Matrix4a16">setScale</a>( v ); 00201 00202 00203 00204 <font class="comment">// setDisplaySceneNodes( true );</font> 00205 <font class="comment">// setShowBoxes( true );</font> 00206 00207 <font class="comment">//</font> 00208 <font class="comment">//setUseCullCamera( true );</font> 00209 <font class="comment">//mSceneRoot isn't put into the octree since it has no volume.</font> 00210 00211 } 00212 <a name="l00213"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1OctreeSceneManagera2">00213</a> OctreeSceneManager::~OctreeSceneManager() 00214 { 00215 <font class="comment">// -- Changed by Steve</font> 00216 <font class="comment">// Don't do this here, SceneManager will do it</font> 00217 <font class="comment">/*</font> 00218 <font class="comment"> if( mSceneRoot )</font> 00219 <font class="comment"> delete mSceneRoot;</font> 00220 <font class="comment"> */</font> 00221 <font class="comment">// --End Changes by Steve</font> 00222 00223 <font class="keywordflow">if</font> ( mOctree ) 00224 <font class="keyword">delete</font> <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>; 00225 } 00226 <a name="l00227"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera13">00227</a> <a class="code" href="classOgre_1_1Camera.html">Camera</a> * OctreeSceneManager::createCamera( <font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a> &name ) 00228 { 00229 <a class="code" href="classOgre_1_1Camera.html">Camera</a> * c = <font class="keyword">new</font> <a class="code" href="classOgre_1_1OctreeCamera.html">OctreeCamera</a>( name, <font class="keyword">this</font> ); 00230 <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagern21">mCameras</a>.insert( CameraList::value_type( name, c ) ); 00231 <font class="keywordflow">return</font> c; 00232 } 00233 <a name="l00234"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera14">00234</a> <font class="keywordtype">void</font> OctreeSceneManager::destroySceneNode( <font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a> &name ) 00235 { 00236 <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a> * on = static_cast < OctreeNode* > ( <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagera47">getSceneNode</a>( name ) ); 00237 00238 <font class="keywordflow">if</font> ( on != 0 ) 00239 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera18">_removeOctreeNode</a>( on ); 00240 00241 SceneManager::destroySceneNode( name ); 00242 } 00243 <a name="l00244"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera30">00244</a> <font class="keywordtype">bool</font> OctreeSceneManager::getOptionValues( <font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a> & key, std::list < SDDataChunk > &refValueList ) 00245 { 00246 <font class="keywordflow">return</font> SceneManager::getOptionValues( key, refValueList ); 00247 } 00248 <a name="l00249"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera31">00249</a> <font class="keywordtype">bool</font> OctreeSceneManager::getOptionKeys( std::list < String > & refKeys ) 00250 { 00251 SceneManager::getOptionKeys( refKeys ); 00252 refKeys.push_back( <font class="stringliteral">"CullCamera"</font> ); 00253 refKeys.push_back( <font class="stringliteral">"Size"</font> ); 00254 refKeys.push_back( <font class="stringliteral">"ShowOctree"</font> ); 00255 refKeys.push_back( <font class="stringliteral">"Depth"</font> ); 00256 00257 <font class="keywordflow">return</font> <font class="keyword">true</font>; 00258 } 00259 00260 <a name="l00261"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera17">00261</a> <font class="keywordtype">void</font> OctreeSceneManager::_updateOctreeNode( <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a> * onode ) 00262 { 00263 <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> box = onode -> _getWorldAABB(); 00264 00265 <font class="keywordflow">if</font> ( box.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa16">isNull</a>() ) 00266 <font class="keywordflow">return</font> ; 00267 00268 00269 <font class="keywordflow">if</font> ( onode -> getOctant() == 0 ) 00270 { 00271 <font class="comment">//if outside the octree, force into the root node.</font> 00272 <font class="keywordflow">if</font> ( ! onode -> _isIn( <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> -> mBox ) ) 00273 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>-><a class="code" href="classOgre_1_1Octree.html#Ogre_1_1Octreea2">_addNode</a>( onode ); 00274 <font class="keywordflow">else</font> 00275 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera19">_addOctreeNode</a>( onode, <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> ); 00276 <font class="keywordflow">return</font> ; 00277 } 00278 00279 <font class="keywordflow">if</font> ( ! onode -> _isIn( onode -> getOctant() -> mBox ) ) 00280 { 00281 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera18">_removeOctreeNode</a>( onode ); 00282 00283 <font class="comment">//if outside the octree, force into the root node.</font> 00284 <font class="keywordflow">if</font> ( ! onode -> _isIn( <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> -> mBox ) ) 00285 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>-><a class="code" href="classOgre_1_1Octree.html#Ogre_1_1Octreea2">_addNode</a>( onode ); 00286 <font class="keywordflow">else</font> 00287 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera19">_addOctreeNode</a>( onode, <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> ); 00288 } 00289 } 00290 <a name="l00293"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera18">00293</a> <font class="keywordtype">void</font> OctreeSceneManager::_removeOctreeNode( <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a> * n ) 00294 { 00295 <a class="code" href="classOgre_1_1Octree.html">Octree</a> * oct = n -> getOctant(); 00296 00297 <font class="keywordflow">if</font> ( oct ) 00298 { 00299 oct -> _removeNode( n ); 00300 } 00301 } 00302 00303 <a name="l00304"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera19">00304</a> <font class="keywordtype">void</font> OctreeSceneManager::_addOctreeNode( <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a> * n, <a class="code" href="classOgre_1_1Octree.html">Octree</a> *octant, <font class="keywordtype">int</font> depth ) 00305 { 00306 00307 <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> bx = n -> _getWorldAABB(); 00308 00309 00310 <font class="comment">//if the octree is twice as big as the scene node,</font> 00311 <font class="comment">//we will add it to a child.</font> 00312 <font class="keywordflow">if</font> ( ( depth < <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern12">mMaxDepth</a> ) && octant -> _isTwiceSize( bx ) ) 00313 { 00314 <font class="keywordtype">int</font> x, y, z; 00315 octant -> _getChildIndexes( bx, &x, &y, &z ); 00316 00317 <font class="keywordflow">if</font> ( octant -> mChildren[ x ][ y ][ z ] == 0 ) 00318 { 00319 octant -> mChildren[ x ][ y ][ z ] = <font class="keyword">new</font> <a class="code" href="classOgre_1_1Octree.html">Octree</a>( octant ); 00320 00321 <font class="keyword">const</font> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> *corners = octant -> mBox.getAllCorners(); 00322 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> min, max; 00323 00324 <font class="keywordflow">if</font> ( x == 0 ) 00325 { 00326 min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> = corners[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a>; 00327 max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> = ( corners[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> + corners[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> ) / 2; 00328 } 00329 00330 <font class="keywordflow">else</font> 00331 { 00332 min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> = ( corners[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> + corners[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> ) / 2; 00333 max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> = corners[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a>; 00334 } 00335 00336 <font class="keywordflow">if</font> ( y == 0 ) 00337 { 00338 min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> = corners[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a>; 00339 max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> = ( corners[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> + corners[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> ) / 2; 00340 } 00341 00342 <font class="keywordflow">else</font> 00343 { 00344 min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> = ( corners[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> + corners[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> ) / 2; 00345 max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> = corners[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a>; 00346 } 00347 00348 <font class="keywordflow">if</font> ( z == 0 ) 00349 { 00350 min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> = corners[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a>; 00351 max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> = ( corners[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> + corners[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> ) / 2; 00352 } 00353 00354 <font class="keywordflow">else</font> 00355 { 00356 min.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> = ( corners[ 0 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> + corners[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> ) / 2; 00357 max.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> = corners[ 4 ].<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a>; 00358 } 00359 00360 octant -> mChildren[ x ][ y ][ z ] -> mBox.setExtents( min, max ); 00361 octant -> mChildren[ x ][ y ][ z ] -> mHalfSize = ( max - min ) / 2; 00362 } 00363 00364 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera19">_addOctreeNode</a>( n, octant -> mChildren[ x ][ y ][ z ], ++depth ); 00365 00366 } 00367 00368 <font class="keywordflow">else</font> 00369 { 00370 octant -> _addNode( n ); 00371 } 00372 } 00373 00374 <a name="l00375"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera11">00375</a> <a class="code" href="classOgre_1_1SceneNode.html">SceneNode</a> * OctreeSceneManager::createSceneNode( <font class="keywordtype">void</font> ) 00376 { 00377 <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a> * on = <font class="keyword">new</font> <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a>( <font class="keyword">this</font> ); 00378 <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagern25">mSceneNodes</a>[ on-><a class="code" href="classOgre_1_1Node.html#Ogre_1_1TagPointa22">getName</a>() ] = on; 00379 <font class="keywordflow">return</font> on; 00380 } 00381 <a name="l00382"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera12">00382</a> <a class="code" href="classOgre_1_1SceneNode.html">SceneNode</a> * OctreeSceneManager::createSceneNode( <font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a> &name ) 00383 { 00384 <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a> * on = <font class="keyword">new</font> <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a>( <font class="keyword">this</font>, name ); 00385 <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagern25">mSceneNodes</a>[ on-><a class="code" href="classOgre_1_1Node.html#Ogre_1_1TagPointa22">getName</a>() ] = on; 00386 <font class="keywordflow">return</font> on; 00387 } 00388 <a name="l00389"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1OctreeSceneManagera8">00389</a> <font class="keywordtype">void</font> OctreeSceneManager::_updateSceneGraph( <a class="code" href="classOgre_1_1Camera.html">Camera</a> * cam ) 00390 { 00391 SceneManager::_updateSceneGraph( cam ); 00392 } 00393 <a name="l00394"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera15">00394</a> <font class="keywordtype">void</font> OctreeSceneManager::_alertVisibleObjects( <font class="keywordtype">void</font> ) 00395 { 00396 NodeList::iterator it = <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern7">mVisible</a>.begin(); 00397 00398 <font class="keywordflow">while</font> ( it != <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern7">mVisible</a>.end() ) 00399 { 00400 <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a> * node = *it; 00401 00402 ++it; 00403 } 00404 } 00405 <a name="l00406"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1OctreeSceneManagera9">00406</a> <font class="keywordtype">void</font> OctreeSceneManager::_findVisibleObjects( <a class="code" href="classOgre_1_1Camera.html">Camera</a> * cam ) 00407 { 00408 00409 <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagern18">mRenderQueue</a>.<a class="code" href="classOgre_1_1RenderQueue.html#Ogre_1_1RenderQueuea2">clear</a>(); 00410 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern10">mBoxes</a>.clear(); 00411 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern7">mVisible</a>.clear(); 00412 00413 <font class="keywordflow">if</font> ( mCullCamera ) 00414 { 00415 <a class="code" href="classOgre_1_1Camera.html">Camera</a> * c = <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagera32">getCamera</a>( <font class="stringliteral">"CullCamera"</font> ); 00416 00417 <font class="keywordflow">if</font> ( c != 0 ) 00418 cam = <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagera32">getCamera</a>( <font class="stringliteral">"CullCamera"</font> ); 00419 } 00420 00421 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern11">mNumObjects</a> = 0; 00422 00423 <font class="comment">//walk the octree, adding all visible Octreenodes nodes to the render queue.</font> 00424 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera16">walkOctree</a>( static_cast < OctreeCamera * > ( cam ), &<a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagern18">mRenderQueue</a>, <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>, <font class="keyword">false</font> ); 00425 00426 00427 <font class="comment">// Show the octree boxes & cull camera if required</font> 00428 <font class="keywordflow">if</font> ( <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern13">mShowBoxes</a> || <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern14">mCullCamera</a> ) 00429 { 00430 00431 00432 00433 <font class="keywordflow">if</font> ( mShowBoxes ) 00434 { 00435 <font class="keywordflow">for</font> ( BoxList::iterator it = <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern10">mBoxes</a>.begin(); it != <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern10">mBoxes</a>.end(); ++it ) 00436 { 00437 <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagern18">mRenderQueue</a>.<a class="code" href="classOgre_1_1RenderQueue.html#Ogre_1_1RenderQueuea3">addRenderable</a>(*it); 00438 } 00439 } 00440 00441 <font class="keywordflow">if</font> ( mCullCamera ) 00442 { 00443 <a class="code" href="classOgre_1_1OctreeCamera.html">OctreeCamera</a> * c = static_cast<OctreeCamera*>(<a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagera32">getCamera</a>( <font class="stringliteral">"CullCamera"</font> )); 00444 00445 <font class="keywordflow">if</font> ( c != 0 ) 00446 { 00447 <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagern18">mRenderQueue</a>.<a class="code" href="classOgre_1_1RenderQueue.html#Ogre_1_1RenderQueuea3">addRenderable</a>(c); 00448 } 00449 } 00450 00451 } 00452 00453 00454 00455 } 00456 <a name="l00457"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera16">00457</a> <font class="keywordtype">void</font> OctreeSceneManager::walkOctree( <a class="code" href="classOgre_1_1OctreeCamera.html">OctreeCamera</a> *camera, <a class="code" href="classOgre_1_1RenderQueue.html">RenderQueue</a> *queue, <a class="code" href="classOgre_1_1Octree.html">Octree</a> *octant, <font class="keywordtype">bool</font> foundvisible ) 00458 { 00459 00460 <font class="comment">//return immediately if nothing is in the node.</font> 00461 <font class="keywordflow">if</font> ( octant -> numNodes() == 0 ) 00462 <font class="keywordflow">return</font> ; 00463 00464 OctreeCamera::Visibility v = OctreeCamera::NONE; 00465 00466 <font class="keywordflow">if</font> ( foundvisible ) 00467 { 00468 v = OctreeCamera::FULL; 00469 } 00470 00471 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( octant == <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> ) 00472 { 00473 v = OctreeCamera::PARTIAL; 00474 } 00475 00476 <font class="keywordflow">else</font> 00477 { 00478 <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> box; 00479 octant -> _getCullBounds( &box ); 00480 v = camera -> getVisibility( box ); 00481 } 00482 00483 00484 <font class="comment">// if the octant is visible, or if it's the root node...</font> 00485 <font class="keywordflow">if</font> ( v != OctreeCamera::NONE ) 00486 { 00487 00488 <font class="comment">//Add stuff to be rendered;</font> 00489 NodeList::iterator it = octant -> mNodes.begin(); 00490 00491 <font class="keywordflow">if</font> ( mShowBoxes ) 00492 { 00493 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern10">mBoxes</a>.push_back( octant-><a class="code" href="classOgre_1_1Octree.html#Ogre_1_1Octreea5">getWireBoundingBox</a>() ); 00494 } 00495 00496 <font class="keywordtype">bool</font> vis = <font class="keyword">true</font>; 00497 00498 <font class="keywordflow">while</font> ( it != octant -> mNodes.end() ) 00499 { 00500 <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a> * sn = *it; 00501 00502 <font class="comment">// if this octree is partially visible, manually cull all</font> 00503 <font class="comment">// scene nodes attached directly to this level.</font> 00504 00505 <font class="keywordflow">if</font> ( v == OctreeCamera::PARTIAL ) 00506 vis = camera -> isVisible( sn -> _getWorldAABB() ); 00507 00508 <font class="keywordflow">if</font> ( vis ) 00509 { 00510 00511 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern11">mNumObjects</a>++; 00512 sn -> _addToRenderQueue(camera, queue ); 00513 00514 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern7">mVisible</a>.push_back( sn ); 00515 00516 <font class="keywordflow">if</font> ( mDisplayNodes ) 00517 queue -> addRenderable( sn ); 00518 00519 <font class="comment">// check if the scene manager or this node wants the bounding box shown.</font> 00520 <font class="keywordflow">if</font> (sn-><a class="code" href="classOgre_1_1SceneNode.html#Ogre_1_1SceneNodea23">getShowBoundingBox</a>() || <a class="code" href="classOgre_1_1SceneManager.html#Ogre_1_1TerrainSceneManagern53">mShowBoundingBoxes</a>) 00521 sn-><a class="code" href="classOgre_1_1SceneNode.html#Ogre_1_1SceneNodea22">_addBoundingBoxToQueue</a>(queue); 00522 } 00523 00524 ++it; 00525 } 00526 00527 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 0 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera16">walkOctree</a>( camera, queue, octant -> mChildren[ 0 ][ 0 ][ 0 ], ( v == OctreeCamera::FULL ) ); 00528 00529 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 0 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera16">walkOctree</a>( camera, queue, octant -> mChildren[ 1 ][ 0 ][ 0 ], ( v == OctreeCamera::FULL ) ); 00530 00531 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 1 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera16">walkOctree</a>( camera, queue, octant -> mChildren[ 0 ][ 1 ][ 0 ], ( v == OctreeCamera::FULL ) ); 00532 00533 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 1 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera16">walkOctree</a>( camera, queue, octant -> mChildren[ 1 ][ 1 ][ 0 ], ( v == OctreeCamera::FULL ) ); 00534 00535 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 0 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera16">walkOctree</a>( camera, queue, octant -> mChildren[ 0 ][ 0 ][ 1 ], ( v == OctreeCamera::FULL ) ); 00536 00537 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 0 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera16">walkOctree</a>( camera, queue, octant -> mChildren[ 1 ][ 0 ][ 1 ], ( v == OctreeCamera::FULL ) ); 00538 00539 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 1 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera16">walkOctree</a>( camera, queue, octant -> mChildren[ 0 ][ 1 ][ 1 ], ( v == OctreeCamera::FULL ) ); 00540 00541 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 1 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera16">walkOctree</a>( camera, queue, octant -> mChildren[ 1 ][ 1 ][ 1 ], ( v == OctreeCamera::FULL ) ); 00542 00543 } 00544 00545 } 00546 <a name="l00547"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera20">00547</a> <font class="keywordtype">void</font> OctreeSceneManager::findNodesIn( <font class="keyword">const</font> <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> &box, std::list < SceneNode * > &list, <a class="code" href="classOgre_1_1SceneNode.html">SceneNode</a> *exclude ) 00548 { 00549 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( box, list, exclude ); 00550 } 00551 <a name="l00552"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera21">00552</a> <font class="keywordtype">void</font> OctreeSceneManager::findNodesIn( <font class="keyword">const</font> <a class="code" href="classOgre_1_1Sphere.html">Sphere</a> &sphere, std::list < SceneNode * > &list, <a class="code" href="classOgre_1_1SceneNode.html">SceneNode</a> *exclude ) 00553 { 00554 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( sphere, list, exclude ); 00555 } 00556 <a name="l00557"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">00557</a> <font class="keywordtype">void</font> OctreeSceneManager::_findNodes( <font class="keyword">const</font> <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> &box, std::list < SceneNode * > &list, <a class="code" href="classOgre_1_1SceneNode.html">SceneNode</a> *exclude, <font class="keywordtype">bool</font> full, <a class="code" href="classOgre_1_1Octree.html">Octree</a> *octant ) 00558 { 00559 <font class="keywordflow">if</font> ( octant == 0 ) 00560 { 00561 octant = <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>; 00562 } 00563 00564 <font class="keywordflow">if</font> ( !full ) 00565 { 00566 <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> obox; 00567 octant -> _getCullBounds( &obox ); 00568 00569 <a class="code" href="namespaceOgre.html#a649">Intersection</a> isect = <a class="code" href="namespaceOgre.html#a581">intersect</a>( box, obox ); 00570 00571 <font class="keywordflow">if</font> ( isect == <a class="code" href="namespaceOgre.html#a649a479">OUTSIDE</a> ) 00572 <font class="keywordflow">return</font> ; 00573 00574 full = ( isect == <a class="code" href="namespaceOgre.html#a649a480">INSIDE</a> ); 00575 } 00576 00577 00578 NodeList::iterator it = octant -> mNodes.begin(); 00579 00580 <font class="keywordflow">while</font> ( it != octant -> mNodes.end() ) 00581 { 00582 <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a> * on = ( *it ); 00583 00584 <font class="keywordflow">if</font> ( on != exclude ) 00585 { 00586 <font class="keywordflow">if</font> ( full ) 00587 { 00588 list.push_back( on ); 00589 } 00590 00591 <font class="keywordflow">else</font> 00592 { 00593 <a class="code" href="namespaceOgre.html#a649">Intersection</a> nsect = <a class="code" href="namespaceOgre.html#a581">intersect</a>( box, on -> _getWorldAABB() ); 00594 00595 <font class="keywordflow">if</font> ( nsect != <a class="code" href="namespaceOgre.html#a649a479">OUTSIDE</a> ) 00596 { 00597 list.push_back( on ); 00598 } 00599 } 00600 00601 } 00602 00603 ++it; 00604 } 00605 00606 00607 00608 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 0 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( box, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 0 ] ); 00609 00610 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 0 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( box, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 0 ] ); 00611 00612 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 1 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( box, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 0 ] ); 00613 00614 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 1 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( box, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 0 ] ); 00615 00616 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 0 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( box, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 1 ] ); 00617 00618 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 0 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( box, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 1 ] ); 00619 00620 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 1 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( box, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 1 ] ); 00621 00622 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 1 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( box, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 1 ] ); 00623 00624 } 00625 <a name="l00626"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera23">00626</a> <font class="keywordtype">void</font> OctreeSceneManager::_findNodes( <font class="keyword">const</font> <a class="code" href="classOgre_1_1Sphere.html">Sphere</a> &sphere, std::list < SceneNode * > &list, <a class="code" href="classOgre_1_1SceneNode.html">SceneNode</a> *exclude, <font class="keywordtype">bool</font> full, <a class="code" href="classOgre_1_1Octree.html">Octree</a> *octant ) 00627 { 00628 <font class="keywordflow">if</font> ( octant == 0 ) 00629 { 00630 octant = <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>; 00631 } 00632 00633 <font class="keywordflow">if</font> ( !full ) 00634 { 00635 <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> obox; 00636 octant -> _getCullBounds( &obox ); 00637 00638 <a class="code" href="namespaceOgre.html#a649">Intersection</a> isect = <a class="code" href="namespaceOgre.html#a581">intersect</a>( sphere, obox ); 00639 00640 <font class="keywordflow">if</font> ( isect == <a class="code" href="namespaceOgre.html#a649a479">OUTSIDE</a> ) 00641 <font class="keywordflow">return</font> ; 00642 00643 full = ( isect == <a class="code" href="namespaceOgre.html#a649a480">INSIDE</a> ); 00644 } 00645 00646 NodeList::iterator it = octant -> mNodes.begin(); 00647 00648 <font class="keywordflow">while</font> ( it != octant -> mNodes.end() ) 00649 { 00650 <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a> * on = ( *it ); 00651 00652 <font class="keywordflow">if</font> ( on != exclude ) 00653 { 00654 <font class="keywordflow">if</font> ( full ) 00655 { 00656 list.push_back( on ); 00657 } 00658 00659 <font class="keywordflow">else</font> 00660 { 00661 <a class="code" href="namespaceOgre.html#a649">Intersection</a> nsect = <a class="code" href="namespaceOgre.html#a581">intersect</a>( sphere, on -> _getWorldAABB() ); 00662 00663 <font class="keywordflow">if</font> ( nsect != <a class="code" href="namespaceOgre.html#a649a479">OUTSIDE</a> ) 00664 { 00665 list.push_back( on ); 00666 } 00667 } 00668 } 00669 00670 ++it; 00671 } 00672 00673 00674 00675 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 0 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( sphere, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 0 ] ); 00676 00677 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 0 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( sphere, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 0 ] ); 00678 00679 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 1 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( sphere, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 0 ] ); 00680 00681 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 1 ][ 0 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( sphere, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 0 ] ); 00682 00683 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 0 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( sphere, list, exclude, full, octant -> mChildren[ 0 ][ 0 ][ 1 ] ); 00684 00685 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 0 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( sphere, list, exclude, full, octant -> mChildren[ 1 ][ 0 ][ 1 ] ); 00686 00687 <font class="keywordflow">if</font> ( octant -> mChildren[ 0 ][ 1 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( sphere, list, exclude, full, octant -> mChildren[ 0 ][ 1 ][ 1 ] ); 00688 00689 <font class="keywordflow">if</font> ( octant -> mChildren[ 1 ][ 1 ][ 1 ] != 0 ) <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( sphere, list, exclude, full, octant -> mChildren[ 1 ][ 1 ][ 1 ] ); 00690 00691 } 00692 <a name="l00693"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera27">00693</a> <font class="keywordtype">void</font> OctreeSceneManager::resize( <font class="keyword">const</font> <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> &box ) 00694 { 00695 std::list < SceneNode * > nodes; 00696 std::list < SceneNode * > ::iterator it; 00697 00698 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera22">_findNodes</a>( <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>-><a class="code" href="classOgre_1_1Octree.html#Ogre_1_1Octreem0">mBox</a>, nodes, 0, <font class="keyword">true</font>, <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> ); 00699 00700 <font class="keyword">delete</font> <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>; 00701 00702 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a> = <font class="keyword">new</font> <a class="code" href="classOgre_1_1Octree.html">Octree</a>( 0 ); 00703 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>-><a class="code" href="classOgre_1_1Octree.html#Ogre_1_1Octreem0">mBox</a> = box; 00704 00705 it = nodes.begin(); 00706 00707 <font class="keywordflow">while</font> ( it != nodes.end() ) 00708 { 00709 <a class="code" href="classOgre_1_1OctreeNode.html">OctreeNode</a> * on = static_cast < OctreeNode * > ( *it ); 00710 on -> setOctant( 0 ); 00711 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera17">_updateOctreeNode</a>( on ); 00712 ++it; 00713 } 00714 00715 } 00716 <a name="l00717"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera28">00717</a> <font class="keywordtype">bool</font> OctreeSceneManager::setOption( <font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a> & key, <font class="keyword">const</font> <font class="keywordtype">void</font> * val ) 00718 { 00719 <font class="keywordflow">if</font> ( key == <font class="stringliteral">"Size"</font> ) 00720 { 00721 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera27">resize</a>( * static_cast < const AxisAlignedBox * > ( val ) ); 00722 <font class="keywordflow">return</font> <font class="keyword">true</font>; 00723 } 00724 00725 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( key == <font class="stringliteral">"Depth"</font> ) 00726 { 00727 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern12">mMaxDepth</a> = * static_cast < const int * > ( val ); 00728 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera27">resize</a>( <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>-><a class="code" href="classOgre_1_1Octree.html#Ogre_1_1Octreem0">mBox</a> ); 00729 <font class="keywordflow">return</font> <font class="keyword">true</font>; 00730 } 00731 00732 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( key == <font class="stringliteral">"ShowOctree"</font> ) 00733 { 00734 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern13">mShowBoxes</a> = * static_cast < const bool * > ( val ); 00735 <font class="keywordflow">return</font> <font class="keyword">true</font>; 00736 } 00737 00738 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( key == <font class="stringliteral">"CullCamera"</font> ) 00739 { 00740 <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern14">mCullCamera</a> = * static_cast < const bool * > ( val ); 00741 <font class="keywordflow">return</font> <font class="keyword">true</font>; 00742 } 00743 00744 <font class="keywordflow">return</font> SceneManager::setOption( key, val ); 00745 00746 00747 } 00748 <a name="l00749"></a><a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagera29">00749</a> <font class="keywordtype">bool</font> OctreeSceneManager::getOption( <font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a> & key, <font class="keywordtype">void</font> *val ) 00750 { 00751 <font class="keywordflow">if</font> ( key == <font class="stringliteral">"Size"</font> ) 00752 { 00753 <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> * b = static_cast < AxisAlignedBox * > ( val ); 00754 b -> setExtents( <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>-><a class="code" href="classOgre_1_1Octree.html#Ogre_1_1Octreem0">mBox</a>.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa3">getMinimum</a>(), <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern9">mOctree</a>-><a class="code" href="classOgre_1_1Octree.html#Ogre_1_1Octreem0">mBox</a>.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa4">getMaximum</a>() ); 00755 <font class="keywordflow">return</font> <font class="keyword">true</font>; 00756 } 00757 00758 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( key == <font class="stringliteral">"Depth"</font> ) 00759 { 00760 * static_cast < int * > ( val ) = <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern12">mMaxDepth</a>; 00761 <font class="keywordflow">return</font> <font class="keyword">true</font>; 00762 } 00763 00764 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( key == <font class="stringliteral">"ShowOctree"</font> ) 00765 { 00766 00767 * static_cast < bool * > ( val ) = <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern13">mShowBoxes</a>; 00768 <font class="keywordflow">return</font> <font class="keyword">true</font>; 00769 } 00770 00771 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( key == <font class="stringliteral">"CullCamera"</font> ) 00772 { 00773 * static_cast < bool * > ( val ) = <a class="code" href="classOgre_1_1OctreeSceneManager.html#Ogre_1_1TerrainSceneManagern14">mCullCamera</a>; 00774 <font class="keywordflow">return</font> <font class="keyword">true</font>; 00775 } 00776 00777 <font class="keywordflow">return</font> SceneManager::getOption( key, val ); 00778 00779 } 00780 } </pre></div><p> Copyright © 2002-2003 by The OGRE Team<br /> Last modified Wed Jan 21 00:10:19 2004 </p> </body> </html>