00001 /*************************************************************************** 00002 octreescenemanager.h - description 00003 ------------------- 00004 begin : Fri Sep 27 2002 00005 copyright : (C) 2002 by Jon Anderson 00006 email : janders@users.sf.net 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU Lesser General Public License as * 00013 * published by the Free Software Foundation; either version 2 of the * 00014 * License, or (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef OCTREESCENEMANAGER_H 00019 #define OCTREESCENEMANAGER_H 00020 00021 #include <OgreSceneManager.h> 00022 #include <OgreRenderOperation.h> 00023 #include <OgreSphere.h> 00024 00025 #include <list> 00026 #include <algorithm> 00027 00028 #include <OgreOctree.h> 00029 00030 00031 namespace Ogre 00032 { 00033 00034 class OctreeNode; 00035 00036 class OctreeCamera; 00037 00038 00039 typedef std::list < AxisAlignedBox * > BoxList; 00040 typedef std::list < unsigned long > ColorList; 00041 //typedef std::list < SceneNode * > SceneNodeList; 00042 00043 00051 class OctreeSceneManager : public SceneManager 00052 { 00053 public: 00054 static int intersect_call; 00056 OctreeSceneManager( ); 00058 OctreeSceneManager( AxisAlignedBox &box, int max_depth ); 00060 ~OctreeSceneManager(); 00061 00064 void init( AxisAlignedBox &box, int d ); 00065 00067 virtual SceneNode * createSceneNode ( void ); 00069 virtual SceneNode * createSceneNode ( const String &name ); 00071 virtual Camera * createCamera( const String &name ); 00072 00074 virtual void destroySceneNode( const String &name ); 00075 00076 00077 00079 virtual void _updateSceneGraph( Camera * cam ); 00081 virtual void _renderVisibleObjects( void ); 00083 virtual void _findVisibleObjects ( Camera * cam ); 00084 00089 virtual void _alertVisibleObjects( void ); 00090 00096 void walkOctree( OctreeCamera *, RenderQueue *, Octree *, bool foundvisible ); 00097 00101 void _updateOctreeNode( OctreeNode * ); 00103 void _removeOctreeNode( OctreeNode * ); 00106 void _addOctreeNode( OctreeNode *, Octree *octree, int depth = 0 ); 00107 00111 void findNodesIn( const AxisAlignedBox &box, std::list < SceneNode * > &list, SceneNode *exclude = 0 ); 00112 00116 void findNodesIn( const Sphere &sphere, std::list < SceneNode * > &list, SceneNode *exclude = 0 ); 00117 00118 00122 void _findNodes( const AxisAlignedBox &box, std::list < SceneNode * > &list, SceneNode *exclude = 0, bool full = false, Octree *octant = 0 ); 00123 00127 void _findNodes( const Sphere &sphere, std::list < SceneNode * > &list, SceneNode *exclude = 0, bool full = false, Octree *octant = 0 ); 00128 00129 00131 void setShowBoxes( bool b ) 00132 { 00133 mShowBoxes = b; 00134 }; 00135 00137 void setUseCullCamera( bool b ) 00138 { 00139 mCullCamera = b; 00140 }; 00141 00142 void setLooseOctree( bool b ) 00143 { 00144 mLoose = b; 00145 }; 00146 00147 00149 void resize( const AxisAlignedBox &box ); 00150 00160 virtual bool setOption( const String &, const void * ); 00165 virtual bool getOption( const String &, void * ); 00166 00167 bool getOptionValues( const String & key, std::list < SDDataChunk > &refValueList ); 00168 bool getOptionKeys( std::list < String > & refKeys ); 00169 00170 00171 00172 00173 protected: 00174 00175 Material * mBlankMaterial; 00176 00177 NodeList mVisible; 00178 00180 void getBoxVerts( AxisAlignedBox &box, Real *r ); 00181 00183 float mWorldSize; 00184 00186 Octree *mOctree; 00187 00189 BoxList mBoxes; 00190 00192 RenderOperation mRenderOp; 00193 00195 int mNumObjects; 00196 00198 int mMaxDepth; 00199 00201 bool mShowBoxes; 00202 00204 bool mCullCamera; 00205 00206 00207 bool mLoose; 00208 00209 Real mCorners[ 24 ]; 00210 static unsigned long mColors[ 8 ]; 00211 static unsigned short mIndexes[ 24 ]; 00212 00213 Matrix4 mScaleFactor; 00214 00215 }; 00216 00217 } 00218 00219 #endif 00220
Copyright © 2002 by The OGRE Team