Coverage Report

Created: 2026-05-16 06:44

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