OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreMovableObject.h
Go to the documentation of this file.
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-2011 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 "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"
41 #include "OgreUserObjectBindings.h"
42 
43 namespace Ogre {
44 
45  // Forward declaration
46  class MovableObjectFactory;
47 
60  {
61  public:
65  {
66  public:
67  Listener(void) {}
68  virtual ~Listener() {}
70  virtual void objectDestroyed(MovableObject*) {}
72  virtual void objectAttached(MovableObject*) {}
74  virtual void objectDetached(MovableObject*) {}
76  virtual void objectMoved(MovableObject*) {}
81  virtual bool objectRendering(const MovableObject*, const Camera*) { return true; }
104  virtual const LightList* objectQueryLights(const MovableObject*) { return 0; }
105  };
106 
107  protected:
118  bool mVisible;
142  // Cached world bounding sphere
148 
153 
158 
161 
162  // Static members
167 
168 
169 
170  public:
172  MovableObject();
173 
175  MovableObject(const String& name);
178  virtual ~MovableObject();
179 
181  virtual void _notifyCreator(MovableObjectFactory* fact) { mCreator = fact; }
183  virtual MovableObjectFactory* _getCreator(void) const { return mCreator; }
185  virtual void _notifyManager(SceneManager* man) { mManager = man; }
187  virtual SceneManager* _getManager(void) const { return mManager; }
188 
190  virtual const String& getName(void) const { return mName; }
191 
193  virtual const String& getMovableType(void) const = 0;
194 
201  virtual Node* getParentNode(void) const;
202 
210  virtual SceneNode* getParentSceneNode(void) const;
211 
213  virtual bool isParentTagPoint() const { return mParentIsTagPoint; }
214 
217  virtual void _notifyAttached(Node* parent, bool isTagPoint = false);
218 
220  virtual bool isAttached(void) const;
221 
223  virtual void detachFromParent(void);
224 
228  virtual bool isInScene(void) const;
229 
232  virtual void _notifyMoved(void);
233 
239  virtual void _notifyCurrentCamera(Camera* cam);
240 
245  virtual const AxisAlignedBox& getBoundingBox(void) const = 0;
246 
250  virtual Real getBoundingRadius(void) const = 0;
251 
253  virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
255  virtual const Sphere& getWorldBoundingSphere(bool derive = false) const;
261  virtual void _updateRenderQueue(RenderQueue* queue) = 0;
262 
277  virtual void setVisible(bool visible);
278 
283  virtual bool getVisible(void) const;
284 
289  virtual bool isVisible(void) const;
290 
295  virtual void setRenderingDistance(Real dist) {
296  mUpperDistance = dist;
297  mSquaredUpperDistance = mUpperDistance * mUpperDistance;
298  }
299 
301  virtual Real getRenderingDistance(void) const { return mUpperDistance; }
302 
310  virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); }
311 
315  virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); }
316 
321  UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
322 
327  const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
328 
341  virtual void setRenderQueueGroup(uint8 queueID);
342 
358  virtual void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority);
359 
361  virtual uint8 getRenderQueueGroup(void) const;
362 
364  virtual const Matrix4& _getParentNodeFullTransform(void) const;
365 
373  virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; }
374 
377  virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; }
378 
381  virtual void removeQueryFlags(uint32 flags) { mQueryFlags &= ~flags; }
382 
384  virtual uint32 getQueryFlags(void) const { return mQueryFlags; }
385 
388  static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; }
389 
392  static uint32 getDefaultQueryFlags() { return msDefaultQueryFlags; }
393 
394 
401  virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; }
402 
405  virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; }
406 
409  virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; }
410 
412  virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; }
413 
416  static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; }
417 
420  static uint32 getDefaultVisibilityFlags() { return msDefaultVisibilityFlags; }
421 
427  virtual void setListener(Listener* listener) { mListener = listener; }
428 
431  virtual Listener* getListener(void) const { return mListener; }
432 
451  virtual const LightList& queryLights(void) const;
452 
457  virtual uint32 getLightMask()const { return mLightMask; }
464  virtual void setLightMask(uint32 lightMask);
465 
472  virtual LightList* _getLightList() { return &mLightList; }
473 
475  EdgeData* getEdgeList(void) { return NULL; }
477  bool hasEdgeList(void) { return false; }
479  ShadowRenderableListIterator getShadowVolumeRenderableIterator(
480  ShadowTechnique shadowTechnique, const Light* light,
481  HardwareIndexBufferSharedPtr* indexBuffer,
482  bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
483 
485  const AxisAlignedBox& getLightCapBounds(void) const;
487  const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const;
500  void setCastShadows(bool enabled) { mCastShadows = enabled; }
502  bool getCastShadows(void) const { return mCastShadows; }
506  bool getReceivesShadows();
507 
509  Real getPointExtrusionDistance(const Light* l) const;
520  virtual uint32 getTypeFlags(void) const;
521 
533  virtual void visitRenderables(Renderable::Visitor* visitor,
534  bool debugRenderables = false) = 0;
535 
544  virtual void setDebugDisplayEnabled(bool enabled) { mDebugDisplay = enabled; }
546  virtual bool isDebugDisplayEnabled(void) const { return mDebugDisplay; }
547 
548 
549 
550 
551 
552  };
553 
560  {
561  protected:
563  unsigned long mTypeFlag;
564 
566  virtual MovableObject* createInstanceImpl(
567  const String& name, const NameValuePairList* params = 0) = 0;
568  public:
569  MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {}
572  virtual const String& getType(void) const = 0;
573 
581  virtual MovableObject* createInstance(
582  const String& name, SceneManager* manager,
583  const NameValuePairList* params = 0);
585  virtual void destroyInstance(MovableObject* obj) = 0;
586 
600  virtual bool requestTypeFlags(void) const { return false; }
609  void _notifyTypeFlags(unsigned long flag) { mTypeFlag = flag; }
610 
616  uint32 getTypeFlags(void) const { return mTypeFlag; }
617 
618  };
622 }
623 #endif
unsigned char uint8
Definition: OgrePlatform.h:248
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:85
virtual void objectDetached(MovableObject *)
MovableObject has been detached from a node.
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
virtual bool requestTypeFlags(void) const
Does this factory require the allocation of a 'type flag', used to selectively include / exclude this...
float Real
Software floating point type.
virtual void addVisibilityFlags(uint32 flags)
As setVisibilityFlags, except the flags passed as parameters are appended to the existing flags on th...
unsigned int uint32
Definition: OgrePlatform.h:246
#define _OgreExport
Definition: OgrePlatform.h:203
Variant type that can hold Any other type.
Definition: OgreAny.h:56
unsigned long ulong
UserObjectBindings & getUserObjectBindings()
Return an instance of user objects binding associated with this class.
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:524
UserObjectBindings mUserObjectBindings
User objects binding.
EdgeData * getEdgeList(void)
Define a default implementation of method from ShadowCaster which implements no shadows.
static uint32 getDefaultVisibilityFlags()
Get the default visibility flags for all future MovableObject instances.
bool mDebugDisplay
Is debug display enabled?
virtual void _notifyManager(SceneManager *man)
Notify the object of it's manager (internal use only)
virtual void objectAttached(MovableObject *)
MovableObject has been attached to a node.
Manages the organisation and rendering of a 'scene' i.e.
bool mRenderQueueIDSet
Flags whether the RenderQueue's default should be used.
Real mUpperDistance
Upper distance to still render.
virtual uint32 getLightMask() const
Get a bitwise mask which will filter the lights affecting this object.
const UserObjectBindings & getUserObjectBindings() const
Return an instance of user objects binding associated with this class.
virtual void setListener(Listener *listener)
Sets a listener for this object.
A 3D box aligned with the x/y/z axes.
MovableObjectFactory * mCreator
Creator of this object (if created by a factory)
virtual void removeVisibilityFlags(uint32 flags)
As setVisibilityFlags, except the flags passed as parameters are removed from the existing flags on t...
virtual void setVisibilityFlags(uint32 flags)
Sets the visiblity flags for this object.
Defines an interface to classes which have one or more AnimableValue instances to expose...
Definition: OgreAnimable.h:237
virtual void objectDestroyed(MovableObject *)
MovableObject is being destroyed.
Interface definition for a factory class which produces a certain kind of MovableObject, and can be registered with Root in order to allow all clients to produce new instances of this object, integrated with the standard Ogre processing.
bool hasEdgeList(void)
Define a default implementation of method from ShadowCaster which implements no shadows.
uint32 mLightMask
the light mask defined for this movable. This will be taken into consideration when deciding which li...
Listener which gets called back on MovableObject events.
Abstract class defining a movable object in a scene.
virtual const LightList * objectQueryLights(const MovableObject *)
Called when the movable object needs to query a light list.
Class representing a node in the scene graph.
Definition: OgreSceneNode.h:57
static uint32 msDefaultVisibilityFlags
Default visibility flags.
bool mCastShadows
Does this object cast shadows?
virtual void setDebugDisplayEnabled(bool enabled)
Sets whether or not the debug display of this object is enabled.
virtual Real getRenderingDistance(void) const
Gets the distance at which batches are no longer rendered.
bool mBeyondFarDistance
Hidden because of distance?
Shared pointer implementation used to share index buffers.
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:72
virtual bool isDebugDisplayEnabled(void) const
Gets whether debug display of this object is enabled.
uint32 mVisibilityFlags
Flags determining whether this object is visible (compared to SceneManager mask)
virtual LightList * _getLightList()
Returns a pointer to the current list of lights for this object.
ShadowTechnique
An enumeration of broad shadow techniques.
Definition: OgreCommon.h:191
static uint32 getDefaultQueryFlags()
Get the default query flags for all future MovableObject instances.
virtual const Any & getUserAny(void) const
virtual void setQueryFlags(uint32 flags)
Sets the query flags for this object.
void _notifyTypeFlags(unsigned long flag)
Notify this factory of the type mask to apply.
virtual bool isParentTagPoint() const
Gets whether the parent node is a TagPoint (or a SceneNode)
virtual bool objectRendering(const MovableObject *, const Camera *)
Called when the movable object of the camera to be used for rendering.
static void setDefaultVisibilityFlags(uint32 flags)
Set the default visibility flags for all future MovableObject instances.
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
static uint32 msDefaultQueryFlags
Default query flags.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
bool mRenderingDisabled
Does rendering this object disabled by listener?
virtual void removeQueryFlags(uint32 flags)
As setQueryFlags, except the flags passed as parameters are removed from the existing flags on this o...
uint32 mQueryFlags
Flags determining whether this object is included / excluded from scene queries.
uint32 getTypeFlags(void) const
Gets the type flag for this factory.
SceneManager * mManager
SceneManager holding this object (if applicable)
bool mRenderQueuePrioritySet
Flags whether the RenderQueue's default should be used.
virtual MovableObjectFactory * _getCreator(void) const
Get the creator of this object, if any (internal use only)
unsigned short ushort
uint8 mRenderQueueID
The render queue to use when rendering this object.
virtual uint32 getVisibilityFlags(void) const
Returns the visibility flags relevant for this object.
bool getCastShadows(void) const
Returns whether shadow casting is enabled for this object.
LightList mLightList
List of lights for this object.
virtual uint32 getQueryFlags(void) const
Returns the query flags relevant for this object.
virtual Listener * getListener(void) const
Gets the current listener for this object.
Class to manage the scene object rendering queue.
virtual SceneManager * _getManager(void) const
Get the manager of this object, if any (internal use only)
static void setDefaultQueryFlags(uint32 flags)
Set the default query flags for all future MovableObject instances.
This class contains the information required to describe the edge connectivity of a given set of vert...
virtual void _notifyCreator(MovableObjectFactory *fact)
Notify the object of it's creator (internal use only)
bool mVisible
Is this object visible?
virtual void objectMoved(MovableObject *)
MovableObject has been moved.
virtual const String & getName(void) const
Returns the name of this object.
_StringBase String
virtual void setUserAny(const Any &anything)
Node * mParentNode
node to which this object is attached
This class defines the interface that must be implemented by shadow casters.
String mName
Name of this object.
AxisAlignedBox mWorldAABB
Cached world AABB of this object.
void setCastShadows(bool enabled)
Sets whether or not this object will cast shadows.
AxisAlignedBox mWorldDarkCapBounds
World space AABB of this object's dark cap.
ulong mLightListUpdated
The last frame that this light list was updated in.
virtual void setRenderingDistance(Real dist)
Sets the distance at which the object is no longer rendered.
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:62
unsigned long mTypeFlag
Type flag, allocated if requested.
Listener * mListener
MovableObject listener - only one allowed (no list) for size & performance reasons. */.
Class that provide convenient interface to establish a linkage between custom user application object...
ushort mRenderQueuePriority
The render queue group to use when rendering this object.
virtual void addQueryFlags(uint32 flags)
As setQueryFlags, except the flags passed as parameters are appended to the existing flags on this ob...