OgreMovableObject.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2009 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 
00029 #ifndef __MovableObject_H__
00030 #define __MovableObject_H__
00031 
00032 // Precompiler options
00033 #include "OgrePrerequisites.h"
00034 #include "OgreRenderQueue.h"
00035 #include "OgreAxisAlignedBox.h"
00036 #include "OgreSphere.h"
00037 #include "OgreShadowCaster.h"
00038 #include "OgreFactoryObj.h"
00039 #include "OgreAnimable.h"
00040 #include "OgreAny.h"
00041 #include "OgreUserObjectBindings.h"
00042 
00043 namespace Ogre {
00044 
00045     // Forward declaration
00046     class MovableObjectFactory;
00047 
00059     class _OgreExport MovableObject : public ShadowCaster, public AnimableObject, public MovableAlloc
00060     {
00061     public:
00064         class _OgreExport Listener
00065         {
00066         public:
00067             Listener(void) {}
00068             virtual ~Listener() {}
00070             virtual void objectDestroyed(MovableObject*) {}
00072             virtual void objectAttached(MovableObject*) {}
00074             virtual void objectDetached(MovableObject*) {}
00076             virtual void objectMoved(MovableObject*) {}
00081             virtual bool objectRendering(const MovableObject*, const Camera*) { return true; }
00104             virtual const LightList* objectQueryLights(const MovableObject*) { return 0; }
00105         };
00106 
00107     protected:
00109         String mName;
00111         MovableObjectFactory* mCreator;
00113         SceneManager* mManager;
00115         Node* mParentNode;
00116         bool mParentIsTagPoint;
00118         bool mVisible;
00120         bool mDebugDisplay;
00122         Real mUpperDistance;
00123         Real mSquaredUpperDistance;
00125         bool mBeyondFarDistance;    
00127         UserObjectBindings mUserObjectBindings;
00129         uint8 mRenderQueueID;
00131         bool mRenderQueueIDSet;
00133         ushort mRenderQueuePriority;
00135         bool mRenderQueuePrioritySet;
00137         uint32 mQueryFlags;
00139         uint32 mVisibilityFlags;
00141         mutable AxisAlignedBox mWorldAABB;
00142         // Cached world bounding sphere
00143         mutable Sphere mWorldBoundingSphere;
00145         mutable AxisAlignedBox mWorldDarkCapBounds;
00147         bool mCastShadows;
00148 
00150         bool mRenderingDisabled;
00152         Listener* mListener;
00153 
00155         mutable LightList mLightList;
00157         mutable ulong mLightListUpdated;
00158 
00160         uint32 mLightMask;
00161 
00162         // Static members
00164         static uint32 msDefaultQueryFlags;
00166         static uint32 msDefaultVisibilityFlags;
00167 
00168 
00169 
00170     public:
00172         MovableObject();
00173 
00175         MovableObject(const String& name);
00178         virtual ~MovableObject();
00179 
00181         virtual void _notifyCreator(MovableObjectFactory* fact) { mCreator = fact; }
00183         virtual MovableObjectFactory*  _getCreator(void) const { return mCreator; }
00185         virtual void _notifyManager(SceneManager* man) { mManager = man; }
00187         virtual SceneManager* _getManager(void) const { return mManager; }
00188 
00190         virtual const String& getName(void) const { return mName; }
00191 
00193         virtual const String& getMovableType(void) const = 0;
00194 
00201         virtual Node* getParentNode(void) const;
00202 
00210         virtual SceneNode* getParentSceneNode(void) const;
00211 
00213         virtual bool isParentTagPoint() const { return mParentIsTagPoint; }
00214 
00217         virtual void _notifyAttached(Node* parent, bool isTagPoint = false);
00218 
00220         virtual bool isAttached(void) const;
00221 
00223         virtual void detachFromParent(void);
00224 
00228         virtual bool isInScene(void) const;
00229 
00232         virtual void _notifyMoved(void);
00233 
00239         virtual void _notifyCurrentCamera(Camera* cam);
00240 
00245         virtual const AxisAlignedBox& getBoundingBox(void) const = 0;
00246 
00250         virtual Real getBoundingRadius(void) const = 0;
00251 
00253         virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
00255         virtual const Sphere& getWorldBoundingSphere(bool derive = false) const;
00261         virtual void _updateRenderQueue(RenderQueue* queue) = 0;
00262 
00277         virtual void setVisible(bool visible);
00278 
00283         virtual bool getVisible(void) const;
00284 
00289         virtual bool isVisible(void) const;
00290 
00295         virtual void setRenderingDistance(Real dist) { 
00296             mUpperDistance = dist; 
00297             mSquaredUpperDistance = mUpperDistance * mUpperDistance;
00298         }
00299 
00301         virtual Real getRenderingDistance(void) const { return mUpperDistance; }        
00302 
00310         virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); }
00311 
00315         virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); }
00316 
00321         UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
00322 
00327         const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
00328 
00341         virtual void setRenderQueueGroup(uint8 queueID);
00342 
00358         virtual void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority);
00359 
00361         virtual uint8 getRenderQueueGroup(void) const;
00362 
00364         virtual const Matrix4& _getParentNodeFullTransform(void) const;
00365 
00373         virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; }
00374 
00377         virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; }
00378             
00381         virtual void removeQueryFlags(unsigned long flags) { mQueryFlags &= ~flags; }
00382         
00384         virtual uint32 getQueryFlags(void) const { return mQueryFlags; }
00385 
00388         static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; }
00389 
00392         static uint32 getDefaultQueryFlags() { return msDefaultQueryFlags; }
00393 
00394         
00401         virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; }
00402 
00405         virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; }
00406             
00409         virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; }
00410         
00412         virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; }
00413 
00416         static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; }
00417         
00420         static uint32 getDefaultVisibilityFlags() { return msDefaultVisibilityFlags; }
00421 
00427         virtual void setListener(Listener* listener) { mListener = listener; }
00428 
00431         virtual Listener* getListener(void) const { return mListener; }
00432 
00451         virtual const LightList& queryLights(void) const;
00452 
00457         virtual uint32 getLightMask()const { return mLightMask; }
00464         virtual void setLightMask(uint32 lightMask);
00465 
00472         virtual LightList* _getLightList() { return &mLightList; }
00473 
00475         EdgeData* getEdgeList(void) { return NULL; }
00477         bool hasEdgeList(void) { return false; }
00479         ShadowRenderableListIterator getShadowVolumeRenderableIterator(
00480             ShadowTechnique shadowTechnique, const Light* light, 
00481             HardwareIndexBufferSharedPtr* indexBuffer, 
00482             bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
00483         
00485         const AxisAlignedBox& getLightCapBounds(void) const;
00487         const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const;
00500         void setCastShadows(bool enabled) { mCastShadows = enabled; }
00502         bool getCastShadows(void) const { return mCastShadows; }
00506         bool getReceivesShadows();
00507             
00509         Real getPointExtrusionDistance(const Light* l) const;
00520         virtual uint32 getTypeFlags(void) const;
00521 
00533         virtual void visitRenderables(Renderable::Visitor* visitor, 
00534             bool debugRenderables = false) = 0;
00535 
00544         virtual void setDebugDisplayEnabled(bool enabled) { mDebugDisplay = enabled; }
00546         virtual bool isDebugDisplayEnabled(void) const { return mDebugDisplay; }
00547 
00548 
00549 
00550 
00551 
00552     };
00553 
00559     class _OgreExport MovableObjectFactory : public MovableAlloc
00560     {
00561     protected:
00563         unsigned long mTypeFlag;
00564 
00566         virtual MovableObject* createInstanceImpl(
00567             const String& name, const NameValuePairList* params = 0) = 0;
00568     public:
00569         MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {}
00570         virtual ~MovableObjectFactory() {}
00572         virtual const String& getType(void) const = 0;
00573 
00581         virtual MovableObject* createInstance(
00582             const String& name, SceneManager* manager, 
00583             const NameValuePairList* params = 0);
00585         virtual void destroyInstance(MovableObject* obj) = 0;
00586 
00600         virtual bool requestTypeFlags(void) const { return false; }
00609         void _notifyTypeFlags(unsigned long flag) { mTypeFlag = flag; }
00610 
00616         unsigned long getTypeFlags(void) const { return mTypeFlag; }
00617 
00618     };
00622 }
00623 #endif

Copyright © 2008 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52