Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreOctreeSceneManager.h

Go to the documentation of this file.
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 < WireBoundingBox * > 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 _findVisibleObjects ( Camera * cam );
00082 
00087     virtual void _alertVisibleObjects( void );
00088 
00094     void walkOctree( OctreeCamera *, RenderQueue *, Octree *, bool foundvisible );
00095 
00099     void _updateOctreeNode( OctreeNode * );
00101     void _removeOctreeNode( OctreeNode * );
00104     void _addOctreeNode( OctreeNode *, Octree *octree, int depth = 0 );
00105 
00109     void findNodesIn( const AxisAlignedBox &box, std::list < SceneNode * > &list, SceneNode *exclude = 0 );
00110 
00114     void findNodesIn( const Sphere &sphere, std::list < SceneNode * > &list, SceneNode *exclude = 0 );
00115 
00116 
00120     void _findNodes( const AxisAlignedBox &box, std::list < SceneNode * > &list, SceneNode *exclude = 0, bool full = false, Octree *octant = 0 );
00121 
00125     void _findNodes( const Sphere &sphere, std::list < SceneNode * > &list, SceneNode *exclude = 0, bool full = false, Octree *octant = 0 );
00126 
00127 
00129     void setShowBoxes( bool b )
00130     {
00131         mShowBoxes = b;
00132     };
00133 
00135     void setUseCullCamera( bool b )
00136     {
00137         mCullCamera = b;
00138     };
00139 
00140     void setLooseOctree( bool b )
00141     {
00142         mLoose = b;
00143     };
00144 
00145 
00147     void resize( const AxisAlignedBox &box );
00148 
00158     virtual bool setOption( const String &, const void * );
00163     virtual bool getOption( const String &, void * );
00164 
00165     bool getOptionValues( const String & key, std::list < SDDataChunk > &refValueList );
00166     bool getOptionKeys( std::list < String > & refKeys );
00167 
00168 
00169 
00170 
00171 protected:
00172 
00173 
00174     NodeList mVisible;
00175 
00177     float mWorldSize;
00178 
00180     Octree *mOctree;
00181 
00183     BoxList mBoxes;
00184 
00186     int mNumObjects;
00187 
00189     int mMaxDepth;
00190 
00192     bool mShowBoxes;
00193 
00195     bool mCullCamera;
00196 
00197 
00198     bool mLoose;
00199 
00200     Real mCorners[ 24 ];
00201     static unsigned long mColors[ 8 ];
00202     static unsigned short mIndexes[ 24 ];
00203 
00204     Matrix4 mScaleFactor;
00205 
00206 };
00207 
00208 }
00209 
00210 #endif
00211 

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:19 2004