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