OGRE  2.0
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 "OgrePCZPrerequisites.h"
41 #include "OgreSceneManager.h"
42 #include "OgrePCZone.h"
43 
44 namespace Ogre
45 {
46  class PCZoneFactoryManager;
47  class PortalBase;
48 
51 
56  {
58  friend class PCZRaySceneQuery;
59  friend class PCZSphereSceneQuery;
62 
63  public:
65  PCZSceneManager(const String& name);
67  ~PCZSceneManager();
68 
70  const String& getTypeName(void) const;
71 
74  void init(const String &defaultZoneTypeName,
75  const String &filename = "none");
76 
79  Portal* createPortal(const String& name, PortalBase::PORTAL_TYPE type = PortalBase::PORTAL_TYPE_QUAD);
80 
83  void destroyPortal(Portal * p);
84 
87  void destroyPortal(const String & portalName);
88 
90  AntiPortal* createAntiPortal(const String& name, PortalBase::PORTAL_TYPE type = PortalBase::PORTAL_TYPE_QUAD);
91 
93  void destroyAntiPortal(AntiPortal * p);
94 
96  void destroyAntiPortal(const String& portalName);
97 
101  PCZone * createZoneFromFile(const String &zoneTypeName,
102  const String &zoneName,
103  PCZSceneNode * parentNode,
104  const String & filename);
105 
107  virtual void setZoneGeometry(const String & zoneName,
108  PCZSceneNode * parentNode,
109  const String &filename);
110 
112  virtual SceneNode* createSceneNodeImpl(void);
114  virtual SceneNode* createSceneNodeImpl(const String& name);
116  virtual SceneNode * createSceneNode ( void );
118  virtual SceneNode * createSceneNode ( const String &name );
120  virtual Camera * createCamera( const String &name );
121 
123  virtual void destroySceneNode( const String &name );
124 
126  virtual void destroySceneNode(SceneNode* sn);
127 
130  virtual void clearScene(void);
131 
133  void setWorldGeometryRenderQueue(uint8 qid);
134 
136  void _renderScene(Camera *cam, Viewport *vp, bool includeOverlays);
137 
139  void enableSky(bool);
140 
142  void setSkyZone(PCZone * zone);
143 
145  virtual void _updateSceneGraph( Camera * cam );
146 
148  virtual void _findVisibleObjects ( Camera * cam,
149  VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters );
150 
155  virtual void _alertVisibleObjects( void );
156 
167  virtual Light* createLight(const String& name);
168 
172  virtual Light* getLight(const String& name) const;
173 
176  virtual bool hasLight(const String& name) const;
177 
182  virtual void destroyLight(const String& name);
183 
186  virtual void destroyAllLights(void);
187 
192  void _updatePortalZoneData(void);
193 
195  void _dirtyNodeByMovingPortals(void);
196 
199  void _updatePCZSceneNodes(void);
200 
203  void _calcZonesAffectedByLights(Camera * cam);
204 
205  /* Attempt to automatically connect unconnected portals to proper target zones
206  * by looking for matching portals in other zones which are at the same location
207  */
208  void connectPortalsToTargetZonesByLocation(void);
209 
213  void _updatePCZSceneNode( PCZSceneNode * );
214 
216  void removeSceneNode( SceneNode * );
217 
221  void addPCZSceneNode(PCZSceneNode * sn, PCZone * zone);
222 
224  PCZone * createZone(const String& zoneType, const String& instanceName);
225 
227  void destroyZone(PCZone* zone, bool destroySceneNodes);
228 
231  void _updateHomeZone( PCZSceneNode *, bool );
232 
234  PCZone * findZoneForPoint(Vector3 & point);
235 
237  void createZoneSpecificNodeData(PCZSceneNode *);
238 
240  void createZoneSpecificNodeData(PCZone *);
241 
243  void setNodeHomeZone(SceneNode *, PCZone *);
244 
248  void findNodesIn( const AxisAlignedBox &box,
250  PCZone * startZone,
251  PCZSceneNode *exclude = 0 );
252 
256  void findNodesIn( const Sphere &sphere,
258  PCZone * startZone,
259  PCZSceneNode *start = 0 );
260 
264  void findNodesIn( const PlaneBoundedVolume &volume,
266  PCZone * startZone,
267  PCZSceneNode *start=0 );
268 
273  void findNodesIn( const Ray &ray,
275  PCZone * startZone,
276  PCZSceneNode *start=0 );
277 
280  {
281  return mDefaultZone;
282  }
283 
285  PCZone * getZoneByName(const String & zoneName);
286 
288  void setShowPortals( bool b )
289  {
290  mShowPortals = b;
291  };
292 
299  virtual bool setOption( const String &, const void * );
304  virtual bool getOption( const String &, void * );
305 
306  bool getOptionValues( const String & key, StringVector &refValueList );
307  bool getOptionKeys( StringVector &refKeys );
308 
310  AxisAlignedBoxSceneQuery* createAABBQuery(const AxisAlignedBox& box, uint32 mask = 0xFFFFFFFF);
311  SphereSceneQuery* createSphereQuery(const Sphere& sphere, uint32 mask = 0xFFFFFFFF);
312  PlaneBoundedVolumeListSceneQuery* createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, uint32 mask = 0xFFFFFFFF);
313  RaySceneQuery* createRayQuery(const Ray& ray, uint32 mask = 0xFFFFFFFF);
314  IntersectionSceneQuery* createIntersectionQuery(uint32 mask = 0xFFFFFFFF);
315 
318  ZoneIterator getZoneIterator(void) {return ZoneIterator(mZones.begin(), mZones.end());}
319 
321  void _clearAllZonesPortalUpdateFlag(void);
322 
324  virtual void prepareShadowTextures(Camera* cam, Viewport* vp, const LightList* lightList = 0);
325 
326  protected:
329 
332 
335 
338 
341 
344 
347 
350 
353 
355  unsigned long mFrameCount;
356 
359 
362 
369  virtual void findLightsAffectingFrustum(const Camera* camera);
371  virtual void ensureShadowTexturesCreated();
373  virtual void destroyShadowTextures(void);
375  virtual void fireShadowTexturesPreCaster(Light* light, Camera* camera, size_t iteration);
376  };
377 
380  {
381  protected:
382  void initMetaData(void) const;
383  public:
387  static const String FACTORY_TYPE_NAME;
388  SceneManager* createInstance(const String& instanceName);
389  void destroyInstance(SceneManager* instance);
390  };
391 
392 
393 
394 }
395 
396 #endif
397 
398 
vector< SceneNode * >::type NodeList
Definition: OgrePCZone.h:74
Representation of a ray in space, i.e.
Definition: OgreRay.h:45
PortalList mPortals
Master list of Portals in the world (includes all portals)
unsigned char uint8
Definition: OgrePlatform.h:422
Factory for PCZSceneManager.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
AntiPortal datastructure for occlusion culling.
set< PCZSceneNode * >::type PCZSceneNodeList
unsigned int uint32
Definition: OgrePlatform.h:420
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:53
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:70
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:50
SceneManager * createInstance(const String &instanceName)
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:56
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
Definition: OgreCommon.h:53
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.
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.