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 // World geometry 00066 BspLevelPtr mLevel; 00067 00068 // State variables for rendering WIP 00069 // Set of face groups (by index) already included 00070 typedef std::set<int> FaceGroupSet; 00071 FaceGroupSet mFaceGroupSet; 00072 // Material -> face group hashmap 00073 typedef std::map<Material*, std::vector<StaticFaceGroup*>, materialLess > MaterialFaceGroupMap; 00074 MaterialFaceGroupMap mMatFaceGroupMap; 00075 00076 RenderOperation mRenderOp; 00077 00078 // Debugging features 00079 bool mShowNodeAABs; 00080 RenderOperation mAABGeometry; 00081 00088 BspNode* walkTree(Camera* camera, bool onlyShadowCasters); 00090 void processVisibleLeaf(BspNode* leaf, Camera* cam, bool onlyShadowCasters); 00091 00093 unsigned int cacheGeometry(unsigned int* pIndexes, const StaticFaceGroup* faceGroup); 00094 00096 void freeMemory(void); 00097 00099 void addBoundingBox(const AxisAlignedBox& aab, bool visible); 00100 00102 void renderStaticGeometry(void); 00103 00105 void clearScene(void); 00106 00107 00108 typedef std::set<const MovableObject*> MovablesForRendering; 00109 MovablesForRendering mMovablesForRendering; 00110 00111 public: 00112 BspSceneManager(const String& name); 00113 ~BspSceneManager(); 00114 00115 00117 const String& getTypeName(void) const; 00118 00120 void setWorldGeometry(const String& filename); 00121 00123 size_t estimateWorldGeometry(const String& filename); 00124 00126 void setWorldGeometry(DataStreamPtr& stream, 00127 const String& typeName = StringUtil::BLANK); 00128 00130 size_t estimateWorldGeometry(DataStreamPtr& stream, 00131 const String& typeName = StringUtil::BLANK); 00132 00136 void showNodeBoxes(bool show); 00137 00139 ViewPoint getSuggestedViewpoint(bool random = false); 00140 00141 const BspLevelPtr& getLevel(void) {return mLevel; } 00142 00144 void _findVisibleObjects(Camera* cam, bool onlyShadowCasters); 00145 00147 void _renderVisibleObjects(void); 00148 00150 SceneNode * createSceneNode ( void ); 00152 SceneNode * createSceneNode ( const String &name ); 00153 00155 void _notifyObjectMoved(const MovableObject* mov, const Vector3& pos); 00157 void _notifyObjectDetached(const MovableObject* mov); 00158 00171 /* 00172 virtual AxisAlignedBoxSceneQuery* 00173 createAABBQuery(const AxisAlignedBox& box, unsigned long mask = 0xFFFFFFFF); 00174 */ 00187 /* 00188 virtual SphereSceneQuery* 00189 createSphereQuery(const Sphere& sphere, unsigned long mask = 0xFFFFFFFF); 00190 */ 00203 virtual RaySceneQuery* 00204 createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF); 00216 virtual IntersectionSceneQuery* 00217 createIntersectionQuery(unsigned long mask = 0xFFFFFFFF); 00218 00219 }; 00220 00222 class BspIntersectionSceneQuery : public DefaultIntersectionSceneQuery 00223 { 00224 public: 00225 BspIntersectionSceneQuery(SceneManager* creator); 00226 00228 void execute(IntersectionSceneQueryListener* listener); 00229 00230 }; 00231 00233 class BspRaySceneQuery : public DefaultRaySceneQuery 00234 { 00235 public: 00236 BspRaySceneQuery(SceneManager* creator); 00237 ~BspRaySceneQuery(); 00238 00240 void execute(RaySceneQueryListener* listener); 00241 protected: 00243 std::set<MovableObject*> mObjsThisQuery; 00245 std::vector<SceneQuery::WorldFragment*> mSingleIntersections; 00246 00247 void clearTemporaries(void); 00251 bool processNode(const BspNode* node, const Ray& tracingRay, RaySceneQueryListener* listener, 00252 Real maxDistance = Math::POS_INFINITY, Real traceDistance = 0.0f); 00256 bool processLeaf(const BspNode* node, const Ray& tracingRay, RaySceneQueryListener* listener, 00257 Real maxDistance = Math::POS_INFINITY, Real traceDistance = 0.0f); 00258 00259 }; 00260 00262 class BspSceneManagerFactory : public SceneManagerFactory 00263 { 00264 protected: 00265 void initMetaData(void) const; 00266 public: 00267 BspSceneManagerFactory() {} 00268 ~BspSceneManagerFactory() {} 00270 static const String FACTORY_TYPE_NAME; 00271 SceneManager* createInstance(const String& instanceName); 00272 void destroyInstance(SceneManager* instance); 00273 }; 00274 } 00275 00276 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:38 2006