Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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-2005 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 
00026 #ifndef __MovableObject_H__
00027 #define __MovableObject_H__
00028 
00029 // Precompiler options
00030 #include "OgrePrerequisites.h"
00031 #include "OgreRenderQueue.h"
00032 #include "OgreAxisAlignedBox.h"
00033 #include "OgreSphere.h"
00034 #include "OgreShadowCaster.h"
00035 #include "OgreFactoryObj.h"
00036 #include "OgreAnimable.h"
00037 #include "OgreAny.h"
00038 #include "OgreUserDefinedObject.h"
00039 
00040 namespace Ogre {
00041 
00042     // Forward declaration
00043     class MovableObjectFactory;
00044 
00050     class _OgreExport MovableObject : public ShadowCaster, public AnimableObject
00051     {
00052     protected:
00054         String mName;
00056         MovableObjectFactory* mCreator;
00058         SceneManager* mManager;
00060         Node* mParentNode;
00061         bool mParentIsTagPoint;
00063         bool mVisible;
00065         Real mUpperDistance;
00066         Real mSquaredUpperDistance;
00068         bool mBeyondFarDistance;
00070         Any mUserAny;
00072         uint8 mRenderQueueID;
00074         bool mRenderQueueIDSet;
00076         uint32 mQueryFlags;
00078         uint32 mVisibilityFlags;
00080         mutable AxisAlignedBox mWorldAABB;
00081         // Cached world bounding sphere
00082         mutable Sphere mWorldBoundingSphere;
00084         mutable AxisAlignedBox mWorldDarkCapBounds;
00086         bool mCastShadows;
00087 
00088         // Static members
00090         static uint32 msDefaultQueryFlags;
00092         static uint32 msDefaultVisibilityFlags;
00093 
00094 
00095 
00096     public:
00098         MovableObject();
00099 
00101         MovableObject(const String& name);
00104         virtual ~MovableObject();
00105 
00107         virtual void _notifyCreator(MovableObjectFactory* fact) { mCreator = fact; }
00109         virtual void _notifyManager(SceneManager* man) { mManager = man; }
00111         virtual SceneManager* _getManager(void) const { return mManager; }
00112 
00114         virtual const String& getName(void) const { return mName; }
00115 
00117         virtual const String& getMovableType(void) const = 0;
00118 
00125         virtual Node* getParentNode(void) const;
00126 
00134         virtual SceneNode* getParentSceneNode(void) const;
00135 
00138         virtual void _notifyAttached(Node* parent, bool isTagPoint = false);
00139 
00141         virtual bool isAttached(void) const;
00142 
00146         virtual bool isInScene(void) const;
00147 
00153         virtual void _notifyCurrentCamera(Camera* cam);
00154 
00159         virtual const AxisAlignedBox& getBoundingBox(void) const = 0;
00160 
00164         virtual Real getBoundingRadius(void) const = 0;
00165 
00167         virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
00169         virtual const Sphere& getWorldBoundingSphere(bool derive = false) const;
00175         virtual void _updateRenderQueue(RenderQueue* queue) = 0;
00176 
00191         virtual void setVisible(bool visible);
00192 
00197         virtual bool isVisible(void) const;
00202         virtual void setRenderingDistance(Real dist) { 
00203             mUpperDistance = dist; 
00204             mSquaredUpperDistance = mUpperDistance * mUpperDistance;
00205         }
00206 
00208         virtual Real getRenderingDistance(void) const { return mUpperDistance; }
00209 
00216         virtual void setUserObject(UserDefinedObject* obj) { mUserAny = Any(obj); }
00220         virtual UserDefinedObject* getUserObject(void) 
00221         { 
00222             return mUserAny.isEmpty() ? 0 : any_cast<UserDefinedObject*>(mUserAny); 
00223         }
00224 
00232         virtual void setUserAny(const Any& anything) { mUserAny = anything; }
00233 
00236         virtual const Any& getUserAny(void) const { return mUserAny; }
00237 
00249         virtual void setRenderQueueGroup(uint8 queueID);
00250 
00252         virtual uint8 getRenderQueueGroup(void) const;
00253 
00255         virtual Matrix4 _getParentNodeFullTransform(void) const;
00256 
00264         virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; }
00265 
00268         virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; }
00269             
00272         virtual void removeQueryFlags(unsigned long flags) { mQueryFlags &= ~flags; }
00273         
00275         virtual uint32 getQueryFlags(void) const { return mQueryFlags; }
00276 
00279         static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; }
00280 
00283         static uint32 getDefaultQueryFlags(uint32 flags) { return msDefaultQueryFlags; }
00284 
00285         
00292         virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; }
00293 
00296         virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; }
00297             
00300         virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; }
00301         
00303         virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; }
00304 
00307         static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; }
00308         
00311         static uint32 getDefaultVisibilityFlags(uint32 flags) { return msDefaultVisibilityFlags; }
00312 
00314         EdgeData* getEdgeList(void) { return NULL; }
00316         ShadowRenderableListIterator getShadowVolumeRenderableIterator(
00317             ShadowTechnique shadowTechnique, const Light* light, 
00318             HardwareIndexBufferSharedPtr* indexBuffer, 
00319             bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
00320         
00322         const AxisAlignedBox& getLightCapBounds(void) const;
00324         const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const;
00337         void setCastShadows(bool enabled) { mCastShadows = enabled; }
00339         bool getCastShadows(void) const { return mCastShadows; }
00341         Real getPointExtrusionDistance(const Light* l) const;
00352         virtual uint32 getTypeFlags(void) const;
00353 
00354 
00355 
00356 
00357 
00358     };
00359 
00365     class _OgreExport MovableObjectFactory 
00366     {
00367     protected:
00369         unsigned long mTypeFlag;
00370 
00372         virtual MovableObject* createInstanceImpl(
00373             const String& name, const NameValuePairList* params = 0) = 0;
00374     public:
00375         MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {}
00376         virtual ~MovableObjectFactory() {}
00378         virtual const String& getType(void) const = 0;
00379 
00387         virtual MovableObject* createInstance(
00388             const String& name, SceneManager* manager, 
00389             const NameValuePairList* params = 0);
00391         virtual void destroyInstance(MovableObject* obj) = 0;
00392 
00406         virtual bool requestTypeFlags(void) const { return false; }
00415         void _notifyTypeFlags(unsigned long flag) { mTypeFlag = flag; }
00416 
00422         unsigned long getTypeFlags(void) const { return mTypeFlag; }
00423 
00424     };
00425 
00426 }
00427 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:44 2006