[657] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 | #ifndef __RenderQueue_H__
|
---|
| 26 | #define __RenderQueue_H__
|
---|
| 27 |
|
---|
| 28 | #include "OgrePrerequisites.h"
|
---|
| 29 | #include "OgreIteratorWrappers.h"
|
---|
| 30 |
|
---|
| 31 | namespace Ogre {
|
---|
| 32 |
|
---|
| 33 | /** Enumeration of queue groups, by which the application may group queued renderables
|
---|
| 34 | so that they are rendered together with events in between
|
---|
| 35 | */
|
---|
| 36 | enum RenderQueueGroupID
|
---|
| 37 | {
|
---|
| 38 | /// Use this queue for objects which must be rendered first e.g. backgrounds
|
---|
| 39 | RENDER_QUEUE_BACKGROUND = 0,
|
---|
| 40 | /// First queue (after backgrounds), used for skyboxes if rendered first
|
---|
| 41 | RENDER_QUEUE_SKIES_EARLY = 5,
|
---|
| 42 | RENDER_QUEUE_1 = 10,
|
---|
| 43 | RENDER_QUEUE_2 = 20,
|
---|
| 44 | RENDER_QUEUE_WORLD_GEOMETRY_1 = 25,
|
---|
| 45 | RENDER_QUEUE_3 = 30,
|
---|
| 46 | RENDER_QUEUE_4 = 40,
|
---|
| 47 | /// The default render queue
|
---|
| 48 | RENDER_QUEUE_MAIN = 50,
|
---|
| 49 | RENDER_QUEUE_6 = 60,
|
---|
| 50 | RENDER_QUEUE_7 = 70,
|
---|
| 51 | RENDER_QUEUE_WORLD_GEOMETRY_2 = 75,
|
---|
| 52 | RENDER_QUEUE_8 = 80,
|
---|
| 53 | RENDER_QUEUE_9 = 90,
|
---|
| 54 | /// Penultimate queue(before overlays), used for skyboxes if rendered last
|
---|
| 55 | RENDER_QUEUE_SKIES_LATE = 95,
|
---|
| 56 | /// Use this queue for objects which must be rendered last e.g. overlays
|
---|
| 57 | RENDER_QUEUE_OVERLAY = 100
|
---|
| 58 | };
|
---|
| 59 |
|
---|
| 60 | #define OGRE_RENDERABLE_DEFAULT_PRIORITY 100
|
---|
| 61 |
|
---|
| 62 | /** Class to manage the scene object rendering queue.
|
---|
| 63 | @remarks
|
---|
| 64 | Objects are grouped by material to minimise rendering state changes. The map from
|
---|
| 65 | material to renderable object is wrapped in a class for ease of use.
|
---|
| 66 | @par
|
---|
| 67 | This class now includes the concept of 'queue groups' which allows the application
|
---|
| 68 | adding the renderable to specifically schedule it so that it is included in
|
---|
| 69 | a discrete group. Good for separating renderables into the main scene,
|
---|
| 70 | backgrounds and overlays, and also could be used in the future for more
|
---|
| 71 | complex multipass routines like stenciling.
|
---|
| 72 | */
|
---|
| 73 | class _OgreExport RenderQueue
|
---|
| 74 | {
|
---|
| 75 | public:
|
---|
| 76 | typedef std::map< RenderQueueGroupID, RenderQueueGroup* > RenderQueueGroupMap;
|
---|
| 77 | /// Iterator over queue groups
|
---|
| 78 | typedef MapIterator<RenderQueueGroupMap> QueueGroupIterator;
|
---|
| 79 | protected:
|
---|
| 80 | RenderQueueGroupMap mGroups;
|
---|
| 81 | /// The current default queue group
|
---|
| 82 | RenderQueueGroupID mDefaultQueueGroup;
|
---|
| 83 | /// The default priority
|
---|
| 84 | ushort mDefaultRenderablePriority;
|
---|
| 85 |
|
---|
| 86 | bool mSplitPassesByLightingType;
|
---|
| 87 | bool mSplitNoShadowPasses;
|
---|
| 88 | public:
|
---|
| 89 | RenderQueue();
|
---|
| 90 | virtual ~RenderQueue();
|
---|
| 91 |
|
---|
| 92 | /** Empty the queue - should only be called by SceneManagers.
|
---|
| 93 | @param destroyPassMaps Set to true to destroy all pass maps so that
|
---|
| 94 | the queue is completely clean (useful when switching scene managers)
|
---|
| 95 | */
|
---|
| 96 | void clear(bool destroyPassMaps = false);
|
---|
| 97 |
|
---|
| 98 | /** Get a render queue group.
|
---|
| 99 | @remarks
|
---|
| 100 | OGRE registers new queue groups as they are requested,
|
---|
| 101 | therefore this method will always return a valid group.
|
---|
| 102 | */
|
---|
| 103 | RenderQueueGroup* getQueueGroup(RenderQueueGroupID qid);
|
---|
| 104 |
|
---|
| 105 | /** Add a renderable object to the queue.
|
---|
| 106 | @remarks
|
---|
| 107 | This methods adds a Renderable to the queue, which will be rendered later by
|
---|
| 108 | the SceneManager. This is the advanced version of the call which allows the renderable
|
---|
| 109 | to be added to any queue.
|
---|
| 110 | @note
|
---|
| 111 | Called by implementation of MovableObject::_updateRenderQueue.
|
---|
| 112 | @param
|
---|
| 113 | pRend Pointer to the Renderable to be added to the queue
|
---|
| 114 | @param
|
---|
| 115 | groupID The group the renderable is to be added to. This
|
---|
| 116 | can be used to schedule renderable objects in separate groups such that the SceneManager
|
---|
| 117 | respects the divisions between the groupings and does not reorder them outside these
|
---|
| 118 | boundaries. This can be handy for overlays where no matter what you want the overlay to
|
---|
| 119 | be rendered last.
|
---|
| 120 | @param
|
---|
| 121 | priority Controls the priority of the renderable within the queue group. If this number
|
---|
| 122 | is raised, the renderable will be rendered later in the group compared to it's peers.
|
---|
| 123 | Don't use this unless you really need to, manually ordering renderables prevents OGRE
|
---|
| 124 | from sorting them for best efficiency. However this could be useful for ordering 2D
|
---|
| 125 | elements manually for example.
|
---|
| 126 | */
|
---|
| 127 | void addRenderable(Renderable* pRend, RenderQueueGroupID groupID, ushort priority);
|
---|
| 128 |
|
---|
| 129 | /** Add a renderable object to the queue.
|
---|
| 130 | @remarks
|
---|
| 131 | This methods adds a Renderable to the queue, which will be rendered later by
|
---|
| 132 | the SceneManager. This is the simplified version of the call which does not
|
---|
| 133 | require a priority to be specified. The queue priority is take from the
|
---|
| 134 | current default (see setDefaultRenderablePriority).
|
---|
| 135 | @note
|
---|
| 136 | Called by implementation of MovableObject::_updateRenderQueue.
|
---|
| 137 | @param
|
---|
| 138 | pRend Pointer to the Renderable to be added to the queue
|
---|
| 139 | @param
|
---|
| 140 | groupID The group the renderable is to be added to. This
|
---|
| 141 | can be used to schedule renderable objects in separate groups such that the SceneManager
|
---|
| 142 | respects the divisions between the groupings and does not reorder them outside these
|
---|
| 143 | boundaries. This can be handy for overlays where no matter what you want the overlay to
|
---|
| 144 | be rendered last.
|
---|
| 145 | */
|
---|
| 146 | void addRenderable(Renderable* pRend, RenderQueueGroupID groupId);
|
---|
| 147 |
|
---|
| 148 | /** Add a renderable object to the queue.
|
---|
| 149 | @remarks
|
---|
| 150 | This methods adds a Renderable to the queue, which will be rendered later by
|
---|
| 151 | the SceneManager. This is the simplified version of the call which does not
|
---|
| 152 | require a queue or priority to be specified. The queue group is taken from the
|
---|
| 153 | current default (see setDefaultQueueGroup). The queue priority is take from the
|
---|
| 154 | current default (see setDefaultRenderablePriority).
|
---|
| 155 | @note
|
---|
| 156 | Called by implementation of MovableObject::_updateRenderQueue.
|
---|
| 157 | @param
|
---|
| 158 | pRend Pointer to the Renderable to be added to the queue
|
---|
| 159 | */
|
---|
| 160 | void addRenderable(Renderable* pRend);
|
---|
| 161 |
|
---|
| 162 | /** Gets the current default queue group, which will be used for all renderable which do not
|
---|
| 163 | specify which group they wish to be on.
|
---|
| 164 | */
|
---|
| 165 | RenderQueueGroupID getDefaultQueueGroup(void) const;
|
---|
| 166 |
|
---|
| 167 | /** Sets the current default renderable priority,
|
---|
| 168 | which will be used for all renderables which do not
|
---|
| 169 | specify which priority they wish to use.
|
---|
| 170 | */
|
---|
| 171 | void setDefaultRenderablePriority(ushort priority);
|
---|
| 172 |
|
---|
| 173 | /** Gets the current default renderable priority, which will be used for all renderables which do not
|
---|
| 174 | specify which priority they wish to use.
|
---|
| 175 | */
|
---|
| 176 | ushort getDefaultRenderablePriority(void) const;
|
---|
| 177 |
|
---|
| 178 | /** Sets the current default queue group, which will be used for all renderable which do not
|
---|
| 179 | specify which group they wish to be on.
|
---|
| 180 | */
|
---|
| 181 | void setDefaultQueueGroup(RenderQueueGroupID grp);
|
---|
| 182 |
|
---|
| 183 | /** Internal method, returns an iterator for the queue groups. */
|
---|
| 184 | QueueGroupIterator _getQueueGroupIterator(void);
|
---|
| 185 | /** Sets whether or not the queue will split passes by their lighting type,
|
---|
| 186 | ie ambient, per-light and decal.
|
---|
| 187 | */
|
---|
| 188 | void setSplitPassesByLightingType(bool split);
|
---|
| 189 | /** Sets whether or not the queue will split passes which have shadow receive
|
---|
| 190 | turned off (in their parent material), which is needed when certain shadow
|
---|
| 191 | techniques are used.
|
---|
| 192 | */
|
---|
| 193 | void setSplitNoShadowPasses(bool split);
|
---|
| 194 | };
|
---|
| 195 |
|
---|
| 196 |
|
---|
| 197 | }
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 | #endif
|
---|