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 source file is part of OGRE
    00012 (Object-oriented Graphics Rendering Engine)
    00013 For the latest info, see http://www.ogre3d.org/
    00014
    00015 Copyright © 2000-2004 The OGRE Team
    00016 Also see acknowledgements in Readme.html
    00017
    00018 This program is free software; you can redistribute it and/or modify it under
    00019 the terms of the GNU Lesser General Public License as published by the Free Software
    00020 Foundation; either version 2 of the License, or (at your option) any later
    00021 version.
    00022
    00023 This program is distributed in the hope that it will be useful, but WITHOUT
    00024 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00025 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00026
    00027 You should have received a copy of the GNU Lesser General Public License along with
    00028 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00029 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00030 http://www.gnu.org/copyleft/lesser.txt.
    00031 -----------------------------------------------------------------------------
    00032 */
    00033
    00034 #ifndef OCTREESCENEMANAGER_H
    00035 #define OCTREESCENEMANAGER_H
    00036
    00037 #include "OgreSceneManager.h"
    00038 #include "OgreRenderOperation.h"
    00039 #include "OgreSphere.h"
    00040
    00041 #include <list>
    00042 #include <algorithm>
    00043
    00044 #include <OgreOctree.h>
    00045
    00046
    00047 namespace Ogre
    00048 {
    00049
    00050 class OctreeNode;
    00051
    00052 class OctreeCamera;
    00053 class OctreeIntersectionSceneQuery;
    00054 class OctreeRaySceneQuery;
    00055 class OctreeSphereSceneQuery;
    00056 class OctreeAxisAlignedBoxSceneQuery;
    00057 class OctreePlaneBoundedVolumeListSceneQuery;
    00058
    00059
    00060 typedef std::list < WireBoundingBox * > BoxList;
    00061 typedef std::list < unsigned long > ColorList;
    00062 //typedef std::list < SceneNode * > SceneNodeList;
    00063
    00064
    00072 class OctreeSceneManager : public SceneManager
    00073 {
    00074     friend class OctreeIntersectionSceneQuery;
    00075     friend class OctreeRaySceneQuery;
    00076     friend class OctreeSphereSceneQuery;
    00077     friend class OctreeAxisAlignedBoxSceneQuery;
    00078     friend class OctreePlaneBoundedVolumeListSceneQuery;
    00079
    00080 public:
    00081     static int intersect_call;
    00083     OctreeSceneManager( );
    00085     OctreeSceneManager( AxisAlignedBox &box, int max_depth );
    00087     ~OctreeSceneManager();
    00088
    00091     void init( AxisAlignedBox &box, int d );
    00092
    00094     virtual SceneNode * createSceneNode ( void );
    00096     virtual SceneNode * createSceneNode ( const String &name );
    00098     virtual Camera * createCamera( const String &name );
    00099
    00101     virtual void destroySceneNode( const String &name );
    00102
    00103
    00104
    00106     virtual void _updateSceneGraph( Camera * cam );
    00108     virtual void _findVisibleObjects ( Camera * cam, bool onlyShadowCasters );
    00109
    00114     virtual void _alertVisibleObjects( void );
    00115
    00121     void walkOctree( OctreeCamera *, RenderQueue *, Octree *, bool foundvisible,
    00122                      bool onlyShadowCasters);
    00123
    00127     void _updateOctreeNode( OctreeNode * );
    00129     void _removeOctreeNode( OctreeNode * );
    00132     void _addOctreeNode( OctreeNode *, Octree *octree, int depth = 0 );
    00133
    00137     void findNodesIn( const AxisAlignedBox &box, std::list < SceneNode * > &list, SceneNode *exclude = 0 );
    00138
    00142     void findNodesIn( const Sphere &sphere, std::list < SceneNode * > &list, SceneNode *exclude = 0 );
    00143
    00147     void findNodesIn( const PlaneBoundedVolume &volume, std::list < SceneNode * > &list, SceneNode *exclude=0 );
    00148
    00152     void findNodesIn( const Ray &ray, std::list < SceneNode * > &list, SceneNode *exclude=0 );
    00153
    00155     void setShowBoxes( bool b )
    00156     {
    00157         mShowBoxes = b;
    00158     };
    00159
    00161     void setUseCullCamera( bool b )
    00162     {
    00163         mCullCamera = b;
    00164     };
    00165
    00166     void setLooseOctree( bool b )
    00167     {
    00168         mLoose = b;
    00169     };
    00170
    00171
    00173     void resize( const AxisAlignedBox &box );
    00174
    00184     virtual bool setOption( const String &, const void * );
    00189     virtual bool getOption( const String &, void * );
    00190
    00191     bool getOptionValues( const String & key, std::list < SDDataChunk > &refValueList );
    00192     bool getOptionKeys( std::list < String > & refKeys );
    00194     void clearScene(void);
    00195
    00196     AxisAlignedBoxSceneQuery* OctreeSceneManager::createAABBQuery(const AxisAlignedBox& box, unsigned long mask);
    00197     SphereSceneQuery* OctreeSceneManager::createSphereQuery(const Sphere& sphere, unsigned long mask);
    00198     PlaneBoundedVolumeListSceneQuery* createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, unsigned long mask);
    00199     RaySceneQuery* createRayQuery(const Ray& ray, unsigned long mask);
    00200     IntersectionSceneQuery* createIntersectionQuery(unsigned long mask);
    00201
    00202
    00203 protected:
    00204
    00205
    00206     NodeList mVisible;
    00207
    00209     Octree *mOctree;
    00210
    00212     BoxList mBoxes;
    00213
    00215     int mNumObjects;
    00216
    00218     int mMaxDepth;
    00220     AxisAlignedBox mBox;
    00221
    00223     bool mShowBoxes;
    00224
    00226     bool mCullCamera;
    00227
    00228
    00229     bool mLoose;
    00230
    00231     Real mCorners[ 24 ];
    00232     static unsigned long mColors[ 8 ];
    00233     static unsigned short mIndexes[ 24 ];
    00234
    00235     Matrix4 mScaleFactor;
    00236
    00237 };
    00238
    00239
    00240 }
    00241
    00242 #endif
    00243

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:36 2004