OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgrePCZSceneManager.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 PCZSceneManager.h - Portal Connected Zone Scene Manager
28 
29 -----------------------------------------------------------------------------
30 begin : Mon Feb 19 2007
31 author : Eric Cha
32 email : ericc@xenopi.com
33 Code Style Update :
34 -----------------------------------------------------------------------------
35 */
36 
37 #ifndef PCZ_SCENEMANAGER_H
38 #define PCZ_SCENEMANAGER_H
39 
40 #include <OgreSceneManager.h>
41 #include <OgreSphere.h>
42 
43 #include "OgrePCZPrerequisites.h"
44 #include "OgrePCZSceneNode.h"
45 #include "OgrePCZone.h"
46 #include "OgrePCZoneFactory.h"
47 #include "OgrePortal.h"
48 #include "OgreAntiPortal.h"
49 
50 namespace Ogre
51 {
52 
53  class PCZone;
54  class PCZCamera;
55  class PCZIntersectionSceneQuery;
56  class PCZRaySceneQuery;
57  class PCZSphereSceneQuery;
58  class PCZAxisAlignedBoxSceneQuery;
59  class PCZPlaneBoundedVolumeListSceneQuery;
60 
63 
68  {
70  friend class PCZRaySceneQuery;
71  friend class PCZSphereSceneQuery;
74 
75  public:
77  PCZSceneManager(const String& name);
79  ~PCZSceneManager();
80 
82  const String& getTypeName(void) const;
83 
86  void init(const String &defaultZoneTypeName,
87  const String &filename = "none");
88 
91  Portal* createPortal(const String& name, PortalBase::PORTAL_TYPE type = PortalBase::PORTAL_TYPE_QUAD);
92 
95  void destroyPortal(Portal * p);
96 
99  void destroyPortal(const String & portalName);
100 
102  AntiPortal* createAntiPortal(const String& name, PortalBase::PORTAL_TYPE type = PortalBase::PORTAL_TYPE_QUAD);
103 
105  void destroyAntiPortal(AntiPortal * p);
106 
108  void destroyAntiPortal(const String& portalName);
109 
113  PCZone * createZoneFromFile(const String &zoneTypeName,
114  const String &zoneName,
115  PCZSceneNode * parentNode,
116  const String & filename);
117 
119  virtual void setZoneGeometry(const String & zoneName,
120  PCZSceneNode * parentNode,
121  const String &filename);
122 
124  virtual SceneNode* createSceneNodeImpl(void);
126  virtual SceneNode* createSceneNodeImpl(const String& name);
128  virtual SceneNode * createSceneNode ( void );
130  virtual SceneNode * createSceneNode ( const String &name );
132  virtual Camera * createCamera( const String &name );
133 
135  virtual void destroySceneNode( const String &name );
136 
138  virtual void destroySceneNode(SceneNode* sn);
139 
142  virtual void clearScene(void);
143 
145  void setWorldGeometryRenderQueue(uint8 qid);
146 
148  void _renderScene(Camera *cam, Viewport *vp, bool includeOverlays);
149 
151  void enableSky(bool);
152 
154  void setSkyZone(PCZone * zone);
155 
157  virtual void _updateSceneGraph( Camera * cam );
158 
160  virtual void _findVisibleObjects ( Camera * cam,
161  VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters );
162 
167  virtual void _alertVisibleObjects( void );
168 
179  virtual Light* createLight(const String& name);
180 
184  virtual Light* getLight(const String& name) const;
185 
188  virtual bool hasLight(const String& name) const;
189 
194  virtual void destroyLight(const String& name);
195 
198  virtual void destroyAllLights(void);
199 
204  void _updatePortalZoneData(void);
205 
207  void _dirtyNodeByMovingPortals(void);
208 
211  void _updatePCZSceneNodes(void);
212 
215  void _calcZonesAffectedByLights(Camera * cam);
216 
217  /* Attempt to automatically connect unconnected portals to proper target zones
218  * by looking for matching portals in other zones which are at the same location
219  */
220  void connectPortalsToTargetZonesByLocation(void);
221 
225  void _updatePCZSceneNode( PCZSceneNode * );
226 
228  void removeSceneNode( SceneNode * );
229 
233  void addPCZSceneNode(PCZSceneNode * sn, PCZone * zone);
234 
236  PCZone * createZone(const String& zoneType, const String& instanceName);
237 
239  void destroyZone(PCZone* zone, bool destroySceneNodes);
240 
243  void _updateHomeZone( PCZSceneNode *, bool );
244 
246  PCZone * findZoneForPoint(Vector3 & point);
247 
249  void createZoneSpecificNodeData(PCZSceneNode *);
250 
252  void createZoneSpecificNodeData(PCZone *);
253 
255  void setNodeHomeZone(SceneNode *, PCZone *);
256 
260  void findNodesIn( const AxisAlignedBox &box,
262  PCZone * startZone,
263  PCZSceneNode *exclude = 0 );
264 
268  void findNodesIn( const Sphere &sphere,
270  PCZone * startZone,
271  PCZSceneNode *start = 0 );
272 
276  void findNodesIn( const PlaneBoundedVolume &volume,
278  PCZone * startZone,
279  PCZSceneNode *start=0 );
280 
285  void findNodesIn( const Ray &ray,
287  PCZone * startZone,
288  PCZSceneNode *start=0 );
289 
292  {
293  return mDefaultZone;
294  }
295 
297  PCZone * getZoneByName(const String & zoneName);
298 
300  void setShowPortals( bool b )
301  {
302  mShowPortals = b;
303  };
304 
311  virtual bool setOption( const String &, const void * );
316  virtual bool getOption( const String &, void * );
317 
318  bool getOptionValues( const String & key, StringVector &refValueList );
319  bool getOptionKeys( StringVector &refKeys );
320 
322  AxisAlignedBoxSceneQuery* createAABBQuery(const AxisAlignedBox& box, uint32 mask = 0xFFFFFFFF);
323  SphereSceneQuery* createSphereQuery(const Sphere& sphere, uint32 mask = 0xFFFFFFFF);
324  PlaneBoundedVolumeListSceneQuery* createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, uint32 mask = 0xFFFFFFFF);
325  RaySceneQuery* createRayQuery(const Ray& ray, uint32 mask = 0xFFFFFFFF);
326  IntersectionSceneQuery* createIntersectionQuery(uint32 mask = 0xFFFFFFFF);
327 
330  ZoneIterator getZoneIterator(void) {return ZoneIterator(mZones.begin(), mZones.end());}
331 
333  void _clearAllZonesPortalUpdateFlag(void);
334 
336  virtual void prepareShadowTextures(Camera* cam, Viewport* vp, const LightList* lightList = 0);
337 
338  protected:
341 
344 
347 
350 
353 
356 
359 
362 
365 
367  unsigned long mFrameCount;
368 
371 
374 
381  virtual void findLightsAffectingFrustum(const Camera* camera);
383  virtual void ensureShadowTexturesCreated();
385  virtual void destroyShadowTextures(void);
387  virtual void fireShadowTexturesPreCaster(Light* light, Camera* camera, size_t iteration);
388  };
389 
392  {
393  protected:
394  void initMetaData(void) const;
395  public:
399  static const String FACTORY_TYPE_NAME;
400  SceneManager* createInstance(const String& instanceName);
401  void destroyInstance(SceneManager* instance);
402  };
403 
404 
405 
406 }
407 
408 #endif
409 
410 
vector< SceneNode * >::type NodeList
Definition: OgrePCZone.h:74
Representation of a ray in space, i.e.
Definition: OgreRay.h:46
PortalList mPortals
Master list of Portals in the world (includes all portals)
unsigned char uint8
Definition: OgrePlatform.h:346
Factory for PCZSceneManager.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
AntiPortal datastructure for occlusion culling.
set< PCZSceneNode * >::type PCZSceneNodeList
unsigned int uint32
Definition: OgrePlatform.h:344
std::vector< SceneNode *, A > type
Camera * mLastActiveCamera
Camera of last _findVisibleObjects()
ZoneIterator getZoneIterator(void)
PCZoneFactoryManager * mZoneFactoryManager
ZoneFactoryManager instance.
NodeList mVisible
List of visible nodes since last _findVisibleObjects()
Manages the organisation and rendering of a 'scene' i.e.
void setShowPortals(bool b)
Sets the portal visibility flag.
Specialises the SceneQuery class for querying within a sphere.
A 3D box aligned with the x/y/z axes.
std::list< WireBoundingBox *, A > type
unsigned long mFrameCount
Frame counter used in visibility determination.
PCZ implementation of AxisAlignedBoxSceneQuery.
Class representing a node in the scene graph.
Definition: OgreSceneNode.h:58
static const String FACTORY_TYPE_NAME
Factory type name.
PCZone * getDefaultZone(void)
Get the default zone.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
vector< PlaneBoundedVolume >::type PlaneBoundedVolumeList
PCZ implementation of RaySceneQuery.
Portal datastructure for connecting zones.
Definition: OgrePortal.h:51
bool mShowPortals
Portals visibility flag.
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:73
PCZ implementation of IntersectionSceneQuery.
String mDefaultZoneFileName
Name of data file for default zone.
PCZ implementation of SphereSceneQuery.
PCZone * mDefaultZone
The root PCZone;.
void initMetaData(void) const
Internal method to initialise the metadata, must be implemented.
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
PCZone * mActiveCameraZone
The zone of the active camera (for shadow texture casting use);.
#define _OgrePCZPluginExport
list< WireBoundingBox * >::type BoxList
AntiPortalList mAntiPortals
Master list of AntiPortals in the world.
vector< String >::type StringVector
String mDefaultZoneTypeName
Type of default zone to be used.
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
SceneManager * createInstance(const String &instanceName)
Create a new instance of a SceneManager.
Represents a convex volume bounded by planes.
list< Portal * >::type PortalList
Definition: OgrePCZone.h:71
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:57
PCZ implementation of PlaneBoundedVolumeListSceneQuery.
list< AntiPortal * >::type AntiPortalList
Definition: OgrePCZone.h:72
ZoneMap mZones
The list of all PCZones.
MapIterator< ZoneMap > ZoneIterator
ZoneMap iterator for read-only access to the zonemap.
Specialises the SceneQuery class for querying within an axis aligned box.
Specialises the SceneQuery class for querying within a plane-bounded volume.
Portal-Connected Zone datastructure for managing scene nodes.
Definition: OgrePCZone.h:81
_StringBase String
Separate SceneQuery class to query for pairs of objects which are possibly intersecting one another...
void destroyInstance(SceneManager *instance)
Destroy an instance of a SceneManager.
Structure collecting together information about the visible objects that have been discovered in a sc...
Specialises the SceneQuery class for querying along a ray.
map< String, PCZone * >::type ZoneMap
Definition: OgrePCZone.h:67
Specialized SceneManager that uses Portal-Connected-Zones to divide the scene spatially.
Class which will create instances of a given SceneManager.