/src/ogre/OgreMain/include/OgreMovableObject.h
Line | Count | Source |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org/ |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | |
29 | | #ifndef __MovableObject_H__ |
30 | | #define __MovableObject_H__ |
31 | | |
32 | | // Precompiler options |
33 | | #include "OgrePrerequisites.h" |
34 | | #include "OgreAxisAlignedBox.h" |
35 | | #include "OgreSphere.h" |
36 | | #include "OgreShadowCaster.h" |
37 | | #include "OgreAnimable.h" |
38 | | #include "OgreHeaderPrefix.h" |
39 | | |
40 | | namespace Ogre { |
41 | | |
42 | | // Forward declaration |
43 | | class MovableObjectFactory; |
44 | | |
45 | | /** \addtogroup Core |
46 | | * @{ |
47 | | */ |
48 | | /** \addtogroup Scene |
49 | | * @{ |
50 | | */ |
51 | | /** Abstract class defining a movable object in a scene. |
52 | | |
53 | | Instances of this class are discrete, relatively small, movable objects |
54 | | which are attached to SceneNode objects to define their position. |
55 | | */ |
56 | | class _OgreExport MovableObject : public ShadowCaster, public AnimableObject, public MovableAlloc |
57 | | { |
58 | | public: |
59 | | /** Listener which gets called back on MovableObject events. |
60 | | */ |
61 | | class _OgreExport Listener |
62 | | { |
63 | | public: |
64 | 0 | Listener(void) {} |
65 | 0 | virtual ~Listener() {} |
66 | | /** MovableObject is being destroyed */ |
67 | 0 | virtual void objectDestroyed(MovableObject*) {} |
68 | | /** MovableObject has been attached to a node */ |
69 | 0 | virtual void objectAttached(MovableObject*) {} |
70 | | /** MovableObject has been detached from a node */ |
71 | 0 | virtual void objectDetached(MovableObject*) {} |
72 | | /** MovableObject has been moved */ |
73 | 0 | virtual void objectMoved(MovableObject*) {} |
74 | | /** Called when the movable object of the camera to be used for rendering. |
75 | | @return |
76 | | true if allows queue for rendering, false otherwise. |
77 | | */ |
78 | 0 | virtual bool objectRendering(const MovableObject*, const Camera*) { return true; } |
79 | | /** Called when the movable object needs to query a light list. |
80 | | |
81 | | If you want to customize light finding for this object, you should override |
82 | | this method and hook into MovableObject via MovableObject::setListener. |
83 | | Be aware that the default method caches results within a frame to |
84 | | prevent unnecessary recalculation, so if you override this you |
85 | | should provide your own caching to maintain performance. |
86 | | @note |
87 | | If you use texture shadows, there is an additional restriction - |
88 | | since the lights which should have shadow textures rendered for |
89 | | them are determined based on the entire frustum, and not per-object, |
90 | | it is important that the lights returned at the start of this |
91 | | list (up to the number of shadow textures available) are the same |
92 | | lights that were used to generate the shadow textures, |
93 | | and they are in the same order (particularly for additive effects). |
94 | | @note |
95 | | This method will not be called for additive stencil shadows since the |
96 | | light list cannot be varied per object with this technique. |
97 | | @return |
98 | | A pointer to a light list if you populated the light list yourself, or |
99 | | NULL to fall back on the default finding process. |
100 | | */ |
101 | 0 | virtual const LightList* objectQueryLights(const MovableObject*) { return 0; } |
102 | | }; |
103 | | |
104 | | protected: |
105 | | /// Name of this object |
106 | | String mName; |
107 | | /// Creator of this object (if created by a factory) |
108 | | MovableObjectFactory* mCreator; |
109 | | /// SceneManager holding this object (if applicable) |
110 | | SceneManager* mManager; |
111 | | /// node to which this object is attached |
112 | | Node* mParentNode; |
113 | | /// MovableObject listener - only one allowed (no list) for size & performance reasons. */ |
114 | | Listener* mListener; |
115 | | bool mParentIsTagPoint : 1; |
116 | | /// Is this object visible? |
117 | | bool mVisible : 1; |
118 | | /// Is debug display enabled? |
119 | | bool mDebugDisplay : 1; |
120 | | /// Hidden because of distance? |
121 | | bool mBeyondFarDistance : 1; |
122 | | /// Does this object cast shadows? |
123 | | bool mCastShadows : 1; |
124 | | /// Flags whether the RenderQueue's default should be used. |
125 | | bool mRenderQueueIDSet : 1; |
126 | | /// Flags whether the RenderQueue's default should be used. |
127 | | bool mRenderQueuePrioritySet : 1; |
128 | | /// Does rendering this object disabled by listener? |
129 | | bool mRenderingDisabled : 1; |
130 | | /// The render queue to use when rendering this object |
131 | | uint8 mRenderQueueID; |
132 | | /// The render queue group to use when rendering this object |
133 | | ushort mRenderQueuePriority; |
134 | | /// Upper distance to still render |
135 | | Real mUpperDistance; |
136 | | Real mSquaredUpperDistance; |
137 | | /// Minimum pixel size to still render |
138 | | Real mMinPixelSize; |
139 | | /// User objects binding. |
140 | | UserObjectBindings mUserObjectBindings; |
141 | | /// Flags determining whether this object is included / excluded from scene queries |
142 | | uint32 mQueryFlags; |
143 | | /// Flags determining whether this object is visible (compared to SceneManager mask) |
144 | | uint32 mVisibilityFlags; |
145 | | /// Cached world AABB of this object |
146 | | mutable AxisAlignedBox mWorldAABB; |
147 | | // Cached world bounding sphere |
148 | | mutable Sphere mWorldBoundingSphere; |
149 | | /// List of lights for this object |
150 | | mutable LightList mLightList; |
151 | | /// The last frame that this light list was updated in |
152 | | mutable ulong mLightListUpdated; |
153 | | /// the light mask defined for this movable. This will be taken into consideration when deciding which light should affect this movable |
154 | | uint32 mLightMask; |
155 | | |
156 | | // Static members |
157 | | /// Default query flags |
158 | | static uint32 msDefaultQueryFlags; |
159 | | /// Default visibility flags |
160 | | static uint32 msDefaultVisibilityFlags; |
161 | | |
162 | | |
163 | | |
164 | | public: |
165 | | /// Constructor |
166 | | MovableObject(); |
167 | | |
168 | | /// Named constructor |
169 | | MovableObject(const String& name); |
170 | | /** Virtual destructor - read Scott Meyers if you don't know why this is needed. |
171 | | */ |
172 | | virtual ~MovableObject(); |
173 | | |
174 | | /** Notify the object of it's creator (internal use only) */ |
175 | 0 | virtual void _notifyCreator(MovableObjectFactory* fact) { mCreator = fact; } |
176 | | /** Get the creator of this object, if any (internal use only) */ |
177 | 0 | MovableObjectFactory* _getCreator(void) const { return mCreator; } |
178 | | /** Notify the object of it's manager (internal use only) */ |
179 | 0 | virtual void _notifyManager(SceneManager* man) { mManager = man; } |
180 | | /** Get the manager of this object, if any (internal use only) */ |
181 | 0 | SceneManager* _getManager(void) const { return mManager; } |
182 | | |
183 | | /** Notifies the movable object that hardware resources were lost |
184 | | |
185 | | Called automatically by RenderSystem if hardware resources |
186 | | were lost and can not be restored using some internal mechanism. |
187 | | Among affected resources are nested shadow renderables, ManualObjects, etc. |
188 | | */ |
189 | 0 | virtual void _releaseManualHardwareResources() {} |
190 | | |
191 | | /** Notifies the movable object that hardware resources should be restored |
192 | | |
193 | | @copydetails _releaseManualHardwareResources |
194 | | */ |
195 | 0 | virtual void _restoreManualHardwareResources() {} |
196 | | |
197 | | /** Returns the name of this object. */ |
198 | 0 | const String& getName(void) const { return mName; } |
199 | | |
200 | | /** Returns the type name of this object. */ |
201 | | virtual const String& getMovableType(void) const = 0; |
202 | | |
203 | | /** Returns the node to which this object is attached. |
204 | | |
205 | | A MovableObject may be attached to either a SceneNode or to a TagPoint, |
206 | | the latter case if it's attached to a bone on an animated entity. |
207 | | Both are Node subclasses so this method will return either. |
208 | | */ |
209 | 0 | Node* getParentNode(void) const { return mParentNode; } |
210 | | |
211 | | /** Returns the scene node to which this object is attached. |
212 | | |
213 | | A MovableObject may be attached to either a SceneNode or to a TagPoint, |
214 | | the latter case if it's attached to a bone on an animated entity. |
215 | | This method will return the scene node of the parent entity |
216 | | if the latter is true. |
217 | | */ |
218 | | SceneNode* getParentSceneNode(void) const; |
219 | | |
220 | | /// Gets whether the parent node is a TagPoint (or a SceneNode) |
221 | 0 | bool isParentTagPoint() const { return mParentIsTagPoint; } |
222 | | |
223 | | /** Internal method called to notify the object that it has been attached to a node. |
224 | | */ |
225 | | virtual void _notifyAttached(Node* parent, bool isTagPoint = false); |
226 | | |
227 | | /** Returns true if this object is attached to a SceneNode or TagPoint. */ |
228 | 0 | bool isAttached(void) const { return (mParentNode != NULL); } |
229 | | |
230 | | /** Detaches an object from a parent SceneNode or TagPoint, if attached. */ |
231 | | void detachFromParent(void); |
232 | | |
233 | | /** Returns true if this object is attached to a SceneNode or TagPoint, |
234 | | and this SceneNode / TagPoint is currently in an active part of the |
235 | | scene graph. */ |
236 | | virtual bool isInScene(void) const; |
237 | | |
238 | | /** Internal method called to notify the object that it has been moved. |
239 | | */ |
240 | | virtual void _notifyMoved(void); |
241 | | |
242 | | /** Internal method to notify the object of the camera to be used for the next rendering operation. |
243 | | |
244 | | Certain objects may want to do specific processing based on the camera position. This method notifies |
245 | | them in case they wish to do this. |
246 | | */ |
247 | | virtual void _notifyCurrentCamera(Camera* cam); |
248 | | |
249 | | /** Retrieves the local axis-aligned bounding box for this object. |
250 | | |
251 | | This bounding box is in local coordinates. |
252 | | */ |
253 | | virtual const AxisAlignedBox& getBoundingBox(void) const = 0; |
254 | | |
255 | | /** Retrieves the radius of the origin-centered bounding sphere |
256 | | for this object. |
257 | | */ |
258 | | virtual Real getBoundingRadius(void) const = 0; |
259 | | |
260 | | /// as getBoundingRadius, but with scaling applied |
261 | | Real getBoundingRadiusScaled() const; |
262 | | |
263 | | /** Retrieves the axis-aligned bounding box for this object in world coordinates. */ |
264 | | const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const override; |
265 | | /** Retrieves the worldspace bounding sphere for this object. */ |
266 | | virtual const Sphere& getWorldBoundingSphere(bool derive = false) const; |
267 | | /** Internal method by which the movable object must add Renderable subclass instances to the rendering queue. |
268 | | |
269 | | The engine will call this method when this object is to be rendered. The object must then create one or more |
270 | | Renderable subclass instances which it places on the passed in Queue for rendering. |
271 | | */ |
272 | | virtual void _updateRenderQueue(RenderQueue* queue) = 0; |
273 | | |
274 | | /** Tells this object whether to be visible or not, if it has a renderable component. |
275 | | @note An alternative approach of making an object invisible is to detach it |
276 | | from it's SceneNode, or to remove the SceneNode entirely. |
277 | | Detaching a node means that structurally the scene graph changes. |
278 | | Once this change has taken place, the objects / nodes that have been |
279 | | removed have less overhead to the visibility detection pass than simply |
280 | | making the object invisible, so if you do this and leave the objects |
281 | | out of the tree for a long time, it's faster. However, the act of |
282 | | detaching / reattaching nodes is in itself more expensive than |
283 | | setting an object visibility flag, since in the latter case |
284 | | structural changes are not made. Therefore, small or frequent visibility |
285 | | changes are best done using this method; large or more longer term |
286 | | changes are best done by detaching. |
287 | | */ |
288 | 0 | void setVisible(bool visible) { mVisible = visible; } |
289 | | |
290 | | /** Gets this object whether to be visible or not, if it has a renderable component. |
291 | | |
292 | | Returns the value set by MovableObject::setVisible only. |
293 | | */ |
294 | 0 | bool getVisible(void) const { return mVisible; } |
295 | | |
296 | | /** Returns whether or not this object is supposed to be visible or not. |
297 | | |
298 | | Takes into account both upper rendering distance and visible flag. |
299 | | */ |
300 | | virtual bool isVisible(void) const; |
301 | | |
302 | | /** Sets the distance at which the object is no longer rendered. |
303 | | @note Camera::setUseRenderingDistance() needs to be called for this parameter to be used. |
304 | | @param dist Distance beyond which the object will not be rendered |
305 | | (the default is 0, which means objects are always rendered). |
306 | | */ |
307 | 0 | void setRenderingDistance(Real dist) { |
308 | 0 | mUpperDistance = dist; |
309 | 0 | mSquaredUpperDistance = mUpperDistance * mUpperDistance; |
310 | 0 | } |
311 | | |
312 | | /** Gets the distance at which batches are no longer rendered. */ |
313 | 0 | Real getRenderingDistance(void) const { return mUpperDistance; } |
314 | | |
315 | | /** Sets the minimum pixel size an object needs to be in both screen axes in order to be rendered |
316 | | @note Camera::setUseMinPixelSize() needs to be called for this parameter to be used. |
317 | | @param pixelSize Number of minimum pixels |
318 | | (the default is 0, which means objects are always rendered). |
319 | | */ |
320 | 0 | void setRenderingMinPixelSize(Real pixelSize) { |
321 | 0 | mMinPixelSize = pixelSize; |
322 | 0 | } |
323 | | |
324 | | /** Returns the minimum pixel size an object needs to be in both screen axes in order to be rendered |
325 | | */ |
326 | 0 | Real getRenderingMinPixelSize() const { |
327 | 0 | return mMinPixelSize; |
328 | 0 | } |
329 | | |
330 | | /** @deprecated use UserObjectBindings::setUserAny via getUserObjectBindings() instead. |
331 | | */ |
332 | 0 | OGRE_DEPRECATED void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); } |
333 | | |
334 | | /** @deprecated use UserObjectBindings::getUserAny via getUserObjectBindings() instead. |
335 | | */ |
336 | 0 | OGRE_DEPRECATED const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); } |
337 | | |
338 | | /// @copydoc UserObjectBindings |
339 | 0 | UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; } |
340 | | |
341 | | /// @overload |
342 | 0 | const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; } |
343 | | |
344 | | /** Sets the render queue group this entity will be rendered through. |
345 | | |
346 | | Render queues are grouped to allow you to more tightly control the ordering |
347 | | of rendered objects. If you do not call this method, all Entity objects default |
348 | | to the default queue (RenderQueue::getDefaultQueueGroup), which is fine for most objects. You may want to alter this |
349 | | if you want this entity to always appear in front of other objects, e.g. for |
350 | | a 3D menu system or such. |
351 | | @par |
352 | | See RenderQueue for more details. |
353 | | @param queueID Enumerated value of the queue group to use. See the |
354 | | enum RenderQueueGroupID for what kind of values can be used here. |
355 | | */ |
356 | | virtual void setRenderQueueGroup(uint8 queueID); |
357 | | |
358 | | /** Sets the render queue group and group priority this entity will be rendered through. |
359 | | |
360 | | Render queues are grouped to allow you to more tightly control the ordering |
361 | | of rendered objects. Within a single render group there another type of grouping |
362 | | called priority which allows further control. If you do not call this method, |
363 | | all Entity objects default to the default queue and priority |
364 | | (RenderQueue::getDefaultQueueGroup, RenderQueue::getDefaultRenderablePriority), |
365 | | which is fine for most objects. You may want to alter this if you want this entity |
366 | | to always appear in front of other objects, e.g. for a 3D menu system or such. |
367 | | @par |
368 | | See RenderQueue for more details. |
369 | | @param queueID Enumerated value of the queue group to use. See the |
370 | | enum RenderQueueGroupID for what kind of values can be used here. |
371 | | @param priority The priority within a group to use. |
372 | | */ |
373 | | virtual void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority); |
374 | | |
375 | | /** Gets the queue group for this entity |
376 | | @see setRenderQueueGroup |
377 | | */ |
378 | 0 | uint8 getRenderQueueGroup(void) const { return mRenderQueueID; } |
379 | | |
380 | | /// Return the full transformation of the parent sceneNode or the attachingPoint node |
381 | | virtual const Affine3& _getParentNodeFullTransform(void) const; |
382 | | |
383 | | /** Sets the query flags for this object. |
384 | | |
385 | | When performing a scene query, this object will be included or excluded according |
386 | | to flags on the object and flags on the query. This is a bitwise value, so only when |
387 | | a bit on these flags is set, will it be included in a query asking for that flag. The |
388 | | meaning of the bits is application-specific. |
389 | | */ |
390 | 0 | void setQueryFlags(uint32 flags) { mQueryFlags = flags; } |
391 | | |
392 | | /** As setQueryFlags, except the flags passed as parameters are appended to the |
393 | | existing flags on this object. */ |
394 | 0 | void addQueryFlags(uint32 flags) { mQueryFlags |= flags; } |
395 | | |
396 | | /** As setQueryFlags, except the flags passed as parameters are removed from the |
397 | | existing flags on this object. */ |
398 | 0 | void removeQueryFlags(uint32 flags) { mQueryFlags &= ~flags; } |
399 | | |
400 | | /// Returns the query flags relevant for this object |
401 | 0 | virtual uint32 getQueryFlags(void) const { return mQueryFlags; } |
402 | | |
403 | | /** Set the default query flags for all future MovableObject instances. |
404 | | */ |
405 | 0 | static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; } |
406 | | |
407 | | /** Get the default query flags for all future MovableObject instances. |
408 | | */ |
409 | 0 | static uint32 getDefaultQueryFlags() { return msDefaultQueryFlags; } |
410 | | |
411 | | |
412 | | /** Sets the visibility flags for this object. |
413 | | |
414 | | As well as a simple true/false value for visibility (as seen in setVisible), |
415 | | you can also set visibility flags which when 'and'ed with the SceneManager's |
416 | | visibility mask can also make an object invisible. |
417 | | */ |
418 | 0 | void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; } |
419 | | |
420 | | /** As setVisibilityFlags, except the flags passed as parameters are appended to the |
421 | | existing flags on this object. */ |
422 | 0 | void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; } |
423 | | |
424 | | /** As setVisibilityFlags, except the flags passed as parameters are removed from the |
425 | | existing flags on this object. */ |
426 | 0 | void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; } |
427 | | |
428 | | /// Returns the visibility flags relevant for this object |
429 | 0 | virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; } |
430 | | |
431 | | /** Set the default visibility flags for all future MovableObject instances. |
432 | | */ |
433 | 0 | static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; } |
434 | | |
435 | | /** Get the default visibility flags for all future MovableObject instances. |
436 | | */ |
437 | 0 | static uint32 getDefaultVisibilityFlags() { return msDefaultVisibilityFlags; } |
438 | | |
439 | | /** Sets a listener for this object. |
440 | | |
441 | | Note for size and performance reasons only one listener per object |
442 | | is allowed. |
443 | | */ |
444 | 0 | void setListener(Listener* listener) { mListener = listener; } |
445 | | |
446 | | /** Gets the current listener for this object. |
447 | | */ |
448 | 0 | Listener* getListener(void) const { return mListener; } |
449 | | |
450 | | /** Gets a list of lights, ordered relative to how close they are to this movable object. |
451 | | |
452 | | By default, this method gives the listener a chance to populate light list first, |
453 | | if there is no listener or Listener::objectQueryLights returns NULL, it'll |
454 | | query the light list from parent entity if it is present, or returns |
455 | | SceneNode::findLights if it has parent scene node, otherwise it just returns |
456 | | an empty list. |
457 | | @par |
458 | | The object internally caches the light list, so it will recalculate |
459 | | it only when object is moved, or lights that affect the frustum have |
460 | | been changed (@see SceneManager::_getLightsDirtyCounter), |
461 | | but if listener exists, it will be called each time, so the listener |
462 | | should implement their own cache mechanism to optimise performance. |
463 | | @par |
464 | | This method can be useful when implementing Renderable::getLights in case |
465 | | the renderable is a part of the movable. |
466 | | @return The list of lights use to lighting this object. |
467 | | */ |
468 | | const LightList& queryLights(void) const; |
469 | | |
470 | | /** Get a bitwise mask which will filter the lights affecting this object |
471 | | |
472 | | By default, this mask is fully set meaning all lights will affect this object |
473 | | */ |
474 | 0 | uint32 getLightMask()const { return mLightMask; } |
475 | | /** Set a bitwise mask which will filter the lights affecting this object |
476 | | |
477 | | This mask will be compared against the mask held against Light to determine |
478 | | if a light should affect a given object. |
479 | | By default, this mask is fully set meaning all lights will affect this object |
480 | | */ |
481 | | void setLightMask(uint32 lightMask); |
482 | | |
483 | | /** Returns a pointer to the current list of lights for this object. |
484 | | |
485 | | You should not modify this list outside of MovableObject::Listener::objectQueryLights |
486 | | (say if you want to use it to implement this method, and use the pointer |
487 | | as a return value) and for reading it's only accurate as at the last frame. |
488 | | */ |
489 | 0 | LightList* _getLightList() { return &mLightList; } |
490 | | |
491 | | /** Sets whether or not this object will cast shadows. |
492 | | |
493 | | This setting simply allows you to turn on/off shadows for a given object. |
494 | | An object will not cast shadows unless the scene supports it in any case |
495 | | (see SceneManager::setShadowTechnique), and also the material which is |
496 | | in use must also have shadow casting enabled. By default all entities cast |
497 | | shadows. If, however, for some reason you wish to disable this for a single |
498 | | object then you can do so using this method. |
499 | | @note This method normally refers to objects which block the light, but |
500 | | since Light is also a subclass of MovableObject, in that context it means |
501 | | whether the light causes shadows itself. |
502 | | */ |
503 | 0 | void setCastShadows(bool enabled) { mCastShadows = enabled; } |
504 | | /** Returns whether shadow casting is enabled for this object. */ |
505 | 0 | bool getCastShadows(void) const override { return mCastShadows; } |
506 | | /** Returns whether the Material of any Renderable that this MovableObject will add to |
507 | | the render queue will receive shadows. |
508 | | */ |
509 | | bool getReceivesShadows(); |
510 | | |
511 | | /** Get the distance to extrude for a point/spot light */ |
512 | | Real getPointExtrusionDistance(const Light* l) const override; |
513 | | /** Get the 'type flags' for this MovableObject. |
514 | | |
515 | | A type flag identifies the type of the MovableObject as a bitpattern. |
516 | | This is used for categorical inclusion / exclusion in SceneQuery |
517 | | objects. By default, this method returns all ones for objects not |
518 | | created by a MovableObjectFactory (hence always including them); |
519 | | otherwise it returns the value assigned to the MovableObjectFactory. |
520 | | Custom objects which don't use MovableObjectFactory will need to |
521 | | override this if they want to be included in queries. |
522 | | */ |
523 | | virtual uint32 getTypeFlags(void) const; |
524 | | |
525 | | /** Method to allow a caller to abstractly iterate over the Renderable |
526 | | instances that this MovableObject will add to the render queue when |
527 | | asked, if any. |
528 | | @param visitor Pointer to a class implementing the Renderable::Visitor |
529 | | interface which will be called back for each Renderable which will |
530 | | be queued. Bear in mind that the state of the Renderable instances |
531 | | may not be finalised depending on when you call this. |
532 | | @param debugRenderables If false, only regular renderables will be visited |
533 | | (those for normal display). If true, debug renderables will be |
534 | | included too. |
535 | | */ |
536 | | virtual void visitRenderables(Renderable::Visitor* visitor, |
537 | | bool debugRenderables = false) = 0; |
538 | | |
539 | | /** Sets whether or not the debug display of this object is enabled. |
540 | | |
541 | | Some objects aren't visible themselves but it can be useful to display |
542 | | a debug representation of them. Or, objects may have an additional |
543 | | debug display on top of their regular display. This option enables / |
544 | | disables that debug display. Objects that are not visible never display |
545 | | debug geometry regardless of this setting. |
546 | | */ |
547 | 0 | void setDebugDisplayEnabled(bool enabled) { mDebugDisplay = enabled; } |
548 | | /// Gets whether debug display of this object is enabled. |
549 | 0 | bool isDebugDisplayEnabled(void) const { return mDebugDisplay; } |
550 | | |
551 | | |
552 | | |
553 | | |
554 | | |
555 | | }; |
556 | | |
557 | | /** Interface definition for a factory class which produces a certain |
558 | | kind of MovableObject, and can be registered with Root in order |
559 | | to allow all clients to produce new instances of this object, integrated |
560 | | with the standard Ogre processing. |
561 | | */ |
562 | | class _OgreExport MovableObjectFactory : public MovableAlloc |
563 | | { |
564 | | private: |
565 | | /// Type flag, allocated if requested |
566 | | uint32 mTypeFlag; |
567 | | |
568 | | /// Internal implementation of create method - must be overridden |
569 | | virtual MovableObject* createInstanceImpl( |
570 | | const String& name, const NameValuePairList* params = 0) = 0; |
571 | | public: |
572 | 0 | MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {} |
573 | 0 | virtual ~MovableObjectFactory() {} |
574 | | /// Get the type of the object to be created |
575 | | virtual const String& getType(void) const = 0; |
576 | | |
577 | | /** Create a new instance of the object. |
578 | | @param name The name of the new object |
579 | | @param manager The SceneManager instance that will be holding the |
580 | | instance once created. |
581 | | @param params Name/value pair list of additional parameters required to |
582 | | construct the object (defined per subtype). Optional. |
583 | | */ |
584 | | MovableObject* createInstance( |
585 | | const String& name, SceneManager* manager, |
586 | | const NameValuePairList* params = 0); |
587 | | /** Destroy an instance of the object */ |
588 | 0 | virtual void destroyInstance(MovableObject* obj) { delete obj; } |
589 | | |
590 | | /** Does this factory require the allocation of a 'type flag', used to |
591 | | selectively include / exclude this type from scene queries? |
592 | | |
593 | | The default implementation here is to return 'false', ie not to |
594 | | request a unique type mask from Root. For objects that |
595 | | never need to be excluded in SceneQuery results, that's fine, since |
596 | | the default implementation of MovableObject::getTypeFlags is to return |
597 | | all ones, hence matching any query type mask. However, if you want the |
598 | | objects created by this factory to be filterable by queries using a |
599 | | broad type, you have to give them a (preferably unique) type mask - |
600 | | and given that you don't know what other MovableObject types are |
601 | | registered, Root will allocate you one. |
602 | | */ |
603 | 0 | virtual bool requestTypeFlags(void) const { return false; } |
604 | | /** Notify this factory of the type mask to apply. |
605 | | |
606 | | This should normally only be called by Root in response to |
607 | | a 'true' result from requestTypeMask. However, you can actually use |
608 | | it yourself if you're careful; for example to assign the same mask |
609 | | to a number of different types of object, should you always wish them |
610 | | to be treated the same in queries. |
611 | | */ |
612 | 0 | void _notifyTypeFlags(uint32 flag) { mTypeFlag = flag; } |
613 | | |
614 | | /** Gets the type flag for this factory. |
615 | | |
616 | | A type flag is like a query flag, except that it applies to all instances |
617 | | of a certain type of object. |
618 | | */ |
619 | 0 | uint32 getTypeFlags(void) const { return mTypeFlag; } |
620 | | |
621 | | }; |
622 | | /** @} */ |
623 | | /** @} */ |
624 | | |
625 | | } |
626 | | |
627 | | #include "OgreHeaderSuffix.h" |
628 | | |
629 | | #endif |