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