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