OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgrePCZone.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 PCZone.h - Portal Connected Zone (PCZone) header file.
28 -----------------------------------------------------------------------------
29 Portal Connected Zones are spatial constructs for partitioning space into cross
30 connected zones. Each zone is connected to other zones using Portal nodes.
31 
32 Zones contain references to nodes which touch them. However, zones do not
33 care how nodes are arranged hierarchically. Whether or not a node is
34 referenced as being part of a zone is entirely determined by the user or
35 by the node crossing a portal into or out-of the zone.
36 
37 Nodes can be referenced by several zones at once, but only one zone is
38 considered the "home" zone of the node. Home zone is determined by location
39 of the centerpoint of the node. Nodes can "touch" other zones if the node
40 BV intersects a portal (this is also called "visiting" a zone). Nodes keep
41 a pointer to their home zone and a list of references to zones they are
42 "visiting".
43 -----------------------------------------------------------------------------
44 begin : Tue Feb 20 2007
45 author : Eric Cha
46 email : ericc@xenopi.com
47 Code Style Update :
48 -----------------------------------------------------------------------------
49 */
50 
51 #ifndef PCZONE_H
52 #define PCZONE_H
53 
54 #include "OgrePCZPrerequisites.h"
55 #include "OgrePCZSceneNode.h"
56 #include "OgrePCZCamera.h"
57 #include "OgrePCZFrustum.h"
58 
59 namespace Ogre
60 {
61 
62  class PCZone;
63  class Portal;
64  class AntiPortal;
65  class PCZSceneNode;
66  class PCZSceneManager;
67  class PCZLight;
68 
77 
82  {
83  public:
84 
86  {
87  HOME_NODE_LIST = 1,
88  VISITOR_NODE_LIST = 2
89  };
90 
91  PCZone( PCZSceneManager *, const String& );
92  virtual ~PCZone();
93 
95  const String& getZoneTypeName() const { return mZoneTypeName; }
96 
98  const String& getName(void) const { return mName; }
99 
102  SceneNode * getEnclosureNode(void) {return mEnclosureNode;}
103 
106  void setHasSky(bool yesno) {mHasSky = yesno;}
107 
110  bool hasSky(void) {return mHasSky;}
111 
113  void setLastVisibleFrame(unsigned long frameCount) {mLastVisibleFrame = frameCount;}
114 
116  unsigned long getLastVisibleFrame(void) {return mLastVisibleFrame;}
117 
119  void setLastVisibleFromCamera(PCZCamera * camera) {mLastVisibleFromCamera = camera;}
120 
122  PCZCamera* getLastVisibleFromCamera() {return mLastVisibleFromCamera;}
123 
124  public:
127  virtual void setEnclosureNode(PCZSceneNode *) = 0;
128 
134  virtual void _addNode( PCZSceneNode * ) = 0;
135 
138  virtual void removeNode( PCZSceneNode * ) = 0;
139 
142  virtual void _clearNodeLists(short nodeListTypes);
143 
147  virtual bool requiresZoneSpecificNodeData(void) = 0;
148 
151  virtual void createNodeZoneData(PCZSceneNode *);
152 
155  virtual Portal * findMatchingPortal(Portal *);
156 
158  virtual void _addPortal(Portal* newPortal);
159 
161  virtual void _removePortal(Portal* removePortal);
162 
164  virtual void _addAntiPortal(AntiPortal* newAntiPortal);
165 
167  virtual void _removeAntiPortal(AntiPortal* removeAntiPortal);
168 
171  virtual void _checkNodeAgainstPortals(PCZSceneNode *, Portal * ) = 0;
172 
175  virtual void _checkLightAgainstPortals(PCZLight *,
176  unsigned long,
177  PCZFrustum *,
178  Portal *) = 0;
179 
182  virtual void updatePortalsZoneData(void) = 0;
183 
185  virtual void dirtyNodeByMovingPortals(void) = 0;
186 
188  virtual PCZone * updateNodeHomeZone(PCZSceneNode * pczsn, bool allowBackTouces) = 0;
189 
195  virtual void findVisibleNodes(PCZCamera *,
196  NodeList & visibleNodeList,
197  RenderQueue * queue,
198  VisibleObjectsBoundsInfo* visibleBounds,
199  bool onlyShadowCasters,
200  bool displayNodes,
201  bool showBoundingBoxes) = 0;
202 
203  /* Functions for finding Nodes that intersect various shapes */
204  virtual void _findNodes( const AxisAlignedBox &t,
206  PortalList &visitedPortals,
207  bool includeVisitors,
208  bool recurseThruPortals,
209  PCZSceneNode *exclude) = 0;
210  virtual void _findNodes( const Sphere &t,
212  PortalList &visitedPortals,
213  bool includeVisitors,
214  bool recurseThruPortals,
215  PCZSceneNode *exclude ) = 0;
216  virtual void _findNodes( const PlaneBoundedVolume &t,
218  PortalList &visitedPortals,
219  bool includeVisitors,
220  bool recurseThruPortals,
221  PCZSceneNode *exclude ) = 0;
222  virtual void _findNodes( const Ray &t,
224  PortalList &visitedPortals,
225  bool includeVisitors,
226  bool recurseThruPortals,
227  PCZSceneNode *exclude ) = 0;
228 
230  virtual bool setOption( const String &, const void * ) = 0;
234  virtual void notifyCameraCreated( Camera* c ) = 0;
236  virtual void notifyWorldGeometryRenderQueue(uint8 qid) = 0;
238  virtual void notifyBeginRenderScene(void) = 0;
240  virtual void setZoneGeometry(const String &filename, PCZSceneNode * parentNode) = 0;
242  virtual void getAABB(AxisAlignedBox &);
243  void setPortalsUpdated(bool updated) { mPortalsUpdated = updated; }
244  bool getPortalsUpdated(void) { return mPortalsUpdated; }
246  void * getUserData(void) {return mUserData;}
247  void setUserData(void * userData) {mUserData = userData;}
254 
255  protected:
258  {
260  PortalSortDistance(const Vector3& inCameraPosition) : cameraPosition(inCameraPosition)
261  { }
262 
263  bool _OgrePCZPluginExport operator()(const PortalBase* p1, const PortalBase* p2) const
264  {
265  Real depth1 = p1->getDerivedCP().squaredDistance(cameraPosition);
266  Real depth2 = p2->getDerivedCP().squaredDistance(cameraPosition);
267  return (depth1 < depth2);
268  }
269  };
270 
276  unsigned long mLastVisibleFrame;
280  bool mHasSky;
291  void * mUserData;
292 
293  };
294 
296  {
297  public:
301  virtual ~ZoneData();
303  virtual void update(void);
304  public:
307 
308  };
309 
310 }
311 
312 #endif
313 
314 
315 
vector< SceneNode * >::type NodeList
Definition: OgrePCZone.h:74
Representation of a ray in space, i.e.
Definition: OgreRay.h:46
unsigned char uint8
Definition: OgrePlatform.h:346
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
const Vector3 & getDerivedCP() const
Get the position (centerpoint) of the portal in world coordinates.
AntiPortal datastructure for occlusion culling.
set< PCZSceneNode * >::type PCZSceneNodeList
bool mHasSky
Flag determining whether or not this zone has sky in it.
Definition: OgrePCZone.h:280
float Real
Software floating point type.
std::vector< T, A > type
map< String, SceneNode * >::type SceneNodeList
Definition: OgrePCZone.h:76
Specialized frustum shaped culling volume that has culling planes created from portals.
const String & getZoneTypeName() const
Definition: OgrePCZone.h:95
void * getUserData(void)
Get & set the user data.
Definition: OgrePCZone.h:246
void setLastVisibleFrame(unsigned long frameCount)
Set the lastVisibleFrame counter.
Definition: OgrePCZone.h:113
Real squaredDistance(const Vector3 &rhs) const
Returns the square of the distance to another vector.
Definition: OgreVector3.h:398
bool getPortalsUpdated(void)
Definition: OgrePCZone.h:244
PCZCamera * getLastVisibleFromCamera()
Get the lastVisibleFromCamera pointer.
Definition: OgrePCZone.h:122
AntiPortalList mAntiPortals
Definition: OgrePCZone.h:251
PortalSortDistance(const Vector3 &inCameraPosition)
Definition: OgrePCZone.h:260
A 3D box aligned with the x/y/z axes.
PortalBase - Base class to Portal and AntiPortal classes.
PCZSceneNodeList mHomeNodeList
List of SceneNodes contained in this particular PCZone.
Definition: OgrePCZone.h:284
Class representing a node in the scene graph.
Definition: OgreSceneNode.h:58
bool _OgrePCZPluginExport operator()(const PortalBase *p1, const PortalBase *p2) const
Definition: OgrePCZone.h:263
Portal datastructure for connecting zones.
Definition: OgrePortal.h:51
PCZSceneManager * mPCZSM
Pointer to the pcz scene manager that created this zone.
Definition: OgrePCZone.h:253
String mName
Name of the zone (must be unique)
Definition: OgrePCZone.h:272
PCZSceneNodeList mVisitorNodeList
List of SceneNodes visiting this particular PCZone.
Definition: OgrePCZone.h:286
vector< PortalBase * >::type PortalBaseList
Definition: OgrePCZone.h:73
PCZSceneNode * mAssociatedNode
Definition: OgrePCZone.h:306
unsigned long mLastVisibleFrame
Frame counter for visibility.
Definition: OgrePCZone.h:276
void setHasSky(bool yesno)
If sky should be drawn with this zone.
Definition: OgrePCZone.h:106
SceneNode * mEnclosureNode
SceneNode which corresponds to the enclosure for this zone.
Definition: OgrePCZone.h:282
Specialized version of Ogre::Light which caches which zones the light affects.
Definition: OgrePCZLight.h:51
bool hasSky(void)
Definition: OgrePCZone.h:110
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
PCZCamera * mLastVisibleFromCamera
Last camera which this zone was visible to.
Definition: OgrePCZone.h:278
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
#define _OgrePCZPluginExport
SceneNode * getEnclosureNode(void)
Get a pointer to the enclosure node for this PCZone.
Definition: OgrePCZone.h:102
const String & getName(void) const
Definition: OgrePCZone.h:98
void setLastVisibleFromCamera(PCZCamera *camera)
Set the lastVisibleFromCamera pointer.
Definition: OgrePCZone.h:119
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
list< PCZone * >::type PCZoneList
Definition: OgrePCZone.h:70
void setPortalsUpdated(bool updated)
Definition: OgrePCZone.h:243
unsigned long getLastVisibleFrame(void)
Get the lastVisibleFrame counter value.
Definition: OgrePCZone.h:116
Represents a convex volume bounded by planes.
list< Portal * >::type PortalList
Definition: OgrePCZone.h:71
list< AntiPortal * >::type AntiPortalList
Definition: OgrePCZone.h:72
String mZoneTypeName
Zone type name.
Definition: OgrePCZone.h:274
PortalList mPortals
List of Portals which this zone contains (each portal leads to another zone)
Definition: OgrePCZone.h:250
void setUserData(void *userData)
Definition: OgrePCZone.h:247
Class to manage the scene object rendering queue.
Portal-Connected Zone datastructure for managing scene nodes.
Definition: OgrePCZone.h:81
_StringBase String
Binary predicate for portal <-> camera distance sorting.
Definition: OgrePCZone.h:257
PCZone * mAssociatedZone
Definition: OgrePCZone.h:305
Structure collecting together information about the visible objects that have been discovered in a sc...
map< String, PCZone * >::type ZoneMap
Definition: OgrePCZone.h:67
Specialized SceneManager that uses Portal-Connected-Zones to divide the scene spatially.
bool mPortalsUpdated
Flag recording whether any portals in this zone have moved.
Definition: OgrePCZone.h:288
Specialized viewpoint from which an PCZone Scene can be rendered.
Definition: OgrePCZCamera.h:54
void * mUserData
User defined data pointer - NOT allocated or deallocated by the zone! you must clean it up yourself! ...
Definition: OgrePCZone.h:291