1 /*-------------------------------------------------------------------------
2 This source file is a part of OGRE
3 (Object-oriented Graphics Rendering Engine)
4 
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE
25 
26 You may alternatively use this source under the terms of a specific version of
27 the OGRE Unrestricted License provided you have obtained such a license from
28 Torus Knot Software Ltd.
29 -------------------------------------------------------------------------*/
30 #ifndef __SceneManager_H__
31 #define __SceneManager_H__
32 
33 // Precompiler options
34 #include "OgrePrerequisites.h"
35 
36 #include "OgrePlane.h"
37 #include "OgreQuaternion.h"
38 #include "OgreColourValue.h"
39 #include "OgreCommon.h"
40 #include "OgreSceneQuery.h"
41 #include "OgreAutoParamDataSource.h"
42 #include "OgreAnimationState.h"
43 #include "OgreRenderQueue.h"
44 #include "OgreRenderQueueSortingGrouping.h"
45 #include "OgreResourceGroupManager.h"
46 #include "OgreShadowTextureManager.h"
47 #include "OgreInstanceManager.h"
48 #include "OgreManualObject.h"
49 #include "OgreRenderSystem.h"
50 #include "OgreLodListener.h"
51 #include "OgreHeaderPrefix.h"
52 #include "OgreNameGenerator.h"
53 
54 namespace Ogre {
55     /** \addtogroup Core
56     *  @{
57     */
58     /** \addtogroup Scene
59     *  @{
60     */
61 
62     /** Structure for holding a position & orientation pair. */
63     struct ViewPoint
64     {
65         Vector3 position;
66         Quaternion orientation;
67     };
68 
69     // Forward declarations
70     class CompositorChain;
71     class InstancedGeometry;
72     class Rectangle2D;
73     class LodListener;
74     struct MovableObjectLodChangedEvent;
75     struct EntityMeshLodChangedEvent;
76     struct EntityMaterialLodChangedEvent;
77 
78     /** Structure collecting together information about the visible objects
79     that have been discovered in a scene.
80     */
81     struct _OgreExport VisibleObjectsBoundsInfo
82     {
83         /// The axis-aligned bounds of the visible objects
84         AxisAlignedBox aabb;
85         /// The axis-aligned bounds of the visible shadow receiver objects
86         AxisAlignedBox receiverAabb;
87         /// The closest a visible object is to the camera
88         Real minDistance;
89         /// The farthest a visible objects is from the camera
90         Real maxDistance;
91         /// The closest a object in the frustum regardless of visibility / shadow caster flags
92         Real minDistanceInFrustum;
93         /// The farthest object in the frustum regardless of visibility / shadow caster flags
94         Real maxDistanceInFrustum;
95 
96         VisibleObjectsBoundsInfo();
97         void reset();
98         void merge(const AxisAlignedBox& boxBounds, const Sphere& sphereBounds,
99             const Camera* cam, bool receiver=true);
100         /** Merge an object that is not being rendered because it's not a shadow caster,
101             but is a shadow receiver so should be included in the range.
102         */
103         void mergeNonRenderedButInFrustum(const AxisAlignedBox& boxBounds,
104             const Sphere& sphereBounds, const Camera* cam);
105 
106 
107     };
108 
109     /** Manages the organisation and rendering of a 'scene' i.e. a collection
110         of objects and potentially world geometry.
111     @remarks
112         This class defines the interface and the basic behaviour of a
113         'Scene Manager'. A SceneManager organises the culling and rendering of
114         the scene, in conjunction with the RenderQueue. This class is designed
115         to be extended through subclassing in order to provide more specialised
116         scene organisation structures for particular needs. The default
117         SceneManager culls based on a hierarchy of node bounding boxes, other
118         implementations can use an octree (@see OctreeSceneManager), a BSP
119         tree (@see BspSceneManager), and many other options. New SceneManager
120         implementations can be added at runtime by plugins, see
121         SceneManagerEnumerator for the interfaces for adding new SceneManager
122         types.
123     @par
124         There is a distinction between 'objects' (which subclass MovableObject,
125         and are movable, discrete objects in the world), and 'world geometry',
126         which is large, generally static geometry. World geometry tends to
127         influence the SceneManager organisational structure (e.g. lots of indoor
128         static geometry might result in a spatial tree structure) and as such
129         world geometry is generally tied to a given SceneManager implementation,
130         whilst MovableObject instances can be used with any SceneManager.
131         Subclasses are free to define world geometry however they please.
132     @par
133         Multiple SceneManager instances can exist at one time, each one with
134         a distinct scene. Which SceneManager is used to render a scene is
135         dependent on the Camera, which will always call back the SceneManager
136         which created it to render the scene.
137      */
138     class _OgreExport SceneManager : public SceneMgtAlloc
139     {
140     public:
141         /// Query type mask which will be used for world geometry @see SceneQuery
142         static uint32 WORLD_GEOMETRY_TYPE_MASK;
143         /// Query type mask which will be used for entities @see SceneQuery
144         static uint32 ENTITY_TYPE_MASK;
145         /// Query type mask which will be used for effects like billboardsets / particle systems @see SceneQuery
146         static uint32 FX_TYPE_MASK;
147         /// Query type mask which will be used for StaticGeometry  @see SceneQuery
148         static uint32 STATICGEOMETRY_TYPE_MASK;
149         /// Query type mask which will be used for lights  @see SceneQuery
150         static uint32 LIGHT_TYPE_MASK;
151         /// Query type mask which will be used for frusta and cameras @see SceneQuery
152         static uint32 FRUSTUM_TYPE_MASK;
153         /// User type mask limit
154         static uint32 USER_TYPE_MASK_LIMIT;
155         /** Comparator for material map, for sorting materials into render order (e.g. transparent last).
156         */
157         struct materialLess
158         {
159             _OgreExport bool operator()(const Material* x, const Material* y) const;
160         };
161         /// Comparator for sorting lights relative to a point
162         struct lightLess
163         {
164             _OgreExport bool operator()(const Light* a, const Light* b) const;
165         };
166 
167         /// Describes the stage of rendering when performing complex illumination
168         enum IlluminationRenderStage
169         {
170             /// No special illumination stage
171             IRS_NONE,
172             /// Render to texture stage, used for texture based shadows
173             IRS_RENDER_TO_TEXTURE,
174             /// Render from shadow texture to receivers stage
175             IRS_RENDER_RECEIVER_PASS
176         };
177 
178         /** Enumeration of the possible modes allowed for processing the special case
179         render queue list.
180         @see SceneManager::setSpecialCaseRenderQueueMode
181         */
182         enum SpecialCaseRenderQueueMode
183         {
184             /// Render only the queues in the special case list
185             SCRQM_INCLUDE,
186             /// Render all except the queues in the special case list
187             SCRQM_EXCLUDE
188         };
189 
190         struct SkyDomeGenParameters
191         {
192             Real skyDomeCurvature;
193             Real skyDomeTiling;
194             Real skyDomeDistance;
195             int skyDomeXSegments;
196             int skyDomeYSegments;
197             int skyDomeYSegments_keep;
198         };
199 
200         struct SkyPlaneGenParameters
201         {
202             Real skyPlaneScale;
203             Real skyPlaneTiling;
204             Real skyPlaneBow;
205             int skyPlaneXSegments;
206             int skyPlaneYSegments;
207         };
208 
209         struct SkyBoxGenParameters
210         {
211             Real skyBoxDistance;
212         };
213 
214         /** Class that allows listening in on the various stages of SceneManager
215             processing, so that custom behaviour can be implemented from outside.
216         */
217         class Listener
218         {
219         public:
Listener()220             Listener() {}
~Listener()221             virtual ~Listener() {}
222 
223             /** Called prior to updating the scene graph in this SceneManager.
224             @remarks
225                 This is called before updating the scene graph for a camera.
226             @param source The SceneManager instance raising this event.
227             @param camera The camera being updated.
228             */
preUpdateSceneGraph(SceneManager * source,Camera * camera)229             virtual void preUpdateSceneGraph(SceneManager* source, Camera* camera)
230                         { (void)source; (void)camera; }
231 
232             /** Called after updating the scene graph in this SceneManager.
233             @remarks
234                 This is called after updating the scene graph for a camera.
235             @param source The SceneManager instance raising this event.
236             @param camera The camera being updated.
237             */
postUpdateSceneGraph(SceneManager * source,Camera * camera)238             virtual void postUpdateSceneGraph(SceneManager* source, Camera* camera)
239                         { (void)source; (void)camera; }
240 
241             /** Called prior to searching for visible objects in this SceneManager.
242             @remarks
243                 Note that the render queue at this stage will be full of the last
244                 render's contents and will be cleared after this method is called.
245             @param source The SceneManager instance raising this event.
246             @param irs The stage of illumination being dealt with. IRS_NONE for
247                 a regular render, IRS_RENDER_TO_TEXTURE for a shadow caster render.
248             @param v The viewport being updated. You can get the camera from here.
249             */
preFindVisibleObjects(SceneManager * source,IlluminationRenderStage irs,Viewport * v)250             virtual void preFindVisibleObjects(SceneManager* source,
251                 IlluminationRenderStage irs, Viewport* v)
252                         { (void)source; (void)irs; (void)v; }
253 
254             /** Called after searching for visible objects in this SceneManager.
255             @remarks
256                 Note that the render queue at this stage will be full of the current
257                 scenes contents, ready for rendering. You may manually add renderables
258                 to this queue if you wish.
259             @param source The SceneManager instance raising this event.
260             @param irs The stage of illumination being dealt with. IRS_NONE for
261                 a regular render, IRS_RENDER_TO_TEXTURE for a shadow caster render.
262             @param v The viewport being updated. You can get the camera from here.
263             */
postFindVisibleObjects(SceneManager * source,IlluminationRenderStage irs,Viewport * v)264             virtual void postFindVisibleObjects(SceneManager* source,
265                 IlluminationRenderStage irs, Viewport* v)
266                         { (void)source; (void)irs; (void)v; }
267 
268             /** Event raised after all shadow textures have been rendered into for
269                 all queues / targets but before any other geometry has been rendered
270                 (including main scene geometry and any additional shadow receiver
271                 passes).
272             @remarks
273                 This callback is useful for those that wish to perform some
274                 additional processing on shadow textures before they are used to
275                 render shadows. For example you could perform some filtering by
276                 rendering the existing shadow textures into another alternative
277                 shadow texture with a shader.]
278             @note
279                 This event will only be fired when texture shadows are in use.
280             @param numberOfShadowTextures The number of shadow textures in use
281             */
shadowTexturesUpdated(size_t numberOfShadowTextures)282             virtual void shadowTexturesUpdated(size_t numberOfShadowTextures)
283                         { (void)numberOfShadowTextures; }
284 
285             /** This event occurs just before the view & projection matrices are
286                 set for rendering into a shadow texture.
287             @remarks
288                 You can use this event hook to perform some custom processing,
289                 such as altering the camera being used for rendering the light's
290                 view, including setting custom view & projection matrices if you
291                 want to perform an advanced shadow technique.
292             @note
293                 This event will only be fired when texture shadows are in use.
294             @param light Pointer to the light for which shadows are being rendered
295             @param camera Pointer to the camera being used to render
296             @param iteration For lights that use multiple shadow textures, the iteration number
297             */
shadowTextureCasterPreViewProj(Light * light,Camera * camera,size_t iteration)298             virtual void shadowTextureCasterPreViewProj(Light* light,
299                 Camera* camera, size_t iteration)
300                         { (void)light; (void)camera; (void)iteration; }
301 
302             /** This event occurs just before the view & projection matrices are
303                 set for re-rendering a shadow receiver.
304             @remarks
305                 You can use this event hook to perform some custom processing,
306                 such as altering the projection frustum being used for rendering
307                 the shadow onto the receiver to perform an advanced shadow
308                 technique.
309             @note
310                 This event will only be fired when texture shadows are in use.
311             @param light Pointer to the light for which shadows are being rendered
312             @param frustum Pointer to the projection frustum being used to project
313                 the shadow texture
314             */
shadowTextureReceiverPreViewProj(Light * light,Frustum * frustum)315             virtual void shadowTextureReceiverPreViewProj(Light* light,
316                 Frustum* frustum)
317                         { (void)light; (void)frustum; }
318 
319             /** Hook to allow the listener to override the ordering of lights for
320                 the entire frustum.
321             @remarks
322                 Whilst ordinarily lights are sorted per rendered object
323                 (@see MovableObject::queryLights), texture shadows adds another issue
324                 in that, given there is a finite number of shadow textures, we must
325                 choose which lights to render texture shadows from based on the entire
326                 frustum. These lights should always be listed first in every objects
327                 own list, followed by any other lights which will not cast texture
328                 shadows (either because they have shadow casting off, or there aren't
329                 enough shadow textures to service them).
330             @par
331                 This hook allows you to override the detailed ordering of the lights
332                 per frustum. The default ordering is shadow casters first (which you
333                 must also respect if you override this method), and ordered
334                 by distance from the camera within those 2 groups. Obviously the closest
335                 lights with shadow casting enabled will be listed first. Only lights
336                 within the range of the frustum will be in the list.
337             @param lightList The list of lights within range of the frustum which you
338                 may sort.
339             @return true if you sorted the list, false otherwise.
340             */
sortLightsAffectingFrustum(LightList & lightList)341             virtual bool sortLightsAffectingFrustum(LightList& lightList)
342                         { (void)lightList; return false; }
343 
344             /** Event notifying the listener of the SceneManager's destruction. */
sceneManagerDestroyed(SceneManager * source)345             virtual void sceneManagerDestroyed(SceneManager* source)
346                         { (void)source; }
347         };
348 
349         /** Inner helper class to implement the visitor pattern for rendering objects
350             in a queue.
351         */
352         class _OgreExport SceneMgrQueuedRenderableVisitor : public QueuedRenderableVisitor
353         {
354         protected:
355             /// Pass that was actually used at the grouping level
356             const Pass* mUsedPass;
357         public:
SceneMgrQueuedRenderableVisitor()358             SceneMgrQueuedRenderableVisitor()
359                 :transparentShadowCastersMode(false) {}
~SceneMgrQueuedRenderableVisitor()360             ~SceneMgrQueuedRenderableVisitor() {}
361             void visit(const Pass* p, RenderableList& rs);
362             void visit(RenderablePass* rp);
363 
364             /// Target SM to send renderables to
365             SceneManager* targetSceneMgr;
366             /// Are we in transparent shadow caster mode?
367             bool transparentShadowCastersMode;
368             /// Automatic light handling?
369             bool autoLights;
370             /// Manual light list
371             const LightList* manualLightList;
372             /// Scissoring if requested?
373             bool scissoring;
374 
375         };
376         /// Allow visitor helper to access protected methods
377         friend class SceneMgrQueuedRenderableVisitor;
378 
379         typedef std::map<String, Camera* > CameraList;
380         typedef std::map<String, Animation*> AnimationList;
381     protected:
382 
383         /// Subclasses can override this to ensure their specialised SceneNode is used.
384         virtual SceneNode* createSceneNodeImpl(void);
385         /// Subclasses can override this to ensure their specialised SceneNode is used.
386         virtual SceneNode* createSceneNodeImpl(const String& name);
387 
388         /// Instance name
389         String mName;
390 
391         /// Queue of objects for rendering
392         std::unique_ptr<RenderQueue> mRenderQueue;
393         bool mLastRenderQueueInvocationCustom;
394 
395         /// The rendering system to send the scene to
396         RenderSystem *mDestRenderSystem;
397 
398         /** Central list of cameras - for easy memory management and lookup.
399         */
400         CameraList mCameras;
401 
402         typedef std::map<String, StaticGeometry* > StaticGeometryList;
403         StaticGeometryList mStaticGeometryList;
404         typedef std::map<String, InstancedGeometry* > InstancedGeometryList;
405         InstancedGeometryList mInstancedGeometryList;
406 
407         typedef std::map<String, InstanceManager*> InstanceManagerMap;
408         InstanceManagerMap  mInstanceManagerMap;
409 
410         typedef std::vector<SceneNode*> SceneNodeList;
411 
412         /** Central list of SceneNodes - for easy memory management.
413             @note
414                 Note that this list is used only for memory management; the structure of the scene
415                 is held using the hierarchy of SceneNodes starting with the root node. However you
416                 can look up nodes this way.
417         */
418         SceneNodeList mSceneNodes;
419 
420         /// additional map to speed up lookup by name
421         std::map<String, SceneNode*> mNamedNodes;
422 
423         /// Camera in progress
424         Camera* mCameraInProgress;
425         /// Current Viewport
426         Viewport* mCurrentViewport;
427 
428         /// Root scene node
429         std::unique_ptr<SceneNode> mSceneRoot;
430 
431         /// Autotracking scene nodes
432         typedef std::set<SceneNode*> AutoTrackingSceneNodes;
433         AutoTrackingSceneNodes mAutoTrackingSceneNodes;
434 
435         // Sky params
436         struct _OgreExport SkyRenderer
437         {
438             SkyRenderer(SceneManager* owner);
439 
440             SceneManager* mSceneManager;
441 
442             // Sky plane
443             Entity* mSkyPlaneEntity;
444             Entity* mSkyDomeEntity[5];
445             std::unique_ptr<ManualObject> mSkyBoxObj;
446 
447             SceneNode* mSkyPlaneNode;
448             SceneNode* mSkyDomeNode;
449             SceneNode* mSkyBoxNode;
450 
451             // Sky plane
452             bool mSkyPlaneEnabled;
453             uint8 mSkyPlaneRenderQueue;
454             Plane mSkyPlane;
455             SkyPlaneGenParameters mSkyPlaneGenParameters;
456             // Sky box
457             bool mSkyBoxEnabled;
458             uint8 mSkyBoxRenderQueue;
459             Quaternion mSkyBoxOrientation;
460             SkyBoxGenParameters mSkyBoxGenParameters;
461             // Sky dome
462             bool mSkyDomeEnabled;
463             uint8 mSkyDomeRenderQueue;
464             Quaternion mSkyDomeOrientation;
465             SkyDomeGenParameters mSkyDomeGenParameters;
466 
467             enum BoxPlane
468             {
469                 BP_FRONT = 0,
470                 BP_BACK = 1,
471                 BP_LEFT = 2,
472                 BP_RIGHT = 3,
473                 BP_UP = 4,
474                 BP_DOWN = 5
475             };
476 
477             /* Internal utility method for creating the planes of a skybox.
478             */
479             MeshPtr createSkyboxPlane(
480                 BoxPlane bp,
481                 Real distance,
482                 const Quaternion& orientation,
483                 const String& groupName);
484 
485             /* Internal utility method for creating the planes of a skydome.
486             */
487             MeshPtr createSkydomePlane(
488                 BoxPlane bp,
489                 Real curvature, Real tiling, Real distance,
490                 const Quaternion& orientation,
491                 int xsegments, int ysegments, int ySegmentsToKeep,
492                 const String& groupName);
493 
494             /** Internal method for queueing the sky objects with the params as
495                 previously set through setSkyBox, setSkyPlane and setSkyDome.
496             */
497             void queueSkiesForRendering(RenderQueue* queue, Camera* cam);
498 
499             void clear();
500 
501             void setSkyBox(bool enable, const String& materialName, Real distance,
502                            uint8 renderQueue, const Quaternion& orientation,
503                            const String& groupName);
504 
505             void setSkyPlane(bool enable, const Plane& plane, const String& materialName,
506                              Real scale, Real tiling, uint8 renderQueue, Real bow, int xsegments,
507                              int ysegments, const String& groupName);
508 
509             void setSkyDome(bool enable, const String& materialName, Real curvature, Real tiling,
510                             Real distance, uint8 renderQueue, const Quaternion& orientation,
511                             int xsegments, int ysegments, int ysegments_keep,
512                             const String& groupName);
513         } mSkyRenderer;
514 
515         // Fog
516         FogMode mFogMode;
517         ColourValue mFogColour;
518         Real mFogStart;
519         Real mFogEnd;
520         Real mFogDensity;
521 
522         typedef std::set<uint8> SpecialCaseRenderQueueList;
523         SpecialCaseRenderQueueList mSpecialCaseQueueList;
524         SpecialCaseRenderQueueMode mSpecialCaseQueueMode;
525         uint8 mWorldGeometryRenderQueue;
526 
527         unsigned long mLastFrameNumber;
528         bool mResetIdentityView;
529         bool mResetIdentityProj;
530 
531         bool mNormaliseNormalsOnScale;
532         bool mFlipCullingOnNegativeScale;
533         CullingMode mPassCullingMode;
534 
535     protected:
536 
537         /** Visible objects bounding box list.
538             @remarks
539                 Holds an ABB for each camera that contains the physical extends of the visible
540                 scene elements by each camera. The map is crucial for shadow algorithms which
541                 have a focus step to limit the shadow sample distribution to only valid visible
542                 scene elements.
543         */
544         typedef std::map< const Camera*, VisibleObjectsBoundsInfo> CamVisibleObjectsMap;
545         CamVisibleObjectsMap mCamVisibleObjectsMap;
546 
547         /// Cached light information, used to tracking light's changes
548         struct _OgreExport LightInfo
549         {
550             Light* light;       /// Just a pointer for comparison, the light might destroyed for some reason
551             int type;           /// Use int instead of Light::LightTypes to avoid header file dependence
552             Real range;         /// Sets to zero if directional light
553             Vector3 position;   /// Sets to zero if directional light
554             uint32 lightMask;   /// Light mask
555 
556             bool operator== (const LightInfo& rhs) const
557             {
558                 return light == rhs.light && type == rhs.type &&
559                     range == rhs.range && position == rhs.position && lightMask == rhs.lightMask;
560             }
561 
562             bool operator!= (const LightInfo& rhs) const
563             {
564                 return !(*this == rhs);
565             }
566         };
567 
568         typedef std::vector<LightInfo> LightInfoList;
569 
570         LightList mLightsAffectingFrustum;
571         LightInfoList mCachedLightInfos;
572         LightInfoList mTestLightInfos; // potentially new list
573         ulong mLightsDirtyCounter;
574 
575         typedef std::map<String, MovableObject*> MovableObjectMap;
576         /// Simple structure to hold MovableObject map and a mutex to go with it.
577         struct MovableObjectCollection
578         {
579                     MovableObjectMap map;
580                     OGRE_MUTEX(mutex);
581         };
582         typedef std::map<String, MovableObjectCollection*> MovableObjectCollectionMap;
583         MovableObjectCollectionMap mMovableObjectCollectionMap;
584         NameGenerator mMovableNameGenerator;
585         /** Gets the movable object collection for the given type name.
586         @remarks
587             This method create new collection if the collection does not exist.
588         */
589         MovableObjectCollection* getMovableObjectCollection(const String& typeName);
590         /** Gets the movable object collection for the given type name.
591         @remarks
592             This method throw exception if the collection does not exist.
593         */
594         const MovableObjectCollection* getMovableObjectCollection(const String& typeName) const;
595         /// Mutex over the collection of MovableObject types
596         OGRE_MUTEX(mMovableObjectCollectionMapMutex);
597 
598         /** Internal method for initialising the render queue.
599         @remarks
600             Subclasses can use this to install their own RenderQueue implementation.
601         */
602         virtual void initRenderQueue(void);
603 
604         struct _OgreExport ShadowRenderer
605         {
606             typedef std::vector<Camera*> CameraList;
607             typedef std::map< const Camera*, const Light* > ShadowCamLightMapping;
608 
609             ShadowRenderer(SceneManager* owner);
610             ~ShadowRenderer();
611 
612             SceneManager* mSceneManager;
613             RenderSystem* mDestRenderSystem;
614 
615             ShadowTechnique mShadowTechnique;
616             ColourValue mShadowColour;
617 
618             /// A pass designed to let us render shadow colour on white for texture shadows
619             Pass* mShadowCasterPlainBlackPass;
620             /// A pass designed to let us render shadow receivers for texture shadows
621             Pass* mShadowReceiverPass;
622 
623             Pass* mShadowModulativePass;
624 
625             Pass* mShadowDebugPass;
626             Pass* mShadowStencilPass;
627             HardwareIndexBufferSharedPtr mShadowIndexBuffer;
628             size_t mShadowIndexBufferSize;
629             size_t mShadowIndexBufferUsedSize;
630             static GpuProgramParametersSharedPtr msInfiniteExtrusionParams;
631             static GpuProgramParametersSharedPtr msFiniteExtrusionParams;
632 
633             Pass* mShadowTextureCustomCasterPass;
634             Pass* mShadowTextureCustomReceiverPass;
635             String mShadowTextureCustomCasterVertexProgram;
636             String mShadowTextureCustomCasterFragmentProgram;
637             String mShadowTextureCustomReceiverVertexProgram;
638             String mShadowTextureCustomReceiverFragmentProgram;
639             GpuProgramParametersSharedPtr mShadowTextureCustomCasterVPParams;
640             GpuProgramParametersSharedPtr mShadowTextureCustomCasterFPParams;
641             GpuProgramParametersSharedPtr mShadowTextureCustomReceiverVPParams;
642             GpuProgramParametersSharedPtr mShadowTextureCustomReceiverFPParams;
643 
644             TexturePtr mNullShadowTexture;
645             CameraList mShadowTextureCameras;
646             LightList mShadowTextureCurrentCasterLightList;
647             // ShadowCamera to light mapping
648             ShadowCamLightMapping mShadowCamLightMapping;
649             // Array defining shadow texture index in light list.
650             std::vector<size_t> mShadowTextureIndexLightList;
651 
652             std::unique_ptr<Rectangle2D> mFullScreenQuad;
653 
654             ShadowTextureList mShadowTextures;
655             Texture* mCurrentShadowTexture;
656 
657             bool mShadowAdditiveLightClip;
658             bool mDebugShadows;
659             bool mShadowMaterialInitDone;
660             bool mShadowUseInfiniteFarPlane;
661             Real mShadowDirLightExtrudeDist;
662 
663             Real mDefaultShadowFarDist;
664             Real mDefaultShadowFarDistSquared;
665             Real mShadowTextureOffset; /// Proportion of texture offset in view direction e.g. 0.4
666             Real mShadowTextureFadeStart; /// As a proportion e.g. 0.6
667             Real mShadowTextureFadeEnd; /// As a proportion e.g. 0.9
668 
669             /// Array defining shadow count per light type.
670             size_t mShadowTextureCountPerType[3];
671 
672             /// default shadow camera setup
673             ShadowCameraSetupPtr mDefaultShadowCameraSetup;
674 
675             void setShadowTechnique(ShadowTechnique technique);
676 
677             /// Internal method for creating shadow textures (texture-based shadows)
678             void ensureShadowTexturesCreated();
679             void prepareShadowTextures(Camera* cam, Viewport* vp, const LightList* lightList);
680             /// Internal method for destroying shadow textures (texture-based shadows)
681             void destroyShadowTextures(void);
682 
683             /** Internal method for turning a regular pass into a shadow caster pass.
684             @remarks
685                 This is only used for texture shadows, basically we're trying to
686                 ensure that objects are rendered solid black.
687                 This method will usually return the standard solid black pass for
688                 all fixed function passes, but will merge in a vertex program
689                 and fudge the AutoParamDataSource to set black lighting for
690                 passes with vertex programs.
691             */
692             const Pass* deriveShadowCasterPass(const Pass* pass);
693             /** Internal method for turning a regular pass into a shadow receiver pass.
694             @remarks
695             This is only used for texture shadows, basically we're trying to
696             ensure that objects are rendered with a projective texture.
697             This method will usually return a standard single-texture pass for
698             all fixed function passes, but will merge in a vertex program
699             for passes with vertex programs.
700             */
701             const Pass* deriveShadowReceiverPass(const Pass* pass);
702 
703             void initShadowVolumeMaterials();
704             void setShadowTextureCasterMaterial(const MaterialPtr& mat);
705             void setShadowTextureReceiverMaterial(const MaterialPtr& mat);
706             void setShadowColour(const ColourValue& colour);
707             void render(RenderQueueGroup* group, QueuedRenderableCollection::OrganisationMode om);
708 
709             /** Render a group with the added complexity of additive stencil shadows. */
710             void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* group,
711                 QueuedRenderableCollection::OrganisationMode om);
712             /** Render a group with the added complexity of modulative stencil shadows. */
713             void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* group,
714                 QueuedRenderableCollection::OrganisationMode om);
715             /** Render a group rendering only shadow casters. */
716             void renderTextureShadowCasterQueueGroupObjects(RenderQueueGroup* group,
717                 QueuedRenderableCollection::OrganisationMode om);
718             /** Render a group rendering only shadow receivers. */
719             void renderTextureShadowReceiverQueueGroupObjects(RenderQueueGroup* group,
720                 QueuedRenderableCollection::OrganisationMode om);
721             /** Render a group with the added complexity of modulative texture shadows. */
722             void renderModulativeTextureShadowedQueueGroupObjects(RenderQueueGroup* group,
723                 QueuedRenderableCollection::OrganisationMode om);
724 
725             /** Render a group with additive texture shadows. */
726             void renderAdditiveTextureShadowedQueueGroupObjects(RenderQueueGroup* group,
727                 QueuedRenderableCollection::OrganisationMode om);
728 
729             /**  Returns the shadow caster AAB for a specific light-camera combination */
730             const VisibleObjectsBoundsInfo& getShadowCasterBoundsInfo(const Light* light, size_t iteration) const;
731 
732             /** Internal method for rendering all the objects for a given light into the
733                 stencil buffer.
734             @param light The light source
735             @param cam The camera being viewed from
736             @param calcScissor Whether the method should set up any scissor state, or
737                 false if that's already been done
738             */
739             void renderShadowVolumesToStencil(const Light* light, const Camera* cam,
740                 bool calcScissor);
741 
742             /** Internal utility method for setting stencil state for rendering shadow volumes.
743             @param secondpass Is this the second pass?
744             @param zfail Should we be using the zfail method?
745             @param twosided Should we use a 2-sided stencil?
746             */
747             void setShadowVolumeStencilState(bool secondpass, bool zfail, bool twosided);
748             /** Render a set of shadow renderables. */
749             void renderShadowVolumeObjects(ShadowCaster::ShadowRenderableListIterator iShadowRenderables,
750                 Pass* pass, const LightList *manualLightList, unsigned long flags,
751                 bool secondpass, bool zfail, bool twosided);
752 
753             size_t getShadowTexIndex(size_t lightIndex);
754 
755             void setShadowIndexBufferSize(size_t size);
756         } mShadowRenderer;
757 
758         /** Internal method to validate whether a Pass should be allowed to render.
759         @remarks
760             Called just before a pass is about to be used for rendering a group to
761             allow the SceneManager to omit it if required. A return value of false
762             skips this pass.
763         */
764         bool validatePassForRendering(const Pass* pass);
765 
766         /** Internal method to validate whether a Renderable should be allowed to render.
767         @remarks
768         Called just before a pass is about to be used for rendering a Renderable to
769         allow the SceneManager to omit it if required. A return value of false
770         skips it.
771         */
772         bool validateRenderableForRendering(const Pass* pass, const Renderable* rend);
773 
774         /// Flag indicating whether SceneNodes will be rendered as a set of 3 axes
775         bool mDisplayNodes;
776 
777         /// Storage of animations, lookup by name
778         AnimationList mAnimationsList;
779         OGRE_MUTEX(mAnimationsListMutex);
780         AnimationStateSet mAnimationStates;
781 
782 
783         /** Internal method used by _renderSingleObject to deal with renderables
784             which override the camera's own view / projection materices. */
785         void useRenderableViewProjMode(const Renderable* pRend, bool fixedFunction);
786 
787         /** Internal method used by _renderSingleObject to set the world transform */
788         void setWorldTransform(Renderable* rend, bool fixedFunction);
789 
790         /** Internal method used by _renderSingleObject to render a single light pass */
791         void issueRenderWithLights(Renderable* rend, const Pass* pass,
792                                    const LightList* pLightListToUse, bool fixedFunction,
793                                    bool lightScissoringClipping);
794 
795         /** Internal method used by _renderSingleObject to deal with renderables
796             which override the camera's own view / projection matrices. */
797         void resetViewProjMode(bool fixedFunction);
798 
799         typedef std::vector<RenderQueueListener*> RenderQueueListenerList;
800         RenderQueueListenerList mRenderQueueListeners;
801 
802         typedef std::vector<RenderObjectListener*> RenderObjectListenerList;
803         RenderObjectListenerList mRenderObjectListeners;
804         typedef std::vector<Listener*> ListenerList;
805         ListenerList mListeners;
806         /// Internal method for firing the queue start event
807         void firePreRenderQueues();
808         /// Internal method for firing the queue end event
809         void firePostRenderQueues();
810         /// Internal method for firing the queue start event, returns true if queue is to be skipped
811         virtual bool fireRenderQueueStarted(uint8 id, const String& invocation);
812         /// Internal method for firing the queue end event, returns true if queue is to be repeated
813         virtual bool fireRenderQueueEnded(uint8 id, const String& invocation);
814         /// Internal method for firing when rendering a single object.
815         void fireRenderSingleObject(Renderable* rend, const Pass* pass, const AutoParamDataSource* source,
816             const LightList* pLightList, bool suppressRenderStateChanges);
817 
818         /// Internal method for firing the texture shadows updated event
819         void fireShadowTexturesUpdated(size_t numberOfShadowTextures);
820         /// Internal method for firing the pre caster texture shadows event
821         virtual void fireShadowTexturesPreCaster(Light* light, Camera* camera, size_t iteration);
822         /// Internal method for firing the pre receiver texture shadows event
823         virtual void fireShadowTexturesPreReceiver(Light* light, Frustum* f);
824         /// Internal method for firing pre update scene graph event
825         void firePreUpdateSceneGraph(Camera* camera);
826         /// Internal method for firing post update scene graph event
827         void firePostUpdateSceneGraph(Camera* camera);
828         /// Internal method for firing find visible objects event
829         void firePreFindVisibleObjects(Viewport* v);
830         /// Internal method for firing find visible objects event
831         void firePostFindVisibleObjects(Viewport* v);
832         /// Internal method for firing destruction event
833         void fireSceneManagerDestroyed();
834         /** Internal method for setting the destination viewport for the next render. */
835         void setViewport(Viewport *vp);
836 
837         /** Flag that indicates if all of the scene node's bounding boxes should be shown as a wireframe. */
838         bool mShowBoundingBoxes;
839 
840         /** Internal method for rendering all objects using the default queue sequence. */
841         void renderVisibleObjectsDefaultSequence(void);
842         /** Internal method for rendering all objects using a custom queue sequence. */
843         void renderVisibleObjectsCustomSequence(RenderQueueInvocationSequence* s);
844         /** Internal method for preparing the render queue for use with each render. */
845         void prepareRenderQueue(void);
846 
847 
848         /** Internal utility method for rendering a single object.
849         @remarks
850             Assumes that the pass has already been set up.
851         @param rend The renderable to issue to the pipeline
852         @param pass The pass which is being used
853         @param lightScissoringClipping If true, passes that have the getLightScissorEnabled
854             and/or getLightClipPlanesEnabled flags will cause calculation and setting of
855             scissor rectangle and user clip planes.
856         @param doLightIteration If true, this method will issue the renderable to
857             the pipeline possibly multiple times, if the pass indicates it should be
858             done once per light
859         @param manualLightList Only applicable if doLightIteration is false, this
860             method allows you to pass in a previously determined set of lights
861             which will be used for a single render of this object.
862         */
863         void renderSingleObject(Renderable* rend, const Pass* pass,
864             bool lightScissoringClipping, bool doLightIteration, const LightList* manualLightList = 0);
865 
866         /** Internal method for creating the AutoParamDataSource instance. */
createAutoParamDataSource(void)867         AutoParamDataSource* createAutoParamDataSource(void) const
868         {
869             return OGRE_NEW AutoParamDataSource();
870         }
871 
872         /// Utility class for calculating automatic parameters for gpu programs
873         std::unique_ptr<AutoParamDataSource> mAutoParamDataSource;
874 
875         CompositorChain* mActiveCompositorChain;
876         bool mLateMaterialResolving;
877 
878         IlluminationRenderStage mIlluminationStage;
879         ShadowTextureConfigList mShadowTextureConfigList;
880         bool mShadowTextureConfigDirty;
881         bool mShadowCasterRenderBackFaces;
882 
883         /// Struct for caching light clipping information for re-use in a frame
884         struct LightClippingInfo
885         {
886             RealRect scissorRect;
887             PlaneList clipPlanes;
888             bool scissorValid;
889             unsigned long clipPlanesValid;
LightClippingInfoLightClippingInfo890             LightClippingInfo() : scissorValid(false), clipPlanesValid(false) {}
891 
892         };
893         typedef std::map<Light*, LightClippingInfo> LightClippingInfoMap;
894         LightClippingInfoMap mLightClippingInfoMap;
895         unsigned long mLightClippingInfoMapFrameNumber;
896 
897         /** Default sorting routine which sorts lights which cast shadows
898             to the front of a list, sub-sorting by distance.
899         @remarks
900             Since shadow textures are generated from lights based on the
901             frustum rather than individual objects, a shadow and camera-wise sort is
902             required to pick the best lights near the start of the list. Up to
903             the number of shadow textures will be generated from this.
904         */
905         struct lightsForShadowTextureLess
906         {
907             _OgreExport bool operator()(const Light* l1, const Light* l2) const;
908         };
909 
910 
911         /** Internal method for locating a list of lights which could be affecting the frustum.
912         @remarks
913             Custom scene managers are encouraged to override this method to make use of their
914             scene partitioning scheme to more efficiently locate lights, and to eliminate lights
915             which may be occluded by word geometry.
916         */
917         virtual void findLightsAffectingFrustum(const Camera* camera);
918         /// Internal method for setting up materials for shadows
919         virtual void initShadowVolumeMaterials(void);
920         /// Internal method for creating shadow textures (texture-based shadows)
921         virtual void ensureShadowTexturesCreated();
922         /// Internal method for destroying shadow textures (texture-based shadows)
923         virtual void destroyShadowTextures(void);
924 
925         typedef std::vector<InstanceManager*>      InstanceManagerVec;
926         InstanceManagerVec mDirtyInstanceManagers;
927         InstanceManagerVec mDirtyInstanceMgrsTmp;
928 
929         /** Updates all instance managaers with dirty instance batches. @see _addDirtyInstanceManager */
930         void updateDirtyInstanceManagers(void);
931 
932         void _destroySceneNode(SceneNodeList::iterator it);
933     public:
934         /// Method for preparing shadow textures ready for use in a regular render
935         /// Do not call manually unless before frame start or rendering is paused
936         /// If lightList is not supplied, will render all lights in frustum
937         virtual void prepareShadowTextures(Camera* cam, Viewport* vp, const LightList* lightList = 0);
938 
939         //A render context, used to store internal data for pausing/resuming rendering
940         struct RenderContext
941         {
942             RenderQueue* renderQueue;
943             Viewport* viewport;
944             Camera* camera;
945             CompositorChain* activeChain;
946             RenderSystem::RenderSystemContext* rsContext;
947         };
948 
949         /** Pause rendering of the frame. This has to be called when inside a renderScene call
950             (Usually using a listener of some sort)
951         */
952         RenderContext* _pauseRendering();
953         /** Resume rendering of the frame. This has to be called after a _pauseRendering call
954         @param context The rendring context, as returned by the _pauseRendering call
955         */
956         void _resumeRendering(RenderContext* context);
957 
958     protected:
959         typedef std::vector<ShadowCaster*> ShadowCasterList;
960         ShadowCasterList mShadowCasterList;
961         std::unique_ptr<SphereSceneQuery> mShadowCasterSphereQuery;
962         std::unique_ptr<AxisAlignedBoxSceneQuery> mShadowCasterAABBQuery;
963         bool mShadowTextureSelfShadow;
964 
965         /// Visibility mask used to show / hide objects
966         uint32 mVisibilityMask;
967         bool mFindVisibleObjects;
968         /// Suppress render state changes?
969         bool mSuppressRenderStateChanges;
970         /// Suppress shadows?
971         bool mSuppressShadows;
972 
973         /// Inner class to use as callback for shadow caster scene query
974         class _OgreExport ShadowCasterSceneQueryListener : public SceneQueryListener, public SceneMgtAlloc
975         {
976         protected:
977             SceneManager* mSceneMgr;
978             ShadowCasterList* mCasterList;
979             bool mIsLightInFrustum;
980             const PlaneBoundedVolumeList* mLightClipVolumeList;
981             const Camera* mCamera;
982             const Light* mLight;
983             Real mFarDistSquared;
984         public:
ShadowCasterSceneQueryListener(SceneManager * sm)985             ShadowCasterSceneQueryListener(SceneManager* sm) : mSceneMgr(sm),
986                 mCasterList(0), mIsLightInFrustum(false), mLightClipVolumeList(0),
987                 mCamera(0), mFarDistSquared(0) {}
988             // Prepare the listener for use with a set of parameters
prepare(bool lightInFrustum,const PlaneBoundedVolumeList * lightClipVolumes,const Light * light,const Camera * cam,ShadowCasterList * casterList,Real farDistSquared)989             void prepare(bool lightInFrustum,
990                 const PlaneBoundedVolumeList* lightClipVolumes,
991                 const Light* light, const Camera* cam, ShadowCasterList* casterList,
992                 Real farDistSquared)
993             {
994                 mCasterList = casterList;
995                 mIsLightInFrustum = lightInFrustum;
996                 mLightClipVolumeList = lightClipVolumes;
997                 mCamera = cam;
998                 mLight = light;
999                 mFarDistSquared = farDistSquared;
1000             }
1001             bool queryResult(MovableObject* object);
1002             bool queryResult(SceneQuery::WorldFragment* fragment);
1003         };
1004 
1005         std::unique_ptr<ShadowCasterSceneQueryListener> mShadowCasterQueryListener;
1006 
1007         /** Internal method for locating a list of shadow casters which
1008             could be affecting the frustum for a given light.
1009         @remarks
1010             Custom scene managers are encouraged to override this method to add optimisations,
1011             and to add their own custom shadow casters (perhaps for world geometry)
1012         */
1013         const ShadowCasterList& findShadowCastersForLight(const Light* light,
1014             const Camera* camera);
1015         /** Render a group in the ordinary way */
1016         void renderBasicQueueGroupObjects(RenderQueueGroup* pGroup,
1017             QueuedRenderableCollection::OrganisationMode om);
1018         /** Render a set of objects, see renderSingleObject for param definitions
1019             @remarks
1020             transparentShadowCastersMode is intended to be used to render the shadows of transparent objects which have
1021             transparency_casts_shadows set to 'on' in their material
1022         */
1023         void renderObjects(const QueuedRenderableCollection& objs,
1024             QueuedRenderableCollection::OrganisationMode om, bool lightScissoringClipping,
1025             bool doLightIteration, const LightList* manualLightList = 0, bool transparentShadowCastersMode = false);
1026 
1027         /** Update the state of the global render queue splitting based on a shadow
1028         option change. */
1029         void updateRenderQueueSplitOptions(void);
1030         /** Update the state of the render queue group splitting based on a shadow
1031         option change. */
1032         void updateRenderQueueGroupSplitOptions(RenderQueueGroup* group,
1033             bool suppressShadows, bool suppressRenderState);
1034 
1035         /// Set up a scissor rectangle from a group of lights
1036         ClipResult buildAndSetScissor(const LightList& ll, const Camera* cam);
1037         /// Update a scissor rectangle from a single light
1038         void buildScissor(const Light* l, const Camera* cam, RealRect& rect);
1039         void resetScissor();
1040         /// Build a set of user clip planes from a single non-directional light
1041         ClipResult buildAndSetLightClip(const LightList& ll);
1042         void buildLightClip(const Light* l, PlaneList& planes);
1043         void resetLightClip();
1044         void checkCachedLightClippingInfo(bool forceScissorRectsInvalidation = false);
1045 
1046         /// The active renderable visitor class - subclasses could override this
1047         SceneMgrQueuedRenderableVisitor* mActiveQueuedRenderableVisitor;
1048         /// Storage for default renderable visitor
1049         SceneMgrQueuedRenderableVisitor mDefaultQueuedRenderableVisitor;
1050 
1051         /// Whether to use camera-relative rendering
1052         bool mCameraRelativeRendering;
1053         Affine3 mCachedViewMatrix;
1054 
1055         /// Last light sets
1056         uint32 mLastLightHash;
1057         unsigned short mLastLightLimit;
1058         /// Gpu params that need rebinding (mask of GpuParamVariability)
1059         uint16 mGpuParamsDirty;
1060 
1061         void useLights(const LightList& lights, ushort limit, bool fixedFunction);
1062         void setViewMatrix(const Affine3& m);
1063         void bindGpuProgram(GpuProgram* prog);
1064         void updateGpuProgramParameters(const Pass* p);
1065 
1066 
1067 
1068 
1069 
1070 
1071 
1072 
1073         /// Set of registered LOD listeners
1074         typedef std::set<LodListener*> LodListenerSet;
1075         LodListenerSet mLodListeners;
1076 
1077         /// List of movable object LOD changed events
1078         typedef std::vector<MovableObjectLodChangedEvent> MovableObjectLodChangedEventList;
1079         MovableObjectLodChangedEventList mMovableObjectLodChangedEvents;
1080 
1081         /// List of entity mesh LOD changed events
1082         typedef std::vector<EntityMeshLodChangedEvent> EntityMeshLodChangedEventList;
1083         EntityMeshLodChangedEventList mEntityMeshLodChangedEvents;
1084 
1085         /// List of entity material LOD changed events
1086         typedef std::vector<EntityMaterialLodChangedEvent> EntityMaterialLodChangedEventList;
1087         EntityMaterialLodChangedEventList mEntityMaterialLodChangedEvents;
1088 
1089     public:
1090         /** Constructor.
1091         */
1092         SceneManager(const String& instanceName);
1093 
1094         /** Default destructor.
1095         */
1096         virtual ~SceneManager();
1097 
1098 
1099         /** Mutex to protect the scene graph from simultaneous access from
1100             multiple threads.
1101         @remarks
1102             If you are updating the scene in a separate thread from the rendering
1103             thread, then you should lock this mutex before making any changes to
1104             the scene graph - that means creating, modifying or deleting a
1105             scene node, or attaching / detaching objects. It is <b>your</b>
1106             responsibility to take out this lock, the detail methods on the nodes
1107             will not do it for you (for the reasons discussed below).
1108         @par
1109             Note that locking this mutex will prevent the scene being rendered until
1110             it is unlocked again. Therefore you should do this sparingly. Try
1111             to create any objects you need separately and fully prepare them
1112             before doing all your scene graph work in one go, thus keeping this
1113             lock for the shortest time possible.
1114         @note
1115             A single global lock is used rather than a per-node lock since
1116             it keeps the number of locks required during rendering down to a
1117             minimum. Obtaining a lock, even if there is no contention, is not free
1118             so for performance it is good to do it as little as possible.
1119             Since modifying the scene in a separate thread is a fairly
1120             rare occurrence (relative to rendering), it is better to keep the
1121             locking required during rendering lower than to make update locks
1122             more granular.
1123         */
1124         OGRE_MUTEX(sceneGraphMutex);
1125 
1126         /** Return the instance name of this SceneManager. */
getName(void)1127         const String& getName(void) const { return mName; }
1128 
1129         /** Retrieve the type name of this scene manager.
1130         @remarks
1131             This method has to be implemented by subclasses. It should
1132             return the type name of this SceneManager which agrees with
1133             the type name of the SceneManagerFactory which created it.
1134         */
1135         virtual const String& getTypeName(void) const = 0;
1136 
1137         /** Creates a camera to be managed by this scene manager.
1138             @remarks
1139                 This camera must be added to the scene at a later time using
1140                 the attachObject method of the SceneNode class.
1141             @param
1142                 name Name to give the new camera.
1143         */
1144         virtual Camera* createCamera(const String& name);
1145 
1146         /** Retrieves a pointer to the named camera.
1147         @note Throws an exception if the named instance does not exist
1148         */
1149         Camera* getCamera(const String& name) const;
1150 
1151         /** Returns whether a camera with the given name exists.
1152         */
1153         bool hasCamera(const String& name) const;
1154 
1155         /** Removes a camera from the scene.
1156             @remarks
1157                 This method removes a previously added camera from the scene.
1158                 The camera is deleted so the caller must ensure no references
1159                 to it's previous instance (e.g. in a SceneNode) are used.
1160             @param
1161                 cam Pointer to the camera to remove
1162         */
1163         virtual void destroyCamera(Camera *cam);
1164 
1165         /** Removes a camera from the scene.
1166             @remarks
1167                 This method removes an camera from the scene based on the
1168                 camera's name rather than a pointer.
1169         */
1170         virtual void destroyCamera(const String& name);
1171 
1172         /** Removes (and destroys) all cameras from the scene.
1173             @remarks
1174                 Some cameras are internal created to dealing with texture shadow,
1175                 their aren't supposed to destroy outside. So, while you are using
1176                 texture shadow, don't call this method, or you can set the shadow
1177                 technique other than texture-based, which will destroy all internal
1178                 created shadow cameras and textures.
1179         */
1180         virtual void destroyAllCameras(void);
1181 
1182         /** Creates a light for use in the scene.
1183             @remarks
1184                 Lights can either be in a fixed position and independent of the
1185                 scene graph, or they can be attached to SceneNodes so they derive
1186                 their position from the parent node. Either way, they are created
1187                 using this method so that the SceneManager manages their
1188                 existence.
1189             @param
1190                 name The name of the new light, to identify it later.
1191         */
1192         virtual Light* createLight(const String& name);
1193 
1194         /** Creates a light with a generated name. */
1195         virtual Light* createLight();
1196 
1197         /** Returns a pointer to the named Light which has previously been added to the scene.
1198         @note Throws an exception if the named instance does not exist
1199         */
1200         virtual Light* getLight(const String& name) const;
1201 
1202         /** Returns whether a light with the given name exists.
1203         */
1204         virtual bool hasLight(const String& name) const;
1205 
1206         /** Retrieve a set of clipping planes for a given light.
1207         */
1208         const PlaneList& getLightClippingPlanes(Light* l);
1209 
1210         /** Retrieve a scissor rectangle for a given light and camera.
1211         */
1212         const RealRect& getLightScissorRect(Light* l, const Camera* cam);
1213 
1214         /** Scissor rects are cached during frame, and this cache should be explicitly invalidated
1215             if several renders are done during one frame using different projections matrices,
1216             for example for tiled, stereo or multiview orthographic projection rendering.
1217         */
1218         virtual void invalidatePerFrameScissorRectCache();
1219 
1220         /** Removes the named light from the scene and destroys it.
1221             @remarks
1222                 Any pointers held to this light after calling this method will be invalid.
1223         */
1224         virtual void destroyLight(const String& name);
1225 
1226         /** Removes the light from the scene and destroys it based on a pointer.
1227             @remarks
1228                 Any pointers held to this light after calling this method will be invalid.
1229         */
1230         virtual void destroyLight(Light* light);
1231         /** Removes and destroys all lights in the scene.
1232         */
1233         virtual void destroyAllLights(void);
1234 
1235         /** Advance method to increase the lights dirty counter due lights changed.
1236         @remarks
1237             Scene manager tracking lights that affecting the frustum, if changes
1238             detected (the changes includes light list itself and the light's position
1239             and attenuation range), then increase the lights dirty counter.
1240         @par
1241             For some reason, you can call this method to force whole scene objects
1242             re-populate their light list. But near in mind, call to this method
1243             will harm performance, so should avoid if possible.
1244         */
1245         void _notifyLightsDirty(void);
1246 
1247         /** Advance method to gets the lights dirty counter.
1248         @remarks
1249             Scene manager tracking lights that affecting the frustum, if changes
1250             detected (the changes includes light list itself and the light's position
1251             and attenuation range), then increase the lights dirty counter.
1252         @par
1253             When implementing customise lights finding algorithm relied on either
1254             SceneManager::_getLightsAffectingFrustum or SceneManager::_populateLightList,
1255             might check this value for sure that the light list are really need to
1256             re-populate, otherwise, returns cached light list (if exists) for better
1257             performance.
1258         */
_getLightsDirtyCounter(void)1259         ulong _getLightsDirtyCounter(void) const { return mLightsDirtyCounter; }
1260 
1261         /** Get the list of lights which could be affecting the frustum.
1262         @remarks
1263             Note that default implementation of this method returns a cached light list,
1264             which is populated when rendering the scene. So by default the list of lights
1265             is only available during scene rendering.
1266         */
1267         const LightList& _getLightsAffectingFrustum(void) const;
1268 
1269         /** Populate a light list with an ordered set of the lights which are closest
1270         to the position specified.
1271         @remarks
1272             Note that since directional lights have no position, they are always considered
1273             closer than any point lights and as such will always take precedence.
1274         @par
1275             Subclasses of the default SceneManager may wish to take into account other issues
1276             such as possible visibility of the light if that information is included in their
1277             data structures. This basic scenemanager simply orders by distance, eliminating
1278             those lights which are out of range or could not be affecting the frustum (i.e.
1279             only the lights returned by SceneManager::_getLightsAffectingFrustum are take into
1280             account).
1281         @par
1282             The number of items in the list max exceed the maximum number of lights supported
1283             by the renderer, but the extraneous ones will never be used. In fact the limit will
1284             be imposed by Pass::getMaxSimultaneousLights.
1285         @param position The position at which to evaluate the list of lights
1286         @param radius The bounding radius to test
1287         @param destList List to be populated with ordered set of lights; will be cleared by
1288             this method before population.
1289         @param lightMask The mask with which to include / exclude lights
1290         */
1291         void _populateLightList(const Vector3& position, Real radius, LightList& destList, uint32 lightMask = 0xFFFFFFFF);
1292 
1293         /** Populates a light list with an ordered set of the lights which are closest
1294         to the position of the SceneNode given.
1295         @remarks
1296             Note that since directional lights have no position, they are always considered
1297             closer than any point lights and as such will always take precedence.
1298             This overloaded version will take the SceneNode's position and use the second method
1299             to populate the list.
1300         @par
1301             Subclasses of the default SceneManager may wish to take into account other issues
1302             such as possible visibility of the light if that information is included in their
1303             data structures. This basic scenemanager simply orders by distance, eliminating
1304             those lights which are out of range or could not be affecting the frustum (i.e.
1305             only the lights returned by SceneManager::_getLightsAffectingFrustum are take into
1306             account).
1307         @par
1308             Also note that subclasses of the SceneNode might be used here to provide cached
1309             scene related data, accelerating the list population (for example light lists for
1310             SceneNodes could be cached inside subclassed SceneNode objects).
1311         @par
1312             The number of items in the list may exceed the maximum number of lights supported
1313             by the renderer, but the extraneous ones will never be used. In fact the limit will
1314             be imposed by Pass::getMaxSimultaneousLights.
1315         @param sn The SceneNode for which to evaluate the list of lights
1316         @param radius The bounding radius to test
1317         @param destList List to be populated with ordered set of lights; will be cleared by
1318             this method before population.
1319         @param lightMask The mask with which to include / exclude lights
1320         */
1321         void _populateLightList(const SceneNode* sn, Real radius, LightList& destList, uint32 lightMask = 0xFFFFFFFF);
1322 
1323         /** Creates an instance of a SceneNode.
1324             @remarks
1325                 Note that this does not add the SceneNode to the scene hierarchy.
1326                 This method is for convenience, since it allows an instance to
1327                 be created for which the SceneManager is responsible for
1328                 allocating and releasing memory, which is convenient in complex
1329                 scenes.
1330             @par
1331                 To include the returned SceneNode in the scene, use the addChild
1332                 method of the SceneNode which is to be it's parent.
1333             @par
1334                 Note that this method takes no parameters, and the node created is unnamed (it is
1335                 actually given a generated name, which you can retrieve if you want).
1336                 If you wish to create a node with a specific name, call the alternative method
1337                 which takes a name parameter.
1338         */
1339         virtual SceneNode* createSceneNode(void);
1340 
1341         /// @overload
1342         virtual SceneNode* createSceneNode(const String& name);
1343 
1344         /** Destroys a SceneNode.
1345         @remarks
1346             This allows you to physically delete an individual SceneNode if you want to.
1347             Note that this is not normally recommended, it's better to allow SceneManager
1348             to delete the nodes when the scene is cleared.
1349         */
1350         virtual void destroySceneNode(SceneNode* sn);
1351 
1352         /// @overload
1353         virtual void destroySceneNode(const String& name);
1354 
1355         /** Gets the SceneNode at the root of the scene hierarchy.
1356             @remarks
1357                 The entire scene is held as a hierarchy of nodes, which
1358                 allows things like relative transforms, general changes in
1359                 rendering state etc (See the SceneNode class for more info).
1360                 In this basic SceneManager class, the application using
1361                 Ogre is free to structure this hierarchy however it likes,
1362                 since it has no real significance apart from making transforms
1363                 relative to each node (more specialised subclasses will
1364                 provide utility methods for building specific node structures
1365                 e.g. loading a BSP tree).
1366             @par
1367                 However, in all cases there is only ever one root node of
1368                 the hierarchy, and this method returns a pointer to it.
1369         */
1370         SceneNode* getRootSceneNode(void);
1371 
1372         /** Retrieves a named SceneNode from the scene graph.
1373 
1374             If you chose to name a SceneNode as you created it, you can look it
1375             up wherever it is in the scene graph using this method.
1376             @param name
1377             @param throwExceptionIfNotFound Throws an exception if the named instance does not exist
1378         */
1379         SceneNode* getSceneNode(const String& name, bool throwExceptionIfNotFound = true) const;
1380 
1381         /** Returns whether a scene node with the given name exists.
1382         */
hasSceneNode(const String & name)1383         bool hasSceneNode(const String& name) const { return getSceneNode(name, false) != NULL; }
1384 
1385         /** Create an Entity (instance of a discrete mesh).
1386             @param
1387                 entityName The name to be given to the entity (must be unique).
1388             @param
1389                 meshName The name of the Mesh it is to be based on (e.g. 'knot.oof'). The
1390                 mesh will be loaded if it is not already.
1391             @param groupName The resource name where the mesh lives
1392         */
1393         Entity* createEntity(const String& entityName, const String& meshName, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
1394 
1395         /** Create an Entity (instance of a discrete mesh).
1396             @param
1397                 entityName The name to be given to the entity (must be unique).
1398             @param
1399                 pMesh The pointer to the Mesh it is to be based on.
1400         */
1401         Entity* createEntity(const String& entityName, const MeshPtr& pMesh );
1402 
1403         /** Create an Entity (instance of a discrete mesh) with an autogenerated name.
1404             @param
1405                 meshName The name of the Mesh it is to be based on (e.g. 'knot.oof'). The
1406                 mesh will be loaded if it is not already.
1407         */
1408         Entity* createEntity(const String& meshName);
1409 
1410         /** Create an Entity (instance of a discrete mesh) with an autogenerated name.
1411             @param
1412                 pMesh The pointer to the Mesh it is to be based on.
1413         */
1414         Entity* createEntity(const MeshPtr& pMesh);
1415 
1416         /** Prefab shapes available without loading a model.
1417             @note
1418                 Minimal implementation at present.
1419             @todo
1420                 Add more prefabs (teapots, teapots!!!)
1421         */
1422         enum PrefabType {
1423             PT_PLANE,
1424             PT_CUBE,
1425             PT_SPHERE
1426         };
1427 
1428         /** Create an Entity (instance of a discrete mesh) from a range of prefab shapes.
1429             @param
1430                 entityName The name to be given to the entity (must be unique).
1431             @param
1432                 ptype The prefab type.
1433         */
1434         Entity* createEntity(const String& entityName, PrefabType ptype);
1435 
1436         /** Create an Entity (instance of a discrete mesh) from a range of prefab shapes, generating the name.
1437             @param ptype The prefab type.
1438         */
1439         Entity* createEntity(PrefabType ptype);
1440         /** Retrieves a pointer to the named Entity.
1441         @note Throws an exception if the named instance does not exist
1442         */
1443         Entity* getEntity(const String& name) const;
1444         /** Returns whether an entity with the given name exists.
1445         */
1446         bool hasEntity(const String& name) const;
1447 
1448         /** Removes & destroys an Entity from the SceneManager.
1449             @warning
1450                 Must only be done if the Entity is not attached
1451                 to a SceneNode. It may be safer to wait to clear the whole
1452                 scene if you are unsure use clearScene.
1453             @see
1454                 SceneManager::clearScene
1455         */
1456         void destroyEntity(Entity* ent);
1457 
1458         /// @overload
1459         void destroyEntity(const String& name);
1460 
1461         /** Removes & destroys all Entities.
1462             @warning
1463                 Again, use caution since no Entity must be referred to
1464                 elsewhere e.g. attached to a SceneNode otherwise a crash
1465                 is likely. Use clearScene if you are unsure (it clears SceneNode
1466                 entries too.)
1467             @see
1468                 SceneManager::clearScene
1469         */
1470         virtual void destroyAllEntities(void);
1471 
1472         /** Create a ManualObject, an object which you populate with geometry
1473             manually through a GL immediate-mode style interface.
1474         @param
1475             name The name to be given to the object (must be unique).
1476         */
1477         ManualObject* createManualObject(const String& name);
1478         /** Create a ManualObject, an object which you populate with geometry
1479         manually through a GL immediate-mode style interface, generating the name.
1480         */
1481         ManualObject* createManualObject();
1482         /** Retrieves a pointer to the named ManualObject.
1483         @note Throws an exception if the named instance does not exist
1484         */
1485         ManualObject* getManualObject(const String& name) const;
1486         /** Returns whether a manual object with the given name exists.
1487         */
1488         bool hasManualObject(const String& name) const;
1489 
1490         /** Removes & destroys a ManualObject from the SceneManager.
1491         */
1492         void destroyManualObject(ManualObject* obj);
1493         /// @overload
1494         void destroyManualObject(const String& name);
1495         /** Removes & destroys all ManualObjects from the SceneManager.
1496         */
1497         void destroyAllManualObjects(void);
1498         /** Create a BillboardChain, an object which you can use to render
1499             a linked chain of billboards.
1500         @param
1501             name The name to be given to the object (must be unique).
1502         */
1503         BillboardChain* createBillboardChain(const String& name);
1504         /** Create a BillboardChain, an object which you can use to render
1505         a linked chain of billboards, with a generated name.
1506         */
1507         BillboardChain* createBillboardChain();
1508         /** Retrieves a pointer to the named BillboardChain.
1509         @note Throws an exception if the named instance does not exist
1510         */
1511         BillboardChain* getBillboardChain(const String& name) const;
1512         /** Returns whether a billboard chain with the given name exists.
1513         */
1514         bool hasBillboardChain(const String& name) const;
1515 
1516         /** Removes & destroys a BillboardChain from the SceneManager.
1517         */
1518         void destroyBillboardChain(BillboardChain* obj);
1519         /// @overload
1520         void destroyBillboardChain(const String& name);
1521         /** Removes & destroys all BillboardChains from the SceneManager.
1522         */
1523         void destroyAllBillboardChains(void);
1524         /** Create a RibbonTrail, an object which you can use to render
1525             a linked chain of billboards which follows one or more nodes.
1526         @param
1527             name The name to be given to the object (must be unique).
1528         */
1529         RibbonTrail* createRibbonTrail(const String& name);
1530         /** Create a RibbonTrail, an object which you can use to render
1531         a linked chain of billboards which follows one or more nodes, generating the name.
1532         */
1533         RibbonTrail* createRibbonTrail();
1534         /** Retrieves a pointer to the named RibbonTrail.
1535         @note Throws an exception if the named instance does not exist
1536         */
1537         RibbonTrail* getRibbonTrail(const String& name) const;
1538         /** Returns whether a ribbon trail with the given name exists.
1539         */
1540         bool hasRibbonTrail(const String& name) const;
1541 
1542         /** Removes & destroys a RibbonTrail from the SceneManager.
1543         */
1544         void destroyRibbonTrail(RibbonTrail* obj);
1545         /// @overload
1546         void destroyRibbonTrail(const String& name);
1547         /** Removes & destroys all RibbonTrails from the SceneManager.
1548         */
1549         void destroyAllRibbonTrails(void);
1550 
1551         /** Creates a particle system based on a template.
1552         @remarks
1553             This method creates a new ParticleSystem instance based on the named template
1554             (defined through ParticleSystemManager::createTemplate) and returns a
1555             pointer to the caller. The caller should not delete this object, it will be freed at system shutdown,
1556             or can be released earlier using the destroyParticleSystem method.
1557         @par
1558             Each system created from a template takes the template's settings at the time of creation,
1559             but is completely separate from the template from there on.
1560         @par
1561             Creating a particle system does not make it a part of the scene. As with other MovableObject
1562             subclasses, a ParticleSystem is not rendered until it is attached to a SceneNode.
1563         @par
1564             This is probably the more useful particle system creation method since it does not require manual
1565             setup of the system. Note that the initial quota is based on the template but may be changed later.
1566         @param
1567             name The name to give the new particle system instance.
1568         @param
1569             templateName The name of the template to base the new instance on.
1570         */
1571         ParticleSystem* createParticleSystem(const String& name,
1572             const String& templateName);
1573         /** Create a blank particle system.
1574         @remarks
1575             This method creates a new, blank ParticleSystem instance and returns a pointer to it.
1576             The caller should not delete this object, it will be freed at system shutdown, or can
1577             be released earlier using the destroyParticleSystem method.
1578         @par
1579             The instance returned from this method won't actually do anything because on creation a
1580             particle system has no emitters. The caller should manipulate the instance through it's
1581             ParticleSystem methods to actually create a real particle effect.
1582         @par
1583             Creating a particle system does not make it a part of the scene. As with other MovableObject
1584             subclasses, a ParticleSystem is not rendered until it is attached to a SceneNode.
1585         @param
1586             name The name to give the ParticleSystem.
1587         @param
1588             quota The maximum number of particles to allow in this system.
1589         @param
1590             resourceGroup The resource group which will be used to load dependent resources
1591         */
1592         ParticleSystem* createParticleSystem(const String& name,
1593             size_t quota = 500,
1594             const String& resourceGroup = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
1595 
1596         /** Create a blank particle system with a generated name.
1597         @remarks
1598             This method creates a new, blank ParticleSystem instance and returns a pointer to it.
1599             The caller should not delete this object, it will be freed at system shutdown, or can
1600             be released earlier using the destroyParticleSystem method.
1601         @par
1602             The instance returned from this method won't actually do anything because on creation a
1603             particle system has no emitters. The caller should manipulate the instance through it's
1604             ParticleSystem methods to actually create a real particle effect.
1605         @par
1606             Creating a particle system does not make it a part of the scene. As with other MovableObject
1607             subclasses, a ParticleSystem is not rendered until it is attached to a SceneNode.
1608         @param
1609             quota The maximum number of particles to allow in this system.
1610         @param
1611             resourceGroup The resource group which will be used to load dependent resources
1612         */
1613         ParticleSystem* createParticleSystem(size_t quota = 500,
1614             const String& resourceGroup = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
1615         /** Retrieves a pointer to the named ParticleSystem.
1616         @note Throws an exception if the named instance does not exist
1617         */
1618         ParticleSystem* getParticleSystem(const String& name) const;
1619         /** Returns whether a particle system with the given name exists.
1620         */
1621         bool hasParticleSystem(const String& name) const;
1622 
1623         /** Removes & destroys a ParticleSystem from the SceneManager.
1624         */
1625         void destroyParticleSystem(ParticleSystem* obj);
1626         /** Removes & destroys a ParticleSystem from the SceneManager.
1627         */
1628         void destroyParticleSystem(const String& name);
1629         /** Removes & destroys all ParticleSystems from the SceneManager.
1630         */
1631         void destroyAllParticleSystems(void);
1632 
1633         /** Empties the entire scene, inluding all SceneNodes, Entities, Lights,
1634             BillboardSets etc. Cameras are not deleted at this stage since
1635             they are still referenced by viewports, which are not destroyed during
1636             this process.
1637         */
1638         virtual void clearScene(void);
1639 
1640         /** Sets the ambient light level to be used for the scene.
1641             @remarks
1642                 This sets the colour and intensity of the ambient light in the scene, i.e. the
1643                 light which is 'sourceless' and illuminates all objects equally.
1644                 The colour of an object is affected by a combination of the light in the scene,
1645                 and the amount of light that object reflects (in this case based on the Material::ambient
1646                 property).
1647             @remarks
1648                 By default the ambient light in the scene is ColourValue::Black, i.e. no ambient light. This
1649                 means that any objects rendered with a Material which has lighting enabled (see Material::setLightingEnabled)
1650                 will not be visible unless you have some dynamic lights in your scene.
1651         */
1652         void setAmbientLight(const ColourValue& colour);
1653 
1654         /** Returns the ambient light level to be used for the scene.
1655         */
1656         const ColourValue& getAmbientLight(void) const;
1657 
1658         /** Sets the source of the 'world' geometry, i.e. the large, mainly static geometry
1659             making up the world e.g. rooms, landscape etc.
1660             This function can be called before setWorldGeometry in a background thread, do to
1661             some slow tasks (e.g. IO) that do not involve the backend render system.
1662             @remarks
1663                 Depending on the type of SceneManager (subclasses will be specialised
1664                 for particular world geometry types) you have requested via the Root or
1665                 SceneManagerEnumerator classes, you can pass a filename to this method and it
1666                 will attempt to load the world-level geometry for use. If you try to load
1667                 an inappropriate type of world data an exception will be thrown. The default
1668                 SceneManager cannot handle any sort of world geometry and so will always
1669                 throw an exception. However subclasses like BspSceneManager can load
1670                 particular types of world geometry e.g. "q3dm1.bsp".
1671 
1672         */
1673         virtual void prepareWorldGeometry(const String& filename);
1674 
1675         /** @overload
1676             @param stream Data stream containing data to load
1677             @param typeName String identifying the type of world geometry
1678                 contained in the stream - not required if this manager only
1679                 supports one type of world geometry.
1680         */
1681         virtual void prepareWorldGeometry(DataStreamPtr& stream,
1682             const String& typeName = BLANKSTRING);
1683 
1684         /** Sets the source of the 'world' geometry, i.e. the large, mainly static geometry
1685             making up the world e.g. rooms, landscape etc.
1686             @remarks
1687                 Depending on the type of SceneManager (subclasses will be specialised
1688                 for particular world geometry types) you have requested via the Root or
1689                 SceneManagerEnumerator classes, you can pass a filename to this method and it
1690                 will attempt to load the world-level geometry for use. If you try to load
1691                 an inappropriate type of world data an exception will be thrown. The default
1692                 SceneManager cannot handle any sort of world geometry and so will always
1693                 throw an exception. However subclasses like BspSceneManager can load
1694                 particular types of world geometry e.g. "q3dm1.bsp".
1695         */
1696         virtual void setWorldGeometry(const String& filename);
1697 
1698         /** @overload
1699             @param stream Data stream containing data to load
1700             @param typeName String identifying the type of world geometry
1701                 contained in the stream - not required if this manager only
1702                 supports one type of world geometry.
1703         */
1704         virtual void setWorldGeometry(DataStreamPtr& stream,
1705             const String& typeName = BLANKSTRING);
1706 
1707         /** Estimate the number of loading stages required to load the named
1708             world geometry.
1709         @remarks
1710             This method should be overridden by SceneManagers that provide
1711             custom world geometry that can take some time to load. They should
1712             return from this method a count of the number of stages of progress
1713             they can report on whilst loading. During real loading (setWorldGeometry),
1714             they should call ResourceGroupManager::_notifyWorldGeometryProgress exactly
1715             that number of times when loading the geometry for real.
1716         @note
1717             The default is to return 0, ie to not report progress.
1718         */
estimateWorldGeometry(const String & filename)1719         virtual size_t estimateWorldGeometry(const String& filename)
1720         { (void)filename; return 0; }
1721 
1722         /** @overload
1723         @param stream Data stream containing data to load
1724         @param typeName String identifying the type of world geometry
1725             contained in the stream - not required if this manager only
1726             supports one type of world geometry.
1727         */
1728         virtual size_t estimateWorldGeometry(DataStreamPtr& stream,
1729             const String& typeName = BLANKSTRING)
1730         { (void)stream; (void)typeName; return 0; }
1731 
1732         /** Asks the SceneManager to provide a suggested viewpoint from which the scene should be viewed.
1733             @remarks
1734                 Typically this method returns the origin unless a) world geometry has been loaded using
1735                 SceneManager::setWorldGeometry and b) that world geometry has suggested 'start' points.
1736                 If there is more than one viewpoint which the scene manager can suggest, it will always suggest
1737                 the first one unless the random parameter is true.
1738             @param
1739                 random If true, and there is more than one possible suggestion, a random one will be used. If false
1740                 the same one will always be suggested.
1741             @return
1742                 On success, true is returned.
1743             @par
1744                 On failure, false is returned.
1745         */
1746         virtual ViewPoint getSuggestedViewpoint(bool random = false);
1747 
1748         /** Method for setting a specific option of the Scene Manager. These options are usually
1749             specific for a certain implemntation of the Scene Manager class, and may (and probably
1750             will) not exist across different implementations.
1751             @param
1752                 strKey The name of the option to set
1753             @param
1754                 pValue A pointer to the value - the size should be calculated by the scene manager
1755                 based on the key
1756             @return
1757                 On success, true is returned.
1758             @par
1759                 On failure, false is returned.
1760         */
setOption(const String & strKey,const void * pValue)1761         virtual bool setOption( const String& strKey, const void* pValue )
1762         { (void)strKey; (void)pValue; return false; }
1763 
1764         /** Method for getting the value of an implementation-specific Scene Manager option.
1765             @param
1766                 strKey The name of the option
1767             @param
1768                 pDestValue A pointer to a memory location where the value will
1769                 be copied. Currently, the memory will be allocated by the
1770                 scene manager, but this may change
1771             @return
1772                 On success, true is returned and pDestValue points to the value of the given
1773                 option.
1774             @par
1775                 On failure, false is returned and pDestValue is set to NULL.
1776         */
getOption(const String & strKey,void * pDestValue)1777         virtual bool getOption( const String& strKey, void* pDestValue )
1778         { (void)strKey; (void)pDestValue; return false; }
1779 
1780         /** Method for verifying whether the scene manager has an implementation-specific
1781             option.
1782             @param
1783                 strKey The name of the option to check for.
1784             @return
1785                 If the scene manager contains the given option, true is returned.
1786             @remarks
1787                 If it does not, false is returned.
1788         */
hasOption(const String & strKey)1789         virtual bool hasOption( const String& strKey ) const
1790         { (void)strKey; return false; }
1791 
1792         /** Method for getting all possible values for a specific option. When this list is too large
1793             (i.e. the option expects, for example, a float), the return value will be true, but the
1794             list will contain just one element whose size will be set to 0.
1795             Otherwise, the list will be filled with all the possible values the option can
1796             accept.
1797             @param
1798                 strKey The name of the option to get the values for.
1799             @param
1800                 refValueList A reference to a list that will be filled with the available values.
1801             @return
1802                 On success (the option exists), true is returned.
1803             @par
1804                 On failure, false is returned.
1805         */
getOptionValues(const String & strKey,StringVector & refValueList)1806         virtual bool getOptionValues( const String& strKey, StringVector& refValueList )
1807         { (void)strKey; (void)refValueList; return false; }
1808 
1809         /** Method for getting all the implementation-specific options of the scene manager.
1810             @param
1811                 refKeys A reference to a list that will be filled with all the available options.
1812             @return
1813                 On success, true is returned. On failure, false is returned.
1814         */
getOptionKeys(StringVector & refKeys)1815         virtual bool getOptionKeys( StringVector& refKeys )
1816         { (void)refKeys; return false; }
1817 
1818         /** Internal method for updating the scene graph ie the tree of SceneNode instances managed by this class.
1819             @remarks
1820                 This must be done before issuing objects to the rendering pipeline, since derived transformations from
1821                 parent nodes are not updated until required. This SceneManager is a basic implementation which simply
1822                 updates all nodes from the root. This ensures the scene is up to date but requires all the nodes
1823                 to be updated even if they are not visible. Subclasses could trim this such that only potentially visible
1824                 nodes are updated.
1825         */
1826         virtual void _updateSceneGraph(Camera* cam);
1827 
1828         /** Internal method which parses the scene to find visible objects to render.
1829             @remarks
1830                 If you're implementing a custom scene manager, this is the most important method to
1831                 override since it's here you can apply your custom world partitioning scheme. Once you
1832                 have added the appropriate objects to the render queue, you can let the default
1833                 SceneManager objects _renderVisibleObjects handle the actual rendering of the objects
1834                 you pick.
1835             @par
1836                 Any visible objects will be added to a rendering queue, which is indexed by material in order
1837                 to ensure objects with the same material are rendered together to minimise render state changes.
1838         */
1839         virtual void _findVisibleObjects(Camera* cam, VisibleObjectsBoundsInfo* visibleBounds, bool onlyShadowCasters);
1840 
1841         /** Internal method for issuing the render operation.*/
1842         void _issueRenderOp(Renderable* rend, const Pass* pass);
1843 
1844         /** Internal method for applying animations to scene nodes.
1845         @remarks
1846             Uses the internally stored AnimationState objects to apply animation to SceneNodes.
1847         */
1848         void _applySceneAnimations(void);
1849 
1850         /** Sends visible objects found in _findVisibleObjects to the rendering engine.
1851         */
1852         void _renderVisibleObjects(void);
1853 
1854         /** Prompts the class to send its contents to the renderer.
1855             @remarks
1856                 This method prompts the scene manager to send the
1857                 contents of the scene it manages to the rendering
1858                 pipeline, possibly preceded by some sorting, culling
1859                 or other scene management tasks. Note that this method is not normally called
1860                 directly by the user application; it is called automatically
1861                 by the Ogre rendering loop.
1862             @param camera Pointer to a camera from whose viewpoint the scene is to
1863                 be rendered.
1864             @param vp The target viewport
1865             @param includeOverlays Whether or not overlay objects should be rendered
1866         */
1867         virtual void _renderScene(Camera* camera, Viewport* vp, bool includeOverlays);
1868 
1869         /** Internal method for queueing the sky objects with the params as
1870             previously set through setSkyBox, setSkyPlane and setSkyDome.
1871         */
_queueSkiesForRendering(Camera * cam)1872         void _queueSkiesForRendering(Camera* cam)
1873         {
1874             mSkyRenderer.queueSkiesForRendering(getRenderQueue(), cam);
1875         }
1876 
1877         /** Notifies the scene manager of its destination render system
1878             @remarks
1879                 Called automatically by RenderSystem::addSceneManager
1880                 this method simply notifies the manager of the render
1881                 system to which its output must be directed.
1882             @param
1883                 sys Pointer to the RenderSystem subclass to be used as a render target.
1884         */
1885         void _setDestinationRenderSystem(RenderSystem* sys);
1886 
1887         /** Notifies the scene manager that hardware resources were lost
1888             @remarks
1889                 Called automatically by RenderSystem if hardware resources
1890                 were lost and can not be restored using some internal mechanism.
1891                 Among affected resources are manual meshes without loaders,
1892                 manual textures without loaders, ManualObjects, etc.
1893         */
1894         void _releaseManualHardwareResources();
1895 
1896         /** Notifies the scene manager that hardware resources should be restored
1897             @remarks
1898                 Called automatically by RenderSystem if hardware resources
1899                 were lost and can not be restored using some internal mechanism.
1900                 Among affected resources are manual meshes without loaders,
1901                 manual textures without loaders, ManualObjects, etc.
1902         */
1903         void _restoreManualHardwareResources();
1904 
1905         /** Enables / disables a 'sky plane' i.e. a plane at constant
1906             distance from the camera representing the sky.
1907             @remarks
1908                 You can create sky planes yourself using the standard mesh and
1909                 entity methods, but this creates a plane which the camera can
1910                 never get closer or further away from - it moves with the camera.
1911                 (NB you could create this effect by creating a world plane which
1912                 was attached to the same SceneNode as the Camera too, but this
1913                 would only apply to a single camera whereas this plane applies to
1914                 any camera using this scene manager).
1915             @note
1916                 To apply scaling, scrolls etc to the sky texture(s) you
1917                 should use the TextureUnitState class methods.
1918             @param
1919                 enable True to enable the plane, false to disable it
1920             @param
1921                 plane Details of the plane, i.e. it's normal and it's
1922                 distance from the camera.
1923             @param
1924                 materialName The name of the material the plane will use
1925             @param
1926                 scale The scaling applied to the sky plane - higher values
1927                 mean a bigger sky plane - you may want to tweak this
1928                 depending on the size of plane.d and the other
1929                 characteristics of your scene
1930             @param
1931                 tiling How many times to tile the texture across the sky.
1932                 Applies to all texture layers. If you need finer control use
1933                 the TextureUnitState texture coordinate transformation methods.
1934             @param
1935                 drawFirst If true, the plane is drawn before all other
1936                 geometry in the scene, without updating the depth buffer.
1937                 This is the safest rendering method since all other objects
1938                 will always appear in front of the sky. However this is not
1939                 the most efficient way if most of the sky is often occluded
1940                 by other objects. If this is the case, you can set this
1941                 parameter to false meaning it draws <em>after</em> all other
1942                 geometry which can be an optimisation - however you must
1943                 ensure that the plane.d value is large enough that no objects
1944                 will 'poke through' the sky plane when it is rendered.
1945             @param
1946                 bow If zero, the plane will be completely flat (like previous
1947                 versions.  If above zero, the plane will be curved, allowing
1948                 the sky to appear below camera level.  Curved sky planes are
1949                 simular to skydomes, but are more compatible with fog.
1950             @param xsegments, ysegments
1951                 Determines the number of segments the plane will have to it. This
1952                 is most important when you are bowing the plane, but may also be useful
1953                 if you need tessellation on the plane to perform per-vertex effects.
1954             @param groupName
1955                 The name of the resource group to which to assign the plane mesh.
1956         */
1957 
1958         void setSkyPlane(
1959             bool enable,
1960             const Plane& plane, const String& materialName, Real scale = 1000,
1961             Real tiling = 10, bool drawFirst = true, Real bow = 0,
1962             int xsegments = 1, int ysegments = 1,
1963             const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
1964         /** @copydoc setSkyPlane
1965             @param
1966                 renderQueue The render queue to use when rendering this object
1967         */
1968         void _setSkyPlane(
1969             bool enable,
1970             const Plane& plane, const String& materialName, Real scale = 1000,
1971             Real tiling = 10, uint8 renderQueue = RENDER_QUEUE_SKIES_EARLY, Real bow = 0,
1972             int xsegments = 1, int ysegments = 1,
1973             const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
1974 
1975         /** Enables / disables a 'sky plane' */
setSkyPlaneEnabled(bool enable)1976         void setSkyPlaneEnabled(bool enable) { mSkyRenderer.mSkyPlaneEnabled = enable; }
1977 
1978         /** Return whether a key plane is enabled */
isSkyPlaneEnabled(void)1979         bool isSkyPlaneEnabled(void) const { return mSkyRenderer.mSkyPlaneEnabled; }
1980 
1981         /** Get the sky plane node, if enabled. */
getSkyPlaneNode(void)1982         SceneNode* getSkyPlaneNode(void) const { return mSkyRenderer.mSkyPlaneNode; }
1983 
1984         /** Get the parameters used to construct the SkyPlane, if any **/
getSkyPlaneGenParameters(void)1985         const SkyPlaneGenParameters& getSkyPlaneGenParameters(void) const { return mSkyRenderer.mSkyPlaneGenParameters; }
1986 
1987         /** Enables / disables a 'sky box' i.e. a 6-sided box at constant
1988             distance from the camera representing the sky.
1989             @remarks
1990                 You could create a sky box yourself using the standard mesh and
1991                 entity methods, but this creates a plane which the camera can
1992                 never get closer or further away from - it moves with the camera.
1993                 (NB you could create this effect by creating a world box which
1994                 was attached to the same SceneNode as the Camera too, but this
1995                 would only apply to a single camera whereas this skybox applies
1996                 to any camera using this scene manager).
1997             @par
1998                 The material you use for the skybox can either contain layers
1999                 which are single textures, or they can be cubic textures, i.e.
2000                 made up of 6 images, one for each plane of the cube. See the
2001                 TextureUnitState class for more information.
2002             @param
2003                 enable True to enable the skybox, false to disable it
2004             @param
2005                 materialName The name of the material the box will use
2006             @param
2007                 distance Distance in world coorinates from the camera to
2008                 each plane of the box. The default is normally OK.
2009             @param
2010                 drawFirst If true, the box is drawn before all other
2011                 geometry in the scene, without updating the depth buffer.
2012                 This is the safest rendering method since all other objects
2013                 will always appear in front of the sky. However this is not
2014                 the most efficient way if most of the sky is often occluded
2015                 by other objects. If this is the case, you can set this
2016                 parameter to false meaning it draws <em>after</em> all other
2017                 geometry which can be an optimisation - however you must
2018                 ensure that the distance value is large enough that no
2019                 objects will 'poke through' the sky box when it is rendered.
2020             @param
2021                 orientation Optional parameter to specify the orientation
2022                 of the box. By default the 'top' of the box is deemed to be
2023                 in the +y direction, and the 'front' at the -z direction.
2024                 You can use this parameter to rotate the sky if you want.
2025             @param groupName
2026                 The name of the resource group to which to assign the plane mesh.
2027         */
2028         void setSkyBox(
2029             bool enable, const String& materialName, Real distance = 5000,
2030             bool drawFirst = true, const Quaternion& orientation = Quaternion::IDENTITY,
2031             const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
2032 
2033         /** @copydoc setSkyBox
2034             @param
2035                 renderQueue The render queue to use when rendering this object
2036         */
2037         void _setSkyBox(
2038             bool enable, const String& materialName, Real distance = 5000,
2039             uint8 renderQueue = RENDER_QUEUE_SKIES_EARLY, const Quaternion& orientation = Quaternion::IDENTITY,
2040             const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
2041 
2042         /** Enables / disables a 'sky box' */
setSkyBoxEnabled(bool enable)2043         void setSkyBoxEnabled(bool enable) { mSkyRenderer.mSkyBoxEnabled = enable; }
2044 
2045         /** Return whether a skybox is enabled */
isSkyBoxEnabled(void)2046         bool isSkyBoxEnabled(void) const { return mSkyRenderer.mSkyBoxEnabled; }
2047 
2048         /** Get the skybox node, if enabled. */
getSkyBoxNode(void)2049         SceneNode* getSkyBoxNode(void) const { return mSkyRenderer.mSkyBoxNode; }
2050 
2051         /** Get the parameters used to generate the current SkyBox, if any */
getSkyBoxGenParameters(void)2052         const SkyBoxGenParameters& getSkyBoxGenParameters(void) const { return mSkyRenderer.mSkyBoxGenParameters; }
2053 
2054         /** Enables / disables a 'sky dome' i.e. an illusion of a curved sky.
2055             @remarks
2056                 A sky dome is actually formed by 5 sides of a cube, but with
2057                 texture coordinates generated such that the surface appears
2058                 curved like a dome. Sky domes are appropriate where you need a
2059                 realistic looking sky where the scene is not going to be
2060                 'fogged', and there is always a 'floor' of some sort to prevent
2061                 the viewer looking below the horizon (the distortion effect below
2062                 the horizon can be pretty horrible, and there is never anyhting
2063                 directly below the viewer). If you need a complete wrap-around
2064                 background, use the setSkyBox method instead. You can actually
2065                 combine a sky box and a sky dome if you want, to give a positional
2066                 backdrop with an overlayed curved cloud layer.
2067             @par
2068                 Sky domes work well with 2D repeating textures like clouds. You
2069                 can change the apparent 'curvature' of the sky depending on how
2070                 your scene is viewed - lower curvatures are better for 'open'
2071                 scenes like landscapes, whilst higher curvatures are better for
2072                 say FPS levels where you don't see a lot of the sky at once and
2073                 the exaggerated curve looks good.
2074             @param
2075                 enable True to enable the skydome, false to disable it
2076             @param
2077                 materialName The name of the material the dome will use
2078             @param
2079                 curvature The curvature of the dome. Good values are
2080                 between 2 and 65. Higher values are more curved leading to
2081                 a smoother effect, lower values are less curved meaning
2082                 more distortion at the horizons but a better distance effect.
2083             @param
2084                 tiling How many times to tile the texture(s) across the
2085                 dome.
2086             @param
2087                 distance Distance in world coorinates from the camera to
2088                 each plane of the box the dome is rendered on. The default
2089                 is normally OK.
2090             @param
2091                 drawFirst If true, the dome is drawn before all other
2092                 geometry in the scene, without updating the depth buffer.
2093                 This is the safest rendering method since all other objects
2094                 will always appear in front of the sky. However this is not
2095                 the most efficient way if most of the sky is often occluded
2096                 by other objects. If this is the case, you can set this
2097                 parameter to false meaning it draws <em>after</em> all other
2098                 geometry which can be an optimisation - however you must
2099                 ensure that the distance value is large enough that no
2100                 objects will 'poke through' the sky when it is rendered.
2101             @param
2102                 orientation Optional parameter to specify the orientation
2103                 of the dome. By default the 'top' of the dome is deemed to
2104                 be in the +y direction, and the 'front' at the -z direction.
2105                 You can use this parameter to rotate the sky if you want.
2106             @param groupName
2107                 The name of the resource group to which to assign the plane mesh.
2108                 */
2109         void setSkyDome(
2110             bool enable, const String& materialName, Real curvature = 10,
2111             Real tiling = 8, Real distance = 4000, bool drawFirst = true,
2112             const Quaternion& orientation = Quaternion::IDENTITY,
2113             int xsegments = 16, int ysegments = 16, int ysegments_keep = -1,
2114             const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
2115 
2116         /** @copydoc setSkyDome
2117             @param
2118                 renderQueue The render queue to use when rendering this object
2119                 */
2120         void _setSkyDome(
2121             bool enable, const String& materialName, Real curvature = 10,
2122             Real tiling = 8, Real distance = 4000, uint8 renderQueue = RENDER_QUEUE_SKIES_EARLY,
2123             const Quaternion& orientation = Quaternion::IDENTITY,
2124             int xsegments = 16, int ysegments = 16, int ysegments_keep = -1,
2125             const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
2126 
2127         /** Enables / disables a 'sky dome' */
setSkyDomeEnabled(bool enable)2128         void setSkyDomeEnabled(bool enable) { mSkyRenderer.mSkyDomeEnabled = enable; }
2129 
2130         /** Return whether a skydome is enabled */
isSkyDomeEnabled(void)2131         bool isSkyDomeEnabled(void) const { return mSkyRenderer.mSkyDomeEnabled; }
2132 
2133         /** Get the sky dome node, if enabled. */
getSkyDomeNode(void)2134         SceneNode* getSkyDomeNode(void) const { return mSkyRenderer.mSkyDomeNode; }
2135 
2136         /** Get the parameters used to generate the current SkyDome, if any */
getSkyDomeGenParameters(void)2137         const SkyDomeGenParameters& getSkyDomeGenParameters(void) const { return mSkyRenderer.mSkyDomeGenParameters; }
2138 
2139         /** Sets the fogging mode applied to the scene.
2140             @remarks
2141                 This method sets up the scene-wide fogging effect. These settings
2142                 apply to all geometry rendered, UNLESS the material with which it
2143                 is rendered has it's own fog settings (see Material::setFog).
2144             @param
2145                 mode Set up the mode of fog as described in the FogMode
2146                 enum, or set to FOG_NONE to turn off.
2147             @param
2148                 colour The colour of the fog. Either set this to the same
2149                 as your viewport background colour, or to blend in with a
2150                 skydome or skybox.
2151             @param
2152                 expDensity The density of the fog in FOG_EXP or FOG_EXP2
2153                 mode, as a value between 0 and 1. The default is 0.001.
2154             @param
2155                 linearStart Distance in world units at which linear fog starts to
2156                 encroach. Only applicable if mode is
2157                 FOG_LINEAR.
2158             @param
2159                 linearEnd Distance in world units at which linear fog becomes completely
2160                 opaque. Only applicable if mode is
2161                 FOG_LINEAR.
2162         */
2163         void setFog(
2164             FogMode mode = FOG_NONE, const ColourValue& colour = ColourValue::White,
2165             Real expDensity = 0.001f, Real linearStart = 0.0f, Real linearEnd = 1.0f);
2166 
2167         /** Returns the fog mode for the scene.
2168         */
2169         FogMode getFogMode(void) const;
2170 
2171         /** Returns the fog colour for the scene.
2172         */
2173         const ColourValue& getFogColour(void) const;
2174 
2175         /** Returns the fog start distance for the scene.
2176         */
2177         Real getFogStart(void) const;
2178 
2179         /** Returns the fog end distance for the scene.
2180         */
2181         Real getFogEnd(void) const;
2182 
2183         /** Returns the fog density for the scene.
2184         */
2185         Real getFogDensity(void) const;
2186 
2187 
2188         /** Creates a new BillboardSet for use with this scene manager.
2189             @remarks
2190                 This method creates a new BillboardSet which is registered with
2191                 the SceneManager. The SceneManager will destroy this object when
2192                 it shuts down or when the SceneManager::clearScene method is
2193                 called, so the caller does not have to worry about destroying
2194                 this object (in fact, it definitely should not do this).
2195             @par
2196                 See the BillboardSet documentations for full details of the
2197                 returned class.
2198             @param
2199                 poolSize The initial size of the pool of billboards (see BillboardSet for more information)
2200             @see
2201                 BillboardSet
2202         */
2203         BillboardSet* createBillboardSet(unsigned int poolSize = 20);
2204 
2205         /** @overload
2206             @param
2207                 name The name to give to this billboard set. Must be unique.
2208         */
2209         BillboardSet* createBillboardSet(const String& name, unsigned int poolSize = 20);
2210 
2211         /** Retrieves a pointer to the named BillboardSet.
2212         @note Throws an exception if the named instance does not exist
2213         */
2214         BillboardSet* getBillboardSet(const String& name) const;
2215         /** Returns whether a billboardset with the given name exists.
2216         */
2217         bool hasBillboardSet(const String& name) const;
2218 
2219         /** Removes & destroys an BillboardSet from the SceneManager.
2220             @warning
2221                 Must only be done if the BillboardSet is not attached
2222                 to a SceneNode. It may be safer to wait to clear the whole
2223                 scene. If you are unsure, use clearScene.
2224         */
2225         void destroyBillboardSet(BillboardSet* set);
2226 
2227         /// @overload
2228         void destroyBillboardSet(const String& name);
2229 
2230         /** Removes & destroys all BillboardSets.
2231         @warning
2232         Again, use caution since no BillboardSet must be referred to
2233         elsewhere e.g. attached to a SceneNode otherwise a crash
2234         is likely. Use clearScene if you are unsure (it clears SceneNode
2235         entries too.)
2236         @see
2237         SceneManager::clearScene
2238         */
2239         void destroyAllBillboardSets(void);
2240 
2241         /** Tells the SceneManager whether it should render the SceneNodes which
2242             make up the scene as well as the objects in the scene.
2243         @remarks
2244             This method is mainly for debugging purposes. If you set this to 'true',
2245             each node will be rendered as a set of 3 axes to allow you to easily see
2246             the orientation of the nodes.
2247         */
2248         void setDisplaySceneNodes(bool display);
2249         /** Returns true if all scene nodes axis are to be displayed */
getDisplaySceneNodes(void)2250         bool getDisplaySceneNodes(void) const {return mDisplayNodes;}
2251 
2252         /** Creates an animation which can be used to animate scene nodes.
2253         @remarks
2254             An animation is a collection of 'tracks' which over time change the position / orientation
2255             of Node objects. In this case, the animation will likely have tracks to modify the position
2256             / orientation of SceneNode objects, e.g. to make objects move along a path.
2257         @par
2258             You don't need to use an Animation object to move objects around - you can do it yourself
2259             using the methods of the Node in your FrameListener class. However, when you need relatively
2260             complex scripted animation, this is the class to use since it will interpolate between
2261             keyframes for you and generally make the whole process easier to manage.
2262         @par
2263             A single animation can affect multiple Node objects (each AnimationTrack affects a single Node).
2264             In addition, through animation blending a single Node can be affected by multiple animations,
2265             athough this is more useful when performing skeletal animation (see Skeleton::createAnimation).
2266         @par
2267             Note that whilst it uses the same classes, the animations created here are kept separate from the
2268             skeletal animations of meshes (each Skeleton owns those animations).
2269         @param name The name of the animation, must be unique within this SceneManager.
2270         @param length The total length of the animation.
2271         */
2272         Animation* createAnimation(const String& name, Real length);
2273 
2274         /** Looks up an Animation object previously created with createAnimation.
2275         @note Throws an exception if the named instance does not exist
2276         */
2277         Animation* getAnimation(const String& name) const;
2278         /** Returns whether an animation with the given name exists.
2279         */
2280         bool hasAnimation(const String& name) const;
2281 
2282         /** Destroys an Animation.
2283         @remarks
2284             You should ensure that none of your code is referencing this animation objects since the
2285             memory will be freed.
2286         */
2287         void destroyAnimation(const String& name);
2288 
2289         /** Removes all animations created using this SceneManager. */
2290         void destroyAllAnimations(void);
2291 
2292         /** Create an AnimationState object for managing application of animations.
2293         @remarks
2294             You can create Animation objects for animating SceneNode obejcts using the
2295             createAnimation method. However, in order to actually apply those animations
2296             you have to call methods on Node and Animation in a particular order (namely
2297             Node::resetToInitialState and Animation::apply). To make this easier and to
2298             help track the current time position of animations, the AnimationState object
2299             is provided.
2300             So if you don't want to control animation application manually, call this method,
2301             update the returned object as you like every frame and let SceneManager apply
2302             the animation state for you.
2303         @par
2304             Remember, AnimationState objects are disabled by default at creation time.
2305             Turn them on when you want them using their setEnabled method.
2306         @par
2307             Note that any SceneNode affected by this automatic animation will have it's state
2308             reset to it's initial position before application of the animation. Unless specifically
2309             modified using Node::setInitialState the Node assumes it's initial state is at the
2310             origin. If you want the base state of the SceneNode to be elsewhere, make your changes
2311             to the node using the standard transform methods, then call setInitialState to
2312             'bake' this reference position into the node.
2313         @par
2314             If the target of your animation is to be a generic AnimableValue, you
2315             should ensure that it has a base value set (unlike nodes this has no
2316             default). @see AnimableValue::setAsBaseValue.
2317         @param animName The name of an animation created already with createAnimation.
2318         */
2319         AnimationState* createAnimationState(const String& animName);
2320 
2321         /** Retrieves animation state as previously created using createAnimationState.
2322         @note Throws an exception if the named instance does not exist
2323         */
2324         AnimationState* getAnimationState(const String& animName) const;
2325         /** Returns whether an animation state with the given name exists.
2326         */
2327         bool hasAnimationState(const String& name) const;
2328 
2329         /** Destroys an AnimationState.
2330         @remarks
2331             You should ensure that none of your code is referencing this animation
2332             state object since the memory will be freed.
2333         */
2334         void destroyAnimationState(const String& name);
2335 
2336         /** Removes all animation states created using this SceneManager. */
2337         void destroyAllAnimationStates(void);
2338 
2339         /** Manual rendering method, for advanced users only.
2340         @remarks
2341             This method allows you to send rendering commands through the pipeline on
2342             demand, bypassing OGRE's normal world processing. You should only use this if you
2343             really know what you're doing; OGRE does lots of things for you that you really should
2344             let it do. However, there are times where it may be useful to have this manual interface,
2345             for example overlaying something on top of the scene rendered by OGRE.
2346         @par
2347             Because this is an instant rendering method, timing is important. The best
2348             time to call it is from a RenderTargetListener event handler.
2349         @par
2350             Don't call this method a lot, it's designed for rare (1 or 2 times per frame) use.
2351             Calling it regularly per frame will cause frame rate drops!
2352         @param rend A RenderOperation object describing the rendering op
2353         @param pass The Pass to use for this render
2354         @param vp Pointer to the viewport to render to, or 0 to use the current viewport
2355         @param worldMatrix The transform to apply from object to world space
2356         @param viewMatrix The transform to apply from world to view space
2357         @param projMatrix The transform to apply from view to screen space
2358         @param doBeginEndFrame If true, beginFrame() and endFrame() are called,
2359             otherwise not. You should leave this as false if you are calling
2360             this within the main render loop.
2361         */
2362         void manualRender(RenderOperation* rend, Pass* pass, Viewport* vp,
2363             const Affine3& worldMatrix, const Affine3& viewMatrix, const Matrix4& projMatrix,
2364             bool doBeginEndFrame = false) ;
2365 
2366         /** Manual rendering method for rendering a single object.
2367         @param rend The renderable to issue to the pipeline
2368         @param pass The pass to use
2369         @param vp Pointer to the viewport to render to, or 0 to use the existing viewport
2370         @param doBeginEndFrame If true, beginFrame() and endFrame() are called,
2371         otherwise not. You should leave this as false if you are calling
2372         this within the main render loop.
2373         @param viewMatrix The transform to apply from world to view space
2374         @param projMatrix The transform to apply from view to screen space
2375         @param lightScissoringClipping If true, passes that have the getLightScissorEnabled
2376         and/or getLightClipPlanesEnabled flags will cause calculation and setting of
2377         scissor rectangle and user clip planes.
2378         @param doLightIteration If true, this method will issue the renderable to
2379         the pipeline possibly multiple times, if the pass indicates it should be
2380         done once per light
2381         @param manualLightList Only applicable if doLightIteration is false, this
2382         method allows you to pass in a previously determined set of lights
2383         which will be used for a single render of this object.
2384         */
2385         void manualRender(Renderable* rend, const Pass* pass, Viewport* vp,
2386             const Affine3& viewMatrix, const Matrix4& projMatrix, bool doBeginEndFrame = false, bool lightScissoringClipping = true,
2387             bool doLightIteration = true, const LightList* manualLightList = 0);
2388 
2389         /** Retrieves the internal render queue, for advanced users only.
2390         @remarks
2391             The render queue is mainly used internally to manage the scene object
2392             rendering queue, it also exports some methods to allow advanced users
2393             to configure the behavior of rendering process.
2394             Most methods provided by RenderQueue are supposed to be used
2395             internally only, you should reference to the RenderQueue API for
2396             more information. Do not access this directly unless you know what
2397             you are doing.
2398         */
2399         RenderQueue* getRenderQueue(void);
2400 
2401         /** Registers a new RenderQueueListener which will be notified when render queues
2402             are processed.
2403         */
2404         void addRenderQueueListener(RenderQueueListener* newListener);
2405 
2406         /** Removes a listener previously added with addRenderQueueListener. */
2407         void removeRenderQueueListener(RenderQueueListener* delListener);
2408 
2409         /** Registers a new Render Object Listener which will be notified when rendering an object.
2410         */
2411         void addRenderObjectListener(RenderObjectListener* newListener);
2412         /** Removes a listener previously added with addRenderObjectListener. */
2413         void removeRenderObjectListener(RenderObjectListener* delListener);
2414 
2415         /** Adds an item to the 'special case' render queue list.
2416         @remarks
2417             Normally all render queues are rendered, in their usual sequence,
2418             only varying if a RenderQueueListener nominates for the queue to be
2419             repeated or skipped. This method allows you to add a render queue to
2420             a 'special case' list, which varies the behaviour. The effect of this
2421             list depends on the 'mode' in which this list is in, which might be
2422             to exclude these render queues, or to include them alone (excluding
2423             all other queues). This allows you to perform broad selective
2424             rendering without requiring a RenderQueueListener.
2425         @param qid The identifier of the queue which should be added to the
2426             special case list. Nothing happens if the queue is already in the list.
2427         */
2428         void addSpecialCaseRenderQueue(uint8 qid);
2429         /** Removes an item to the 'special case' render queue list.
2430         @see SceneManager::addSpecialCaseRenderQueue
2431         @param qid The identifier of the queue which should be removed from the
2432             special case list. Nothing happens if the queue is not in the list.
2433         */
2434         void removeSpecialCaseRenderQueue(uint8 qid);
2435         /** Clears the 'special case' render queue list.
2436         @see SceneManager::addSpecialCaseRenderQueue
2437         */
2438         void clearSpecialCaseRenderQueues(void);
2439         /** Sets the way the special case render queue list is processed.
2440         @see SceneManager::addSpecialCaseRenderQueue
2441         @param mode The mode of processing
2442         */
2443         void setSpecialCaseRenderQueueMode(SpecialCaseRenderQueueMode mode);
2444         /** Gets the way the special case render queue list is processed. */
2445         SpecialCaseRenderQueueMode getSpecialCaseRenderQueueMode(void);
2446         /** Returns whether or not the named queue will be rendered based on the
2447             current 'special case' render queue list and mode.
2448         @see SceneManager::addSpecialCaseRenderQueue
2449         @param qid The identifier of the queue which should be tested
2450         @return true if the queue will be rendered, false otherwise
2451         */
2452         bool isRenderQueueToBeProcessed(uint8 qid);
2453 
2454         /** Sets the render queue that the world geometry (if any) this SceneManager
2455             renders will be associated with.
2456         @remarks
2457             SceneManagers which provide 'world geometry' should place it in a
2458             specialised render queue in order to make it possible to enable /
2459             disable it easily using the addSpecialCaseRenderQueue method. Even
2460             if the SceneManager does not use the render queues to render the
2461             world geometry, it should still pick a queue to represent it's manual
2462             rendering, and check isRenderQueueToBeProcessed before rendering.
2463         @note
2464             Setting this may not affect the actual ordering of rendering the
2465             world geometry, if the world geometry is being rendered manually
2466             by the SceneManager. If the SceneManager feeds world geometry into
2467             the queues, however, the ordering will be affected.
2468         */
2469         void setWorldGeometryRenderQueue(uint8 qid);
2470         /** Gets the render queue that the world geometry (if any) this SceneManager
2471             renders will be associated with.
2472         @remarks
2473             SceneManagers which provide 'world geometry' should place it in a
2474             specialised render queue in order to make it possible to enable /
2475             disable it easily using the addSpecialCaseRenderQueue method. Even
2476             if the SceneManager does not use the render queues to render the
2477             world geometry, it should still pick a queue to represent it's manual
2478             rendering, and check isRenderQueueToBeProcessed before rendering.
2479         */
2480         uint8 getWorldGeometryRenderQueue(void);
2481 
2482         /** Allows all bounding boxes of scene nodes to be displayed. */
2483         void showBoundingBoxes(bool bShow);
2484 
2485         /** Returns if all bounding boxes of scene nodes are to be displayed */
2486         bool getShowBoundingBoxes() const;
2487 
2488         /** Internal method for notifying the manager that a SceneNode is autotracking. */
2489         void _notifyAutotrackingSceneNode(SceneNode* node, bool autoTrack);
2490 
2491 
2492         /** Creates an AxisAlignedBoxSceneQuery for this scene manager.
2493         @remarks
2494             This method creates a new instance of a query object for this scene manager,
2495             for an axis aligned box region. See SceneQuery and AxisAlignedBoxSceneQuery
2496             for full details.
2497         @par
2498             The instance returned from this method must be destroyed by calling
2499             SceneManager::destroyQuery when it is no longer required.
2500         @param box Details of the box which describes the region for this query.
2501         @param mask The query mask to apply to this query; can be used to filter out
2502             certain objects; see SceneQuery for details.
2503         */
2504         virtual AxisAlignedBoxSceneQuery*
2505             createAABBQuery(const AxisAlignedBox& box, uint32 mask = 0xFFFFFFFF);
2506         /** Creates a SphereSceneQuery for this scene manager.
2507         @remarks
2508             This method creates a new instance of a query object for this scene manager,
2509             for a spherical region. See SceneQuery and SphereSceneQuery
2510             for full details.
2511         @par
2512             The instance returned from this method must be destroyed by calling
2513             SceneManager::destroyQuery when it is no longer required.
2514         @param sphere Details of the sphere which describes the region for this query.
2515         @param mask The query mask to apply to this query; can be used to filter out
2516             certain objects; see SceneQuery for details.
2517         */
2518         virtual SphereSceneQuery*
2519             createSphereQuery(const Sphere& sphere, uint32 mask = 0xFFFFFFFF);
2520         /** Creates a PlaneBoundedVolumeListSceneQuery for this scene manager.
2521         @remarks
2522         This method creates a new instance of a query object for this scene manager,
2523         for a region enclosed by a set of planes (normals pointing inwards).
2524         See SceneQuery and PlaneBoundedVolumeListSceneQuery for full details.
2525         @par
2526         The instance returned from this method must be destroyed by calling
2527         SceneManager::destroyQuery when it is no longer required.
2528         @param volumes Details of the volumes which describe the region for this query.
2529         @param mask The query mask to apply to this query; can be used to filter out
2530         certain objects; see SceneQuery for details.
2531         */
2532         virtual PlaneBoundedVolumeListSceneQuery*
2533             createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, uint32 mask = 0xFFFFFFFF);
2534 
2535 
2536         /** Creates a RaySceneQuery for this scene manager.
2537         @remarks
2538             This method creates a new instance of a query object for this scene manager,
2539             looking for objects which fall along a ray. See SceneQuery and RaySceneQuery
2540             for full details.
2541         @par
2542             The instance returned from this method must be destroyed by calling
2543             SceneManager::destroyQuery when it is no longer required.
2544         @param ray Details of the ray which describes the region for this query.
2545         @param mask The query mask to apply to this query; can be used to filter out
2546             certain objects; see SceneQuery for details.
2547         */
2548         virtual RaySceneQuery*
2549             createRayQuery(const Ray& ray, uint32 mask = 0xFFFFFFFF);
2550         //PyramidSceneQuery* createPyramidQuery(const Pyramid& p, unsigned long mask = 0xFFFFFFFF);
2551         /** Creates an IntersectionSceneQuery for this scene manager.
2552         @remarks
2553             This method creates a new instance of a query object for locating
2554             intersecting objects. See SceneQuery and IntersectionSceneQuery
2555             for full details.
2556         @par
2557             The instance returned from this method must be destroyed by calling
2558             SceneManager::destroyQuery when it is no longer required.
2559         @param mask The query mask to apply to this query; can be used to filter out
2560             certain objects; see SceneQuery for details.
2561         */
2562         virtual IntersectionSceneQuery*
2563             createIntersectionQuery(uint32 mask = 0xFFFFFFFF);
2564 
2565         /** Destroys a scene query of any type. */
2566         void destroyQuery(SceneQuery* query);
2567 
2568         typedef MapIterator<CameraList> CameraIterator;
2569         typedef MapIterator<AnimationList> AnimationIterator;
2570 
2571         /** Returns a specialised MapIterator over all cameras in the scene.
2572         @deprecated use getCameras()
2573         */
getCameraIterator(void)2574         OGRE_DEPRECATED CameraIterator getCameraIterator(void) {
2575             return CameraIterator(mCameras.begin(), mCameras.end());
2576         }
2577         /** Returns a const version of the camera list.
2578         */
getCameras()2579         const CameraList& getCameras() const { return mCameras; }
2580         /** Returns a specialised MapIterator over all animations in the scene.
2581          * @deprecated use getAnimations() */
getAnimationIterator(void)2582         OGRE_DEPRECATED AnimationIterator getAnimationIterator(void) {
2583             return AnimationIterator(mAnimationsList.begin(), mAnimationsList.end());
2584         }
2585         /** Returns a const version of the animation list.
2586         */
getAnimations()2587         const AnimationList& getAnimations() const { return mAnimationsList; }
2588         /** Returns a specialised MapIterator over all animation states in the scene.
2589          * @deprecated use getAnimationStates() */
getAnimationStateIterator(void)2590         OGRE_DEPRECATED AnimationStateIterator getAnimationStateIterator(void)
2591         {
2592             return mAnimationStates.getAnimationStateIterator();
2593         }
2594 
2595         /** Returns a specialised Map over all animation states in the scene. */
getAnimationStates()2596         const AnimationStateMap& getAnimationStates() {
2597             return mAnimationStates.getAnimationStates();
2598         }
2599 
2600         /** Sets the general shadow technique to be used in this scene.
2601         @remarks
2602             There are multiple ways to generate shadows in a scene, and each has
2603             strengths and weaknesses.
2604             <ul><li>Stencil-based approaches can be used to
2605             draw very long, extreme shadows without loss of precision and the 'additive'
2606             version can correctly show the shadowing of complex effects like bump mapping
2607             because they physically exclude the light from those areas. However, the edges
2608             are very sharp and stencils cannot handle transparency, and they involve a
2609             fair amount of CPU work in order to calculate the shadow volumes, especially
2610             when animated objects are involved.</li>
2611             <li>Texture-based approaches are good for handling transparency (they can, for
2612             example, correctly shadow a mesh which uses alpha to represent holes), and they
2613             require little CPU overhead, and can happily shadow geometry which is deformed
2614             by a vertex program, unlike stencil shadows. However, they have a fixed precision
2615             which can introduce 'jaggies' at long range and have fillrate issues of their own.</li>
2616             </ul>
2617         @par
2618             We support 2 kinds of stencil shadows, and 2 kinds of texture-based shadows, and one
2619             simple decal approach. The 2 stencil approaches differ in the amount of multipass work
2620             that is required - the modulative approach simply 'darkens' areas in shadow after the
2621             main render, which is the least expensive, whilst the additive approach has to perform
2622             a render per light and adds the cumulative effect, which is more expensive but more
2623             accurate. The texture based shadows both work in roughly the same way, the only difference is
2624             that the shadowmap approach is slightly more accurate, but requires a more recent
2625             graphics card.
2626         @par
2627             Note that because mixing many shadow techniques can cause problems, only one technique
2628             is supported at once. Also, you should call this method at the start of the
2629             scene setup.
2630         @param technique The shadowing technique to use for the scene.
2631         */
2632         void setShadowTechnique(ShadowTechnique technique);
2633 
2634         /** Gets the current shadow technique. */
getShadowTechnique(void)2635         ShadowTechnique getShadowTechnique(void) const { return mShadowRenderer.mShadowTechnique; }
2636 
2637         /** Enables / disables the rendering of debug information for shadows. */
setShowDebugShadows(bool debug)2638         void setShowDebugShadows(bool debug) { mShadowRenderer.mDebugShadows = debug; }
2639         /** Are debug shadows shown? */
getShowDebugShadows(void)2640         bool getShowDebugShadows(void ) const { return mShadowRenderer.mDebugShadows; }
2641 
2642         /** Set the colour used to modulate areas in shadow.
2643         @remarks This is only applicable for shadow techniques which involve
2644             darkening the area in shadow, as opposed to masking out the light.
2645             This colour provided is used as a modulative value to darken the
2646             areas.
2647         */
setShadowColour(const ColourValue & colour)2648         void setShadowColour(const ColourValue& colour) { mShadowRenderer.setShadowColour(colour); }
2649         /** Get the colour used to modulate areas in shadow.
2650         @remarks This is only applicable for shadow techniques which involve
2651         darkening the area in shadow, as opposed to masking out the light.
2652         This colour provided is used as a modulative value to darken the
2653         areas.
2654         */
2655         const ColourValue& getShadowColour(void) const;
2656         /** Sets the distance a shadow volume is extruded for a directional light.
2657         @remarks
2658             Although directional lights are essentially infinite, there are many
2659             reasons to limit the shadow extrusion distance to a finite number,
2660             not least of which is compatibility with older cards (which do not
2661             support infinite positions), and shadow caster elimination.
2662         @par
2663             The default value is 10,000 world units. This does not apply to
2664             point lights or spotlights, since they extrude up to their
2665             attenuation range.
2666         */
2667         void setShadowDirectionalLightExtrusionDistance(Real dist);
2668         /** Gets the distance a shadow volume is extruded for a directional light.
2669         */
2670         Real getShadowDirectionalLightExtrusionDistance(void) const;
2671         /** Sets the default maximum distance away from the camera that shadows
2672         will be visible. You have to call this function before you create lights
2673         or the default distance of zero will be used.
2674         @remarks
2675         Shadow techniques can be expensive, therefore it is a good idea
2676         to limit them to being rendered close to the camera if possible,
2677         and to skip the expense of rendering shadows for distance objects.
2678         This method allows you to set the distance at which shadows will no
2679         longer be rendered.
2680         @note
2681         Each shadow technique can interpret this subtely differently.
2682         For example, one technique may use this to eliminate casters,
2683         another might use it to attenuate the shadows themselves.
2684         You should tweak this value to suit your chosen shadow technique
2685         and scene setup.
2686         */
2687         void setShadowFarDistance(Real distance);
2688         /** Gets the default maximum distance away from the camera that shadows
2689         will be visible.
2690         */
getShadowFarDistance(void)2691         Real getShadowFarDistance(void) const
2692         { return mShadowRenderer.mDefaultShadowFarDist; }
getShadowFarDistanceSquared(void)2693         Real getShadowFarDistanceSquared(void) const
2694         { return mShadowRenderer.mDefaultShadowFarDistSquared; }
2695 
2696         /** Sets the maximum size of the index buffer used to render shadow
2697             primitives.
2698         @remarks
2699             This method allows you to tweak the size of the index buffer used
2700             to render shadow primitives (including stencil shadow volumes). The
2701             default size is 51,200 entries, which is 100k of GPU memory, or
2702             enough to render approximately 17,000 triangles. You can reduce this
2703             as long as you do not have any models / world geometry chunks which
2704             could require more than the amount you set.
2705         @par
2706             The maximum number of triangles required to render a single shadow
2707             volume (including light and dark caps when needed) will be 3x the
2708             number of edges on the light silhouette, plus the number of
2709             light-facing triangles. On average, half the
2710             triangles will be facing toward the light, but the number of
2711             triangles in the silhouette entirely depends on the mesh -
2712             angular meshes will have a higher silhouette tris/mesh tris
2713             ratio than a smooth mesh. You can estimate the requirements for
2714             your particular mesh by rendering it alone in a scene with shadows
2715             enabled and a single light - rotate it or the light and make a note
2716             of how high the triangle count goes (remembering to subtract the
2717             mesh triangle count)
2718         @param size The number of indexes; divide this by 3 to determine the
2719             number of triangles.
2720         */
2721         void setShadowIndexBufferSize(size_t size);
2722         /// Get the size of the shadow index buffer
getShadowIndexBufferSize(void)2723         size_t getShadowIndexBufferSize(void) const
2724         { return mShadowRenderer.mShadowIndexBufferSize; }
2725         /** Set the size of the texture used for all texture-based shadows.
2726         @remarks
2727             The larger the shadow texture, the better the detail on
2728             texture based shadows, but obviously this takes more memory.
2729             The default size is 512. Sizes must be a power of 2.
2730         @note This is the simple form, see setShadowTextureConfig for the more
2731             complex form.
2732         */
2733         void setShadowTextureSize(unsigned short size);
2734 
2735         /** Set the detailed configuration for a shadow texture.
2736         @param shadowIndex The index of the texture to configure, must be < the
2737             number of shadow textures setting
2738         @param width The width of the texture
2739         @param height The height of the texture
2740         @param format The pixel format of the texture
2741         @param fsaa The level of multisampling to use. Ignored if the device does not support it.
2742         @param depthBufferPoolId The pool # it should query the depth buffers from
2743         */
2744         void setShadowTextureConfig(size_t shadowIndex, unsigned short width,
2745             unsigned short height, PixelFormat format, unsigned short fsaa = 0, uint16 depthBufferPoolId=1);
2746         /** Set the detailed configuration for a shadow texture.
2747         @param shadowIndex The index of the texture to configure, must be < the
2748             number of shadow textures setting
2749         @param config Configuration structure
2750         */
2751         void setShadowTextureConfig(size_t shadowIndex,
2752             const ShadowTextureConfig& config);
2753 
2754         /** Get the current shadow texture settings. */
getShadowTextureConfigList()2755         const ShadowTextureConfigList& getShadowTextureConfigList() const { return mShadowTextureConfigList; }
2756 
2757         /// @deprecated use getShadowTextureConfigList
2758         OGRE_DEPRECATED ConstShadowTextureConfigIterator getShadowTextureConfigIterator() const;
2759 
2760         /** Set the pixel format of the textures used for texture-based shadows.
2761         @remarks
2762             By default, a colour texture is used (PF_X8R8G8B8) for texture shadows,
2763             but if you want to use more advanced texture shadow types you can
2764             alter this. If you do, you will have to also call
2765             setShadowTextureCasterMaterial and setShadowTextureReceiverMaterial
2766             to provide shader-based materials to use these customised shadow
2767             texture formats.
2768         @note This is the simple form, see setShadowTextureConfig for the more
2769             complex form.
2770         */
2771         void setShadowTexturePixelFormat(PixelFormat fmt);
2772         /** Set the level of multisample AA of the textures used for texture-based shadows.
2773         @remarks
2774             By default, the level of multisample AA is zero.
2775         @note This is the simple form, see setShadowTextureConfig for the more
2776             complex form.
2777         */
2778         void setShadowTextureFSAA(unsigned short fsaa);
2779 
2780         /** Set the number of textures allocated for texture-based shadows.
2781         @remarks
2782             The default number of textures assigned to deal with texture based
2783             shadows is 1; however this means you can only have one light casting
2784             shadows at the same time. You can increase this number in order to
2785             make this more flexible, but be aware of the texture memory it will use.
2786         */
2787         void setShadowTextureCount(size_t count);
2788         /// @deprecated use getShadowTextureConfigList
getShadowTextureCount(void)2789         OGRE_DEPRECATED size_t getShadowTextureCount(void) const {return mShadowTextureConfigList.size(); }
2790 
2791         /** Set the number of shadow textures a light type uses.
2792         @remarks
2793             The default for all light types is 1. This means that each light uses only 1 shadow
2794             texture. Call this if you need more than 1 shadow texture per light, E.G. PSSM.
2795         @note
2796             This feature only works with the Integrated shadow technique.
2797             Also remember to increase the total number of shadow textures you request
2798             appropriately (e.g. via setShadowTextureCount)!!
2799         */
setShadowTextureCountPerLightType(Light::LightTypes type,size_t count)2800         void setShadowTextureCountPerLightType(Light::LightTypes type, size_t count)
2801         { mShadowRenderer.mShadowTextureCountPerType[type] = count; }
2802         /// Get the number of shadow textures is assigned for the given light type.
getShadowTextureCountPerLightType(Light::LightTypes type)2803         size_t getShadowTextureCountPerLightType(Light::LightTypes type) const
2804         {return mShadowRenderer.mShadowTextureCountPerType[type]; }
2805 
2806         /** Sets the size and count of textures used in texture-based shadows.
2807         @see setShadowTextureSize and setShadowTextureCount for details, this
2808             method just allows you to change both at once, which can save on
2809             reallocation if the textures have already been created.
2810         @note This is the simple form, see setShadowTextureConfig for the more
2811             complex form.
2812         */
2813         void setShadowTextureSettings(unsigned short size, unsigned short count,
2814             PixelFormat fmt = PF_X8R8G8B8, unsigned short fsaa = 0, uint16 depthBufferPoolId=1);
2815 
2816         /** Get a reference to the shadow texture currently in use at the given index.
2817         @note
2818             If you change shadow settings, this reference may no longer
2819             be correct, so be sure not to hold the returned reference over
2820             texture shadow configuration changes.
2821         */
2822         const TexturePtr& getShadowTexture(size_t shadowIndex);
2823 
2824         /** Sets the proportional distance which a texture shadow which is generated from a
2825             directional light will be offset into the camera view to make best use of texture space.
2826 
2827             When generating a shadow texture from a directional light, an approximation is used
2828             since it is not possible to render the entire scene to one texture.
2829             The texture is projected onto an area centred on the camera, and is
2830             the shadow far distance * 2 in length (it is square). This wastes
2831             a lot of texture space outside the frustum though, so this offset allows
2832             you to move the texture in front of the camera more. However, be aware
2833             that this can cause a little shadow 'jittering' during rotation, and
2834             that if you move it too far then you'll start to get artefacts close
2835             to the camera. The value is represented as a proportion of the shadow
2836             far distance, and the default is 0.6.
2837         */
setShadowDirLightTextureOffset(Real offset)2838         void setShadowDirLightTextureOffset(Real offset) { mShadowRenderer.mShadowTextureOffset = offset;}
2839         /** Gets the proportional distance which a texture shadow which is generated from a
2840         directional light will be offset into the camera view to make best use of texture space.
2841         */
getShadowDirLightTextureOffset(void)2842         Real getShadowDirLightTextureOffset(void)  const { return mShadowRenderer.mShadowTextureOffset; }
2843         /** Sets the proportional distance at which texture shadows begin to fade out.
2844         @remarks
2845             To hide the edges where texture shadows end (in directional lights)
2846             Ogre will fade out the shadow in the distance. This value is a proportional
2847             distance of the entire shadow visibility distance at which the shadow
2848             begins to fade out. The default is 0.7
2849         */
setShadowTextureFadeStart(Real fadeStart)2850         void setShadowTextureFadeStart(Real fadeStart)
2851         { mShadowRenderer.mShadowTextureFadeStart = fadeStart; }
2852         /** Sets the proportional distance at which texture shadows finish to fading out.
2853         @remarks
2854         To hide the edges where texture shadows end (in directional lights)
2855         Ogre will fade out the shadow in the distance. This value is a proportional
2856         distance of the entire shadow visibility distance at which the shadow
2857         is completely invisible. The default is 0.9.
2858         */
setShadowTextureFadeEnd(Real fadeEnd)2859         void setShadowTextureFadeEnd(Real fadeEnd)
2860         { mShadowRenderer.mShadowTextureFadeEnd = fadeEnd; }
2861 
2862         /** Sets whether or not texture shadows should attempt to self-shadow.
2863         @remarks
2864             The default implementation of texture shadows uses a fixed-function
2865             colour texture projection approach for maximum compatibility, and
2866             as such cannot support self-shadowing. However, if you decide to
2867             implement a more complex shadowing technique using the
2868             setShadowTextureCasterMaterial and setShadowTextureReceiverMaterial
2869             there is a possibility you may be able to support
2870             self-shadowing (e.g by implementing a shader-based shadow map). In
2871             this case you might want to enable this option.
2872         @param selfShadow Whether to attempt self-shadowing with texture shadows
2873         */
2874         void setShadowTextureSelfShadow(bool selfShadow);
2875 
2876         /// Gets whether or not texture shadows attempt to self-shadow.
getShadowTextureSelfShadow(void)2877         bool getShadowTextureSelfShadow(void) const
2878         { return mShadowTextureSelfShadow; }
2879         /** Sets the default material to use for rendering shadow casters.
2880         @remarks
2881             By default shadow casters are rendered into the shadow texture using
2882             an automatically generated fixed-function pass. This allows basic
2883             projective texture shadows, but it's possible to use more advanced
2884             shadow techniques by overriding the caster and receiver materials, for
2885             example providing vertex and fragment programs to implement shadow
2886             maps.
2887         @par
2888             You can rely on the ambient light in the scene being set to the
2889             requested texture shadow colour, if that's useful.
2890         @note
2891             Individual objects may also override the vertex program in
2892             your default material if their materials include
2893             shadow_caster_vertex_program_ref, shadow_receiver_vertex_program_ref
2894             shadow_caster_material entries, so if you use both make sure they are compatible.
2895         @note
2896             Only a single pass is allowed in your material, although multiple
2897             techniques may be used for hardware fallback.
2898         */
setShadowTextureCasterMaterial(const MaterialPtr & mat)2899         void setShadowTextureCasterMaterial(const MaterialPtr& mat)
2900         { mShadowRenderer.setShadowTextureCasterMaterial(mat); }
2901 
2902         /** Sets the default material to use for rendering shadow receivers.
2903         @remarks
2904             By default shadow receivers are rendered as a post-pass using basic
2905             modulation. This allows basic projective texture shadows, but it's
2906             possible to use more advanced shadow techniques by overriding the
2907             caster and receiver materials, for example providing vertex and
2908             fragment programs to implement shadow maps.
2909         @par
2910             You can rely on texture unit 0 containing the shadow texture, and
2911             for the unit to be set to use projective texturing from the light
2912             (only useful if you're using fixed-function, which is unlikely;
2913             otherwise you should rely on the texture_viewproj_matrix auto binding)
2914         @note
2915             Individual objects may also override the vertex program in
2916             your default material if their materials include
2917             shadow_caster_vertex_program_ref shadow_receiver_vertex_program_ref
2918             shadow_receiver_material entries, so if you use both make sure they are compatible.
2919         @note
2920             Only a single pass is allowed in your material, although multiple
2921             techniques may be used for hardware fallback.
2922         */
setShadowTextureReceiverMaterial(const MaterialPtr & mat)2923         void setShadowTextureReceiverMaterial(const MaterialPtr& mat)
2924         { mShadowRenderer.setShadowTextureReceiverMaterial(mat); }
2925 
2926         /** Sets whether or not shadow casters should be rendered into shadow
2927             textures using their back faces rather than their front faces.
2928         @remarks
2929             Rendering back faces rather than front faces into a shadow texture
2930             can help minimise depth comparison issues, if you're using depth
2931             shadowmapping. You will probably still need some biasing but you
2932             won't need as much. For solid objects the result is the same anyway,
2933             if you have objects with holes you may want to turn this option off.
2934             The default is to enable this option.
2935         */
setShadowCasterRenderBackFaces(bool bf)2936         void setShadowCasterRenderBackFaces(bool bf) { mShadowCasterRenderBackFaces = bf; }
2937 
2938         /** Gets whether or not shadow casters should be rendered into shadow
2939             textures using their back faces rather than their front faces.
2940         */
getShadowCasterRenderBackFaces()2941         bool getShadowCasterRenderBackFaces() const { return mShadowCasterRenderBackFaces; }
2942 
2943         /** Set the shadow camera setup to use for all lights which don't have
2944             their own shadow camera setup.
2945         @see ShadowCameraSetup
2946         */
2947         void setShadowCameraSetup(const ShadowCameraSetupPtr& shadowSetup);
2948 
2949         /** Get the shadow camera setup in use for all lights which don't have
2950             their own shadow camera setup.
2951         @see ShadowCameraSetup
2952         */
2953         const ShadowCameraSetupPtr& getShadowCameraSetup() const;
2954 
2955         /** Sets whether we should use an inifinite camera far plane
2956             when rendering stencil shadows.
2957         @remarks
2958             Stencil shadow coherency is very reliant on the shadow volume
2959             not being clipped by the far plane. If this clipping happens, you
2960             get a kind of 'negative' shadow effect. The best way to achieve
2961             coherency is to move the far plane of the camera out to infinity,
2962             thus preventing the far plane from clipping the shadow volumes.
2963             When combined with vertex program extrusion of the volume to
2964             infinity, which Ogre does when available, this results in very
2965             robust shadow volumes. For this reason, when you enable stencil
2966             shadows, Ogre automatically changes your camera settings to
2967             project to infinity if the card supports it. You can disable this
2968             behaviour if you like by calling this method; although you can
2969             never enable infinite projection if the card does not support it.
2970         @par
2971             If you disable infinite projection, or it is not available,
2972             you need to be far more careful with your light attenuation /
2973             directional light extrusion distances to avoid clipping artefacts
2974             at the far plane.
2975         @note
2976             Recent cards will generally support infinite far plane projection.
2977             However, we have found some cases where they do not, especially
2978             on Direct3D. There is no standard capability we can check to
2979             validate this, so we use some heuristics based on experience:
2980             <UL>
2981             <LI>OpenGL always seems to support it no matter what the card</LI>
2982             <LI>Direct3D on non-vertex program capable systems (including
2983             vertex program capable cards on Direct3D7) does not
2984             support it</LI>
2985             <LI>Direct3D on GeForce3 and GeForce4 Ti does not seem to support
2986             infinite projection<LI>
2987             </UL>
2988             Therefore in the RenderSystem implementation, we may veto the use
2989             of an infinite far plane based on these heuristics.
2990         */
setShadowUseInfiniteFarPlane(bool enable)2991         void setShadowUseInfiniteFarPlane(bool enable) {
2992             mShadowRenderer.mShadowUseInfiniteFarPlane = enable; }
2993 
2994         /** Is there a stencil shadow based shadowing technique in use? */
isShadowTechniqueStencilBased(void)2995         bool isShadowTechniqueStencilBased(void) const
2996         { return (mShadowRenderer.mShadowTechnique & SHADOWDETAILTYPE_STENCIL) != 0; }
2997         /** Is there a texture shadow based shadowing technique in use? */
isShadowTechniqueTextureBased(void)2998         bool isShadowTechniqueTextureBased(void) const
2999         { return (mShadowRenderer.mShadowTechnique & SHADOWDETAILTYPE_TEXTURE) != 0; }
3000         /** Is there a modulative shadowing technique in use? */
isShadowTechniqueModulative(void)3001         bool isShadowTechniqueModulative(void) const
3002         { return (mShadowRenderer.mShadowTechnique & SHADOWDETAILTYPE_MODULATIVE) != 0; }
3003         /** Is there an additive shadowing technique in use? */
isShadowTechniqueAdditive(void)3004         bool isShadowTechniqueAdditive(void) const
3005         { return (mShadowRenderer.mShadowTechnique & SHADOWDETAILTYPE_ADDITIVE) != 0; }
3006         /** Is the shadow technique integrated into primary materials? */
isShadowTechniqueIntegrated(void)3007         bool isShadowTechniqueIntegrated(void) const
3008         { return (mShadowRenderer.mShadowTechnique & SHADOWDETAILTYPE_INTEGRATED) != 0; }
3009         /** Is there any shadowing technique in use? */
isShadowTechniqueInUse(void)3010         bool isShadowTechniqueInUse(void) const
3011         { return mShadowRenderer.mShadowTechnique != SHADOWTYPE_NONE; }
3012         /** Sets whether when using a built-in additive shadow mode, user clip
3013             planes should be used to restrict light rendering.
3014         */
setShadowUseLightClipPlanes(bool enabled)3015         void setShadowUseLightClipPlanes(bool enabled) { mShadowRenderer.mShadowAdditiveLightClip = enabled; }
3016         /** Gets whether when using a built-in additive shadow mode, user clip
3017         planes should be used to restrict light rendering.
3018         */
getShadowUseLightClipPlanes()3019         bool getShadowUseLightClipPlanes() const { return mShadowRenderer.mShadowAdditiveLightClip; }
3020 
3021         /** Sets the active compositor chain of the current scene being rendered.
3022             @note CompositorChain does this automatically, no need to call manually.
3023         */
_setActiveCompositorChain(CompositorChain * chain)3024         void _setActiveCompositorChain(CompositorChain* chain) { mActiveCompositorChain = chain; }
3025 
3026         /** Sets whether to use late material resolving or not. If set, materials will be resolved
3027             from the materials at the pass-setting stage and not at the render queue building stage.
3028             This is useful when the active material scheme during the render queue building stage
3029             is different from the one during the rendering stage.
3030         */
setLateMaterialResolving(bool isLate)3031         void setLateMaterialResolving(bool isLate) { mLateMaterialResolving = isLate; }
3032 
3033         /** Gets whether using late material resolving or not.
3034             @see setLateMaterialResolving */
isLateMaterialResolving()3035         bool isLateMaterialResolving() const { return mLateMaterialResolving; }
3036 
3037         /** Gets the active compositor chain of the current scene being rendered */
_getActiveCompositorChain()3038         CompositorChain* _getActiveCompositorChain() const { return mActiveCompositorChain; }
3039 
3040         /** Add a listener which will get called back on scene manager events.
3041         */
3042         void addListener(Listener* s);
3043         /** Remove a listener
3044         */
3045         void removeListener(Listener* s);
3046 
3047         /** Creates a StaticGeometry instance suitable for use with this
3048             SceneManager.
3049         @remarks
3050             StaticGeometry is a way of batching up geometry into a more
3051             efficient form at the expense of being able to move it. Please
3052             read the StaticGeometry class documentation for full information.
3053         @param name The name to give the new object
3054         @return The new StaticGeometry instance
3055         */
3056         StaticGeometry* createStaticGeometry(const String& name);
3057         /** Retrieve a previously created StaticGeometry instance.
3058         @note Throws an exception if the named instance does not exist
3059         */
3060         StaticGeometry* getStaticGeometry(const String& name) const;
3061         /** Returns whether a static geometry instance with the given name exists. */
3062         bool hasStaticGeometry(const String& name) const;
3063         /** Remove & destroy a StaticGeometry instance. */
3064         void destroyStaticGeometry(StaticGeometry* geom);
3065         /** Remove & destroy a StaticGeometry instance. */
3066         void destroyStaticGeometry(const String& name);
3067         /** Remove & destroy all StaticGeometry instances. */
3068         void destroyAllStaticGeometry(void);
3069 
3070         /** Creates an InstanceManager interface to create & manipulate instanced entities
3071             You need to call this function at least once before start calling createInstancedEntity
3072             to build up an instance based on the given mesh.
3073         @remarks
3074             Instancing is a way of batching up geometry into a much more
3075             efficient form, but with some limitations, and still be able to move & animate it.
3076             Please @see InstanceManager class documentation for full information.
3077         @param customName Custom name for referencing. Must be unique
3078         @param meshName The mesh name the instances will be based upon
3079         @param groupName The resource name where the mesh lives
3080         @param technique Technique to use, which may be shader based, or hardware based.
3081         @param numInstancesPerBatch Suggested number of instances per batch. The actual number
3082         may end up being lower if the technique doesn't support having so many. It can't be zero
3083         @param flags Flags to pass to the InstanceManager @see InstanceManagerFlags
3084         @param subMeshIdx InstanceManager only supports using one submesh from the base mesh. This parameter
3085         says which submesh to pick (must be <= Mesh::getNumSubMeshes())
3086         @return The new InstanceManager instance
3087         */
3088         InstanceManager* createInstanceManager( const String &customName, const String &meshName,
3089                                                         const String &groupName,
3090                                                         InstanceManager::InstancingTechnique technique,
3091                                                         size_t numInstancesPerBatch, uint16 flags=0,
3092                                                         unsigned short subMeshIdx=0 );
3093 
3094         /** Retrieves an existing InstanceManager by it's name.
3095         @note Throws an exception if the named InstanceManager does not exist
3096         */
3097         InstanceManager* getInstanceManager( const String &managerName ) const;
3098 
3099         /** Returns whether an InstanceManager with the given name exists. */
3100         bool hasInstanceManager( const String &managerName ) const;
3101 
3102         /** Destroys an InstanceManager <b>if</b> it was created with createInstanceManager()
3103         @remarks
3104             Be sure you don't have any InstancedEntity referenced somewhere which was created with
3105             this manager, since it will become a dangling pointer.
3106         @param name Name of the manager to remove
3107         */
3108         void destroyInstanceManager( const String &name );
3109         void destroyInstanceManager( InstanceManager *instanceManager );
3110 
3111         void destroyAllInstanceManagers(void);
3112 
3113         /** @see InstanceManager::getMaxOrBestNumInstancesPerBatch
3114         @remarks
3115             If you've already created an InstanceManager, you can call it's
3116             getMaxOrBestNumInstancesPerBatch() function directly.
3117             Another (not recommended) way to know if the technique is unsupported is by creating
3118             an InstanceManager and use createInstancedEntity, which will return null pointer.
3119             The input parameter "numInstancesPerBatch" is a suggested value when using IM_VTFBESTFIT
3120             flag (in that case it should be non-zero)
3121         @return
3122             The ideal (or maximum, depending on flags) number of instances per batch for
3123             the given technique. Zero if technique is unsupported or errors were spotted
3124         */
3125         size_t getNumInstancesPerBatch( const String &meshName, const String &groupName,
3126                                                 const String &materialName,
3127                                                 InstanceManager::InstancingTechnique technique,
3128                                                 size_t numInstancesPerBatch, uint16 flags=0,
3129                                                 unsigned short subMeshIdx=0 );
3130 
3131         /** Creates an InstancedEntity based on an existing InstanceManager (@see createInstanceManager)
3132         @remarks
3133             * Return value may be null if the InstanceManger technique isn't supported
3134             * Try to keep the number of entities with different materials <b>to a minimum</b>
3135             * For more information @see InstancedManager @see InstancedBatch, @see InstancedEntity
3136             * Alternatively you can call InstancedManager::createInstanceEntity using the returned
3137             pointer from createInstanceManager
3138         @param materialName Material name
3139         @param managerName Name of the instance manager
3140         @return An InstancedEntity ready to be attached to a SceneNode
3141         */
3142         InstancedEntity* createInstancedEntity( const String &materialName,
3143                                                         const String &managerName );
3144 
3145         /** Removes an InstancedEntity, @see SceneManager::createInstancedEntity &
3146             @see InstanceBatch::removeInstancedEntity
3147         @param instancedEntity Instance to remove
3148         */
3149         void destroyInstancedEntity( InstancedEntity *instancedEntity );
3150 
3151         /** Called by an InstanceManager when it has at least one InstanceBatch that needs their bounds
3152             to be updated for proper culling
3153             @param dirtyManager The manager with dirty batches to update
3154         */
3155         void _addDirtyInstanceManager( InstanceManager *dirtyManager );
3156 
3157         /** Create a movable object of the type specified.
3158         @remarks
3159             This is the generalised form of MovableObject creation where you can
3160             create a MovableObject of any specialised type generically, including
3161             any new types registered using plugins.
3162         @param name The name to give the object. Must be unique within type.
3163         @param typeName The type of object to create
3164         @param params Optional name/value pair list to give extra parameters to
3165             the created object.
3166         */
3167         MovableObject* createMovableObject(const String& name,
3168             const String& typeName, const NameValuePairList* params = 0);
3169         /// @overload
3170         MovableObject* createMovableObject(const String& typeName, const NameValuePairList* params = 0);
3171         /** Destroys a MovableObject with the name specified, of the type specified.
3172         @remarks
3173             The MovableObject will automatically detach itself from any nodes
3174             on destruction.
3175         */
3176         void destroyMovableObject(const String& name, const String& typeName);
3177         /** Destroys a MovableObject.
3178         @remarks
3179             The MovableObject will automatically detach itself from any nodes
3180             on destruction.
3181         */
3182         void destroyMovableObject(MovableObject* m);
3183         /** Destroy all MovableObjects of a given type. */
3184         void destroyAllMovableObjectsByType(const String& typeName);
3185         /** Destroy all MovableObjects. */
3186         void destroyAllMovableObjects(void);
3187         /** Get a reference to a previously created MovableObject.
3188         @note Throws an exception if the named instance does not exist
3189         */
3190         MovableObject* getMovableObject(const String& name, const String& typeName) const;
3191         /** Returns whether a movable object instance with the given name exists. */
3192         bool hasMovableObject(const String& name, const String& typeName) const;
3193         typedef MapIterator<MovableObjectMap> MovableObjectIterator;
3194         /** Get an iterator over all MovableObect instances of a given type.
3195         @note
3196             The iterator returned from this method is not thread safe, do not use this
3197             if you are creating or deleting objects of this type in another thread.
3198         */
3199         MovableObjectIterator getMovableObjectIterator(const String& typeName);
3200         /** Inject a MovableObject instance created externally.
3201         @remarks
3202             This method 'injects' a MovableObject instance created externally into
3203             the MovableObject instance registry held in the SceneManager. You
3204             might want to use this if you have a MovableObject which you don't
3205             want to register a factory for; for example a MovableObject which
3206             cannot be generally constructed by clients.
3207         @note
3208             It is important that the MovableObject has a unique name for the type,
3209             and that its getMovableType() method returns a proper type name.
3210         */
3211         void injectMovableObject(MovableObject* m);
3212         /** Extract a previously injected MovableObject.
3213         @remarks
3214             Essentially this does the same as destroyMovableObject, but only
3215             removes the instance from the internal lists, it does not attempt
3216             to destroy it.
3217         */
3218         void extractMovableObject(const String& name, const String& typeName);
3219         /// @overload
3220         void extractMovableObject(MovableObject* m);
3221         /** Extract all injected MovableObjects of a given type.
3222         @remarks
3223             Essentially this does the same as destroyAllMovableObjectsByType,
3224             but only removes the instances from the internal lists, it does not
3225             attempt to destroy them.
3226         */
3227         void extractAllMovableObjectsByType(const String& typeName);
3228 
3229         /** Sets a mask which is bitwise 'and'ed with objects own visibility masks
3230             to determine if the object is visible.
3231         @remarks
3232             Note that this is combined with any per-viewport visibility mask
3233             through an 'and' operation. @see Viewport::setVisibilityMask
3234         */
setVisibilityMask(uint32 vmask)3235         void setVisibilityMask(uint32 vmask) { mVisibilityMask = vmask; }
3236 
3237         /** Gets a mask which is bitwise 'and'ed with objects own visibility masks
3238             to determine if the object is visible.
3239         */
getVisibilityMask(void)3240         uint32 getVisibilityMask(void) { return mVisibilityMask; }
3241 
3242         /** Internal method for getting the combination between the global visibility
3243             mask and the per-viewport visibility mask.
3244         */
3245         uint32 _getCombinedVisibilityMask(void) const;
3246 
3247         /** Sets whether the SceneManager should search for visible objects, or
3248             whether they are being manually handled.
3249         @remarks
3250             This is an advanced function, you should not use this unless you know
3251             what you are doing.
3252         */
setFindVisibleObjects(bool find)3253         void setFindVisibleObjects(bool find) { mFindVisibleObjects = find; }
3254 
3255         /** Gets whether the SceneManager should search for visible objects, or
3256             whether they are being manually handled.
3257         */
getFindVisibleObjects(void)3258         bool getFindVisibleObjects(void) { return mFindVisibleObjects; }
3259 
3260         /** Set whether to automatically normalise normals on objects whenever they
3261             are scaled.
3262         @remarks
3263             Scaling can distort normals so the default behaviour is to compensate
3264             for this, but it has a cost. If you would prefer to manually manage
3265             this, set this option to 'false' and use Pass::setNormaliseNormals
3266             only when needed.
3267         */
setNormaliseNormalsOnScale(bool n)3268         void setNormaliseNormalsOnScale(bool n) { mNormaliseNormalsOnScale = n; }
3269 
3270         /** Get whether to automatically normalise normals on objects whenever they
3271             are scaled.
3272         */
getNormaliseNormalsOnScale()3273         bool getNormaliseNormalsOnScale() const { return mNormaliseNormalsOnScale; }
3274 
3275         /** Set whether to automatically flip the culling mode on objects whenever they
3276             are negatively scaled.
3277         @remarks
3278             Negativelyl scaling an object has the effect of flipping the triangles,
3279             so the culling mode should probably be inverted to deal with this.
3280             If you would prefer to manually manage this, set this option to 'false'
3281             and use different materials with Pass::setCullingMode set manually as needed.
3282         */
setFlipCullingOnNegativeScale(bool n)3283         void setFlipCullingOnNegativeScale(bool n) { mFlipCullingOnNegativeScale = n; }
3284 
3285         /** Get whether to automatically flip the culling mode on objects whenever they
3286             are negatively scaled.
3287         */
getFlipCullingOnNegativeScale()3288         bool getFlipCullingOnNegativeScale() const { return mFlipCullingOnNegativeScale; }
3289 
3290         /** Render something as if it came from the current queue.
3291             @param pass     Material pass to use for setting up this quad.
3292             @param rend     Renderable to render
3293             @param shadowDerivation Whether passes should be replaced with shadow caster / receiver passes
3294          */
3295         void _injectRenderWithPass(Pass *pass, Renderable *rend, bool shadowDerivation = true,
3296             bool doLightIteration = false, const LightList* manualLightList = 0);
3297 
3298         /** Indicates to the SceneManager whether it should suppress changing
3299             the RenderSystem states when rendering objects.
3300         @remarks
3301             This method allows you to tell the SceneManager not to change any
3302             RenderSystem state until you tell it to. This method is only
3303             intended for advanced use, don't use it if you're unsure of the
3304             effect. The only RenderSystems calls made are to set the world
3305             matrix for each object (note - view an projection matrices are NOT
3306             SET - they are under your control) and to render the object; it is up to
3307             the caller to do everything else, including enabling any vertex /
3308             fragment programs and updating their parameter state, and binding
3309             parameters to the RenderSystem.
3310         @note
3311             Calling this implicitly disables shadow processing since no shadows
3312             can be rendered without changing state.
3313         @param suppress If true, no RenderSystem state changes will be issued
3314             until this method is called again with a parameter of false.
3315         */
3316         void _suppressRenderStateChanges(bool suppress);
3317 
3318         /** Are render state changes suppressed?
3319         @see _suppressRenderStateChanges
3320         */
_areRenderStateChangesSuppressed(void)3321         bool _areRenderStateChangesSuppressed(void) const
3322         { return mSuppressRenderStateChanges; }
3323 
3324         /** Internal method for setting up the renderstate for a rendering pass.
3325             @param pass The Pass details to set.
3326             @param evenIfSuppressed Sets the pass details even if render state
3327                 changes are suppressed; if you are using this to manually set state
3328                 when render state changes are suppressed, you should set this to
3329                 true.
3330             @param shadowDerivation If false, disables the derivation of shadow
3331                 passes from original passes
3332             @return
3333                 A Pass object that was used instead of the one passed in, can
3334                 happen when rendering shadow passes
3335         */
3336         const Pass* _setPass(const Pass* pass,
3337             bool evenIfSuppressed = false, bool shadowDerivation = true);
3338 
3339         /** Method to allow you to mark gpu parameters as dirty, causing them to
3340             be updated according to the mask that you set when updateGpuProgramParameters is
3341             next called. Only really useful if you're controlling parameter state in
3342             inner rendering loop callbacks.
3343             @param mask Some combination of GpuParamVariability which is bitwise OR'ed with the
3344                 current dirty state.
3345         */
3346         void _markGpuParamsDirty(uint16 mask);
3347 
3348 
3349         /** Indicates to the SceneManager whether it should suppress the
3350             active shadow rendering technique until told otherwise.
3351         @remarks
3352             This is a temporary alternative to setShadowTechnique to suppress
3353             the rendering of shadows and forcing all processing down the
3354             standard rendering path. This is intended for internal use only.
3355         @param suppress If true, no shadow rendering will occur until this
3356             method is called again with a parameter of false.
3357         */
3358         void _suppressShadows(bool suppress);
3359 
3360         /** Are shadows suppressed?
3361         @see _suppressShadows
3362         */
_areShadowsSuppressed(void)3363         bool _areShadowsSuppressed(void) const
3364         { return mSuppressShadows; }
3365 
3366         /** Render the objects in a given queue group
3367         @remarks You should only call this from a RenderQueueInvocation implementation
3368         */
3369         void _renderQueueGroupObjects(RenderQueueGroup* group,
3370             QueuedRenderableCollection::OrganisationMode om);
3371 
3372         /** Advanced method for supplying an alternative visitor, used for parsing the
3373             render queues and sending the results to the renderer.
3374         @remarks
3375             You can use this method to insert your own implementation of the
3376             QueuedRenderableVisitor interface, which receives calls as the queued
3377             renderables are parsed in a given order (determined by RenderQueueInvocationSequence)
3378             and are sent to the renderer. If you provide your own implementation of
3379             this visitor, you are responsible for either calling the rendersystem,
3380             or passing the calls on to the base class implementation.
3381         @note
3382             Ownership is not taken of this pointer, you are still required to
3383             delete it yourself once you're finished.
3384         @param visitor Your implementation of SceneMgrQueuedRenderableVisitor.
3385             If you pass 0, the default implementation will be used.
3386         */
3387         void setQueuedRenderableVisitor(SceneMgrQueuedRenderableVisitor* visitor);
3388 
3389         /** Gets the current visitor object which processes queued renderables. */
3390         SceneMgrQueuedRenderableVisitor* getQueuedRenderableVisitor(void) const;
3391 
3392 
3393         /** Get the rendersystem subclass to which the output of this Scene Manager
3394             gets sent
3395         */
3396         RenderSystem *getDestinationRenderSystem();
3397 
3398         /** Gets the current viewport being rendered (advanced use only, only
3399             valid during viewport update. */
getCurrentViewport(void)3400         Viewport* getCurrentViewport(void) const { return mCurrentViewport; }
3401 
3402         /** Returns a visibility boundary box for a specific camera. */
3403         const VisibleObjectsBoundsInfo& getVisibleObjectsBoundsInfo(const Camera* cam) const;
3404 
3405         /**  Returns the shadow caster AAB for a specific light-camera combination */
3406         const VisibleObjectsBoundsInfo& getShadowCasterBoundsInfo(const Light* light, size_t iteration = 0) const;
3407 
3408         /** Set whether to use camera-relative co-ordinates when rendering, ie
3409             to always place the camera at the origin and move the world around it.
3410         @remarks
3411             This is a technique to alleviate some of the precision issues associated with
3412             rendering far from the origin, where single-precision floats as used in most
3413             GPUs begin to lose their precision. Instead of including the camera
3414             translation in the view matrix, it only includes the rotation, and
3415             the world matrices of objects must be expressed relative to this.
3416         @note
3417             If you need this option, you will probably also need to enable double-precision
3418             mode in Ogre (OGRE_DOUBLE_PRECISION), since even though this will
3419             alleviate the rendering precision, the source camera and object positions will still
3420             suffer from precision issues leading to jerky movement.
3421         */
setCameraRelativeRendering(bool rel)3422         void setCameraRelativeRendering(bool rel) { mCameraRelativeRendering = rel; }
3423 
3424         /** Get whether to use camera-relative co-ordinates when rendering, ie
3425             to always place the camera at the origin and move the world around it.
3426         */
getCameraRelativeRendering()3427         bool getCameraRelativeRendering() const { return mCameraRelativeRendering; }
3428 
3429 
3430         /** Add a level of detail listener. */
3431         void addLodListener(LodListener *listener);
3432 
3433         /**
3434         Remove a level of detail listener.
3435         @remarks
3436             Do not call from inside an LodListener callback method.
3437         */
3438         void removeLodListener(LodListener *listener);
3439 
3440         /** Notify that a movable object LOD change event has occurred. */
3441         void _notifyMovableObjectLodChanged(MovableObjectLodChangedEvent& evt);
3442 
3443         /** Notify that an entity mesh LOD change event has occurred. */
3444         void _notifyEntityMeshLodChanged(EntityMeshLodChangedEvent& evt);
3445 
3446         /** Notify that an entity material LOD change event has occurred. */
3447         void _notifyEntityMaterialLodChanged(EntityMaterialLodChangedEvent& evt);
3448 
3449         /** Handle LOD events. */
3450         void _handleLodEvents();
3451 
_getCurrentRenderStage()3452         IlluminationRenderStage _getCurrentRenderStage() {return mIlluminationStage;}
3453 
_getAutoParamDataSource()3454         const AutoParamDataSource* _getAutoParamDataSource() { return mAutoParamDataSource.get(); }
3455     };
3456 
3457     /** Default implementation of IntersectionSceneQuery. */
3458     class _OgreExport DefaultIntersectionSceneQuery :
3459         public IntersectionSceneQuery
3460     {
3461     public:
3462         DefaultIntersectionSceneQuery(SceneManager* creator);
3463         ~DefaultIntersectionSceneQuery();
3464 
3465         /** See IntersectionSceneQuery. */
3466         void execute(IntersectionSceneQueryListener* listener);
3467     };
3468 
3469     /** Default implementation of RaySceneQuery. */
3470     class _OgreExport DefaultRaySceneQuery : public RaySceneQuery
3471     {
3472     public:
3473         DefaultRaySceneQuery(SceneManager* creator);
3474         ~DefaultRaySceneQuery();
3475 
3476         /** See RayScenQuery. */
3477         void execute(RaySceneQueryListener* listener);
3478     };
3479     /** Default implementation of SphereSceneQuery. */
3480     class _OgreExport DefaultSphereSceneQuery : public SphereSceneQuery
3481     {
3482     public:
3483         DefaultSphereSceneQuery(SceneManager* creator);
3484         ~DefaultSphereSceneQuery();
3485 
3486         /** See SceneQuery. */
3487         void execute(SceneQueryListener* listener);
3488     };
3489     /** Default implementation of PlaneBoundedVolumeListSceneQuery. */
3490     class _OgreExport DefaultPlaneBoundedVolumeListSceneQuery : public PlaneBoundedVolumeListSceneQuery
3491     {
3492     public:
3493         DefaultPlaneBoundedVolumeListSceneQuery(SceneManager* creator);
3494         ~DefaultPlaneBoundedVolumeListSceneQuery();
3495 
3496         /** See SceneQuery. */
3497         void execute(SceneQueryListener* listener);
3498     };
3499     /** Default implementation of AxisAlignedBoxSceneQuery. */
3500     class _OgreExport DefaultAxisAlignedBoxSceneQuery : public AxisAlignedBoxSceneQuery
3501     {
3502     public:
3503         DefaultAxisAlignedBoxSceneQuery(SceneManager* creator);
3504         ~DefaultAxisAlignedBoxSceneQuery();
3505 
3506         /** See RayScenQuery. */
3507         void execute(SceneQueryListener* listener);
3508     };
3509 
3510 
3511     /// Bitmask containing scene types
3512     typedef uint16 SceneTypeMask;
3513 
3514     /** Classification of a scene to allow a decision of what type of
3515     SceenManager to provide back to the application.
3516     */
3517     enum SceneType
3518     {
3519         ST_GENERIC = 1,
3520         ST_EXTERIOR_CLOSE = 2,
3521         ST_EXTERIOR_FAR = 4,
3522         ST_EXTERIOR_REAL_FAR = 8,
3523         ST_INTERIOR = 16
3524     };
3525 
3526     /** Structure containing information about a scene manager. */
3527     struct SceneManagerMetaData
3528     {
3529         /// A globally unique string identifying the scene manager type
3530         String typeName;
3531         /// Flag indicating whether world geometry is supported
3532         bool worldGeometrySupported;
3533     };
3534 
3535 
3536 
3537     /** Class which will create instances of a given SceneManager. */
3538     class _OgreExport SceneManagerFactory : public SceneMgtAlloc
3539     {
3540     protected:
3541         mutable SceneManagerMetaData mMetaData;
3542         mutable bool mMetaDataInit;
3543         /// Internal method to initialise the metadata, must be implemented
3544         virtual void initMetaData(void) const = 0;
3545     public:
SceneManagerFactory()3546         SceneManagerFactory() : mMetaDataInit(true) {}
~SceneManagerFactory()3547         virtual ~SceneManagerFactory() {}
3548         /** Get information about the SceneManager type created by this factory. */
getMetaData(void)3549         virtual const SceneManagerMetaData& getMetaData(void) const
3550         {
3551             if (mMetaDataInit)
3552             {
3553                 initMetaData();
3554                 mMetaDataInit = false;
3555             }
3556             return mMetaData;
3557         }
3558         /** Create a new instance of a SceneManager.
3559         @remarks
3560         Don't call directly, use SceneManagerEnumerator::createSceneManager.
3561         */
3562         virtual SceneManager* createInstance(const String& instanceName) = 0;
3563         /** Destroy an instance of a SceneManager. */
3564         virtual void destroyInstance(SceneManager* instance) = 0;
3565 
3566     };
3567 
3568     /** @} */
3569     /** @} */
3570 
3571 
3572 } // Namespace
3573 
3574 #include "OgreHeaderSuffix.h"
3575 
3576 #endif
3577