Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreBspLevel.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://www.ogre3d.org/
00006 
00007 Copyright © 2000-2002 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 _BspLevel_H__
00026 #define _BspLevel_H__
00027 
00028 #include "OgreBspPrerequisites.h"
00029 #include "OgreResource.h"
00030 #include "OgreStaticFaceGroup.h"
00031 #include "OgreSceneManager.h"
00032 #include "OgreBspNode.h"
00033 #include "OgreHardwareBufferManager.h"
00034 #include "OgreDefaultHardwareBufferManager.h"
00035 #include "OgreQuake3Level.h"
00036 
00037 
00038 namespace Ogre {
00039 
00053     class BspLevel : public Resource
00054     {
00055         friend class BspSceneManager;
00056     public:
00058         BspLevel(const String& name);
00059         ~BspLevel();
00060 
00062         virtual void load(void);
00064         virtual void unload(void);
00065 
00067         bool isLeafVisible(const BspNode* from, const BspNode* to) const;
00068 
00070         const BspNode* getRootNode(void);
00071 
00075         BspNode* findLeaf(const Vector3& point) const;
00076 
00080         void _notifyObjectMoved(const MovableObject* mov, 
00081             const Vector3& pos);
00083         void _notifyObjectDetached(const MovableObject* mov);
00085         BspNode* getLeafStart(void) {return &mRootNode[mLeafStart]; }
00087         int getNumLeaves(void) const { return mNumLeaves; }
00088 
00090     protected:
00097         BspNode* mRootNode;
00098         int mNumNodes;
00099         int mNumLeaves;
00100         int mLeafStart; // the index at which leaf nodes begin
00101 
00109         struct BspVertex
00110         {
00111             Real position[3];
00112             Real normal[3];
00113             int colour;
00114             Real texcoords[2];
00115             Real lightmap[2];
00116         };
00117         /*
00119         BspVertex* mVertices;
00120         int mNumVertices;
00121         */
00123         VertexData* mVertexData;
00124 
00128         int* mLeafFaceGroups;
00129         int mNumLeafFaceGroups;
00130 
00132         StaticFaceGroup* mFaceGroups;
00133         int mNumFaceGroups;
00134 
00135 
00136         /*
00138         int* mElements;
00139         int mNumElements;
00140         */
00141 
00143         size_t mNumIndexes;
00144         // system-memory buffer
00145         DefaultHardwareIndexBuffer* mIndexes;
00146 
00148         BspNode::Brush *mBrushes;
00149 
00151         std::vector<ViewPoint> mPlayerStarts;
00152 
00154         void loadQuake3Level(const Quake3Level& q3lvl);
00170         struct VisData
00171         {
00172             unsigned char *tableData;
00173             int numClusters;            // Number of clusters, therefore number of rows
00174             int rowLength;                // Length in bytes of each row (num clusters / 8 rounded up)
00175         };
00176 
00177         VisData mVisData;
00178 
00179 
00181         void loadEntities(const Quake3Level& q3lvl);
00182 
00183         typedef std::map<const MovableObject*, std::list<BspNode*> > MovableToNodeMap;
00185         MovableToNodeMap mMovableToNodeMap;
00186 
00187         void tagNodesWithMovable(BspNode* node, const MovableObject* mov, const Vector3& pos);
00188 
00189         // Storage of patches 
00190         typedef std::map<int, PatchSurface*> PatchMap;
00191         PatchMap mPatches;
00192         // Total number of vertices required for all patches
00193         size_t mPatchVertexCount;
00194         // Total number of indexes required for all patches
00195         size_t mPatchIndexCount;
00196 
00197         void initQuake3Patches(const Quake3Level & q3lvl, VertexDeclaration* decl);
00198         void buildQuake3Patches(size_t vertOffset, size_t indexOffset);
00199 
00200         void quakeVertexToBspVertex(const bsp_vertex_t* src, BspVertex* dest);
00201 
00202 
00203 
00204 
00205 
00206     };
00207 
00208 }
00209 
00210 #endif

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