Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreSceneManager.h @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

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