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-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This library is free software; you can redistribute it and/or modify it
|
---|
11 | under the terms of the GNU Lesser General Public License (LGPL) as
|
---|
12 | published by the Free Software Foundation; either version 2.1 of the
|
---|
13 | License, or (at your option) any later version.
|
---|
14 |
|
---|
15 | This library is distributed in the hope that it will be useful, but
|
---|
16 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
---|
17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
---|
18 | License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU Lesser General Public License
|
---|
21 | along with this library; if not, write to the Free Software Foundation,
|
---|
22 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or go to
|
---|
23 | http://www.gnu.org/copyleft/lesser.txt
|
---|
24 | -------------------------------------------------------------------------*/
|
---|
25 | #ifndef __SceneManager_H__
|
---|
26 | #define __SceneManager_H__
|
---|
27 |
|
---|
28 | // Precompiler options
|
---|
29 | #include "OgrePrerequisites.h"
|
---|
30 |
|
---|
31 | #include "OgreString.h"
|
---|
32 | #include "OgreSceneNode.h"
|
---|
33 | #include "OgrePlane.h"
|
---|
34 | #include "OgreQuaternion.h"
|
---|
35 | #include "OgreColourValue.h"
|
---|
36 | #include "OgreCommon.h"
|
---|
37 | #include "OgreRenderQueue.h"
|
---|
38 | #include "OgreAnimationState.h"
|
---|
39 | #include "OgreSceneQuery.h"
|
---|
40 | #include "OgreAutoParamDataSource.h"
|
---|
41 | #include "OgreAnimationState.h"
|
---|
42 | #include "OgreRenderQueue.h"
|
---|
43 | #include "OgreRenderQueueSortingGrouping.h"
|
---|
44 | #include "OgreRectangle2D.h"
|
---|
45 |
|
---|
46 | namespace Ogre {
|
---|
47 |
|
---|
48 | /** Structure for holding a position & orientation pair. */
|
---|
49 | struct ViewPoint
|
---|
50 | {
|
---|
51 | Vector3 position;
|
---|
52 | Quaternion orientation;
|
---|
53 | };
|
---|
54 |
|
---|
55 | // Forward declarations
|
---|
56 | class DefaultIntersectionSceneQuery;
|
---|
57 | class DefaultRaySceneQuery;
|
---|
58 | class DefaultSphereSceneQuery;
|
---|
59 | class DefaultAxisAlignedBoxSceneQuery;
|
---|
60 |
|
---|
61 | /** Manages the rendering of a 'scene' i.e. a collection of primitives.
|
---|
62 | @remarks
|
---|
63 | This class defines the basic behaviour of the 'Scene Manager' family. These classes will
|
---|
64 | organise the objects in the scene and send them to the rendering system, a subclass of
|
---|
65 | RenderSystem. This basic superclass does no sorting, culling or organising of any sort.
|
---|
66 | @par
|
---|
67 | Subclasses may use various techniques to organise the scene depending on how they are
|
---|
68 | designed (e.g. BSPs, octrees etc). As with other classes, methods preceded with '_' are
|
---|
69 | designed to be called by other classes in the Ogre system, not by user applications,
|
---|
70 | although this is not forbidden.
|
---|
71 | @author
|
---|
72 | Steve Streeting
|
---|
73 | @version
|
---|
74 | 1.0
|
---|
75 | */
|
---|
76 | class _OgreExport SceneManager
|
---|
77 | {
|
---|
78 | friend class DefaultIntersectionSceneQuery;
|
---|
79 | friend class DefaultRaySceneQuery;
|
---|
80 | friend class DefaultSphereSceneQuery;
|
---|
81 | friend class DefaultAxisAlignedBoxSceneQuery;
|
---|
82 | friend class DefaultPlaneBoundedVolumeListSceneQuery;
|
---|
83 | public:
|
---|
84 | /// Query mask which will be used for world geometry @see SceneQuery
|
---|
85 | static unsigned long WORLD_GEOMETRY_QUERY_MASK;
|
---|
86 | /** Comparator for material map, for sorting materials into render order (e.g. transparent last).
|
---|
87 | */
|
---|
88 | struct materialLess
|
---|
89 | {
|
---|
90 | _OgreExport bool operator()(const Material* x, const Material* y) const;
|
---|
91 | };
|
---|
92 | /// Comparator for sorting lights relative to a point
|
---|
93 | struct lightLess
|
---|
94 | {
|
---|
95 | _OgreExport bool operator()(const Light* a, const Light* b) const;
|
---|
96 | };
|
---|
97 |
|
---|
98 | /// Describes the stage of rendering when performing complex illumination
|
---|
99 | enum IlluminationRenderStage
|
---|
100 | {
|
---|
101 | /// No special illumination stage
|
---|
102 | IRS_NONE,
|
---|
103 | /// Ambient stage, when background light is added
|
---|
104 | IRS_AMBIENT,
|
---|
105 | /// Diffuse / specular stage, when individual light contributions are added
|
---|
106 | IRS_PER_LIGHT,
|
---|
107 | /// Decal stage, when texture detail is added to the lit base
|
---|
108 | IRS_DECAL,
|
---|
109 | /// Render to texture stage, used for texture based shadows
|
---|
110 | IRS_RENDER_TO_TEXTURE,
|
---|
111 | /// Modulative render from shadow texture stage
|
---|
112 | IRS_RENDER_MODULATIVE_PASS
|
---|
113 | };
|
---|
114 |
|
---|
115 | /** Enumeration of the possible modes allowed for processing the special case
|
---|
116 | render queue list.
|
---|
117 | @see SceneManager::setSpecialCaseRenderQueueMode
|
---|
118 | */
|
---|
119 | enum SpecialCaseRenderQueueMode
|
---|
120 | {
|
---|
121 | /// Render only the queues in the special case list
|
---|
122 | SCRQM_INCLUDE,
|
---|
123 | /// Render all except the queues in the special case list
|
---|
124 | SCRQM_EXCLUDE
|
---|
125 | };
|
---|
126 | #ifdef GTP_VISIBILITY_MODIFIED_OGRE
|
---|
127 | /** added by matt: Render content of current scene node.
|
---|
128 | @param node scene node to be rendered
|
---|
129 | @param cam current camera
|
---|
130 | @param leaveTransparentsInQueue if only solid objects should be rendered
|
---|
131 | */
|
---|
132 | void _renderSceneNode(Camera *cam, SceneNode *node, bool leaveTransparentsInQueue = false);
|
---|
133 | /** deletes all processed queues
|
---|
134 | @remark clears render queues after rendering scene node
|
---|
135 | */
|
---|
136 | void _deleteRenderedQueueGroups(bool leaveTransparentsInQueue);
|
---|
137 | /** Internal method used by _renderVisibleObjects to deal with renderables
|
---|
138 | which override the camera's own view / projection materices.
|
---|
139 | @remark made public by matt
|
---|
140 | */
|
---|
141 | void useRenderableViewProjMode(Renderable* pRend);
|
---|
142 | /** Method for setting up the renderstate for a rendering pass.
|
---|
143 | @param
|
---|
144 | pass The Pass details to set.
|
---|
145 | @returns
|
---|
146 | A Pass object that was used instead of the one passed in, can
|
---|
147 | happen when rendering shadow passes
|
---|
148 | @remark made public by matt
|
---|
149 | */
|
---|
150 | virtual Pass* setPass(Pass* pass);
|
---|
151 |
|
---|
152 | /** Renders an Ogre Entity.
|
---|
153 | */
|
---|
154 | //void renderEntity(Entity *ent);
|
---|
155 |
|
---|
156 | /** Renders an Ogre MovableObject.
|
---|
157 | */
|
---|
158 | void _renderMovableObject(MovableObject *mov, const bool leaveTransparentsInQueue);
|
---|
159 |
|
---|
160 | #endif // GTP_VISIBILITY_MODIFIED_OGRE
|
---|
161 |
|
---|
162 | protected:
|
---|
163 |
|
---|
164 | /// Queue of objects for rendering
|
---|
165 | RenderQueue* mRenderQueue;
|
---|
166 |
|
---|
167 | /// Current ambient light, cached for RenderSystem
|
---|
168 | ColourValue mAmbientLight;
|
---|
169 |
|
---|
170 | /// The rendering system to send the scene to
|
---|
171 | RenderSystem *mDestRenderSystem;
|
---|
172 |
|
---|
173 | typedef std::map<String, Camera* > CameraList;
|
---|
174 |
|
---|
175 | /** Central list of cameras - for easy memory management and lookup.
|
---|
176 | */
|
---|
177 | CameraList mCameras;
|
---|
178 |
|
---|
179 | typedef std::map<String, Light* > SceneLightList;
|
---|
180 |
|
---|
181 | /** Central list of lights - for easy memory management and lookup.
|
---|
182 | */
|
---|
183 | SceneLightList mLights;
|
---|
184 |
|
---|
185 |
|
---|
186 | typedef std::map<String, Entity* > EntityList;
|
---|
187 |
|
---|
188 | /** Central list of entities - for easy memory management and lookup.
|
---|
189 | */
|
---|
190 | EntityList mEntities;
|
---|
191 |
|
---|
192 | typedef std::map<String, BillboardSet* > BillboardSetList;
|
---|
193 |
|
---|
194 | /** Central list of billboard sets - for easy memory management and lookup.
|
---|
195 | */
|
---|
196 | BillboardSetList mBillboardSets;
|
---|
197 |
|
---|
198 | typedef std::map<String, StaticGeometry* > StaticGeometryList;
|
---|
199 | StaticGeometryList mStaticGeometryList;
|
---|
200 |
|
---|
201 | typedef std::map<String, SceneNode*> SceneNodeList;
|
---|
202 |
|
---|
203 | /** Central list of SceneNodes - for easy memory management.
|
---|
204 | @note
|
---|
205 | Note that this list is used only for memory management; the structure of the scene
|
---|
206 | is held using the hierarchy of SceneNodes starting with the root node. However you
|
---|
207 | can look up nodes this way.
|
---|
208 | */
|
---|
209 | SceneNodeList mSceneNodes;
|
---|
210 |
|
---|
211 | /// Camera in progress
|
---|
212 | Camera* mCameraInProgress;
|
---|
213 | /// Current Viewport
|
---|
214 | Viewport* mCurrentViewport;
|
---|
215 |
|
---|
216 | /// Root scene node
|
---|
217 | SceneNode* mSceneRoot;
|
---|
218 |
|
---|
219 | /// Autotracking scene nodes
|
---|
220 | typedef std::set<SceneNode*> AutoTrackingSceneNodes;
|
---|
221 | AutoTrackingSceneNodes mAutoTrackingSceneNodes;
|
---|
222 |
|
---|
223 | // Sky params
|
---|
224 | // Sky plane
|
---|
225 | Entity* mSkyPlaneEntity;
|
---|
226 | Entity* mSkyDomeEntity[5];
|
---|
227 | Entity* mSkyBoxEntity[6];
|
---|
228 |
|
---|
229 | SceneNode* mSkyPlaneNode;
|
---|
230 | SceneNode* mSkyDomeNode;
|
---|
231 | SceneNode* mSkyBoxNode;
|
---|
232 |
|
---|
233 | bool mSkyPlaneEnabled;
|
---|
234 | bool mSkyPlaneDrawFirst;
|
---|
235 | Plane mSkyPlane;
|
---|
236 | // Sky box
|
---|
237 | bool mSkyBoxEnabled;
|
---|
238 | bool mSkyBoxDrawFirst;
|
---|
239 | Quaternion mSkyBoxOrientation;
|
---|
240 | // Sky dome
|
---|
241 | bool mSkyDomeEnabled;
|
---|
242 | bool mSkyDomeDrawFirst;
|
---|
243 | Quaternion mSkyDomeOrientation;
|
---|
244 | // Fog
|
---|
245 | FogMode mFogMode;
|
---|
246 | ColourValue mFogColour;
|
---|
247 | Real mFogStart;
|
---|
248 | Real mFogEnd;
|
---|
249 | Real mFogDensity;
|
---|
250 |
|
---|
251 | typedef std::set<RenderQueueGroupID> SpecialCaseRenderQueueList;
|
---|
252 | SpecialCaseRenderQueueList mSpecialCaseQueueList;
|
---|
253 | SpecialCaseRenderQueueMode mSpecialCaseQueueMode;
|
---|
254 | RenderQueueGroupID mWorldGeometryRenderQueue;
|
---|
255 |
|
---|
256 | /** Internal method for initialising the render queue.
|
---|
257 | @remarks
|
---|
258 | Subclasses can use this to install their own RenderQueue implementation.
|
---|
259 | */
|
---|
260 | virtual void initRenderQueue(void);
|
---|
261 | /** Retrieves the internal render queue. */
|
---|
262 | virtual RenderQueue* getRenderQueue(void);
|
---|
263 | #ifndef GTP_VISIBILITY_MODIFIED_OGRE // made public, is found in the modfified section
|
---|
264 | /** Internal method for setting up the renderstate for a rendering pass.
|
---|
265 | @param
|
---|
266 | pass The Pass details to set.
|
---|
267 | @returns
|
---|
268 | A Pass object that was used instead of the one passed in, can
|
---|
269 | happen when rendering shadow passes
|
---|
270 | */
|
---|
271 | virtual Pass* setPass(Pass* pass);
|
---|
272 | #endif
|
---|
273 | /// A pass designed to let us render shadow colour on white for texture shadows
|
---|
274 | Pass* mShadowCasterPlainBlackPass;
|
---|
275 | /// A pass designed to let us render shadow receivers for texture shadows
|
---|
276 | Pass* mShadowReceiverPass;
|
---|
277 | /** Internal method for turning a regular pass into a shadow caster pass.
|
---|
278 | @remarks
|
---|
279 | This is only used for texture shadows, basically we're trying to
|
---|
280 | ensure that objects are rendered solid black.
|
---|
281 | This method will usually return the standard solid black pass for
|
---|
282 | all fixed function passes, but will merge in a vertex program
|
---|
283 | and fudge the AutpoParamDataSource to set black lighting for
|
---|
284 | passes with vertex programs.
|
---|
285 | */
|
---|
286 | Pass* deriveShadowCasterPass(Pass* pass);
|
---|
287 | /** Internal method for turning a regular pass into a shadow receiver pass.
|
---|
288 | @remarks
|
---|
289 | This is only used for texture shadows, basically we're trying to
|
---|
290 | ensure that objects are rendered with a projective texture.
|
---|
291 | This method will usually return a standard single-texture pass for
|
---|
292 | all fixed function passes, but will merge in a vertex program
|
---|
293 | for passes with vertex programs.
|
---|
294 | */
|
---|
295 | Pass* deriveShadowReceiverPass(Pass* pass);
|
---|
296 |
|
---|
297 | /** Internal method to validate whether a Pass should be allowed to render.
|
---|
298 | @remarks
|
---|
299 | Called just before a pass is about to be used for rendering a group to
|
---|
300 | allow the SceneManager to omit it if required. A return value of false
|
---|
301 | skips this pass.
|
---|
302 | */
|
---|
303 | bool validatePassForRendering(Pass* pass);
|
---|
304 |
|
---|
305 | /** Internal method to validate whether a Renderable should be allowed to render.
|
---|
306 | @remarks
|
---|
307 | Called just before a pass is about to be used for rendering a Renderable to
|
---|
308 | allow the SceneManager to omit it if required. A return value of false
|
---|
309 | skips it.
|
---|
310 | */
|
---|
311 | bool validateRenderableForRendering(Pass* pass, Renderable* rend);
|
---|
312 |
|
---|
313 | enum BoxPlane
|
---|
314 | {
|
---|
315 | BP_FRONT = 0,
|
---|
316 | BP_BACK = 1,
|
---|
317 | BP_LEFT = 2,
|
---|
318 | BP_RIGHT = 3,
|
---|
319 | BP_UP = 4,
|
---|
320 | BP_DOWN = 5
|
---|
321 | };
|
---|
322 |
|
---|
323 | /* Internal utility method for creating the planes of a skybox.
|
---|
324 | */
|
---|
325 | MeshPtr createSkyboxPlane(
|
---|
326 | BoxPlane bp,
|
---|
327 | Real distance,
|
---|
328 | const Quaternion& orientation,
|
---|
329 | const String& groupName);
|
---|
330 |
|
---|
331 | /* Internal utility method for creating the planes of a skydome.
|
---|
332 | */
|
---|
333 | MeshPtr createSkydomePlane(
|
---|
334 | BoxPlane bp,
|
---|
335 | Real curvature, Real tiling, Real distance,
|
---|
336 | const Quaternion& orientation,
|
---|
337 | int xsegments, int ysegments, int ySegmentsToKeep,
|
---|
338 | const String& groupName);
|
---|
339 |
|
---|
340 | // Flag indicating whether SceneNodes will be rendered as a set of 3 axes
|
---|
341 | bool mDisplayNodes;
|
---|
342 |
|
---|
343 | /// Storage of animations, lookup by name
|
---|
344 | typedef std::map<String, Animation*> AnimationList;
|
---|
345 | AnimationList mAnimationsList;
|
---|
346 | AnimationStateSet mAnimationStates;
|
---|
347 | #ifndef GTP_VISIBILITY_MODIFIED_OGRE // made public, is found in the modfified section
|
---|
348 | /** Internal method used by _renderVisibleObjects to deal with renderables
|
---|
349 | which override the camera's own view / projection materices. */
|
---|
350 | void useRenderableViewProjMode(Renderable* pRend);
|
---|
351 | #endif
|
---|
352 | /// Controller flag for determining if we need to set view/proj matrices
|
---|
353 | bool mCamChanged;
|
---|
354 |
|
---|
355 | typedef std::vector<RenderQueueListener*> RenderQueueListenerList;
|
---|
356 | RenderQueueListenerList mRenderQueueListeners;
|
---|
357 |
|
---|
358 | /// Internal method for firing the queue start event, returns true if queue is to be skipped
|
---|
359 | bool fireRenderQueueStarted(RenderQueueGroupID id);
|
---|
360 | /// Internal method for firing the queue end event, returns true if queue is to be repeated
|
---|
361 | bool fireRenderQueueEnded(RenderQueueGroupID id);
|
---|
362 |
|
---|
363 | /** Internal method for setting the destination viewport for the next render. */
|
---|
364 | virtual void setViewport(Viewport *vp);
|
---|
365 |
|
---|
366 | /** Flag that indicates if all of the scene node's bounding boxes should be shown as a wireframe. */
|
---|
367 | bool mShowBoundingBoxes;
|
---|
368 |
|
---|
369 | /** Internal utility method for rendering a single object.
|
---|
370 | @remarks
|
---|
371 | Assumes that the pass has already been set up.
|
---|
372 | @param rend The renderable to issue to the pipeline
|
---|
373 | @param pass The pass which is being used
|
---|
374 | @param doLightIteration If true, this method will issue the renderable to
|
---|
375 | the pipeline possibly multiple times, if the pass indicates it should be
|
---|
376 | done once per light
|
---|
377 | @param manualLightList Only applicable if doLightIteration is false, this
|
---|
378 | method allows you to pass in a previously determined set of lights
|
---|
379 | which will be used for a single render of this object.
|
---|
380 | */
|
---|
381 | virtual void renderSingleObject(Renderable* rend, Pass* pass, bool doLightIteration,
|
---|
382 | const LightList* manualLightList = 0);
|
---|
383 |
|
---|
384 | /// Utility class for calculating automatic parameters for gpu programs
|
---|
385 | AutoParamDataSource mAutoParamDataSource;
|
---|
386 |
|
---|
387 | ShadowTechnique mShadowTechnique;
|
---|
388 | bool mDebugShadows;
|
---|
389 | ColourValue mShadowColour;
|
---|
390 | Pass* mShadowDebugPass;
|
---|
391 | Pass* mShadowStencilPass;
|
---|
392 | Pass* mShadowModulativePass;
|
---|
393 | bool mShadowMaterialInitDone;
|
---|
394 | LightList mLightsAffectingFrustum;
|
---|
395 | HardwareIndexBufferSharedPtr mShadowIndexBuffer;
|
---|
396 | size_t mShadowIndexBufferSize;
|
---|
397 | Rectangle2D* mFullScreenQuad;
|
---|
398 | Real mShadowDirLightExtrudeDist;
|
---|
399 | IlluminationRenderStage mIlluminationStage;
|
---|
400 | unsigned short mShadowTextureSize;
|
---|
401 | unsigned short mShadowTextureCount;
|
---|
402 | PixelFormat mShadowTextureFormat;
|
---|
403 | typedef std::vector<RenderTexture*> ShadowTextureList;
|
---|
404 | ShadowTextureList mShadowTextures;
|
---|
405 | RenderTexture* mCurrentShadowTexture;
|
---|
406 | bool mShadowUseInfiniteFarPlane;
|
---|
407 | /** Internal method for locating a list of lights which could be affecting the frustum.
|
---|
408 | @remarks
|
---|
409 | Custom scene managers are encouraged to override this method to make use of their
|
---|
410 | scene partitioning scheme to more efficiently locate lights, and to eliminate lights
|
---|
411 | which may be occluded by word geometry.
|
---|
412 | */
|
---|
413 | virtual void findLightsAffectingFrustum(const Camera* camera);
|
---|
414 | /// Internal method for setting up materials for shadows
|
---|
415 | virtual void initShadowVolumeMaterials(void);
|
---|
416 | /// Internal method for creating shadow textures (texture-based shadows)
|
---|
417 | virtual void createShadowTextures(unsigned short size, unsigned short count,
|
---|
418 | PixelFormat fmt);
|
---|
419 | /// Internal method for preparing shadow textures ready for use in a regular render
|
---|
420 | virtual void prepareShadowTextures(Camera* cam, Viewport* vp);
|
---|
421 |
|
---|
422 | /** Internal method for rendering all the objects for a given light into the
|
---|
423 | stencil buffer.
|
---|
424 | @param light The light source
|
---|
425 | @param cam The camera being viewed from
|
---|
426 | */
|
---|
427 | virtual void renderShadowVolumesToStencil(const Light* light, const Camera* cam);
|
---|
428 | /** Internal utility method for setting stencil state for rendering shadow volumes.
|
---|
429 | @param secondpass Is this the second pass?
|
---|
430 | @param zfail Should we be using the zfail method?
|
---|
431 | @param twosided Should we use a 2-sided stencil?
|
---|
432 | */
|
---|
433 | virtual void setShadowVolumeStencilState(bool secondpass, bool zfail, bool twosided);
|
---|
434 | /** Render a set of shadow renderables. */
|
---|
435 | void renderShadowVolumeObjects(ShadowCaster::ShadowRenderableListIterator iShadowRenderables,
|
---|
436 | Pass* pass, const LightList *manualLightList, unsigned long flags,
|
---|
437 | bool secondpass, bool zfail, bool twosided);
|
---|
438 | typedef std::vector<ShadowCaster*> ShadowCasterList;
|
---|
439 | ShadowCasterList mShadowCasterList;
|
---|
440 | SphereSceneQuery* mShadowCasterSphereQuery;
|
---|
441 | AxisAlignedBoxSceneQuery* mShadowCasterAABBQuery;
|
---|
442 | Real mShadowFarDist;
|
---|
443 | Real mShadowFarDistSquared;
|
---|
444 | Real mShadowTextureOffset; // proportion of texture offset in view direction e.g. 0.4
|
---|
445 | Real mShadowTextureFadeStart; // as a proportion e.g. 0.6
|
---|
446 | Real mShadowTextureFadeEnd; // as a proportion e.g. 0.9
|
---|
447 | bool mShadowTextureSelfShadow;
|
---|
448 | Pass* mShadowTextureCustomCasterPass;
|
---|
449 | Pass* mShadowTextureCustomReceiverPass;
|
---|
450 | String mShadowTextureCustomCasterVertexProgram;
|
---|
451 | String mShadowTextureCustomReceiverVertexProgram;
|
---|
452 | GpuProgramParametersSharedPtr mShadowTextureCustomCasterVPParams;
|
---|
453 | GpuProgramParametersSharedPtr mShadowTextureCustomReceiverVPParams;
|
---|
454 | bool mShadowTextureCasterVPDirty;
|
---|
455 | bool mShadowTextureReceiverVPDirty;
|
---|
456 |
|
---|
457 |
|
---|
458 | GpuProgramParametersSharedPtr mInfiniteExtrusionParams;
|
---|
459 | GpuProgramParametersSharedPtr mFiniteExtrusionParams;
|
---|
460 |
|
---|
461 | /// Inner class to use as callback for shadow caster scene query
|
---|
462 | class _OgreExport ShadowCasterSceneQueryListener : public SceneQueryListener
|
---|
463 | {
|
---|
464 | protected:
|
---|
465 | SceneManager* mSceneMgr;
|
---|
466 | ShadowCasterList* mCasterList;
|
---|
467 | bool mIsLightInFrustum;
|
---|
468 | const PlaneBoundedVolumeList* mLightClipVolumeList;
|
---|
469 | const Camera* mCamera;
|
---|
470 | const Light* mLight;
|
---|
471 | Real mFarDistSquared;
|
---|
472 | public:
|
---|
473 | ShadowCasterSceneQueryListener(SceneManager* sm) : mSceneMgr(sm),
|
---|
474 | mCasterList(0), mIsLightInFrustum(false), mLightClipVolumeList(0),
|
---|
475 | mCamera(0) {}
|
---|
476 | // Prepare the listener for use with a set of parameters
|
---|
477 | void prepare(bool lightInFrustum,
|
---|
478 | const PlaneBoundedVolumeList* lightClipVolumes,
|
---|
479 | const Light* light, const Camera* cam, ShadowCasterList* casterList,
|
---|
480 | Real farDistSquared)
|
---|
481 | {
|
---|
482 | mCasterList = casterList;
|
---|
483 | mIsLightInFrustum = lightInFrustum;
|
---|
484 | mLightClipVolumeList = lightClipVolumes;
|
---|
485 | mCamera = cam;
|
---|
486 | mLight = light;
|
---|
487 | mFarDistSquared = farDistSquared;
|
---|
488 | }
|
---|
489 | bool queryResult(MovableObject* object);
|
---|
490 | bool queryResult(SceneQuery::WorldFragment* fragment);
|
---|
491 | };
|
---|
492 |
|
---|
493 | ShadowCasterSceneQueryListener* mShadowCasterQueryListener;
|
---|
494 |
|
---|
495 | /** Internal method for locating a list of shadow casters which
|
---|
496 | could be affecting the frustum for a given light.
|
---|
497 | @remarks
|
---|
498 | Custom scene managers are encouraged to override this method to add optimisations,
|
---|
499 | and to add their own custom shadow casters (perhaps for world geometry)
|
---|
500 | */
|
---|
501 | virtual const ShadowCasterList& findShadowCastersForLight(const Light* light,
|
---|
502 | const Camera* camera);
|
---|
503 | /** Render the objects in a given queue group
|
---|
504 | */
|
---|
505 | virtual void renderQueueGroupObjects(RenderQueueGroup* group);
|
---|
506 | /** Render a group in the ordinary way */
|
---|
507 | virtual void renderBasicQueueGroupObjects(RenderQueueGroup* pGroup);
|
---|
508 | /** Render a group with the added complexity of additive stencil shadows. */
|
---|
509 | virtual void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* group);
|
---|
510 | /** Render a group with the added complexity of additive stencil shadows. */
|
---|
511 | virtual void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* group);
|
---|
512 | /** Render a group rendering only shadow casters. */
|
---|
513 | virtual void renderTextureShadowCasterQueueGroupObjects(RenderQueueGroup* group);
|
---|
514 | /** Render a group rendering only shadow receivers. */
|
---|
515 | virtual void renderTextureShadowReceiverQueueGroupObjects(RenderQueueGroup* group);
|
---|
516 | /** Render a group with the added complexity of additive stencil shadows. */
|
---|
517 | virtual void renderModulativeTextureShadowedQueueGroupObjects(RenderQueueGroup* group);
|
---|
518 | /** Render a set of objects, see renderSingleObject for param definitions */
|
---|
519 | virtual void renderObjects(const RenderPriorityGroup::SolidRenderablePassMap& objs,
|
---|
520 | bool doLightIteration, const LightList* manualLightList = 0);
|
---|
521 | /** Render a set of objects, see renderSingleObject for param definitions */
|
---|
522 | virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs,
|
---|
523 | bool doLightIteration, const LightList* manualLightList = 0);
|
---|
524 | /** Render those objects in the transparent pass list which have shadow casting forced on
|
---|
525 | @remarks
|
---|
526 | This function is intended to be used to render the shadows of transparent objects which have
|
---|
527 | transparency_casts_shadows set to 'on' in their material
|
---|
528 | */
|
---|
529 | virtual void renderTransparentShadowCasterObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs,
|
---|
530 | bool doLightIteration, const LightList* manualLightList = 0);
|
---|
531 |
|
---|
532 | public:
|
---|
533 | /** Default constructor.
|
---|
534 | */
|
---|
535 | SceneManager();
|
---|
536 |
|
---|
537 | /** Default destructor.
|
---|
538 | */
|
---|
539 | virtual ~SceneManager();
|
---|
540 |
|
---|
541 | /** Creates a camera to be managed by this scene manager.
|
---|
542 | @remarks
|
---|
543 | This camera must be added to the scene at a later time using
|
---|
544 | the attachObject method of the SceneNode class.
|
---|
545 | @param
|
---|
546 | name Name to give the new camera.
|
---|
547 | */
|
---|
548 | virtual Camera* createCamera(const String& name);
|
---|
549 |
|
---|
550 | /** Retrieves a pointer to the named camera.
|
---|
551 | */
|
---|
552 | virtual Camera* getCamera(const String& name);
|
---|
553 |
|
---|
554 | /** Removes a camera from the scene.
|
---|
555 | @remarks
|
---|
556 | This method removes a previously added camera from the scene.
|
---|
557 | The camera is deleted so the caller must ensure no references
|
---|
558 | to it's previous instance (e.g. in a SceneNode) are used.
|
---|
559 | @param
|
---|
560 | cam Pointer to the camera to remove
|
---|
561 | */
|
---|
562 | virtual void removeCamera(Camera *cam);
|
---|
563 |
|
---|
564 | /** Removes a camera from the scene.
|
---|
565 | @remarks
|
---|
566 | This method removes an camera from the scene based on the
|
---|
567 | camera's name rather than a pointer.
|
---|
568 | */
|
---|
569 | virtual void removeCamera(const String& name);
|
---|
570 |
|
---|
571 | /** Removes (and destroys) all cameras from the scene.
|
---|
572 | */
|
---|
573 | virtual void removeAllCameras(void);
|
---|
574 |
|
---|
575 | /** Creates a light for use in the scene.
|
---|
576 | @remarks
|
---|
577 | Lights can either be in a fixed position and independent of the
|
---|
578 | scene graph, or they can be attached to SceneNodes so they derive
|
---|
579 | their position from the parent node. Either way, they are created
|
---|
580 | using this method so that the SceneManager manages their
|
---|
581 | existence.
|
---|
582 | @param
|
---|
583 | name The name of the new light, to identify it later.
|
---|
584 | */
|
---|
585 | virtual Light* createLight(const String& name);
|
---|
586 |
|
---|
587 | /** Returns a pointer to the named Light which has previously been added to the scene.
|
---|
588 | */
|
---|
589 | virtual Light* getLight(const String& name);
|
---|
590 |
|
---|
591 | /** Removes the named light from the scene and destroys it.
|
---|
592 | @remarks
|
---|
593 | Any pointers held to this light after calling this method will be invalid.
|
---|
594 | */
|
---|
595 | virtual void removeLight(const String& name);
|
---|
596 |
|
---|
597 | /** Removes the light from the scene and destroys it based on a pointer.
|
---|
598 | @remarks
|
---|
599 | Any pointers held to this light after calling this method will be invalid.
|
---|
600 | */
|
---|
601 | virtual void removeLight(Light* light);
|
---|
602 | /** Removes and destroys all lights in the scene.
|
---|
603 | */
|
---|
604 | virtual void removeAllLights(void);
|
---|
605 |
|
---|
606 | /** Populate a light list with an ordered set of the lights which are closest
|
---|
607 | to the position specified.
|
---|
608 | @remarks
|
---|
609 | Note that since directional lights have no position, they are always considered
|
---|
610 | closer than any point lights and as such will always take precedence.
|
---|
611 | @par
|
---|
612 | Subclasses of the default SceneManager may wish to take into account other issues
|
---|
613 | such as possible visibility of the light if that information is included in their
|
---|
614 | data structures. This basic scenemanager simply orders by distance, eliminating
|
---|
615 | those lights which are out of range.
|
---|
616 | @par
|
---|
617 | The number of items in the list max exceed the maximum number of lights supported
|
---|
618 | by the renderer, but the extraneous ones will never be used. In fact the limit will
|
---|
619 | be imposed by Pass::getMaxSimultaneousLights.
|
---|
620 | @param position The position at which to evaluate the list of lights
|
---|
621 | @param radius The bounding radius to test
|
---|
622 | @param destList List to be populated with ordered set of lights; will be cleared by
|
---|
623 | this method before population.
|
---|
624 | */
|
---|
625 | virtual void _populateLightList(const Vector3& position, Real radius, LightList& destList);
|
---|
626 |
|
---|
627 |
|
---|
628 | /** Creates an instance of a SceneNode.
|
---|
629 | @remarks
|
---|
630 | Note that this does not add the SceneNode to the scene hierarchy.
|
---|
631 | This method is for convenience, since it allows an instance to
|
---|
632 | be created for which the SceneManager is responsible for
|
---|
633 | allocating and releasing memory, which is convenient in complex
|
---|
634 | scenes.
|
---|
635 | @par
|
---|
636 | To include the returned SceneNode in the scene, use the addChild
|
---|
637 | method of the SceneNode which is to be it's parent.
|
---|
638 | @par
|
---|
639 | Note that this method takes no parameters, and the node created is unnamed (it is
|
---|
640 | actually given a generated name, which you can retrieve if you want).
|
---|
641 | If you wish to create a node with a specific name, call the alternative method
|
---|
642 | which takes a name parameter.
|
---|
643 | */
|
---|
644 | virtual SceneNode* createSceneNode(void);
|
---|
645 |
|
---|
646 | /** Creates an instance of a SceneNode with a given name.
|
---|
647 | @remarks
|
---|
648 | Note that this does not add the SceneNode to the scene hierarchy.
|
---|
649 | This method is for convenience, since it allows an instance to
|
---|
650 | be created for which the SceneManager is responsible for
|
---|
651 | allocating and releasing memory, which is convenient in complex
|
---|
652 | scenes.
|
---|
653 | @par
|
---|
654 | To include the returned SceneNode in the scene, use the addChild
|
---|
655 | method of the SceneNode which is to be it's parent.
|
---|
656 | @par
|
---|
657 | Note that this method takes a name parameter, which makes the node easier to
|
---|
658 | retrieve directly again later.
|
---|
659 | */
|
---|
660 | virtual SceneNode* createSceneNode(const String& name);
|
---|
661 |
|
---|
662 | /** Destroys a SceneNode with a given name.
|
---|
663 | @remarks
|
---|
664 | This allows you to physically delete an individual SceneNode if you want to.
|
---|
665 | Note that this is not normally recommended, it's better to allow SceneManager
|
---|
666 | to delete the nodes when the scene is cleared.
|
---|
667 | */
|
---|
668 | virtual void destroySceneNode(const String& name);
|
---|
669 |
|
---|
670 | /** Gets the SceneNode at the root of the scene hierarchy.
|
---|
671 | @remarks
|
---|
672 | The entire scene is held as a hierarchy of nodes, which
|
---|
673 | allows things like relative transforms, general changes in
|
---|
674 | rendering state etc (See the SceneNode class for more info).
|
---|
675 | In this basic SceneManager class, the application using
|
---|
676 | Ogre is free to structure this hierarchy however it likes,
|
---|
677 | since it has no real significance apart from making transforms
|
---|
678 | relative to each node (more specialised subclasses will
|
---|
679 | provide utility methods for building specific node structures
|
---|
680 | e.g. loading a BSP tree).
|
---|
681 | @par
|
---|
682 | However, in all cases there is only ever one root node of
|
---|
683 | the hierarchy, and this method returns a pointer to it.
|
---|
684 | */
|
---|
685 | virtual SceneNode* getRootSceneNode(void) const;
|
---|
686 |
|
---|
687 | /** Retrieves a named SceneNode from the scene graph.
|
---|
688 | @remarks
|
---|
689 | If you chose to name a SceneNode as you created it, or if you
|
---|
690 | happened to make a note of the generated name, you can look it
|
---|
691 | up wherever it is in the scene graph using this method.
|
---|
692 | */
|
---|
693 | virtual SceneNode* getSceneNode(const String& name) const;
|
---|
694 |
|
---|
695 | /** Create an Entity (instance of a discrete mesh).
|
---|
696 | @param
|
---|
697 | entityName The name to be given to the entity (must be unique).
|
---|
698 | @param
|
---|
699 | meshName The name of the Mesh it is to be based on (e.g. 'knot.oof'). The
|
---|
700 | mesh will be loaded if it is not already.
|
---|
701 | */
|
---|
702 | virtual Entity* createEntity(const String& entityName, const String& meshName);
|
---|
703 |
|
---|
704 | /** Prefab shapes available without loading a model.
|
---|
705 | @note
|
---|
706 | Minimal implementation at present.
|
---|
707 | @todo
|
---|
708 | Add more prefabs (teapots, teapots!!!)
|
---|
709 | */
|
---|
710 | enum PrefabType {
|
---|
711 | PT_PLANE
|
---|
712 | };
|
---|
713 |
|
---|
714 | /** Create an Entity (instance of a discrete mesh) from a range of prefab shapes.
|
---|
715 | @param
|
---|
716 | entityName The name to be given to the entity (must be unique).
|
---|
717 | @param
|
---|
718 | ptype The prefab type.
|
---|
719 | */
|
---|
720 | virtual Entity* createEntity(const String& entityName, PrefabType ptype);
|
---|
721 | /** Retrieves a pointer to the named Entity. */
|
---|
722 | virtual Entity* getEntity(const String& name);
|
---|
723 |
|
---|
724 | /** Removes & destroys an Entity from the SceneManager.
|
---|
725 | @warning
|
---|
726 | Must only be done if the Entity is not attached
|
---|
727 | to a SceneNode. It may be safer to wait to clear the whole
|
---|
728 | scene if you are unsure use clearScene.
|
---|
729 | @see
|
---|
730 | SceneManager::clearScene
|
---|
731 | */
|
---|
732 | virtual void removeEntity(Entity* ent);
|
---|
733 |
|
---|
734 | /** Removes & destroys an Entity from the SceneManager by name.
|
---|
735 | @warning
|
---|
736 | Must only be done if the Entity is not attached
|
---|
737 | to a SceneNode. It may be safer to wait to clear the whole
|
---|
738 | scene if you are unsure use clearScene.
|
---|
739 | @see
|
---|
740 | SceneManager::clearScene
|
---|
741 | */
|
---|
742 | virtual void removeEntity(const String& name);
|
---|
743 |
|
---|
744 | /** Removes & destroys all Entities.
|
---|
745 | @warning
|
---|
746 | Again, use caution since no Entity must be referred to
|
---|
747 | elsewhere e.g. attached to a SceneNode otherwise a crash
|
---|
748 | is likely. Use clearScene if you are unsure (it clears SceneNode
|
---|
749 | entries too.)
|
---|
750 | @see
|
---|
751 | SceneManager::clearScene
|
---|
752 | */
|
---|
753 | virtual void removeAllEntities(void);
|
---|
754 |
|
---|
755 | /** Empties the entire scene, inluding all SceneNodes, Entities, Lights,
|
---|
756 | BillboardSets etc. Cameras are not deleted at this stage since
|
---|
757 | they are still referenced by viewports, which are not destroyed during
|
---|
758 | this process.
|
---|
759 | */
|
---|
760 | virtual void clearScene(void);
|
---|
761 |
|
---|
762 | /** Sets the ambient light level to be used for the scene.
|
---|
763 | @remarks
|
---|
764 | This sets the colour and intensity of the ambient light in the scene, i.e. the
|
---|
765 | light which is 'sourceless' and illuminates all objects equally.
|
---|
766 | The colour of an object is affected by a combination of the light in the scene,
|
---|
767 | and the amount of light that object reflects (in this case based on the Material::ambient
|
---|
768 | property).
|
---|
769 | @remarks
|
---|
770 | By default the ambient light in the scene is ColourValue::Black, i.e. no ambient light. This
|
---|
771 | means that any objects rendered with a Material which has lighting enabled (see Material::setLightingEnabled)
|
---|
772 | will not be visible unless you have some dynamic lights in your scene.
|
---|
773 | */
|
---|
774 | void setAmbientLight(const ColourValue& colour);
|
---|
775 |
|
---|
776 | /** Returns the ambient light level to be used for the scene.
|
---|
777 | */
|
---|
778 | const ColourValue& getAmbientLight(void) const;
|
---|
779 |
|
---|
780 | /** Sets the source of the 'world' geometry, i.e. the large, mainly static geometry
|
---|
781 | making up the world e.g. rooms, landscape etc.
|
---|
782 | @remarks
|
---|
783 | Depending on the type of SceneManager (subclasses will be specialised
|
---|
784 | for particular world geometry types) you have requested via the Root or
|
---|
785 | SceneManagerEnumerator classes, you can pass a filename to this method and it
|
---|
786 | will attempt to load the world-level geometry for use. If you try to load
|
---|
787 | an inappropriate type of world data an exception will be thrown. The default
|
---|
788 | SceneManager cannot handle any sort of world geometry and so will always
|
---|
789 | throw an exception. However subclasses like BspSceneManager can load
|
---|
790 | particular types of world geometry e.g. "q3dm1.bsp".
|
---|
791 | @par
|
---|
792 | World geometry will be loaded via the 'common' resource paths and archives set in the
|
---|
793 | ResourceManager class.
|
---|
794 | */
|
---|
795 | virtual void setWorldGeometry(const String& filename);
|
---|
796 |
|
---|
797 | /** Estimate the number of loading stages required to load the named
|
---|
798 | world geometry.
|
---|
799 | @remarks
|
---|
800 | This method should be overridden by SceneManagers that provide
|
---|
801 | custom world geometry that can take some time to load. They should
|
---|
802 | return from this method a count of the number of stages of progress
|
---|
803 | they can report on whilst loading. During real loading (setWorldGeomtry),
|
---|
804 | they should call ResourceGroupManager::_notifyWorldGeometryProgress exactly
|
---|
805 | that number of times when loading the geometry for real.
|
---|
806 | @note
|
---|
807 | The default is to return 0, ie to not report progress.
|
---|
808 | */
|
---|
809 | virtual size_t estimateWorldGeometry(const String& filename) { return 0; }
|
---|
810 |
|
---|
811 | /** Asks the SceneManager to provide a suggested viewpoint from which the scene should be viewed.
|
---|
812 | @remarks
|
---|
813 | Typically this method returns the origin unless a) world geometry has been loaded using
|
---|
814 | SceneManager::setWorldGeometry and b) that world geometry has suggested 'start' points.
|
---|
815 | If there is more than one viewpoint which the scene manager can suggest, it will always suggest
|
---|
816 | the first one unless the random parameter is true.
|
---|
817 | @param
|
---|
818 | random If true, and there is more than one possible suggestion, a random one will be used. If false
|
---|
819 | the same one will always be suggested.
|
---|
820 | @return
|
---|
821 | On success, true is returned.
|
---|
822 | @par
|
---|
823 | On failiure, false is returned.
|
---|
824 | */
|
---|
825 | virtual ViewPoint getSuggestedViewpoint(bool random = false);
|
---|
826 |
|
---|
827 | /** Method for setting a specific option of the Scene Manager. These options are usually
|
---|
828 | specific for a certain implemntation of the Scene Manager class, and may (and probably
|
---|
829 | will) not exist across different implementations.
|
---|
830 | @param
|
---|
831 | strKey The name of the option to set
|
---|
832 | @param
|
---|
833 | pValue A pointer to the value - the size should be calculated by the scene manager
|
---|
834 | based on the key
|
---|
835 | @return
|
---|
836 | On success, true is returned.
|
---|
837 | @par
|
---|
838 | On failiure, false is returned.
|
---|
839 | */
|
---|
840 | virtual bool setOption( const String& strKey, const void* pValue ) { return false; }
|
---|
841 |
|
---|
842 | /** Method for getting the value of an implementation-specific Scene Manager option.
|
---|
843 | @param
|
---|
844 | strKey The name of the option
|
---|
845 | @param
|
---|
846 | pDestValue A pointer to a memory location where the value will
|
---|
847 | be copied. Currently, the memory will be allocated by the
|
---|
848 | scene manager, but this may change
|
---|
849 | @return
|
---|
850 | On success, true is returned and pDestValue points to the value of the given
|
---|
851 | option.
|
---|
852 | @par
|
---|
853 | On failiure, false is returned and pDestValue is set to NULL.
|
---|
854 | */
|
---|
855 | virtual bool getOption( const String& strKey, void* pDestValue ) { return false; }
|
---|
856 |
|
---|
857 | /** Method for verifying wether the scene manager has an implementation-specific
|
---|
858 | option.
|
---|
859 | @param
|
---|
860 | strKey The name of the option to check for.
|
---|
861 | @return
|
---|
862 | If the scene manager contains the given option, true is returned.
|
---|
863 | @remarks
|
---|
864 | If it does not, false is returned.
|
---|
865 | */
|
---|
866 | virtual bool hasOption( const String& strKey ) const { return false; }
|
---|
867 | /** Method for getting all possible values for a specific option. When this list is too large
|
---|
868 | (i.e. the option expects, for example, a float), the return value will be true, but the
|
---|
869 | list will contain just one element whose size will be set to 0.
|
---|
870 | Otherwise, the list will be filled with all the possible values the option can
|
---|
871 | accept.
|
---|
872 | @param
|
---|
873 | strKey The name of the option to get the values for.
|
---|
874 | @param
|
---|
875 | refValueList A reference to a list that will be filled with the available values.
|
---|
876 | @return
|
---|
877 | On success (the option exists), true is returned.
|
---|
878 | @par
|
---|
879 | On failure, false is returned.
|
---|
880 | */
|
---|
881 | virtual bool getOptionValues( const String& strKey, StringVector& refValueList ) { return false; }
|
---|
882 |
|
---|
883 | /** Method for getting all the implementation-specific options of the scene manager.
|
---|
884 | @param
|
---|
885 | refKeys A reference to a list that will be filled with all the available options.
|
---|
886 | @return
|
---|
887 | On success, true is returned. On failiure, false is returned.
|
---|
888 | */
|
---|
889 | virtual bool getOptionKeys( StringVector& refKeys ) { return false; }
|
---|
890 |
|
---|
891 | /** Internal method for updating the scene graph ie the tree of SceneNode instances managed by this class.
|
---|
892 | @remarks
|
---|
893 | This must be done before issuing objects to the rendering pipeline, since derived transformations from
|
---|
894 | parent nodes are not updated until required. This SceneManager is a basic implementation which simply
|
---|
895 | updates all nodes from the root. This ensures the scene is up to date but requires all the nodes
|
---|
896 | to be updated even if they are not visible. Subclasses could trim this such that only potentially visible
|
---|
897 | nodes are updated.
|
---|
898 | */
|
---|
899 | virtual void _updateSceneGraph(Camera* cam);
|
---|
900 |
|
---|
901 | /** Internal method which parses the scene to find visible objects to render.
|
---|
902 | @remarks
|
---|
903 | If you're implementing a custom scene manager, this is the most important method to
|
---|
904 | override since it's here you can apply your custom world partitioning scheme. Once you
|
---|
905 | have added the appropriate objects to the render queue, you can let the default
|
---|
906 | SceneManager objects _renderVisibleObjects handle the actual rendering of the objects
|
---|
907 | you pick.
|
---|
908 | @par
|
---|
909 | Any visible objects will be added to a rendering queue, which is indexed by material in order
|
---|
910 | to ensure objects with the same material are rendered together to minimise render state changes.
|
---|
911 | */
|
---|
912 | virtual void _findVisibleObjects(Camera* cam, bool onlyShadowCasters);
|
---|
913 |
|
---|
914 | /** Internal method for applying animations to scene nodes.
|
---|
915 | @remarks
|
---|
916 | Uses the internally stored AnimationState objects to apply animation to SceneNodes.
|
---|
917 | */
|
---|
918 | virtual void _applySceneAnimations(void);
|
---|
919 |
|
---|
920 | /** Sends visible objects found in _findVisibleObjects to the rendering engine.
|
---|
921 | */
|
---|
922 | virtual void _renderVisibleObjects(void);
|
---|
923 |
|
---|
924 | /** Prompts the class to send its contents to the renderer.
|
---|
925 | @remarks
|
---|
926 | This method prompts the scene manager to send the
|
---|
927 | contents of the scene it manages to the rendering
|
---|
928 | pipeline, possibly preceded by some sorting, culling
|
---|
929 | or other scene management tasks. Note that this method is not normally called
|
---|
930 | directly by the user application; it is called automatically
|
---|
931 | by the Ogre rendering loop.
|
---|
932 | @param camera Pointer to a camera from whose viewpoint the scene is to
|
---|
933 | be rendered.
|
---|
934 | @param vp The target viewport
|
---|
935 | @param includeOverlays Whether or not overlay objects should be rendered
|
---|
936 | */
|
---|
937 | virtual void _renderScene(Camera* camera, Viewport* vp, bool includeOverlays);
|
---|
938 |
|
---|
939 | /** Internal method for queueing the sky objects with the params as
|
---|
940 | previously set through setSkyBox, setSkyPlane and setSkyDome.
|
---|
941 | */
|
---|
942 | virtual void _queueSkiesForRendering(Camera* cam);
|
---|
943 |
|
---|
944 |
|
---|
945 |
|
---|
946 | /** Notifies the scene manager of its destination render system
|
---|
947 | @remarks
|
---|
948 | Called automatically by RenderSystem::addSceneManager
|
---|
949 | this method simply notifies the manager of the render
|
---|
950 | system to which its output must be directed.
|
---|
951 | @param
|
---|
952 | sys Pointer to the RenderSystem subclass to be used as a render target.
|
---|
953 | */
|
---|
954 | virtual void _setDestinationRenderSystem(RenderSystem* sys);
|
---|
955 |
|
---|
956 | /** Enables / disables a 'sky plane' i.e. a plane at constant
|
---|
957 | distance from the camera representing the sky.
|
---|
958 | @remarks
|
---|
959 | You can create sky planes yourself using the standard mesh and
|
---|
960 | entity methods, but this creates a plane which the camera can
|
---|
961 | never get closer or further away from - it moves with the camera.
|
---|
962 | (NB you could create this effect by creating a world plane which
|
---|
963 | was attached to the same SceneNode as the Camera too, but this
|
---|
964 | would only apply to a single camera whereas this plane applies to
|
---|
965 | any camera using this scene manager).
|
---|
966 | @note
|
---|
967 | To apply scaling, scrolls etc to the sky texture(s) you
|
---|
968 | should use the TextureUnitState class methods.
|
---|
969 | @param
|
---|
970 | enable True to enable the plane, false to disable it
|
---|
971 | @param
|
---|
972 | plane Details of the plane, i.e. it's normal and it's
|
---|
973 | distance from the camera.
|
---|
974 | @param
|
---|
975 | materialName The name of the material the plane will use
|
---|
976 | @param
|
---|
977 | scale The scaling applied to the sky plane - higher values
|
---|
978 | mean a bigger sky plane - you may want to tweak this
|
---|
979 | depending on the size of plane.d and the other
|
---|
980 | characteristics of your scene
|
---|
981 | @param
|
---|
982 | tiling How many times to tile the texture across the sky.
|
---|
983 | Applies to all texture layers. If you need finer control use
|
---|
984 | the TextureUnitState texture coordinate transformation methods.
|
---|
985 | @param
|
---|
986 | drawFirst If true, the plane is drawn before all other
|
---|
987 | geometry in the scene, without updating the depth buffer.
|
---|
988 | This is the safest rendering method since all other objects
|
---|
989 | will always appear in front of the sky. However this is not
|
---|
990 | the most efficient way if most of the sky is often occluded
|
---|
991 | by other objects. If this is the case, you can set this
|
---|
992 | parameter to false meaning it draws <em>after</em> all other
|
---|
993 | geometry which can be an optimisation - however you must
|
---|
994 | ensure that the plane.d value is large enough that no objects
|
---|
995 | will 'poke through' the sky plane when it is rendered.
|
---|
996 | @param
|
---|
997 | bow If zero, the plane will be completely flat (like previous
|
---|
998 | versions. If above zero, the plane will be curved, allowing
|
---|
999 | the sky to appear below camera level. Curved sky planes are
|
---|
1000 | simular to skydomes, but are more compatable with fog.
|
---|
1001 | @param xsegments, ysegments
|
---|
1002 | Determines the number of segments the plane will have to it. This
|
---|
1003 | is most important when you are bowing the plane, but may also be useful
|
---|
1004 | if you need tesselation on the plane to perform per-vertex effects.
|
---|
1005 | @param groupName
|
---|
1006 | The name of the resource group to which to assign the plane mesh.
|
---|
1007 | */
|
---|
1008 | virtual void setSkyPlane(
|
---|
1009 | bool enable,
|
---|
1010 | const Plane& plane, const String& materialName, Real scale = 1000,
|
---|
1011 | Real tiling = 10, bool drawFirst = true, Real bow = 0,
|
---|
1012 | int xsegments = 1, int ysegments = 1,
|
---|
1013 | const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
---|
1014 |
|
---|
1015 | /** Enables / disables a 'sky box' i.e. a 6-sided box at constant
|
---|
1016 | distance from the camera representing the sky.
|
---|
1017 | @remarks
|
---|
1018 | You could create a sky box yourself using the standard mesh and
|
---|
1019 | entity methods, but this creates a plane which the camera can
|
---|
1020 | never get closer or further away from - it moves with the camera.
|
---|
1021 | (NB you could create this effect by creating a world box which
|
---|
1022 | was attached to the same SceneNode as the Camera too, but this
|
---|
1023 | would only apply to a single camera whereas this skybox applies
|
---|
1024 | to any camera using this scene manager).
|
---|
1025 | @par
|
---|
1026 | The material you use for the skybox can either contain layers
|
---|
1027 | which are single textures, or they can be cubic textures, i.e.
|
---|
1028 | made up of 6 images, one for each plane of the cube. See the
|
---|
1029 | TextureUnitState class for more information.
|
---|
1030 | @param
|
---|
1031 | enable True to enable the skybox, false to disable it
|
---|
1032 | @param
|
---|
1033 | materialName The name of the material the box will use
|
---|
1034 | @param
|
---|
1035 | distance Distance in world coorinates from the camera to
|
---|
1036 | each plane of the box. The default is normally OK.
|
---|
1037 | @param
|
---|
1038 | drawFirst If true, the box is drawn before all other
|
---|
1039 | geometry in the scene, without updating the depth buffer.
|
---|
1040 | This is the safest rendering method since all other objects
|
---|
1041 | will always appear in front of the sky. However this is not
|
---|
1042 | the most efficient way if most of the sky is often occluded
|
---|
1043 | by other objects. If this is the case, you can set this
|
---|
1044 | parameter to false meaning it draws <em>after</em> all other
|
---|
1045 | geometry which can be an optimisation - however you must
|
---|
1046 | ensure that the distance value is large enough that no
|
---|
1047 | objects will 'poke through' the sky box when it is rendered.
|
---|
1048 | @param
|
---|
1049 | orientation Optional parameter to specify the orientation
|
---|
1050 | of the box. By default the 'top' of the box is deemed to be
|
---|
1051 | in the +y direction, and the 'front' at the -z direction.
|
---|
1052 | You can use this parameter to rotate the sky if you want.
|
---|
1053 | @param groupName
|
---|
1054 | The name of the resource group to which to assign the plane mesh.
|
---|
1055 | */
|
---|
1056 | virtual void setSkyBox(
|
---|
1057 | bool enable, const String& materialName, Real distance = 5000,
|
---|
1058 | bool drawFirst = true, const Quaternion& orientation = Quaternion::IDENTITY,
|
---|
1059 | const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
---|
1060 |
|
---|
1061 | /** Enables / disables a 'sky dome' i.e. an illusion of a curved sky.
|
---|
1062 | @remarks
|
---|
1063 | A sky dome is actually formed by 5 sides of a cube, but with
|
---|
1064 | texture coordinates generated such that the surface appears
|
---|
1065 | curved like a dome. Sky domes are appropriate where you need a
|
---|
1066 | realistic looking sky where the scene is not going to be
|
---|
1067 | 'fogged', and there is always a 'floor' of some sort to prevent
|
---|
1068 | the viewer looking below the horizon (the distortion effect below
|
---|
1069 | the horizon can be pretty horrible, and there is never anyhting
|
---|
1070 | directly below the viewer). If you need a complete wrap-around
|
---|
1071 | background, use the setSkyBox method instead. You can actually
|
---|
1072 | combine a sky box and a sky dome if you want, to give a positional
|
---|
1073 | backdrop with an overlayed curved cloud layer.
|
---|
1074 | @par
|
---|
1075 | Sky domes work well with 2D repeating textures like clouds. You
|
---|
1076 | can change the apparant 'curvature' of the sky depending on how
|
---|
1077 | your scene is viewed - lower curvatures are better for 'open'
|
---|
1078 | scenes like landscapes, whilst higher curvatures are better for
|
---|
1079 | say FPS levels where you don't see a lot of the sky at once and
|
---|
1080 | the exaggerated curve looks good.
|
---|
1081 | @param
|
---|
1082 | enable True to enable the skydome, false to disable it
|
---|
1083 | @param
|
---|
1084 | materialName The name of the material the dome will use
|
---|
1085 | @param
|
---|
1086 | curvature The curvature of the dome. Good values are
|
---|
1087 | between 2 and 65. Higher values are more curved leading to
|
---|
1088 | a smoother effect, lower values are less curved meaning
|
---|
1089 | more distortion at the horizons but a better distance effect.
|
---|
1090 | @param
|
---|
1091 | tiling How many times to tile the texture(s) across the
|
---|
1092 | dome.
|
---|
1093 | @param
|
---|
1094 | distance Distance in world coorinates from the camera to
|
---|
1095 | each plane of the box the dome is rendered on. The default
|
---|
1096 | is normally OK.
|
---|
1097 | @param
|
---|
1098 | drawFirst If true, the dome is drawn before all other
|
---|
1099 | geometry in the scene, without updating the depth buffer.
|
---|
1100 | This is the safest rendering method since all other objects
|
---|
1101 | will always appear in front of the sky. However this is not
|
---|
1102 | the most efficient way if most of the sky is often occluded
|
---|
1103 | by other objects. If this is the case, you can set this
|
---|
1104 | parameter to false meaning it draws <em>after</em> all other
|
---|
1105 | geometry which can be an optimisation - however you must
|
---|
1106 | ensure that the distance value is large enough that no
|
---|
1107 | objects will 'poke through' the sky when it is rendered.
|
---|
1108 | @param
|
---|
1109 | orientation Optional parameter to specify the orientation
|
---|
1110 | of the dome. By default the 'top' of the dome is deemed to
|
---|
1111 | be in the +y direction, and the 'front' at the -z direction.
|
---|
1112 | You can use this parameter to rotate the sky if you want.
|
---|
1113 | @param groupName
|
---|
1114 | The name of the resource group to which to assign the plane mesh.
|
---|
1115 | */
|
---|
1116 | virtual void setSkyDome(
|
---|
1117 | bool enable, const String& materialName, Real curvature = 10,
|
---|
1118 | Real tiling = 8, Real distance = 4000, bool drawFirst = true,
|
---|
1119 | const Quaternion& orientation = Quaternion::IDENTITY,
|
---|
1120 | int xsegments = 16, int ysegments = 16, int ysegments_keep = -1,
|
---|
1121 | const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
---|
1122 |
|
---|
1123 | /** Sets the fogging mode applied to the scene.
|
---|
1124 | @remarks
|
---|
1125 | This method sets up the scene-wide fogging effect. These settings
|
---|
1126 | apply to all geometry rendered, UNLESS the material with which it
|
---|
1127 | is rendered has it's own fog settings (see Material::setFog).
|
---|
1128 | @param
|
---|
1129 | mode Set up the mode of fog as described in the FogMode
|
---|
1130 | enum, or set to FOG_NONE to turn off.
|
---|
1131 | @param
|
---|
1132 | colour The colour of the fog. Either set this to the same
|
---|
1133 | as your viewport background colour, or to blend in with a
|
---|
1134 | skydome or skybox.
|
---|
1135 | @param
|
---|
1136 | expDensity The density of the fog in FOG_EXP or FOG_EXP2
|
---|
1137 | mode, as a value between 0 and 1. The default is 0.001.
|
---|
1138 | @param
|
---|
1139 | linearStart Distance in world units at which linear fog starts to
|
---|
1140 | encroach. Only applicable if mode is
|
---|
1141 | FOG_LINEAR.
|
---|
1142 | @param
|
---|
1143 | linearEnd Distance in world units at which linear fog becomes completely
|
---|
1144 | opaque. Only applicable if mode is
|
---|
1145 | FOG_LINEAR.
|
---|
1146 | */
|
---|
1147 | void setFog(
|
---|
1148 | FogMode mode = FOG_NONE, const ColourValue& colour = ColourValue::White,
|
---|
1149 | Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0);
|
---|
1150 |
|
---|
1151 | /** Returns the fog mode for the scene.
|
---|
1152 | */
|
---|
1153 | virtual FogMode getFogMode(void) const;
|
---|
1154 |
|
---|
1155 | /** Returns the fog colour for the scene.
|
---|
1156 | */
|
---|
1157 | virtual const ColourValue& getFogColour(void) const;
|
---|
1158 |
|
---|
1159 | /** Returns the fog start distance for the scene.
|
---|
1160 | */
|
---|
1161 | virtual Real getFogStart(void) const;
|
---|
1162 |
|
---|
1163 | /** Returns the fog end distance for the scene.
|
---|
1164 | */
|
---|
1165 | virtual Real getFogEnd(void) const;
|
---|
1166 |
|
---|
1167 | /** Returns the fog density for the scene.
|
---|
1168 | */
|
---|
1169 | virtual Real getFogDensity(void) const;
|
---|
1170 |
|
---|
1171 |
|
---|
1172 | /** Creates a new BillboardSet for use with this scene manager.
|
---|
1173 | @remarks
|
---|
1174 | This method creates a new BillboardSet which is registered with
|
---|
1175 | the SceneManager. The SceneManager will destroy this object when
|
---|
1176 | it shuts down or when the SceneManager::clearScene method is
|
---|
1177 | called, so the caller does not have to worry about destroying
|
---|
1178 | this object (in fact, it definitely should not do this).
|
---|
1179 | @par
|
---|
1180 | See the BillboardSet documentations for full details of the
|
---|
1181 | returned class.
|
---|
1182 | @param
|
---|
1183 | name The name to give to this billboard set. Must be unique.
|
---|
1184 | @param
|
---|
1185 | poolSize The initial size of the pool of billboards (see BillboardSet for more information)
|
---|
1186 | @see
|
---|
1187 | BillboardSet
|
---|
1188 | */
|
---|
1189 | virtual BillboardSet* createBillboardSet(const String& name, unsigned int poolSize = 20);
|
---|
1190 |
|
---|
1191 | /** Retrieves a pointer to the named BillboardSet.
|
---|
1192 | */
|
---|
1193 | virtual BillboardSet* getBillboardSet(const String& name);
|
---|
1194 |
|
---|
1195 | /** Removes & destroys an BillboardSet from the SceneManager.
|
---|
1196 | @warning
|
---|
1197 | Must only be done if the BillboardSet is not attached
|
---|
1198 | to a SceneNode. It may be safer to wait to clear the whole
|
---|
1199 | scene. If you are unsure, use clearScene.
|
---|
1200 | */
|
---|
1201 | virtual void removeBillboardSet(BillboardSet* set);
|
---|
1202 |
|
---|
1203 | /** Removes & destroys an BillboardSet from the SceneManager by name.
|
---|
1204 | @warning
|
---|
1205 | Must only be done if the BillboardSet is not attached
|
---|
1206 | to a SceneNode. It may be safer to wait to clear the whole
|
---|
1207 | scene. If you are unsure, use clearScene.
|
---|
1208 | */
|
---|
1209 | virtual void removeBillboardSet(const String& name);
|
---|
1210 |
|
---|
1211 | /** Removes & destroys all BillboardSets.
|
---|
1212 | @warning
|
---|
1213 | Again, use caution since no BillboardSet must be referred to
|
---|
1214 | elsewhere e.g. attached to a SceneNode otherwise a crash
|
---|
1215 | is likely. Use clearScene if you are unsure (it clears SceneNode
|
---|
1216 | entries too.)
|
---|
1217 | @see
|
---|
1218 | SceneManager::clearScene
|
---|
1219 | */
|
---|
1220 | virtual void removeAllBillboardSets(void);
|
---|
1221 |
|
---|
1222 | /** Tells the SceneManager whether it should render the SceneNodes which
|
---|
1223 | make up the scene as well as the objects in the scene.
|
---|
1224 | @remarks
|
---|
1225 | This method is mainly for debugging purposes. If you set this to 'true',
|
---|
1226 | each node will be rendered as a set of 3 axes to allow you to easily see
|
---|
1227 | the orientation of the nodes.
|
---|
1228 | */
|
---|
1229 | virtual void setDisplaySceneNodes(bool display);
|
---|
1230 |
|
---|
1231 | /** Creates an animation which can be used to animate scene nodes.
|
---|
1232 | @remarks
|
---|
1233 | An animation is a collection of 'tracks' which over time change the position / orientation
|
---|
1234 | of Node objects. In this case, the animation will likely have tracks to modify the position
|
---|
1235 | / orientation of SceneNode objects, e.g. to make objects move along a path.
|
---|
1236 | @par
|
---|
1237 | You don't need to use an Animation object to move objects around - you can do it yourself
|
---|
1238 | using the methods of the Node in your FrameListener class. However, when you need relatively
|
---|
1239 | complex scripted animation, this is the class to use since it will interpolate between
|
---|
1240 | keyframes for you and generally make the whole process easier to manage.
|
---|
1241 | @par
|
---|
1242 | A single animation can affect multiple Node objects (each AnimationTrack affects a single Node).
|
---|
1243 | In addition, through animation blending a single Node can be affected by multiple animations,
|
---|
1244 | athough this is more useful when performing skeletal animation (see Skeleton::createAnimation).
|
---|
1245 | @par
|
---|
1246 | Note that whilst it uses the same classes, the animations created here are kept separate from the
|
---|
1247 | skeletal animations of meshes (each Skeleton owns those animations).
|
---|
1248 | @param name The name of the animation, must be unique within this SceneManager.
|
---|
1249 | @param length The total length of the animation.
|
---|
1250 | */
|
---|
1251 | virtual Animation* createAnimation(const String& name, Real length);
|
---|
1252 |
|
---|
1253 | /** Looks up an Animation object previously created with createAnimation. */
|
---|
1254 | virtual Animation* getAnimation(const String& name) const;
|
---|
1255 |
|
---|
1256 | /** Destroys an Animation.
|
---|
1257 | @remarks
|
---|
1258 | You should ensure that none of your code is referencing this animation objects since the
|
---|
1259 | memory will be freed.
|
---|
1260 | */
|
---|
1261 | virtual void destroyAnimation(const String& name);
|
---|
1262 |
|
---|
1263 | /** Removes all animations created using this SceneManager. */
|
---|
1264 | virtual void destroyAllAnimations(void);
|
---|
1265 |
|
---|
1266 | /** Create an AnimationState object for managing application of animations.
|
---|
1267 | @remarks
|
---|
1268 | You can create Animation objects for animating SceneNode obejcts using the
|
---|
1269 | createAnimation method. However, in order to actually apply those animations
|
---|
1270 | you have to call methods on Node and Animation in a particular order (namely
|
---|
1271 | Node::resetToInitialState and Animation::apply). To make this easier and to
|
---|
1272 | help track the current time position of animations, the AnimationState object
|
---|
1273 | is provided. </p>
|
---|
1274 | So if you don't want to control animation application manually, call this method,
|
---|
1275 | update the returned object as you like every frame and let SceneManager apply
|
---|
1276 | the animation state for you.
|
---|
1277 | @par
|
---|
1278 | Remember, AnimationState objects are disabled by default at creation time.
|
---|
1279 | Turn them on when you want them using their setEnabled method.
|
---|
1280 | @par
|
---|
1281 | Note that any SceneNode affected by this automatic animation will have it's state
|
---|
1282 | reset to it's initial position before application of the animation. Unless specifically
|
---|
1283 | modified using Node::setInitialState the Node assumes it's initial state is at the
|
---|
1284 | origin. If you want the base state of the SceneNode to be elsewhere, make your changes
|
---|
1285 | to the node using the standard transform methods, then call setInitialState to
|
---|
1286 | 'bake' this reference position into the node.
|
---|
1287 | @param animName The name of an animation created already with createAnimation.
|
---|
1288 | */
|
---|
1289 | virtual AnimationState* createAnimationState(const String& animName);
|
---|
1290 |
|
---|
1291 | /** Retrieves animation state as previously created using createAnimationState */
|
---|
1292 | virtual AnimationState* getAnimationState(const String& animName);
|
---|
1293 |
|
---|
1294 | /** Destroys an AnimationState.
|
---|
1295 | @remarks
|
---|
1296 | You should ensure that none of your code is referencing this animation
|
---|
1297 | state object since the memory will be freed.
|
---|
1298 | */
|
---|
1299 | virtual void destroyAnimationState(const String& name);
|
---|
1300 |
|
---|
1301 | /** Removes all animation states created using this SceneManager. */
|
---|
1302 | virtual void destroyAllAnimationStates(void);
|
---|
1303 |
|
---|
1304 | /** Manual rendering method, for advanced users only.
|
---|
1305 | @remarks
|
---|
1306 | This method allows you to send rendering commands through the pipeline on
|
---|
1307 | demand, bypassing OGRE's normal world processing. You should only use this if you
|
---|
1308 | really know what you're doing; OGRE does lots of things for you that you really should
|
---|
1309 | let it do. However, there are times where it may be useful to have this manual interface,
|
---|
1310 | for example overlaying something on top of the scene rendered by OGRE.
|
---|
1311 | @par
|
---|
1312 | Because this is an instant rendering method, timing is important. The best
|
---|
1313 | time to call it is from a RenderTargetListener event handler.
|
---|
1314 | @par
|
---|
1315 | Don't call this method a lot, it's designed for rare (1 or 2 times per frame) use.
|
---|
1316 | Calling it regularly per frame will cause frame rate drops!
|
---|
1317 | @param rend A RenderOperation object describing the rendering op
|
---|
1318 | @param pass The Pass to use for this render
|
---|
1319 | @param vp Pointer to the viewport to render to
|
---|
1320 | @param worldMatrix The transform to apply from object to world space
|
---|
1321 | @param viewMatrix The transform to apply from world to view space
|
---|
1322 | @param projMatrix The transform to apply from view to screen space
|
---|
1323 | @param doBeginEndFrame If true, beginFrame() and endFrame() are called,
|
---|
1324 | otherwise not. You should leave this as false if you are calling
|
---|
1325 | this within the main render loop.
|
---|
1326 | */
|
---|
1327 | virtual void manualRender(RenderOperation* rend, Pass* pass, Viewport* vp,
|
---|
1328 | const Matrix4& worldMatrix, const Matrix4& viewMatrix, const Matrix4& projMatrix,
|
---|
1329 | bool doBeginEndFrame = false) ;
|
---|
1330 |
|
---|
1331 | /** Registers a new RenderQueueListener which will be notified when render queues
|
---|
1332 | are processed.
|
---|
1333 | */
|
---|
1334 | virtual void addRenderQueueListener(RenderQueueListener* newListener);
|
---|
1335 |
|
---|
1336 | /** Removes a listener previously added with addRenderQueueListener. */
|
---|
1337 | virtual void removeRenderQueueListener(RenderQueueListener* delListener);
|
---|
1338 |
|
---|
1339 | /** Adds an item to the 'special case' render queue list.
|
---|
1340 | @remarks
|
---|
1341 | Normally all render queues are rendered, in their usual sequence,
|
---|
1342 | only varying if a RenderQueueListener nominates for the queue to be
|
---|
1343 | repeated or skipped. This method allows you to add a render queue to
|
---|
1344 | a 'special case' list, which varies the behaviour. The effect of this
|
---|
1345 | list depends on the 'mode' in which this list is in, which might be
|
---|
1346 | to exclude these render queues, or to include them alone (excluding
|
---|
1347 | all other queues). This allows you to perform broad selective
|
---|
1348 | rendering without requiring a RenderQueueListener.
|
---|
1349 | @param qid The identifier of the queue which should be added to the
|
---|
1350 | special case list. Nothing happens if the queue is already in the list.
|
---|
1351 | */
|
---|
1352 | virtual void addSpecialCaseRenderQueue(RenderQueueGroupID qid);
|
---|
1353 | /** Removes an item to the 'special case' render queue list.
|
---|
1354 | @see SceneManager::addSpecialCaseRenderQueue
|
---|
1355 | @param qid The identifier of the queue which should be removed from the
|
---|
1356 | special case list. Nothing happens if the queue is not in the list.
|
---|
1357 | */
|
---|
1358 | virtual void removeSpecialCaseRenderQueue(RenderQueueGroupID qid);
|
---|
1359 | /** Clears the 'special case' render queue list.
|
---|
1360 | @see SceneManager::addSpecialCaseRenderQueue
|
---|
1361 | */
|
---|
1362 | virtual void clearSpecialCaseRenderQueues(void);
|
---|
1363 | /** Sets the way the special case render queue list is processed.
|
---|
1364 | @see SceneManager::addSpecialCaseRenderQueue
|
---|
1365 | @param mode The mode of processing
|
---|
1366 | */
|
---|
1367 | virtual void setSpecialCaseRenderQueueMode(SpecialCaseRenderQueueMode mode);
|
---|
1368 | /** Gets the way the special case render queue list is processed. */
|
---|
1369 | virtual SpecialCaseRenderQueueMode getSpecialCaseRenderQueueMode(void);
|
---|
1370 | /** Returns whether or not the named queue will be rendered based on the
|
---|
1371 | current 'special case' render queue list and mode.
|
---|
1372 | @see SceneManager::addSpecialCaseRenderQueue
|
---|
1373 | @param qid The identifier of the queue which should be tested
|
---|
1374 | @returns true if the queue will be rendered, false otherwise
|
---|
1375 | */
|
---|
1376 | virtual bool isRenderQueueToBeProcessed(RenderQueueGroupID qid);
|
---|
1377 |
|
---|
1378 | /** Sets the render queue that the world geometry (if any) this SceneManager
|
---|
1379 | renders will be associated with.
|
---|
1380 | @remarks
|
---|
1381 | SceneManagers which provide 'world geometry' should place it in a
|
---|
1382 | specialised render queue in order to make it possible to enable /
|
---|
1383 | disable it easily using the addSpecialCaseRenderQueue method. Even
|
---|
1384 | if the SceneManager does not use the render queues to render the
|
---|
1385 | world geometry, it should still pick a queue to represent it's manual
|
---|
1386 | rendering, and check isRenderQueueToBeProcessed before rendering.
|
---|
1387 | @note
|
---|
1388 | Setting this may not affect the actual ordering of rendering the
|
---|
1389 | world geometry, if the world geometry is being rendered manually
|
---|
1390 | by the SceneManager. If the SceneManager feeds world geometry into
|
---|
1391 | the queues, however, the ordering will be affected.
|
---|
1392 | */
|
---|
1393 | virtual void setWorldGeometryRenderQueue(RenderQueueGroupID qid);
|
---|
1394 | /** Gets the render queue that the world geometry (if any) this SceneManager
|
---|
1395 | renders will be associated with.
|
---|
1396 | @remarks
|
---|
1397 | SceneManagers which provide 'world geometry' should place it in a
|
---|
1398 | specialised render queue in order to make it possible to enable /
|
---|
1399 | disable it easily using the addSpecialCaseRenderQueue method. Even
|
---|
1400 | if the SceneManager does not use the render queues to render the
|
---|
1401 | world geometry, it should still pick a queue to represent it's manual
|
---|
1402 | rendering, and check isRenderQueueToBeProcessed before rendering.
|
---|
1403 | */
|
---|
1404 | virtual RenderQueueGroupID getWorldGeometryRenderQueue(void);
|
---|
1405 |
|
---|
1406 | /** Allows all bounding boxes of scene nodes to be displayed. */
|
---|
1407 | virtual void showBoundingBoxes(bool bShow);
|
---|
1408 |
|
---|
1409 | /** Returns if all bounding boxes of scene nodes are to be displayed */
|
---|
1410 | virtual bool getShowBoundingBoxes() const;
|
---|
1411 |
|
---|
1412 | /** Internal method for notifying the manager that a SceneNode is autotracking. */
|
---|
1413 | virtual void _notifyAutotrackingSceneNode(SceneNode* node, bool autoTrack);
|
---|
1414 |
|
---|
1415 |
|
---|
1416 | /** Creates an AxisAlignedBoxSceneQuery for this scene manager.
|
---|
1417 | @remarks
|
---|
1418 | This method creates a new instance of a query object for this scene manager,
|
---|
1419 | for an axis aligned box region. See SceneQuery and AxisAlignedBoxSceneQuery
|
---|
1420 | for full details.
|
---|
1421 | @par
|
---|
1422 | The instance returned from this method must be destroyed by calling
|
---|
1423 | SceneManager::destroyQuery when it is no longer required.
|
---|
1424 | @param box Details of the box which describes the region for this query.
|
---|
1425 | @param mask The query mask to apply to this query; can be used to filter out
|
---|
1426 | certain objects; see SceneQuery for details.
|
---|
1427 | */
|
---|
1428 | virtual AxisAlignedBoxSceneQuery*
|
---|
1429 | createAABBQuery(const AxisAlignedBox& box, unsigned long mask = 0xFFFFFFFF);
|
---|
1430 | /** Creates a SphereSceneQuery for this scene manager.
|
---|
1431 | @remarks
|
---|
1432 | This method creates a new instance of a query object for this scene manager,
|
---|
1433 | for a spherical region. See SceneQuery and SphereSceneQuery
|
---|
1434 | for full details.
|
---|
1435 | @par
|
---|
1436 | The instance returned from this method must be destroyed by calling
|
---|
1437 | SceneManager::destroyQuery when it is no longer required.
|
---|
1438 | @param sphere Details of the sphere which describes the region for this query.
|
---|
1439 | @param mask The query mask to apply to this query; can be used to filter out
|
---|
1440 | certain objects; see SceneQuery for details.
|
---|
1441 | */
|
---|
1442 | virtual SphereSceneQuery*
|
---|
1443 | createSphereQuery(const Sphere& sphere, unsigned long mask = 0xFFFFFFFF);
|
---|
1444 | /** Creates a PlaneBoundedVolumeListSceneQuery for this scene manager.
|
---|
1445 | @remarks
|
---|
1446 | This method creates a new instance of a query object for this scene manager,
|
---|
1447 | for a region enclosed by a set of planes (normals pointing inwards).
|
---|
1448 | See SceneQuery and PlaneBoundedVolumeListSceneQuery for full details.
|
---|
1449 | @par
|
---|
1450 | The instance returned from this method must be destroyed by calling
|
---|
1451 | SceneManager::destroyQuery when it is no longer required.
|
---|
1452 | @param volumes Details of the volumes which describe the region for this query.
|
---|
1453 | @param mask The query mask to apply to this query; can be used to filter out
|
---|
1454 | certain objects; see SceneQuery for details.
|
---|
1455 | */
|
---|
1456 | virtual PlaneBoundedVolumeListSceneQuery*
|
---|
1457 | createPlaneBoundedVolumeQuery(const PlaneBoundedVolumeList& volumes, unsigned long mask = 0xFFFFFFFF);
|
---|
1458 |
|
---|
1459 |
|
---|
1460 | /** Creates a RaySceneQuery for this scene manager.
|
---|
1461 | @remarks
|
---|
1462 | This method creates a new instance of a query object for this scene manager,
|
---|
1463 | looking for objects which fall along a ray. See SceneQuery and RaySceneQuery
|
---|
1464 | for full details.
|
---|
1465 | @par
|
---|
1466 | The instance returned from this method must be destroyed by calling
|
---|
1467 | SceneManager::destroyQuery when it is no longer required.
|
---|
1468 | @param ray Details of the ray which describes the region for this query.
|
---|
1469 | @param mask The query mask to apply to this query; can be used to filter out
|
---|
1470 | certain objects; see SceneQuery for details.
|
---|
1471 | */
|
---|
1472 | virtual RaySceneQuery*
|
---|
1473 | createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF);
|
---|
1474 | //PyramidSceneQuery* createPyramidQuery(const Pyramid& p, unsigned long mask = 0xFFFFFFFF);
|
---|
1475 | /** Creates an IntersectionSceneQuery for this scene manager.
|
---|
1476 | @remarks
|
---|
1477 | This method creates a new instance of a query object for locating
|
---|
1478 | intersecting objects. See SceneQuery and IntersectionSceneQuery
|
---|
1479 | for full details.
|
---|
1480 | @par
|
---|
1481 | The instance returned from this method must be destroyed by calling
|
---|
1482 | SceneManager::destroyQuery when it is no longer required.
|
---|
1483 | @param mask The query mask to apply to this query; can be used to filter out
|
---|
1484 | certain objects; see SceneQuery for details.
|
---|
1485 | */
|
---|
1486 | virtual IntersectionSceneQuery*
|
---|
1487 | createIntersectionQuery(unsigned long mask = 0xFFFFFFFF);
|
---|
1488 |
|
---|
1489 | /** Destroys a scene query of any type. */
|
---|
1490 | virtual void destroyQuery(SceneQuery* query);
|
---|
1491 |
|
---|
1492 | typedef MapIterator<SceneLightList> LightIterator;
|
---|
1493 | typedef MapIterator<EntityList> EntityIterator;
|
---|
1494 | typedef MapIterator<CameraList> CameraIterator;
|
---|
1495 | typedef MapIterator<BillboardSetList> BillboardSetIterator;
|
---|
1496 | typedef MapIterator<AnimationList> AnimationIterator;
|
---|
1497 |
|
---|
1498 | /** Returns a specialised MapIterator over all lights in the scene. */
|
---|
1499 | LightIterator getLightIterator(void) {
|
---|
1500 | return LightIterator(mLights.begin(), mLights.end());
|
---|
1501 | }
|
---|
1502 | /** Returns a specialised MapIterator over all entities in the scene. */
|
---|
1503 | EntityIterator getEntityIterator(void) {
|
---|
1504 | return EntityIterator(mEntities.begin(), mEntities.end());
|
---|
1505 | }
|
---|
1506 | /** Returns a specialised MapIterator over all cameras in the scene. */
|
---|
1507 | CameraIterator getCameraIterator(void) {
|
---|
1508 | return CameraIterator(mCameras.begin(), mCameras.end());
|
---|
1509 | }
|
---|
1510 | /** Returns a specialised MapIterator over all BillboardSets in the scene. */
|
---|
1511 | BillboardSetIterator getBillboardSetIterator(void) {
|
---|
1512 | return BillboardSetIterator(mBillboardSets.begin(), mBillboardSets.end());
|
---|
1513 | }
|
---|
1514 | /** Returns a specialised MapIterator over all animations in the scene. */
|
---|
1515 | AnimationIterator getAnimationIterator(void) {
|
---|
1516 | return AnimationIterator(mAnimationsList.begin(), mAnimationsList.end());
|
---|
1517 | }
|
---|
1518 | /** Returns a specialised MapIterator over all animation states in the scene. */
|
---|
1519 | AnimationStateIterator getAnimationStateIterator(void) {
|
---|
1520 | return AnimationStateIterator(mAnimationStates.begin(), mAnimationStates.end());
|
---|
1521 | }
|
---|
1522 |
|
---|
1523 | /** Sets the general shadow technique to be used in this scene.
|
---|
1524 | @remarks
|
---|
1525 | There are multiple ways to generate shadows in a scene, and each has
|
---|
1526 | strengths and weaknesses.
|
---|
1527 | <ul><li>Stencil-based approaches can be used to
|
---|
1528 | draw very long, extreme shadows without loss of precision and the 'additive'
|
---|
1529 | version can correctly show the shadowing of complex effects like bump mapping
|
---|
1530 | because they physically exclude the light from those areas. However, the edges
|
---|
1531 | are very sharp and stencils cannot handle transparency, and they involve a
|
---|
1532 | fair amount of CPU work in order to calculate the shadow volumes, especially
|
---|
1533 | when animated objects are involved.</li>
|
---|
1534 | <li>Texture-based approaches are good for handling transparency (they can, for
|
---|
1535 | example, correctly shadow a mesh which uses alpha to represent holes), and they
|
---|
1536 | require little CPU overhead, and can happily shadow geometry which is deformed
|
---|
1537 | by a vertex program, unlike stencil shadows. However, they have a fixed precision
|
---|
1538 | which can introduce 'jaggies' at long range and have fillrate issues of their own.</li>
|
---|
1539 | </ul>
|
---|
1540 | @par
|
---|
1541 | We support 2 kinds of stencil shadows, and 2 kinds of texture-based shadows, and one
|
---|
1542 | simple decal approach. The 2 stencil approaches differ in the amount of multipass work
|
---|
1543 | that is required - the modulative approach simply 'darkens' areas in shadow after the
|
---|
1544 | main render, which is the least expensive, whilst the additive approach has to perform
|
---|
1545 | a render per light and adds the cumulative effect, whcih is more expensive but more
|
---|
1546 | accurate. The texture based shadows both work in roughly the same way, the only difference is
|
---|
1547 | that the shadowmap approach is slightly more accurate, but requires a more recent
|
---|
1548 | graphics card.
|
---|
1549 | @par
|
---|
1550 | Note that because mixing many shadow techniques can cause problems, only one technique
|
---|
1551 | is supported at once. Also, you should call this method at the start of the
|
---|
1552 | scene setup.
|
---|
1553 | @param technique The shadowing technique to use for the scene.
|
---|
1554 | */
|
---|
1555 | virtual void setShadowTechnique(ShadowTechnique technique);
|
---|
1556 |
|
---|
1557 | /** Gets the current shadow technique. */
|
---|
1558 | virtual ShadowTechnique getShadowTechnique(void) const { return mShadowTechnique; }
|
---|
1559 |
|
---|
1560 | /** Enables / disables the rendering of debug information for shadows. */
|
---|
1561 | virtual void setShowDebugShadows(bool debug) { mDebugShadows = debug; }
|
---|
1562 | /** Are debug shadows shown? */
|
---|
1563 | virtual bool getShowDebugShadows(void ) const { return mDebugShadows; }
|
---|
1564 |
|
---|
1565 | /** Set the colour used to modulate areas in shadow.
|
---|
1566 | @remarks This is only applicable for shadow techniques which involve
|
---|
1567 | darkening the area in shadow, as opposed to masking out the light.
|
---|
1568 | This colour provided is used as a modulative value to darken the
|
---|
1569 | areas.
|
---|
1570 | */
|
---|
1571 | virtual void setShadowColour(const ColourValue& colour);
|
---|
1572 | /** Get the colour used to modulate areas in shadow.
|
---|
1573 | @remarks This is only applicable for shadow techniques which involve
|
---|
1574 | darkening the area in shadow, as opposed to masking out the light.
|
---|
1575 | This colour provided is used as a modulative value to darken the
|
---|
1576 | areas.
|
---|
1577 | */
|
---|
1578 | virtual const ColourValue& getShadowColour(void) const;
|
---|
1579 | /** Sets the distance a shadow volume is extruded for a directional light.
|
---|
1580 | @remarks
|
---|
1581 | Although directional lights are essentially infinite, there are many
|
---|
1582 | reasons to limit the shadow extrusion distance to a finite number,
|
---|
1583 | not least of which is compatibility with older cards (which do not
|
---|
1584 | support infinite positions), and shadow caster elimination.
|
---|
1585 | @par
|
---|
1586 | The default value is 10,000 world units. This does not apply to
|
---|
1587 | point lights or spotlights, since they extrude up to their
|
---|
1588 | attenuation range.
|
---|
1589 | */
|
---|
1590 | virtual void setShadowDirectionalLightExtrusionDistance(Real dist);
|
---|
1591 | /** Gets the distance a shadow volume is extruded for a directional light.
|
---|
1592 | */
|
---|
1593 | virtual Real getShadowDirectionalLightExtrusionDistance(void) const;
|
---|
1594 | /** Sets the maximum distance away from the camera that shadows
|
---|
1595 | will be visible.
|
---|
1596 | @remarks
|
---|
1597 | Shadow techniques can be expensive, therefore it is a good idea
|
---|
1598 | to limit them to being rendered close to the camera if possible,
|
---|
1599 | and to skip the expense of rendering shadows for distance objects.
|
---|
1600 | This method allows you to set the distance at which shadows will no
|
---|
1601 | longer be rendered.
|
---|
1602 | @note
|
---|
1603 | Each shadow technique can interpret this subtely differently.
|
---|
1604 | For example, one technique may use this to eliminate casters,
|
---|
1605 | another might use it to attenuate the shadows themselves.
|
---|
1606 | You should tweak this value to suit your chosen shadow technique
|
---|
1607 | and scene setup.
|
---|
1608 | */
|
---|
1609 | virtual void setShadowFarDistance(Real distance);
|
---|
1610 | /** Gets the maximum distance away from the camera that shadows
|
---|
1611 | will be visible.
|
---|
1612 | */
|
---|
1613 | virtual Real getShadowFarDistance(void) const
|
---|
1614 | { return mShadowFarDist; }
|
---|
1615 |
|
---|
1616 | /** Sets the maximum size of the index buffer used to render shadow
|
---|
1617 | primitives.
|
---|
1618 | @remarks
|
---|
1619 | This method allows you to tweak the size of the index buffer used
|
---|
1620 | to render shadow primitives (including stencil shadow volumes). The
|
---|
1621 | default size is 51,200 entries, which is 100k of GPU memory, or
|
---|
1622 | enough to render approximately 17,000 triangles. You can reduce this
|
---|
1623 | as long as you do not have any models / world geometry chunks which
|
---|
1624 | could require more than the amount you set.
|
---|
1625 | @par
|
---|
1626 | The maximum number of triangles required to render a single shadow
|
---|
1627 | volume (including light and dark caps when needed) will be 3x the
|
---|
1628 | number of edges on the light silhouette, plus the number of
|
---|
1629 | light-facing triangles. On average, half the
|
---|
1630 | triangles will be facing toward the light, but the number of
|
---|
1631 | triangles in the silhouette entirely depends on the mesh -
|
---|
1632 | angular meshes will have a higher silhouette tris/mesh tris
|
---|
1633 | ratio than a smooth mesh. You can estimate the requirements for
|
---|
1634 | your particular mesh by rendering it alone in a scene with shadows
|
---|
1635 | enabled and a single light - rotate it or the light and make a note
|
---|
1636 | of how high the triangle count goes (remembering to subtract the
|
---|
1637 | mesh triangle count)
|
---|
1638 | @param size The number of indexes; divide this by 3 to determine the
|
---|
1639 | number of triangles.
|
---|
1640 | */
|
---|
1641 | virtual void setShadowIndexBufferSize(size_t size);
|
---|
1642 | /// Get the size of the shadow index buffer
|
---|
1643 | virtual size_t getShadowIndexBufferSize(void) const
|
---|
1644 | { return mShadowIndexBufferSize; }
|
---|
1645 | /** Set the size of the texture used for texture-based shadows.
|
---|
1646 | @remarks
|
---|
1647 | The larger the shadow texture, the better the detail on
|
---|
1648 | texture based shadows, but obviously this takes more memory.
|
---|
1649 | The default size is 512. Sizes must be a power of 2.
|
---|
1650 | */
|
---|
1651 | virtual void setShadowTextureSize(unsigned short size);
|
---|
1652 | /// Get the size of the texture used for texture based shadows
|
---|
1653 | unsigned short getShadowTextureSize(void) const {return mShadowTextureSize; }
|
---|
1654 | /** Set the pixel format of the textures used for texture-based shadows.
|
---|
1655 | @remarks
|
---|
1656 | By default, a colour texture is used (PF_X8R8G8B8) for texture shadows,
|
---|
1657 | but if you want to use more advanced texture shadow types you can
|
---|
1658 | alter this. If you do, you will have to also call
|
---|
1659 | setShadowTextureCasterMaterial and setShadowTextureReceiverMaterial
|
---|
1660 | to provide shader-based materials to use these customised shadow
|
---|
1661 | texture formats.
|
---|
1662 | */
|
---|
1663 | virtual void setShadowTexturePixelFormat(PixelFormat fmt);
|
---|
1664 | /// Get the format of the textures used for texture based shadows
|
---|
1665 | PixelFormat getShadowTexturePixelFormat(void) const {return mShadowTextureFormat; }
|
---|
1666 | /** Set the number of textures allocated for texture-based shadows.
|
---|
1667 | @remarks
|
---|
1668 | The default number of textures assigned to deal with texture based
|
---|
1669 | shadows is 1; however this means you can only have one light casting
|
---|
1670 | shadows at the same time. You can increase this number in order to
|
---|
1671 | make this more flexible, but be aware of the texture memory it will use.
|
---|
1672 | */
|
---|
1673 | virtual void setShadowTextureCount(unsigned short count);
|
---|
1674 | /// Get the number of the textures allocated for texture based shadows
|
---|
1675 | unsigned short getShadowTextureCount(void) const {return mShadowTextureCount; }
|
---|
1676 | /** Sets the size and count of textures used in texture-based shadows.
|
---|
1677 | @remarks
|
---|
1678 | @see setShadowTextureSize and setShadowTextureCount for details, this
|
---|
1679 | method just allows you to change both at once, which can save on
|
---|
1680 | reallocation if the textures have already been created.
|
---|
1681 | */
|
---|
1682 | virtual void setShadowTextureSettings(unsigned short size, unsigned short count,
|
---|
1683 | PixelFormat fmt = PF_X8R8G8B8);
|
---|
1684 | /** Sets the proportional distance which a texture shadow which is generated from a
|
---|
1685 | directional light will be offset into the camera view to make best use of texture space.
|
---|
1686 | @remarks
|
---|
1687 | When generating a shadow texture from a directional light, an approximation is used
|
---|
1688 | since it is not possible to render the entire scene to one texture.
|
---|
1689 | The texture is projected onto an area centred on the camera, and is
|
---|
1690 | the shadow far distance * 2 in length (it is square). This wastes
|
---|
1691 | a lot of texture space outside the frustum though, so this offset allows
|
---|
1692 | you to move the texture in front of the camera more. However, be aware
|
---|
1693 | that this can cause a little shadow 'jittering' during rotation, and
|
---|
1694 | that if you move it too far then you'll start to get artefacts close
|
---|
1695 | to the camera. The value is represented as a proportion of the shadow
|
---|
1696 | far distance, and the default is 0.6.
|
---|
1697 | */
|
---|
1698 | virtual void setShadowDirLightTextureOffset(Real offset) { mShadowTextureOffset = offset;}
|
---|
1699 | /** Sets the proportional distance at which texture shadows begin to fade out.
|
---|
1700 | @remarks
|
---|
1701 | To hide the edges where texture shadows end (in directional lights)
|
---|
1702 | Ogre will fade out the shadow in the distance. This value is a proportional
|
---|
1703 | distance of the entire shadow visibility distance at which the shadow
|
---|
1704 | begins to fade out. The default is 0.7
|
---|
1705 | */
|
---|
1706 | virtual void setShadowTextureFadeStart(Real fadeStart)
|
---|
1707 | { mShadowTextureFadeStart = fadeStart; }
|
---|
1708 | /** Sets the proportional distance at which texture shadows finish to fading out.
|
---|
1709 | @remarks
|
---|
1710 | To hide the edges where texture shadows end (in directional lights)
|
---|
1711 | Ogre will fade out the shadow in the distance. This value is a proportional
|
---|
1712 | distance of the entire shadow visibility distance at which the shadow
|
---|
1713 | is completely invisible. The default is 0.9.
|
---|
1714 | */
|
---|
1715 | virtual void setShadowTextureFadeEnd(Real fadeEnd)
|
---|
1716 | { mShadowTextureFadeEnd = fadeEnd; }
|
---|
1717 |
|
---|
1718 | /** Sets whether or not texture shadows should attempt to self-shadow.
|
---|
1719 | @remarks
|
---|
1720 | The default implementation of texture shadows uses a fixed-function
|
---|
1721 | colour texture projection approach for maximum compatibility, and
|
---|
1722 | as such cannot support self-shadowing. However, if you decide to
|
---|
1723 | implement a more complex shadowing technique using the
|
---|
1724 | setShadowTextureCasterMaterial and setShadowTextureReceiverMaterial
|
---|
1725 | there is a possibility you may be able to support
|
---|
1726 | self-shadowing (e.g by implementing a shader-based shadow map). In
|
---|
1727 | this case you might want to enable this option.
|
---|
1728 | @param selfShadow Whether to attempt self-shadowing with texture shadows
|
---|
1729 | */
|
---|
1730 | virtual void setShadowTextureSelfShadow(bool selfShadow)
|
---|
1731 | { mShadowTextureSelfShadow = selfShadow; }
|
---|
1732 | /// Gets whether or not texture shadows attempt to self-shadow.
|
---|
1733 | virtual bool getShadowTextureSelfShadow(void) const
|
---|
1734 | { return mShadowTextureSelfShadow; }
|
---|
1735 | /** Sets the default material to use for rendering shadow casters.
|
---|
1736 | @remarks
|
---|
1737 | By default shadow casters are rendered into the shadow texture using
|
---|
1738 | an automatically generated fixed-function pass. This allows basic
|
---|
1739 | projective texture shadows, but it's possible to use more advanced
|
---|
1740 | shadow techniques by overriding the caster and receiver materials, for
|
---|
1741 | example providing vertex and fragment programs to implement shadow
|
---|
1742 | maps.
|
---|
1743 | @par
|
---|
1744 | You can rely on the ambient light in the scene being set to the
|
---|
1745 | requested texture shadow colour, if that's useful.
|
---|
1746 | @note
|
---|
1747 | Individual objects may also override the vertex program in
|
---|
1748 | your default material if their materials include
|
---|
1749 | shadow_caster_vertex_program_ref shadow_receiver_vertex_program_ref
|
---|
1750 | entries, so if you use both make sure they are compatible.
|
---|
1751 | @note
|
---|
1752 | Only a single pass is allowed in your material, although multiple
|
---|
1753 | techniques may be used for hardware fallback.
|
---|
1754 | */
|
---|
1755 | virtual void setShadowTextureCasterMaterial(const String& name);
|
---|
1756 | /** Sets the default material to use for rendering shadow receivers.
|
---|
1757 | @remarks
|
---|
1758 | By default shadow receivers are rendered as a post-pass using basic
|
---|
1759 | modulation. This allows basic projective texture shadows, but it's
|
---|
1760 | possible to use more advanced shadow techniques by overriding the
|
---|
1761 | caster and receiver materials, for example providing vertex and
|
---|
1762 | fragment programs to implement shadow maps.
|
---|
1763 | @par
|
---|
1764 | You can rely on texture unit 0 containing the shadow texture, and
|
---|
1765 | for the unit to be set to use projective texturing from the light
|
---|
1766 | (only useful if you're using fixed-function, which is unlikely;
|
---|
1767 | otherwise you should rely on the texture_viewproj_matrix auto binding)
|
---|
1768 | @note
|
---|
1769 | Individual objects may also override the vertex program in
|
---|
1770 | your default material if their materials include
|
---|
1771 | shadow_caster_vertex_program_ref shadow_receiver_vertex_program_ref
|
---|
1772 | entries, so if you use both make sure they are compatible.
|
---|
1773 | @note
|
---|
1774 | Only a single pass is allowed in your material, although multiple
|
---|
1775 | techniques may be used for hardware fallback.
|
---|
1776 | */
|
---|
1777 | virtual void setShadowTextureReceiverMaterial(const String& name);
|
---|
1778 |
|
---|
1779 | /** Sets whether we should use an inifinite camera far plane
|
---|
1780 | when rendering stencil shadows.
|
---|
1781 | @remarks
|
---|
1782 | Stencil shadow coherency is very reliant on the shadow volume
|
---|
1783 | not being clipped by the far plane. If this clipping happens, you
|
---|
1784 | get a kind of 'negative' shadow effect. The best way to achieve
|
---|
1785 | coherency is to move the far plane of the camera out to infinity,
|
---|
1786 | thus preventing the far plane from clipping the shadow volumes.
|
---|
1787 | When combined with vertex program extrusion of the volume to
|
---|
1788 | infinity, which Ogre does when available, this results in very
|
---|
1789 | robust shadow volumes. For this reason, when you enable stencil
|
---|
1790 | shadows, Ogre automatically changes your camera settings to
|
---|
1791 | project to infinity if the card supports it. You can disable this
|
---|
1792 | behaviour if you like by calling this method; although you can
|
---|
1793 | never enable infinite projection if the card does not support it.
|
---|
1794 | @par
|
---|
1795 | If you disable infinite projection, or it is not available,
|
---|
1796 | you need to be far more careful with your light attenuation /
|
---|
1797 | directional light extrusion distances to avoid clipping artefacts
|
---|
1798 | at the far plane.
|
---|
1799 | @note
|
---|
1800 | Recent cards will generally support infinite far plane projection.
|
---|
1801 | However, we have found some cases where they do not, especially
|
---|
1802 | on Direct3D. There is no standard capability we can check to
|
---|
1803 | validate this, so we use some heuristics based on experience:
|
---|
1804 | <UL>
|
---|
1805 | <LI>OpenGL always seems to support it no matter what the card</LI>
|
---|
1806 | <LI>Direct3D on non-vertex program capable systems (including
|
---|
1807 | vertex program capable cards on Direct3D7) does not
|
---|
1808 | support it</LI>
|
---|
1809 | <LI>Direct3D on GeForce3 and GeForce4 Ti does not seem to support
|
---|
1810 | infinite projection<LI>
|
---|
1811 | </UL>
|
---|
1812 | Therefore in the RenderSystem implementation, we may veto the use
|
---|
1813 | of an infinite far plane based on these heuristics.
|
---|
1814 | */
|
---|
1815 | virtual void setShadowUseInfiniteFarPlane(bool enable) {
|
---|
1816 | mShadowUseInfiniteFarPlane = enable; }
|
---|
1817 |
|
---|
1818 | /** Creates a StaticGeometry instance suitable for use with this
|
---|
1819 | SceneManager.
|
---|
1820 | @remarks
|
---|
1821 | StaticGeometry is a way of batching up geometry into a more
|
---|
1822 | efficient form at the expense of being able to move it. Please
|
---|
1823 | read the StaticGeometry class documentation for full information.
|
---|
1824 | @param name The name to give the new object
|
---|
1825 | @returns The new StaticGeometry instance
|
---|
1826 | */
|
---|
1827 | virtual StaticGeometry* createStaticGeometry(const String& name);
|
---|
1828 | /** Retrieve a previously created StaticGeometry instance. */
|
---|
1829 | virtual StaticGeometry* getStaticGeometry(const String& name) const;
|
---|
1830 | /** Remove & destroy a StaticGeometry instance. */
|
---|
1831 | virtual void removeStaticGeometry(StaticGeometry* geom);
|
---|
1832 | /** Remove & destroy a StaticGeometry instance. */
|
---|
1833 | virtual void removeStaticGeometry(const String& name);
|
---|
1834 | /** Remove & destroy all StaticGeometry instances. */
|
---|
1835 | virtual void removeAllStaticGeometry(void);
|
---|
1836 |
|
---|
1837 |
|
---|
1838 | };
|
---|
1839 |
|
---|
1840 | /** Default implementation of IntersectionSceneQuery. */
|
---|
1841 | class _OgreExport DefaultIntersectionSceneQuery :
|
---|
1842 | public IntersectionSceneQuery
|
---|
1843 | {
|
---|
1844 | public:
|
---|
1845 | DefaultIntersectionSceneQuery(SceneManager* creator);
|
---|
1846 | ~DefaultIntersectionSceneQuery();
|
---|
1847 |
|
---|
1848 | /** See IntersectionSceneQuery. */
|
---|
1849 | void execute(IntersectionSceneQueryListener* listener);
|
---|
1850 | };
|
---|
1851 |
|
---|
1852 | /** Default implementation of RaySceneQuery. */
|
---|
1853 | class _OgreExport DefaultRaySceneQuery : public RaySceneQuery
|
---|
1854 | {
|
---|
1855 | public:
|
---|
1856 | DefaultRaySceneQuery(SceneManager* creator);
|
---|
1857 | ~DefaultRaySceneQuery();
|
---|
1858 |
|
---|
1859 | /** See RayScenQuery. */
|
---|
1860 | void execute(RaySceneQueryListener* listener);
|
---|
1861 | };
|
---|
1862 | /** Default implementation of SphereSceneQuery. */
|
---|
1863 | class _OgreExport DefaultSphereSceneQuery : public SphereSceneQuery
|
---|
1864 | {
|
---|
1865 | public:
|
---|
1866 | DefaultSphereSceneQuery(SceneManager* creator);
|
---|
1867 | ~DefaultSphereSceneQuery();
|
---|
1868 |
|
---|
1869 | /** See SceneQuery. */
|
---|
1870 | void execute(SceneQueryListener* listener);
|
---|
1871 | };
|
---|
1872 | /** Default implementation of PlaneBoundedVolumeListSceneQuery. */
|
---|
1873 | class _OgreExport DefaultPlaneBoundedVolumeListSceneQuery : public PlaneBoundedVolumeListSceneQuery
|
---|
1874 | {
|
---|
1875 | public:
|
---|
1876 | DefaultPlaneBoundedVolumeListSceneQuery(SceneManager* creator);
|
---|
1877 | ~DefaultPlaneBoundedVolumeListSceneQuery();
|
---|
1878 |
|
---|
1879 | /** See SceneQuery. */
|
---|
1880 | void execute(SceneQueryListener* listener);
|
---|
1881 | };
|
---|
1882 | /** Default implementation of AxisAlignedBoxSceneQuery. */
|
---|
1883 | class _OgreExport DefaultAxisAlignedBoxSceneQuery : public AxisAlignedBoxSceneQuery
|
---|
1884 | {
|
---|
1885 | public:
|
---|
1886 | DefaultAxisAlignedBoxSceneQuery(SceneManager* creator);
|
---|
1887 | ~DefaultAxisAlignedBoxSceneQuery();
|
---|
1888 |
|
---|
1889 | /** See RayScenQuery. */
|
---|
1890 | void execute(SceneQueryListener* listener);
|
---|
1891 | };
|
---|
1892 |
|
---|
1893 |
|
---|
1894 |
|
---|
1895 | } // Namespace
|
---|
1896 |
|
---|
1897 |
|
---|
1898 |
|
---|
1899 | #endif
|
---|