OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreBspLevel.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef _BspLevel_H__
29 #define _BspLevel_H__
30 
31 #include "OgreBspPrerequisites.h"
32 #include "OgreResource.h"
33 #include "OgreStaticFaceGroup.h"
34 #include "OgreSceneManager.h"
35 #include "OgreBspNode.h"
38 #include "OgreQuake3Level.h"
39 
40 
41 namespace Ogre {
42 
56  class BspLevel : public Resource
57  {
58  friend class BspSceneManager;
59  public:
61  BspLevel(ResourceManager* creator, const String& name, ResourceHandle handle,
62  const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
63  ~BspLevel();
64 
66  bool isLeafVisible(const BspNode* from, const BspNode* to) const;
67 
69  const BspNode* getRootNode(void);
70 
74  BspNode* findLeaf(const Vector3& point) const;
75 
79  void _notifyObjectMoved(const MovableObject* mov,
80  const Vector3& pos);
82  void _notifyObjectDetached(const MovableObject* mov);
86  int getNumLeaves(void) const { return mNumLeaves; }
87 
89  static size_t calculateLoadingStages(const String& levelName);
91  static size_t calculateLoadingStages(DataStreamPtr& stream);
92 
94  void load(DataStreamPtr& stream);
95 
97  bool isSkyEnabled(void) const;
99  const String& getSkyMaterialName(void) const;
101  Real getSkyCurvature(void) const;
102 
104  protected:
106  void loadImpl(void);
108  void unloadImpl(void);
110  size_t calculateSize(void) const;
122 
130  struct BspVertex
131  {
132  float position[3];
133  float normal[3];
134  int colour;
135  float texcoords[2];
136  float lightmap[2];
137  };
138 
141 
147 
151 
153  size_t mNumIndexes;
156 
159 
162 
164  void loadQuake3Level(const Quake3Level& q3lvl);
180  struct VisData
181  {
182  unsigned char *tableData;
184  int rowLength;
185  };
186 
188 
189 
191  void loadEntities(const Quake3Level& q3lvl);
192 
196 
197  void tagNodesWithMovable(BspNode* node, const MovableObject* mov, const Vector3& pos);
198 
212 
213 
214  void initQuake3Patches(const Quake3Level & q3lvl, VertexDeclaration* decl);
215  void buildQuake3Patches(size_t vertOffset, size_t indexOffset);
216 
217  void quakeVertexToBspVertex(const bsp_vertex_t* src, BspVertex* dest);
218 
219 
220  };
222 }
223 
224 #endif
void load(DataStreamPtr &stream)
Load direct from stream.
float Real
Software floating point type.
size_t calculateSize(void) const
size_t mPatchVertexCount
Total number of vertices required for all patches.
Definition: OgreBspLevel.h:203
std::vector< T, A > type
StaticFaceGroup * mFaceGroups
Array of face groups, indexed into by contents of mLeafFaceGroups.
Definition: OgreBspLevel.h:149
VertexData * mVertexData
Vertex data holding all the data for the level, but able to render parts of it.
Definition: OgreBspLevel.h:140
HardwareIndexBufferSharedPtr mIndexes
System-memory buffer.
Definition: OgreBspLevel.h:155
size_t mNumIndexes
Indexes for the whole level, will be copied to the real indexdata per frame.
Definition: OgreBspLevel.h:153
bool mSkyEnabled
Sky enabled?
Definition: OgreBspLevel.h:207
Interface describing a manual resource loader.
Definition: OgreResource.h:498
int getNumLeaves(void) const
Gets the number of leaf nodes.
Definition: OgreBspLevel.h:86
BspNode * mRootNode
Pointer to the root node of the BSP tree; This pointer actually has a dual purpose; to avoid allocati...
Definition: OgreBspLevel.h:117
void buildQuake3Patches(size_t vertOffset, size_t indexOffset)
BspNode * getLeafStart(void)
Gets a pointer to the start of the leaf nodes.
Definition: OgreBspLevel.h:84
map< int, PatchSurface * >::type PatchMap
Storage of patches.
Definition: OgreBspLevel.h:200
void loadEntities(const Quake3Level &q3lvl)
Internal method for parsing chosen entities.
Abstract class defining a movable object in a scene.
Real getSkyCurvature(void) const
Get sky curvature.
Shared pointer implementation used to share index buffers.
const String & getSkyMaterialName(void) const
Get Sky material name.
BspNode * findLeaf(const Vector3 &point) const
Walks the entire BSP tree and returns the leaf which contains the given point.
Specialisation of the SceneManager class to deal with indoor scenes based on a BSP tree...
Collects a group of static i.e.
The index at which leaf nodes begin.
Definition: OgreBspLevel.h:130
void initQuake3Patches(const Quake3Level &q3lvl, VertexDeclaration *decl)
Support for loading and extracting data from a Quake3 level file.
Real mSkyCurvature
Sky details.
Definition: OgreBspLevel.h:211
const BspNode * getRootNode(void)
Returns a pointer to the root node (BspNode) of the BSP tree.
static size_t calculateLoadingStages(const String &levelName)
Calculate the number of loading stages required for a given level.
BspLevel(ResourceManager *creator, const String &name, ResourceHandle handle, const String &group, bool isManual=false, ManualResourceLoader *loader=0)
Default constructor - used by BspResourceManager (do not call directly)
vector< ViewPoint >::type mPlayerStarts
Vector of player start points.
Definition: OgreBspLevel.h:161
void tagNodesWithMovable(BspNode *node, const MovableObject *mov, const Vector3 &pos)
SharedPtr< BspLevel > BspLevelPtr
Definition: OgreBspLevel.h:221
unsigned char * tableData
Definition: OgreBspLevel.h:182
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
map< const MovableObject *, list< BspNode * >::type >::type MovableToNodeMap
Definition: OgreBspLevel.h:193
Holds all the data associated with a Binary Space Parition (BSP) based indoor level.
Definition: OgreBspLevel.h:56
bool isSkyEnabled(void) const
Is sky enabled?
Internal lookup table to determine visibility between leaves.
Definition: OgreBspLevel.h:180
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:77
VisData mVisData
Definition: OgreBspLevel.h:187
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
Summary class collecting together vertex source information.
size_t mPatchIndexCount
Total number of indexes required for all patches.
Definition: OgreBspLevel.h:205
This class declares the format of a set of vertex inputs, which can be issued to the rendering API th...
void loadImpl(void)
Utility class just to enable queueing of patches.
String mSkyMaterial
Sky material.
Definition: OgreBspLevel.h:209
void unloadImpl(void)
PatchMap mPatches
Definition: OgreBspLevel.h:201
BspNode::Brush * mBrushes
Brushes as used for collision, main memory is here.
Definition: OgreBspLevel.h:158
Defines a generic resource handler.
void quakeVertexToBspVertex(const bsp_vertex_t *src, BspVertex *dest)
_StringBase String
Definition: OgreCommon.h:53
void _notifyObjectMoved(const MovableObject *mov, const Vector3 &pos)
Ensures that the MovableObject is attached to the right leaves of the BSP tree.
void _notifyObjectDetached(const MovableObject *mov)
Internal method, makes sure an object is removed from the leaves when detached from a node...
Encapsulates a node in a BSP tree.
Definition: OgreBspNode.h:51
MovableToNodeMap mMovableToNodeMap
Map for locating the nodes a movable is currently a member of.
Definition: OgreBspLevel.h:195
bool isLeafVisible(const BspNode *from, const BspNode *to) const
Determines if one leaf node is visible from another.
int rowLength
Number of clusters, therefore number of rows.
Definition: OgreBspLevel.h:184
void loadQuake3Level(const Quake3Level &q3lvl)
Internal utility function for loading data from Quake3.
int * mLeafFaceGroups
Array of indexes into the mFaceGroups array.
Definition: OgreBspLevel.h:145