Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreRenderQueue.h @ 1

Last change on this file since 1 was 1, checked in by landauf, 17 years ago
File size: 11.1 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
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 program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#ifndef __RenderQueue_H__
30#define __RenderQueue_H__
31
32#include "OgrePrerequisites.h"
33#include "OgreIteratorWrappers.h"
34
35namespace Ogre {
36
37    /** Enumeration of queue groups, by which the application may group queued renderables
38        so that they are rendered together with events in between
39        @remarks
40                When passed into methods these are actually passed as a uint8 to allow you
41                to use values in between if you want to.
42    */
43    enum RenderQueueGroupID
44    {
45        /// Use this queue for objects which must be rendered first e.g. backgrounds
46        RENDER_QUEUE_BACKGROUND = 0,
47        /// First queue (after backgrounds), used for skyboxes if rendered first
48        RENDER_QUEUE_SKIES_EARLY = 5,
49        RENDER_QUEUE_1 = 10,
50        RENDER_QUEUE_2 = 20,
51                RENDER_QUEUE_WORLD_GEOMETRY_1 = 25,
52        RENDER_QUEUE_3 = 30,
53        RENDER_QUEUE_4 = 40,
54                /// The default render queue
55        RENDER_QUEUE_MAIN = 50,
56        RENDER_QUEUE_6 = 60,
57        RENDER_QUEUE_7 = 70,
58                RENDER_QUEUE_WORLD_GEOMETRY_2 = 75,
59        RENDER_QUEUE_8 = 80,
60        RENDER_QUEUE_9 = 90,
61        /// Penultimate queue(before overlays), used for skyboxes if rendered last
62        RENDER_QUEUE_SKIES_LATE = 95,
63        /// Use this queue for objects which must be rendered last e.g. overlays
64        RENDER_QUEUE_OVERLAY = 100, 
65                /// Final possible render queue, don't exceed this
66                RENDER_QUEUE_MAX = 105
67    };
68
69    #define OGRE_RENDERABLE_DEFAULT_PRIORITY  100
70
71    /** Class to manage the scene object rendering queue.
72        @remarks
73            Objects are grouped by material to minimise rendering state changes. The map from
74            material to renderable object is wrapped in a class for ease of use.
75        @par
76            This class now includes the concept of 'queue groups' which allows the application
77            adding the renderable to specifically schedule it so that it is included in
78            a discrete group. Good for separating renderables into the main scene,
79            backgrounds and overlays, and also could be used in the future for more
80            complex multipass routines like stenciling.
81    */
82    class _OgreExport RenderQueue
83    {
84    public:
85        typedef std::map< uint8, RenderQueueGroup* > RenderQueueGroupMap;
86        /// Iterator over queue groups
87        typedef MapIterator<RenderQueueGroupMap> QueueGroupIterator;
88                /** Class to listen in on items being added to the render queue.
89                @remarks
90                        Use RenderQueue::setRenderableListener to get callbacks when an item
91                        is added to the render queue.
92                */
93                class _OgreExport RenderableListener
94                {
95                public:
96                        RenderableListener() {}
97                        virtual ~RenderableListener() {}
98
99                        /** Method called when a Renderable is added to the queue.
100                        @remarks
101                                You can use this event hook to alter the Technique used to
102                                render a Renderable as the item is added to the queue. This is
103                                a low-level way to override the material settings for a given
104                                Renderable on the fly.
105                        @param rend The Renderable being added to the queue
106                        @param groupID The render queue group this Renderable is being added to
107                        @param priority The priority the Renderable has been given
108                        @param ppTech A pointer to the pointer to the Technique that is
109                                intended to be used; you can alter this to an alternate Technique
110                                if you so wish (the Technique doesn't have to be from the same
111                                Material either).
112                        @returns true to allow the Renderable to be added to the queue,
113                                false if you want to prevent it being added
114                        */
115                        virtual bool renderableQueued(Renderable* rend, uint8 groupID, 
116                                ushort priority, Technique** ppTech) = 0;
117                };
118    protected:
119        RenderQueueGroupMap mGroups;
120        /// The current default queue group
121        uint8 mDefaultQueueGroup;
122        /// The default priority
123        ushort mDefaultRenderablePriority;
124
125        bool mSplitPassesByLightingType;
126        bool mSplitNoShadowPasses;
127                bool mShadowCastersCannotBeReceivers;
128
129                RenderableListener* mRenderableListener;
130    public:
131        RenderQueue();
132        virtual ~RenderQueue();
133
134        /** Empty the queue - should only be called by SceneManagers.
135                @param destroyPassMaps Set to true to destroy all pass maps so that
136                        the queue is completely clean (useful when switching scene managers)
137        */
138        void clear(bool destroyPassMaps = false);
139
140                /** Get a render queue group.
141                @remarks
142                        OGRE registers new queue groups as they are requested,
143                        therefore this method will always return a valid group.
144                */
145                RenderQueueGroup* getQueueGroup(uint8 qid);
146
147        /** Add a renderable object to the queue.
148        @remarks
149            This methods adds a Renderable to the queue, which will be rendered later by
150            the SceneManager. This is the advanced version of the call which allows the renderable
151            to be added to any queue.
152        @note
153            Called by implementation of MovableObject::_updateRenderQueue.
154        @param
155            pRend Pointer to the Renderable to be added to the queue
156        @param
157            groupID The group the renderable is to be added to. This
158            can be used to schedule renderable objects in separate groups such that the SceneManager
159            respects the divisions between the groupings and does not reorder them outside these
160            boundaries. This can be handy for overlays where no matter what you want the overlay to
161            be rendered last.
162        @param
163            priority Controls the priority of the renderable within the queue group. If this number
164            is raised, the renderable will be rendered later in the group compared to it's peers.
165            Don't use this unless you really need to, manually ordering renderables prevents OGRE
166            from sorting them for best efficiency. However this could be useful for ordering 2D
167            elements manually for example.
168        */
169        void addRenderable(Renderable* pRend, uint8 groupID, ushort priority);
170
171        /** Add a renderable object to the queue.
172        @remarks
173            This methods adds a Renderable to the queue, which will be rendered later by
174            the SceneManager. This is the simplified version of the call which does not
175            require a priority to be specified. The queue priority is take from the
176            current default (see setDefaultRenderablePriority).
177        @note
178            Called by implementation of MovableObject::_updateRenderQueue.
179        @param
180            pRend Pointer to the Renderable to be added to the queue
181                @param
182            groupID The group the renderable is to be added to. This
183            can be used to schedule renderable objects in separate groups such that the SceneManager
184            respects the divisions between the groupings and does not reorder them outside these
185            boundaries. This can be handy for overlays where no matter what you want the overlay to
186            be rendered last.
187        */
188        void addRenderable(Renderable* pRend, uint8 groupId);
189
190        /** Add a renderable object to the queue.
191        @remarks
192            This methods adds a Renderable to the queue, which will be rendered later by
193            the SceneManager. This is the simplified version of the call which does not
194            require a queue or priority to be specified. The queue group is taken from the
195            current default (see setDefaultQueueGroup).  The queue priority is take from the
196            current default (see setDefaultRenderablePriority).
197        @note
198            Called by implementation of MovableObject::_updateRenderQueue.
199        @param
200            pRend Pointer to the Renderable to be added to the queue
201        */
202        void addRenderable(Renderable* pRend);
203       
204        /** Gets the current default queue group, which will be used for all renderable which do not
205            specify which group they wish to be on.
206        */
207        uint8 getDefaultQueueGroup(void) const;
208
209        /** Sets the current default renderable priority,
210            which will be used for all renderables which do not
211            specify which priority they wish to use.
212        */
213        void setDefaultRenderablePriority(ushort priority);
214
215        /** Gets the current default renderable priority, which will be used for all renderables which do not
216            specify which priority they wish to use.
217        */
218        ushort getDefaultRenderablePriority(void) const;
219
220        /** Sets the current default queue group, which will be used for all renderable which do not
221            specify which group they wish to be on.
222        */
223        void setDefaultQueueGroup(uint8 grp);
224       
225        /** Internal method, returns an iterator for the queue groups. */
226        QueueGroupIterator _getQueueGroupIterator(void);
227        /** Sets whether or not the queue will split passes by their lighting type,
228            ie ambient, per-light and decal.
229        */
230        void setSplitPassesByLightingType(bool split);
231        /** Sets whether or not the queue will split passes which have shadow receive
232        turned off (in their parent material), which is needed when certain shadow
233        techniques are used.
234        */
235        void setSplitNoShadowPasses(bool split);
236                /** Sets whether or not objects which cast shadows should be treated as
237                never receiving shadows.
238                */
239                void setShadowCastersCannotBeReceivers(bool ind);
240
241                /** Set a renderable listener on the queue.
242                @remarks
243                        There can only be a single renderable listener on the queue, since
244                        that listener has complete control over the techniques in use.
245                */
246                void setRenderableListener(RenderableListener* listener)
247                { mRenderableListener = listener; }
248
249                RenderableListener* getRenderableListener(void) const
250                { return mRenderableListener; }
251
252    };
253
254
255}
256
257
258#endif
Note: See TracBrowser for help on using the repository browser.