OGRE  1.9.0
OgreMovableObject.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28
29#ifndef __MovableObject_H__
30#define __MovableObject_H__
31
32// Precompiler options
33#include "OgrePrerequisites.h"
34#include "OgreRenderQueue.h"
35#include "OgreAxisAlignedBox.h"
36#include "OgreSphere.h"
37#include "OgreShadowCaster.h"
38#include "OgreFactoryObj.h"
39#include "OgreAnimable.h"
40#include "OgreAny.h"
42#include "OgreHeaderPrefix.h"
43
44namespace Ogre {
45
46 // Forward declaration
47 class MovableObjectFactory;
48
61 {
62 public:
66 {
67 public:
68 Listener(void) {}
69 virtual ~Listener() {}
73 virtual void objectAttached(MovableObject*) {}
75 virtual void objectDetached(MovableObject*) {}
77 virtual void objectMoved(MovableObject*) {}
82 virtual bool objectRendering(const MovableObject*, const Camera*) { return true; }
105 virtual const LightList* objectQueryLights(const MovableObject*) { return 0; }
106 };
107
108 protected:
125 // Minimum pixel size to still render
145 // Cached world bounding sphere
151
156
161
164
165 // Static members
170
171
172
173 public:
176
178 MovableObject(const String& name);
181 virtual ~MovableObject();
182
184 virtual void _notifyCreator(MovableObjectFactory* fact) { mCreator = fact; }
186 virtual MovableObjectFactory* _getCreator(void) const { return mCreator; }
188 virtual void _notifyManager(SceneManager* man) { mManager = man; }
190 virtual SceneManager* _getManager(void) const { return mManager; }
191
193 virtual const String& getName(void) const { return mName; }
194
196 virtual const String& getMovableType(void) const = 0;
197
204 virtual Node* getParentNode(void) const;
205
213 virtual SceneNode* getParentSceneNode(void) const;
214
216 virtual bool isParentTagPoint() const { return mParentIsTagPoint; }
217
220 virtual void _notifyAttached(Node* parent, bool isTagPoint = false);
221
223 virtual bool isAttached(void) const;
224
226 virtual void detachFromParent(void);
227
231 virtual bool isInScene(void) const;
232
235 virtual void _notifyMoved(void);
236
242 virtual void _notifyCurrentCamera(Camera* cam);
243
248 virtual const AxisAlignedBox& getBoundingBox(void) const = 0;
249
253 virtual Real getBoundingRadius(void) const = 0;
254
256 virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
258 virtual const Sphere& getWorldBoundingSphere(bool derive = false) const;
264 virtual void _updateRenderQueue(RenderQueue* queue) = 0;
265
280 virtual void setVisible(bool visible);
281
286 virtual bool getVisible(void) const;
287
292 virtual bool isVisible(void) const;
293
299 virtual void setRenderingDistance(Real dist) {
300 mUpperDistance = dist;
301 mSquaredUpperDistance = mUpperDistance * mUpperDistance;
302 }
303
305 virtual Real getRenderingDistance(void) const { return mUpperDistance; }
306
312 virtual void setRenderingMinPixelSize(Real pixelSize) {
313 mMinPixelSize = pixelSize;
314 }
315
319 return mMinPixelSize;
320 }
321
329 OGRE_DEPRECATED virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); }
330
334 OGRE_DEPRECATED virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); }
335
340 UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
341
346 const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
347
360 virtual void setRenderQueueGroup(uint8 queueID);
361
377 virtual void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority);
378
380 virtual uint8 getRenderQueueGroup(void) const;
381
383 virtual const Matrix4& _getParentNodeFullTransform(void) const;
384
392 virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; }
393
396 virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; }
397
400 virtual void removeQueryFlags(uint32 flags) { mQueryFlags &= ~flags; }
401
403 virtual uint32 getQueryFlags(void) const { return mQueryFlags; }
404
407 static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; }
408
411 static uint32 getDefaultQueryFlags() { return msDefaultQueryFlags; }
412
413
420 virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; }
421
424 virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; }
425
428 virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; }
429
431 virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; }
432
435 static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; }
436
439 static uint32 getDefaultVisibilityFlags() { return msDefaultVisibilityFlags; }
440
446 virtual void setListener(Listener* listener) { mListener = listener; }
447
450 virtual Listener* getListener(void) const { return mListener; }
451
470 virtual const LightList& queryLights(void) const;
471
476 virtual uint32 getLightMask()const { return mLightMask; }
483 virtual void setLightMask(uint32 lightMask);
484
491 virtual LightList* _getLightList() { return &mLightList; }
492
494 EdgeData* getEdgeList(void) { return NULL; }
496 bool hasEdgeList(void) { return false; }
499 ShadowTechnique shadowTechnique, const Light* light,
500 HardwareIndexBufferSharedPtr* indexBuffer, size_t* indexBufferUsedSize,
501 bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
502
506 const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const;
519 void setCastShadows(bool enabled) { mCastShadows = enabled; }
521 bool getCastShadows(void) const { return mCastShadows; }
526
539 virtual uint32 getTypeFlags(void) const;
540
552 virtual void visitRenderables(Renderable::Visitor* visitor,
553 bool debugRenderables = false) = 0;
554
563 virtual void setDebugDisplayEnabled(bool enabled) { mDebugDisplay = enabled; }
565 virtual bool isDebugDisplayEnabled(void) const { return mDebugDisplay; }
566
567
568
569
570
571 };
572
579 {
580 protected:
583
586 const String& name, const NameValuePairList* params = 0) = 0;
587 public:
588 MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {}
591 virtual const String& getType(void) const = 0;
592
601 const String& name, SceneManager* manager,
602 const NameValuePairList* params = 0);
604 virtual void destroyInstance(MovableObject* obj) = 0;
605
619 virtual bool requestTypeFlags(void) const { return false; }
628 void _notifyTypeFlags(uint32 flag) { mTypeFlag = flag; }
629
635 uint32 getTypeFlags(void) const { return mTypeFlag; }
636
637 };
641}
642
643#include "OgreHeaderSuffix.h"
644
645#endif
#define _OgreExport
#define OGRE_DEPRECATED
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Defines an interface to classes which have one or more AnimableValue instances to expose.
Variant type that can hold Any other type.
Definition OgreAny.h:57
A 3D box aligned with the x/y/z axes.
A viewpoint from which the scene will be rendered.
Definition OgreCamera.h:87
This class contains the information required to describe the edge connectivity of a given set of vert...
Shared pointer implementation used to share index buffers.
Representation of a dynamic light source in the scene.
Definition OgreLight.h:74
Class encapsulating a standard 4x4 homogeneous matrix.
Definition OgreMatrix4.h:79
Interface definition for a factory class which produces a certain kind of MovableObject,...
virtual MovableObject * createInstance(const String &name, SceneManager *manager, const NameValuePairList *params=0)
Create a new instance of the object.
virtual bool requestTypeFlags(void) const
Does this factory require the allocation of a 'type flag', used to selectively include / exclude this...
virtual MovableObject * createInstanceImpl(const String &name, const NameValuePairList *params=0)=0
Internal implementation of create method - must be overridden.
uint32 getTypeFlags(void) const
Gets the type flag for this factory.
uint32 mTypeFlag
Type flag, allocated if requested.
void _notifyTypeFlags(uint32 flag)
Notify this factory of the type mask to apply.
virtual const String & getType(void) const =0
Get the type of the object to be created.
virtual void destroyInstance(MovableObject *obj)=0
Destroy an instance of the object.
Listener which gets called back on MovableObject events.
virtual void objectDestroyed(MovableObject *)
MovableObject is being destroyed.
virtual const LightList * objectQueryLights(const MovableObject *)
Called when the movable object needs to query a light list.
virtual bool objectRendering(const MovableObject *, const Camera *)
Called when the movable object of the camera to be used for rendering.
virtual void objectAttached(MovableObject *)
MovableObject has been attached to a node.
virtual void objectMoved(MovableObject *)
MovableObject has been moved.
virtual void objectDetached(MovableObject *)
MovableObject has been detached from a node.
Abstract class defining a movable object in a scene.
AxisAlignedBox mWorldDarkCapBounds
World space AABB of this object's dark cap.
bool getCastShadows(void) const
Returns whether shadow casting is enabled for this object.
static uint32 getDefaultQueryFlags()
Get the default query flags for all future MovableObject instances.
virtual const LightList & queryLights(void) const
Gets a list of lights, ordered relative to how close they are to this movable object.
virtual void _notifyCreator(MovableObjectFactory *fact)
Notify the object of it's creator (internal use only)
virtual bool isVisible(void) const
Returns whether or not this object is supposed to be visible or not.
virtual SceneManager * _getManager(void) const
Get the manager of this object, if any (internal use only)
Listener * mListener
MovableObject listener - only one allowed (no list) for size & performance reasons....
virtual Listener * getListener(void) const
Gets the current listener for this object.
virtual Node * getParentNode(void) const
Returns the node to which this object is attached.
virtual bool isInScene(void) const
Returns true if this object is attached to a SceneNode or TagPoint, and this SceneNode / TagPoint is ...
virtual void setLightMask(uint32 lightMask)
Set a bitwise mask which will filter the lights affecting this object.
virtual Real getRenderingDistance(void) const
Gets the distance at which batches are no longer rendered.
Real mUpperDistance
Upper distance to still render.
virtual ~MovableObject()
Virtual destructor - read Scott Meyers if you don't know why this is needed.
virtual const AxisAlignedBox & getWorldBoundingBox(bool derive=false) const
Retrieves the axis-aligned bounding box for this object in world coordinates.
virtual void addQueryFlags(uint32 flags)
As setQueryFlags, except the flags passed as parameters are appended to the existing flags on this ob...
MovableObject()
Constructor.
virtual const Sphere & getWorldBoundingSphere(bool derive=false) const
Retrieves the worldspace bounding sphere for this object.
bool mBeyondFarDistance
Hidden because of distance?
bool mRenderQueueIDSet
Flags whether the RenderQueue's default should be used.
virtual Real getRenderingMinPixelSize() const
Returns the minimum pixel size an object needs to be in both screen axes in order to be rendered.
static uint32 msDefaultVisibilityFlags
Default visibility flags.
LightList mLightList
List of lights for this object.
const UserObjectBindings & getUserObjectBindings() const
Return an instance of user objects binding associated with this class.
virtual void setDebugDisplayEnabled(bool enabled)
Sets whether or not the debug display of this object is enabled.
virtual uint32 getTypeFlags(void) const
Get the 'type flags' for this MovableObject.
static uint32 getDefaultVisibilityFlags()
Get the default visibility flags for all future MovableObject instances.
virtual bool isAttached(void) const
Returns true if this object is attached to a SceneNode or TagPoint.
virtual void setRenderingDistance(Real dist)
Sets the distance at which the object is no longer rendered.
virtual void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority)
Sets the render queue group and group priority this entity will be rendered through.
uint32 mLightMask
the light mask defined for this movable. This will be taken into consideration when deciding which li...
String mName
Name of this object.
MovableObject(const String &name)
Named constructor.
virtual LightList * _getLightList()
Returns a pointer to the current list of lights for this object.
virtual const Matrix4 & _getParentNodeFullTransform(void) const
return the full transformation of the parent sceneNode or the attachingPoint node
virtual SceneNode * getParentSceneNode(void) const
Returns the scene node to which this object is attached.
virtual void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)=0
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
SceneManager * mManager
SceneManager holding this object (if applicable)
virtual uint32 getVisibilityFlags(void) const
Returns the visibility flags relevant for this object.
AxisAlignedBox mWorldAABB
Cached world AABB of this object.
virtual const String & getMovableType(void) const =0
Returns the type name of this object.
uint32 mVisibilityFlags
Flags determining whether this object is visible (compared to SceneManager mask)
virtual const AxisAlignedBox & getBoundingBox(void) const =0
Retrieves the local axis-aligned bounding box for this object.
virtual uint32 getLightMask() const
Get a bitwise mask which will filter the lights affecting this object.
Real getPointExtrusionDistance(const Light *l) const
Get the distance to extrude for a point/spot light.
MovableObjectFactory * mCreator
Creator of this object (if created by a factory)
virtual void setVisible(bool visible)
Tells this object whether to be visible or not, if it has a renderable component.
virtual uint8 getRenderQueueGroup(void) const
Gets the queue group for this entity, see setRenderQueueGroup for full details.
virtual void removeQueryFlags(uint32 flags)
As setQueryFlags, except the flags passed as parameters are removed from the existing flags on this o...
bool mVisible
Is this object visible?
bool getReceivesShadows()
Returns whether the Material of any Renderable that this MovableObject will add to the render queue w...
virtual uint32 getQueryFlags(void) const
Returns the query flags relevant for this object.
virtual void setVisibilityFlags(uint32 flags)
Sets the visibility flags for this object.
Node * mParentNode
node to which this object is attached
virtual void setRenderingMinPixelSize(Real pixelSize)
Sets the minimum pixel size an object needs to be in both screen axes in order to be rendered.
virtual void setListener(Listener *listener)
Sets a listener for this object.
virtual void setQueryFlags(uint32 flags)
Sets the query flags for this object.
ushort mRenderQueuePriority
The render queue group to use when rendering this object.
EdgeData * getEdgeList(void)
Define a default implementation of method from ShadowCaster which implements no shadows.
uint8 mRenderQueueID
The render queue to use when rendering this object.
UserObjectBindings & getUserObjectBindings()
Return an instance of user objects binding associated with this class.
virtual void _notifyCurrentCamera(Camera *cam)
Internal method to notify the object of the camera to be used for the next rendering operation.
virtual const String & getName(void) const
Returns the name of this object.
const AxisAlignedBox & getLightCapBounds(void) const
Overridden member from ShadowCaster.
virtual void detachFromParent(void)
Detaches an object from a parent SceneNode or TagPoint, if attached.
virtual bool getVisible(void) const
Gets this object whether to be visible or not, if it has a renderable component.
ShadowRenderableListIterator getShadowVolumeRenderableIterator(ShadowTechnique shadowTechnique, const Light *light, HardwareIndexBufferSharedPtr *indexBuffer, size_t *indexBufferUsedSize, bool extrudeVertices, Real extrusionDist, unsigned long flags=0)
Define a default implementation of method from ShadowCaster which implements no shadows.
virtual void removeVisibilityFlags(uint32 flags)
As setVisibilityFlags, except the flags passed as parameters are removed from the existing flags on t...
bool hasEdgeList(void)
Define a default implementation of method from ShadowCaster which implements no shadows.
virtual MovableObjectFactory * _getCreator(void) const
Get the creator of this object, if any (internal use only)
static void setDefaultVisibilityFlags(uint32 flags)
Set the default visibility flags for all future MovableObject instances.
bool mDebugDisplay
Is debug display enabled?
virtual void setRenderQueueGroup(uint8 queueID)
Sets the render queue group this entity will be rendered through.
virtual void _updateRenderQueue(RenderQueue *queue)=0
Internal method by which the movable object must add Renderable subclass instances to the rendering q...
bool mRenderQueuePrioritySet
Flags whether the RenderQueue's default should be used.
void setCastShadows(bool enabled)
Sets whether or not this object will cast shadows.
bool mRenderingDisabled
Does rendering this object disabled by listener?
bool mCastShadows
Does this object cast shadows?
const AxisAlignedBox & getDarkCapBounds(const Light &light, Real dirLightExtrusionDist) const
Overridden member from ShadowCaster.
static void setDefaultQueryFlags(uint32 flags)
Set the default query flags for all future MovableObject instances.
virtual bool isParentTagPoint() const
Gets whether the parent node is a TagPoint (or a SceneNode)
static uint32 msDefaultQueryFlags
Default query flags.
uint32 mQueryFlags
Flags determining whether this object is included / excluded from scene queries.
virtual void addVisibilityFlags(uint32 flags)
As setVisibilityFlags, except the flags passed as parameters are appended to the existing flags on th...
virtual void _notifyMoved(void)
Internal method called to notify the object that it has been moved.
virtual OGRE_DEPRECATED void setUserAny(const Any &anything)
virtual void _notifyAttached(Node *parent, bool isTagPoint=false)
Internal method called to notify the object that it has been attached to a node.
virtual OGRE_DEPRECATED const Any & getUserAny(void) const
virtual Real getBoundingRadius(void) const =0
Retrieves the radius of the origin-centered bounding sphere for this object.
UserObjectBindings mUserObjectBindings
User objects binding.
ulong mLightListUpdated
The last frame that this light list was updated in.
virtual void _notifyManager(SceneManager *man)
Notify the object of it's manager (internal use only)
virtual bool isDebugDisplayEnabled(void) const
Gets whether debug display of this object is enabled.
Class representing a general-purpose node an articulated scene graph.
Definition OgreNode.h:65
Class to manage the scene object rendering queue.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly.
Manages the organisation and rendering of a 'scene' i.e.
Class representing a node in the scene graph.
This class defines the interface that must be implemented by shadow casters.
A sphere primitive, mostly used for bounds checking.
Definition OgreSphere.h:52
Class that provides convenient interface to establish a linkage between custom user application objec...
Concrete IteratorWrapper for nonconst access to the underlying container.
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition OgreCommon.h:550
ShadowTechnique
An enumeration of broad shadow techniques.
Definition OgreCommon.h:191
unsigned char uint8
unsigned long ulong
float Real
Software floating point type.
unsigned int uint32
_StringBase String
unsigned short ushort