Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class 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 (c) 2000-2005 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(const String& name);
00085     OctreeSceneManager(const String& name, AxisAlignedBox &box, int max_depth );
00087     ~OctreeSceneManager();
00088 
00090     const String& getTypeName(void) const;
00091 
00094     void init( AxisAlignedBox &box, int d );
00095 
00097     virtual SceneNode * createSceneNode ( void );
00099     virtual SceneNode * createSceneNode ( const String &name );
00101     virtual Camera * createCamera( const String &name );
00102 
00104     virtual void destroySceneNode( const String &name );
00105 
00106 
00107 
00109     virtual void _updateSceneGraph( Camera * cam );
00111     virtual void _findVisibleObjects ( Camera * cam, bool onlyShadowCasters );
00112 
00117     virtual void _alertVisibleObjects( void );
00118 
00124     void walkOctree( OctreeCamera *, RenderQueue *, Octree *, bool foundvisible,
00125                      bool onlyShadowCasters);
00126 
00130     void _updateOctreeNode( OctreeNode * );
00132     void _removeOctreeNode( OctreeNode * );
00135     void _addOctreeNode( OctreeNode *, Octree *octree, int depth = 0 );
00136 
00140     void findNodesIn( const AxisAlignedBox &box, std::list < SceneNode * > &list, SceneNode *exclude = 0 );
00141 
00145     void findNodesIn( const Sphere &sphere, std::list < SceneNode * > &list, SceneNode *exclude = 0 );
00146 
00150     void findNodesIn( const PlaneBoundedVolume &volume, std::list < SceneNode * > &list, SceneNode *exclude=0 );
00151 
00155     void findNodesIn( const Ray &ray, std::list < SceneNode * > &list, SceneNode *exclude=0 );
00156 
00158     void setShowBoxes( bool b )
00159     {
00160         mShowBoxes = b;
00161     };
00162 
00164     void setUseCullCamera( bool b )
00165     {
00166         mCullCamera = b;
00167     };
00168 
00169     void setLooseOctree( bool b )
00170     {
00171         mLoose = b;
00172     };
00173 
00174 
00176     void resize( const AxisAlignedBox &box );
00177 
00187     virtual bool setOption( const String &, const void * );
00192     virtual bool getOption( const String &, void * );
00193 
00194     bool getOptionValues( const String & key, StringVector &refValueList );
00195     bool getOptionKeys( StringVector &refKeys );
00197     void clearScene(void);
00198 
00199     AxisAlignedBoxSceneQuery* OctreeSceneManager::createAABBQuery(const AxisAlignedBox& box, unsigned long mask);
00200     SphereSceneQuery* OctreeSceneManager::createSphereQuery(const Sphere& sphere, unsigned long mask);
00201     PlaneBoundedVolumeListSceneQuery* createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, unsigned long mask);
00202     RaySceneQuery* createRayQuery(const Ray& ray, unsigned long mask);
00203     IntersectionSceneQuery* createIntersectionQuery(unsigned long mask);
00204 
00205 
00206 protected:
00207 
00208 
00209     NodeList mVisible;
00210 
00212     Octree *mOctree;
00213 
00215     BoxList mBoxes;
00216 
00218     int mNumObjects;
00219 
00221     int mMaxDepth;
00223     AxisAlignedBox mBox;
00224 
00226     bool mShowBoxes;
00227 
00229     bool mCullCamera;
00230 
00231 
00232     bool mLoose;
00233 
00234     Real mCorners[ 24 ];
00235     static unsigned long mColors[ 8 ];
00236     static unsigned short mIndexes[ 24 ];
00237 
00238     Matrix4 mScaleFactor;
00239 
00240 };
00241 
00243 class OctreeSceneManagerFactory : public SceneManagerFactory
00244 {
00245 protected:
00246     void initMetaData(void) const;
00247 public:
00248     OctreeSceneManagerFactory() {}
00249     ~OctreeSceneManagerFactory() {}
00251     static const String FACTORY_TYPE_NAME;
00252     SceneManager* createInstance(const String& instanceName);
00253     void destroyInstance(SceneManager* instance);
00254 };
00255 
00256 
00257 
00258 }
00259 
00260 #endif
00261 

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:45 2006