OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreBspSceneManager.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-2013 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 __BspSceneManager_H__
29 #define __BspSceneManager_H__
30 
31 
32 #include "OgreBspPrerequisites.h"
33 #include "OgreSceneManager.h"
34 #include "OgreStaticFaceGroup.h"
35 #include "OgreRenderOperation.h"
36 #include "OgreBspLevel.h"
37 #include <set>
38 
39 
40 namespace Ogre {
41 
42 
65  {
66  protected:
67 
68  // World geometry
70 
71  // State variables for rendering WIP
72  // Set of face groups (by index) already included
75  // Material -> face group hashmap
78 
80 
81  // Debugging features
84 
91  BspNode* walkTree(Camera* camera, VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters);
93  void processVisibleLeaf(BspNode* leaf, Camera* cam,
94  VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters);
95 
97  unsigned int cacheGeometry(unsigned int* pIndexes, const StaticFaceGroup* faceGroup);
98 
100  void freeMemory(void);
101 
103  void addBoundingBox(const AxisAlignedBox& aab, bool visible);
104 
106  void renderStaticGeometry(void);
107 
109  void clearScene(void);
110 
111  // Overridden so we can manually render world geometry
112  bool fireRenderQueueEnded(uint8 id, const String& invocation);
113 
116 
117  public:
118  BspSceneManager(const String& name);
120 
121 
123  const String& getTypeName(void) const;
124 
126  void setWorldGeometry(const String& filename);
127 
129  size_t estimateWorldGeometry(const String& filename);
130 
132  void setWorldGeometry(DataStreamPtr& stream,
133  const String& typeName = StringUtil::BLANK);
134 
136  size_t estimateWorldGeometry(DataStreamPtr& stream,
137  const String& typeName = StringUtil::BLANK);
138 
142  void showNodeBoxes(bool show);
143 
145  ViewPoint getSuggestedViewpoint(bool random = false);
146 
147  const BspLevelPtr& getLevel(void) {return mLevel; }
148 
150  void _findVisibleObjects(Camera* cam, VisibleObjectsBoundsInfo* visibleBounds,
151  bool onlyShadowCasters);
152 
154  SceneNode * createSceneNodeImpl ( void );
156  SceneNode * createSceneNodeImpl ( const String &name );
157 
159  void _notifyObjectMoved(const MovableObject* mov, const Vector3& pos);
161  void _notifyObjectDetached(const MovableObject* mov);
162 
175  /*
176  virtual AxisAlignedBoxSceneQuery*
177  createAABBQuery(const AxisAlignedBox& box, unsigned long mask = 0xFFFFFFFF);
178  */
191  /*
192  virtual SphereSceneQuery*
193  createSphereQuery(const Sphere& sphere, unsigned long mask = 0xFFFFFFFF);
194  */
207  virtual RaySceneQuery*
208  createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF);
220  virtual IntersectionSceneQuery*
221  createIntersectionQuery(unsigned long mask = 0xFFFFFFFF);
222 
223  };
224 
227  {
228  public:
230 
232  void execute(IntersectionSceneQueryListener* listener);
233 
234  };
235 
238  {
239  public:
240  BspRaySceneQuery(SceneManager* creator);
242 
244  void execute(RaySceneQueryListener* listener);
245  protected:
250 
251  void clearTemporaries(void);
255  bool processNode(const BspNode* node, const Ray& tracingRay, RaySceneQueryListener* listener,
256  Real maxDistance = Math::POS_INFINITY, Real traceDistance = 0.0f);
260  bool processLeaf(const BspNode* node, const Ray& tracingRay, RaySceneQueryListener* listener,
261  Real maxDistance = Math::POS_INFINITY, Real traceDistance = 0.0f);
262 
263  };
264 
267  {
268  protected:
269  void initMetaData(void) const;
270  public:
274  static const String FACTORY_TYPE_NAME;
275  SceneManager* createInstance(const String& instanceName);
276  void destroyInstance(SceneManager* instance);
277  };
278 }
279 
280 #endif
Representation of a ray in space, i.e.
Definition: OgreRay.h:46
unsigned char uint8
Definition: OgrePlatform.h:272
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
static const String FACTORY_TYPE_NAME
Factory type name.
float Real
Software floating point type.
virtual RaySceneQueryResult & execute(void)
Executes the query, returning the results back in one list.
map< Material *, vector< StaticFaceGroup * >::type, materialLess >::type MaterialFaceGroupMap
RenderOperation mAABGeometry
std::vector< T, A > type
bool fireRenderQueueEnded(uint8 id, const String &invocation)
Internal method for firing the queue end event, returns true if queue is to be repeated.
void initMetaData(void) const
Internal method to initialise the metadata, must be implemented.
void renderStaticGeometry(void)
Renders the static level geometry tagged in walkTree.
void setWorldGeometry(const String &filename)
Specialised from SceneManager to support Quake3 bsp files.
MovablesForRendering mMovablesForRendering
BspSceneManager(const String &name)
SceneNode * createSceneNodeImpl(void)
Creates a specialized BspSceneNode.
void showNodeBoxes(bool show)
Tells the manager whether to draw the axis-aligned boxes that surround nodes in the Bsp tree...
BSP specialisation of IntersectionSceneQuery.
Manages the organisation and rendering of a 'scene' i.e.
Comparator for material map, for sorting materials into render order (e.g.
ViewPoint getSuggestedViewpoint(bool random=false)
Specialised to suggest viewpoints.
SceneManager * createInstance(const String &instanceName)
Create a new instance of a SceneManager.
A 3D box aligned with the x/y/z axes.
virtual RaySceneQuery * createRayQuery(const Ray &ray, unsigned long mask=0xFFFFFFFF)
Creates an AxisAlignedBoxSceneQuery for this scene manager.
void processVisibleLeaf(BspNode *leaf, Camera *cam, VisibleObjectsBoundsInfo *visibleBounds, bool onlyShadowCasters)
Tags geometry in the leaf specified for later rendering.
Abstract class defining a movable object in a scene.
Class representing a node in the scene graph.
Definition: OgreSceneNode.h:58
const BspLevelPtr & getLevel(void)
Specialisation of SharedPtr to allow SharedPtr to be assigned to BspLevelPtr.
Definition: OgreBspLevel.h:238
std::set< T, P, A > type
set< const MovableObject * >::type MovablesForRendering
void clearTemporaries(void)
void _notifyObjectMoved(const MovableObject *mov, const Vector3 &pos)
Internal method for tagging BspNodes with objects which intersect them.
void addBoundingBox(const AxisAlignedBox &aab, bool visible)
Adds a bounding box to draw if turned on.
Default implementation of IntersectionSceneQuery.
static const Real POS_INFINITY
Definition: OgreMath.h:677
void _notifyObjectDetached(const MovableObject *mov)
Internal method for notifying the level that an object has been detached from a node.
Specialisation of the SceneManager class to deal with indoor scenes based on a BSP tree...
Collects a group of static i.e.
Alternative listener class for dealing with RaySceneQuery.
bool processNode(const BspNode *node, const Ray &tracingRay, RaySceneQueryListener *listener, Real maxDistance=Math::POS_INFINITY, Real traceDistance=0.0f)
Internal processing of a single node.
Alternative listener class for dealing with IntersectionSceneQuery.
void freeMemory(void)
Frees up allocated memory for geometry caches.
void _findVisibleObjects(Camera *cam, VisibleObjectsBoundsInfo *visibleBounds, bool onlyShadowCasters)
Overriden from SceneManager.
virtual IntersectionSceneQueryResult & execute(void)
Executes the query, returning the results back in one list.
size_t estimateWorldGeometry(const String &filename)
Specialised from SceneManager to support Quake3 bsp files.
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
BspIntersectionSceneQuery(SceneManager *creator)
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Default implementation of RaySceneQuery.
'New' rendering operation using vertex buffers.
vector< SceneQuery::WorldFragment * >::type mSingleIntersections
list of the last single intersection world fragments (derived)
BSP specialisation of RaySceneQuery.
void destroyInstance(SceneManager *instance)
Destroy an instance of a SceneManager.
virtual IntersectionSceneQuery * createIntersectionQuery(unsigned long mask=0xFFFFFFFF)
Creates an IntersectionSceneQuery for this scene manager.
Structure for holding a position & orientation pair.
set< MovableObject * >::type mObjsThisQuery
Set for eliminating duplicates since objects can be in > 1 node.
_StringBase String
const String & getTypeName(void) const
Retrieve the type name of this scene manager.
Factory for BspSceneManager.
set< int >::type FaceGroupSet
unsigned int cacheGeometry(unsigned int *pIndexes, const StaticFaceGroup *faceGroup)
Caches a face group for imminent rendering.
BspNode * walkTree(Camera *camera, VisibleObjectsBoundsInfo *visibleBounds, bool onlyShadowCasters)
Walks the BSP tree looking for the node which the camera is in, and tags any geometry which is in a v...
Separate SceneQuery class to query for pairs of objects which are possibly intersecting one another...
MaterialFaceGroupMap mMatFaceGroupMap
void clearScene(void)
Empties the entire scene, inluding all SceneNodes, Entities, Lights, BillboardSets etc...
BspRaySceneQuery(SceneManager *creator)
bool processLeaf(const BspNode *node, const Ray &tracingRay, RaySceneQueryListener *listener, Real maxDistance=Math::POS_INFINITY, Real traceDistance=0.0f)
Internal processing of a single leaf.
Structure collecting together information about the visible objects that have been discovered in a sc...
Specialises the SceneQuery class for querying along a ray.
Encapsulates a node in a BSP tree.
Definition: OgreBspNode.h:51
Class which will create instances of a given SceneManager.