# OgreBspSceneManager.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://ogre.sourceforge.net/
    00006
    00007 Copyright (c) 2000-2005 The OGRE Team
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023 -----------------------------------------------------------------------------
    00024 */
    00025 #ifndef __BspSceneManager_H__
    00026 #define __BspSceneManager_H__
    00027
    00028
    00029 #include "OgreBspPrerequisites.h"
    00030 #include "OgreSceneManager.h"
    00031 #include "OgreStaticFaceGroup.h"
    00032 #include "OgreRenderOperation.h"
    00033 #include "OgreBspLevel.h"
    00034 #include <set>
    00035
    00036
    00037 namespace Ogre {
    00038
    00039
    00061     class BspSceneManager : public SceneManager
    00062     {
    00063     protected:
    00064
    00065         // Pointer to resource manager just for singleton management
    00066         BspResourceManager* mBspResMgr;
    00067
    00068         // World geometry
    00069         BspLevelPtr mLevel;
    00070
    00071         // State variables for rendering WIP
    00072         // Set of face groups (by index) already included
    00073         typedef std::set<int> FaceGroupSet;
    00074         FaceGroupSet mFaceGroupSet;
    00075         // Material -> face group hashmap
    00076         typedef std::map<Material*, std::vector<StaticFaceGroup*>, materialLess > MaterialFaceGroupMap;
    00077         MaterialFaceGroupMap mMatFaceGroupMap;
    00078
    00079         RenderOperation mRenderOp;
    00080
    00081         // Debugging features
    00082         bool mShowNodeAABs;
    00083         RenderOperation mAABGeometry;
    00084
    00091         BspNode* walkTree(Camera* camera, bool onlyShadowCasters);
    00093         void processVisibleLeaf(BspNode* leaf, Camera* cam, bool onlyShadowCasters);
    00094
    00096         unsigned int cacheGeometry(unsigned int* pIndexes, const StaticFaceGroup* faceGroup);
    00097
    00099         void freeMemory(void);
    00100
    00102         void addBoundingBox(const AxisAlignedBox& aab, bool visible);
    00103
    00105         void renderStaticGeometry(void);
    00106
    00108         void clearScene(void);
    00109
    00110
    00111         typedef std::set<const MovableObject*> MovablesForRendering;
    00112         MovablesForRendering mMovablesForRendering;
    00113
    00114     public:
    00115         BspSceneManager();
    00116         ~BspSceneManager();
    00117
    00119         void setWorldGeometry(const String& filename);
    00120
    00122         size_t estimateWorldGeometry(const String& filename);
    00123
    00127         void showNodeBoxes(bool show);
    00128
    00130         ViewPoint getSuggestedViewpoint(bool random = false);
    00131
    00132         const BspLevelPtr& getLevel(void) {return mLevel; }
    00133
    00135         void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
    00136
    00138         void _renderVisibleObjects(void);
    00139
    00141         SceneNode * createSceneNode ( void );
    00143         SceneNode * createSceneNode ( const String &name );
    00144
    00146         void _notifyObjectMoved(const MovableObject* mov, const Vector3& pos);
    00148         void _notifyObjectDetached(const MovableObject* mov);
    00149
    00162         /*
    00163         virtual AxisAlignedBoxSceneQuery*
    00164             createAABBQuery(const AxisAlignedBox& box, unsigned long mask = 0xFFFFFFFF);
    00165         */
    00178         /*
    00179         virtual SphereSceneQuery*
    00180             createSphereQuery(const Sphere& sphere, unsigned long mask = 0xFFFFFFFF);
    00181         */
    00194         virtual RaySceneQuery*
    00195             createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF);
    00207         virtual IntersectionSceneQuery*
    00208             createIntersectionQuery(unsigned long mask = 0xFFFFFFFF);
    00209
    00210     };
    00211
    00213     class BspIntersectionSceneQuery : public DefaultIntersectionSceneQuery
    00214     {
    00215     public:
    00216         BspIntersectionSceneQuery(SceneManager* creator);
    00217
    00219         void execute(IntersectionSceneQueryListener* listener);
    00220
    00221     };
    00222
    00224     class BspRaySceneQuery : public DefaultRaySceneQuery
    00225     {
    00226     public:
    00227         BspRaySceneQuery(SceneManager* creator);
    00228         ~BspRaySceneQuery();
    00229
    00231         void execute(RaySceneQueryListener* listener);
    00232     protected:
    00234         std::set<MovableObject*> mObjsThisQuery;
    00236         std::vector<SceneQuery::WorldFragment*> mSingleIntersections;
    00237
    00238         void clearTemporaries(void);
    00242         bool processNode(const BspNode* node, const Ray& tracingRay, RaySceneQueryListener* listener,
    00243             Real maxDistance = Math::POS_INFINITY, Real traceDistance = 0.0f);
    00247         bool processLeaf(const BspNode* node, const Ray& tracingRay, RaySceneQueryListener* listener,
    00248             Real maxDistance = Math::POS_INFINITY, Real traceDistance = 0.0f);
    00249
    00250     };
    00251 }
    00252
    00253 #endif

Copyright © 2000-2005 by The OGRE Team
Last modified Sun Nov 20 12:35:57 2005