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, bool onlyShadowCasters );
00082 
00087     virtual void _alertVisibleObjects( void );
00088 
00094     void walkOctree( OctreeCamera *, RenderQueue *, Octree *, bool foundvisible, 
00095         bool onlyShadowCasters);
00096 
00100     void _updateOctreeNode( OctreeNode * );
00102     void _removeOctreeNode( OctreeNode * );
00105     void _addOctreeNode( OctreeNode *, Octree *octree, int depth = 0 );
00106 
00110     void findNodesIn( const AxisAlignedBox &box, std::list < SceneNode * > &list, SceneNode *exclude = 0 );
00111 
00115     void findNodesIn( const Sphere &sphere, std::list < SceneNode * > &list, SceneNode *exclude = 0 );
00116 
00117 
00121     void _findNodes( const AxisAlignedBox &box, std::list < SceneNode * > &list, SceneNode *exclude = 0, bool full = false, Octree *octant = 0 );
00122 
00126     void _findNodes( const Sphere &sphere, std::list < SceneNode * > &list, SceneNode *exclude = 0, bool full = false, Octree *octant = 0 );
00127 
00128 
00130     void setShowBoxes( bool b )
00131     {
00132         mShowBoxes = b;
00133     };
00134 
00136     void setUseCullCamera( bool b )
00137     {
00138         mCullCamera = b;
00139     };
00140 
00141     void setLooseOctree( bool b )
00142     {
00143         mLoose = b;
00144     };
00145 
00146 
00148     void resize( const AxisAlignedBox &box );
00149 
00159     virtual bool setOption( const String &, const void * );
00164     virtual bool getOption( const String &, void * );
00165 
00166     bool getOptionValues( const String & key, std::list < SDDataChunk > &refValueList );
00167     bool getOptionKeys( std::list < String > & refKeys );
00169     void clearScene(void);
00170 
00171 
00172 
00173 
00174 protected:
00175 
00176 
00177     NodeList mVisible;
00178 
00180     float mWorldSize;
00181 
00183     Octree *mOctree;
00184 
00186     BoxList mBoxes;
00187 
00189     int mNumObjects;
00190 
00192     int mMaxDepth;
00194     AxisAlignedBox mBox;
00195 
00197     bool mShowBoxes;
00198 
00200     bool mCullCamera;
00201 
00202 
00203     bool mLoose;
00204 
00205     Real mCorners[ 24 ];
00206     static unsigned long mColors[ 8 ];
00207     static unsigned short mIndexes[ 24 ];
00208 
00209     Matrix4 mScaleFactor;
00210 
00211 };
00212 
00213 }
00214 
00215 #endif
00216 

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:29 2004