/usr/include/OGRE/Plugins/PCZSceneManager/OgrePCZSceneManager.h is in libogre-dev 1.7.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2011 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
PCZSceneManager.h - Portal Connected Zone Scene Manager
-----------------------------------------------------------------------------
begin : Mon Feb 19 2007
author : Eric Cha
email : ericc@xenopi.com
Code Style Update :
-----------------------------------------------------------------------------
*/
#ifndef PCZ_SCENEMANAGER_H
#define PCZ_SCENEMANAGER_H
#include <OgreSceneManager.h>
#include <OgreSphere.h>
#include "OgrePCZPrerequisites.h"
#include "OgrePCZSceneNode.h"
#include "OgrePCZone.h"
#include "OgrePCZoneFactory.h"
#include "OgrePortal.h"
#include "OgreAntiPortal.h"
namespace Ogre
{
class PCZone;
class PCZCamera;
class PCZIntersectionSceneQuery;
class PCZRaySceneQuery;
class PCZSphereSceneQuery;
class PCZAxisAlignedBoxSceneQuery;
class PCZPlaneBoundedVolumeListSceneQuery;
typedef vector<SceneNode*>::type NodeList;
typedef list<WireBoundingBox*>::type BoxList;
/** Specialized SceneManager that uses Portal-Connected-Zones to divide the scene spatially.
*/
class _OgrePCZPluginExport PCZSceneManager : public SceneManager
{
friend class PCZIntersectionSceneQuery;
friend class PCZRaySceneQuery;
friend class PCZSphereSceneQuery;
friend class PCZAxisAlignedBoxSceneQuery;
friend class PCZPlaneBoundedVolumeListSceneQuery;
public:
/** Standard Constructor. */
PCZSceneManager(const String& name);
/** Standard destructor */
~PCZSceneManager();
/// @copydoc SceneManager::getTypeName
const String& getTypeName(void) const;
/** Initializes the manager
*/
void init(const String &defaultZoneTypeName,
const String &filename = "none");
/** Create a new portal instance
*/
Portal* createPortal(const String& name, PortalBase::PORTAL_TYPE type = PortalBase::PORTAL_TYPE_QUAD);
/** Delete a portal instance by pointer
*/
void destroyPortal(Portal * p);
/** Delete a portal instance by name
*/
void destroyPortal(const String & portalName);
/** Create a new anti portal instance */
AntiPortal* createAntiPortal(const String& name, PortalBase::PORTAL_TYPE type = PortalBase::PORTAL_TYPE_QUAD);
/** Delete a anti portal instance by pointer */
void destroyAntiPortal(AntiPortal * p);
/** Delete a anti portal instance by name */
void destroyAntiPortal(const String& portalName);
/** Create a zone from a file (type of file
* depends on the zone type
*/
PCZone * createZoneFromFile(const String &zoneTypeName,
const String &zoneName,
PCZSceneNode * parentNode,
const String & filename);
/** Set the "main" geometry of the zone */
virtual void setZoneGeometry(const String & zoneName,
PCZSceneNode * parentNode,
const String &filename);
/// override this to ensure specialised PCZSceneNode is used.
virtual SceneNode* createSceneNodeImpl(void);
/// override this to ensure their specialised PCZSceneNode is used.
virtual SceneNode* createSceneNodeImpl(const String& name);
/** Creates a PCZSceneNode */
virtual SceneNode * createSceneNode ( void );
/** Creates a PCZSceneNode */
virtual SceneNode * createSceneNode ( const String &name );
/** Creates a specialized PCZCamera */
virtual Camera * createCamera( const String &name );
/** Deletes a scene node & corresponding PCZSceneNode */
virtual void destroySceneNode( const String &name );
/** overridden to clean up zones
*/
virtual void clearScene(void);
/** Overridden from SceneManager */
void setWorldGeometryRenderQueue(uint8 qid);
// Overridden from basic scene manager
void _renderScene(Camera *cam, Viewport *vp, bool includeOverlays);
/* enable/disable sky rendering */
void enableSky(bool);
/* Set the zone which contains the sky node */
void setSkyZone(PCZone * zone);
/** Update Scene Graph (does several things now) */
virtual void _updateSceneGraph( Camera * cam );
/** Recurses through the PCZTree determining which nodes are visible. */
virtual void _findVisibleObjects ( Camera * cam,
VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters );
/** Alerts each unculled object, notifying it that it will be drawn.
* Useful for doing calculations only on nodes that will be drawn, prior
* to drawing them...
*/
virtual void _alertVisibleObjects( void );
/** Creates a light for use in the scene.
@remarks
Lights can either be in a fixed position and independent of the
scene graph, or they can be attached to SceneNodes so they derive
their position from the parent node. Either way, they are created
using this method so that the SceneManager manages their
existence.
@param
name The name of the new light, to identify it later.
*/
virtual Light* createLight(const String& name);
/** Returns a pointer to the named Light which has previously been added to the scene.
@note Throws an exception if the named instance does not exist
*/
virtual Light* getLight(const String& name) const;
/** Returns whether a light with the given name exists.
*/
virtual bool hasLight(const String& name) const;
/** Removes the named light from the scene and destroys it.
@remarks
Any pointers held to this light after calling this method will be invalid.
*/
virtual void destroyLight(const String& name);
/** Removes and destroys all lights in the scene.
*/
virtual void destroyAllLights(void);
/** Check/Update the zone data for every portal in the scene.
* Essentially, this routine checks each portal for intersections
* with other portals and updates if a crossing occurs
*/
void _updatePortalZoneData(void);
/** Mark nodes dirty for every zone with moving portal in the scene */
void _dirtyNodeByMovingPortals(void);
/** Update the PCZSceneNodes
*/
void _updatePCZSceneNodes(void);
/** Calculate which zones are affected by each light
*/
void _calcZonesAffectedByLights(Camera * cam);
/* Attempt to automatically connect unconnected portals to proper target zones
* by looking for matching portals in other zones which are at the same location
*/
void connectPortalsToTargetZonesByLocation(void);
/** Checks the given SceneNode, and determines if it needs to be moved
* to a different PCZone or be added to the visitors list of other PCZone(s).
*/
void _updatePCZSceneNode( PCZSceneNode * );
/** Removes the given PCZSceneNode */
void removeSceneNode( SceneNode * );
/** add a PCZSceneNode to the scene by putting it in a zone
* NOTE: This zone will be the scene node's home zone
*/
void addPCZSceneNode(PCZSceneNode * sn, PCZone * zone);
/* Create a zone with the given name */
PCZone * createZone(const String& zoneType, const String& instanceName);
/* destroy an existing zone within the scene */
void destroyZone(PCZone* zone, bool destroySceneNodes);
/** Make sure the home zone for the PCZSceneNode is up-to-date
*/
void _updateHomeZone( PCZSceneNode *, bool );
// Find the smallest zone which contains the point
PCZone * findZoneForPoint(Vector3 & point);
// create any zone-specific data necessary for all zones for the given node
void createZoneSpecificNodeData(PCZSceneNode *);
// create any zone-specific data necessary for all nodes for the given zone
void createZoneSpecificNodeData(PCZone *);
// set the home zone for a scene node
void setNodeHomeZone(SceneNode *, PCZone *);
/** Recurses the scene, adding any nodes intersecting with the box into the given list.
It ignores the exclude scene node.
*/
void findNodesIn( const AxisAlignedBox &box,
PCZSceneNodeList &list,
PCZone * startZone,
PCZSceneNode *exclude = 0 );
/** Recurses the scene, adding any nodes intersecting with the sphere into the given list.
It will start in the start SceneNode if given, otherwise, it will start at the root node.
*/
void findNodesIn( const Sphere &sphere,
PCZSceneNodeList &list,
PCZone * startZone,
PCZSceneNode *start = 0 );
/** Recurses the PCZTree, adding any nodes intersecting with the volume into the given list.
It will start in the start SceneNode if given, otherwise, it will start at the root node.
*/
void findNodesIn( const PlaneBoundedVolume &volume,
PCZSceneNodeList &list,
PCZone * startZone,
PCZSceneNode *start=0 );
/** Recurses the scene, starting in the given startZone, adding any nodes intersecting with
the ray into the given list.
It will start in the start SceneNode if given, otherwise, it will start at the root node.
*/
void findNodesIn( const Ray &ray,
PCZSceneNodeList &list,
PCZone * startZone,
PCZSceneNode *start=0 );
/* Get the default zone */
PCZone * getDefaultZone(void)
{
return mDefaultZone;
}
/* Get a zone by name */
PCZone * getZoneByName(const String & zoneName);
/** Sets the portal visibility flag */
void setShowPortals( bool b )
{
mShowPortals = b;
};
/** Sets the given option for the SceneManager
@remarks
Options are:
"ShowPortals", bool *;
"ShowBoundingBoxes", bool *;
*/
virtual bool setOption( const String &, const void * );
/** Gets the given option for the Scene Manager.
@remarks
See setOption
*/
virtual bool getOption( const String &, void * );
bool getOptionValues( const String & key, StringVector &refValueList );
bool getOptionKeys( StringVector &refKeys );
/** Overridden from SceneManager */
AxisAlignedBoxSceneQuery* createAABBQuery(const AxisAlignedBox& box, unsigned long mask = 0xFFFFFFFF);
SphereSceneQuery* createSphereQuery(const Sphere& sphere, unsigned long mask = 0xFFFFFFFF);
PlaneBoundedVolumeListSceneQuery* createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, unsigned long mask = 0xFFFFFFFF);
RaySceneQuery* createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF);
IntersectionSceneQuery* createIntersectionQuery(unsigned long mask = 0xFFFFFFFF);
// ZoneMap iterator for read-only access to the zonemap
typedef MapIterator<ZoneMap> ZoneIterator;
ZoneIterator getZoneIterator(void) {return ZoneIterator(mZones.begin(), mZones.end());}
// clear portal update flag from all zones
void _clearAllZonesPortalUpdateFlag(void);
/// See SceneManager::prepareShadowTextures.
virtual void prepareShadowTextures(Camera* cam, Viewport* vp, const LightList* lightList = 0);
protected:
// type of default zone to be used
String mDefaultZoneTypeName;
// name of data file for default zone
String mDefaultZoneFileName;
/// list of visible nodes since last _findVisibleObjects()
NodeList mVisible;
/// camera of last _findVisibleObjects()
Camera* mLastActiveCamera;
/// The root PCZone;
PCZone *mDefaultZone;
/// The list of all PCZones
ZoneMap mZones;
/// Master list of Portals in the world (includes all portals)
PortalList mPortals;
/// Master list of AntiPortals in the world.
AntiPortalList mAntiPortals;
/// Portals visibility flag
bool mShowPortals;
/// frame counter used in visibility determination
unsigned long mFrameCount;
// ZoneFactoryManager instance
PCZoneFactoryManager * mZoneFactoryManager;
/// The zone of the active camera (for shadow texture casting use);
PCZone* mActiveCameraZone;
/** Internal method for locating a list of lights which could be affecting the frustum.
@remarks
Custom scene managers are encouraged to override this method to make use of their
scene partitioning scheme to more efficiently locate lights, and to eliminate lights
which may be occluded by word geometry.
*/
virtual void findLightsAffectingFrustum(const Camera* camera);
/// Internal method for creating shadow textures (texture-based shadows)
virtual void ensureShadowTexturesCreated();
/// Internal method for destroying shadow textures (texture-based shadows)
virtual void destroyShadowTextures(void);
/// Internal method for firing the pre caster texture shadows event
virtual void fireShadowTexturesPreCaster(Light* light, Camera* camera, size_t iteration);
};
/// Factory for PCZSceneManager
class PCZSceneManagerFactory : public SceneManagerFactory
{
protected:
void initMetaData(void) const;
public:
PCZSceneManagerFactory() {}
~PCZSceneManagerFactory() {}
/// Factory type name
static const String FACTORY_TYPE_NAME;
SceneManager* createInstance(const String& instanceName);
void destroyInstance(SceneManager* instance);
};
}
#endif
|