Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | 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 MovableObjectFactory*  _getCreator(void) const { return mCreator; }
00111         virtual void _notifyManager(SceneManager* man) { mManager = man; }
00113         virtual SceneManager* _getManager(void) const { return mManager; }
00114 
00116         virtual const String& getName(void) const { return mName; }
00117 
00119         virtual const String& getMovableType(void) const = 0;
00120 
00127         virtual Node* getParentNode(void) const;
00128 
00136         virtual SceneNode* getParentSceneNode(void) const;
00137 
00140         virtual void _notifyAttached(Node* parent, bool isTagPoint = false);
00141 
00143         virtual bool isAttached(void) const;
00144 
00148         virtual bool isInScene(void) const;
00149 
00155         virtual void _notifyCurrentCamera(Camera* cam);
00156 
00161         virtual const AxisAlignedBox& getBoundingBox(void) const = 0;
00162 
00166         virtual Real getBoundingRadius(void) const = 0;
00167 
00169         virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
00171         virtual const Sphere& getWorldBoundingSphere(bool derive = false) const;
00177         virtual void _updateRenderQueue(RenderQueue* queue) = 0;
00178 
00193         virtual void setVisible(bool visible);
00194 
00199         virtual bool getVisible(void) const;
00200 
00205         virtual bool isVisible(void) const;
00206 
00211         virtual void setRenderingDistance(Real dist) { 
00212             mUpperDistance = dist; 
00213             mSquaredUpperDistance = mUpperDistance * mUpperDistance;
00214         }
00215 
00217         virtual Real getRenderingDistance(void) const { return mUpperDistance; }
00218 
00225         virtual void setUserObject(UserDefinedObject* obj) { mUserAny = Any(obj); }
00229         virtual UserDefinedObject* getUserObject(void) 
00230         { 
00231             return mUserAny.isEmpty() ? 0 : any_cast<UserDefinedObject*>(mUserAny); 
00232         }
00233 
00241         virtual void setUserAny(const Any& anything) { mUserAny = anything; }
00242 
00245         virtual const Any& getUserAny(void) const { return mUserAny; }
00246 
00258         virtual void setRenderQueueGroup(uint8 queueID);
00259 
00261         virtual uint8 getRenderQueueGroup(void) const;
00262 
00264         virtual const Matrix4& _getParentNodeFullTransform(void) const;
00265 
00273         virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; }
00274 
00277         virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; }
00278             
00281         virtual void removeQueryFlags(unsigned long flags) { mQueryFlags &= ~flags; }
00282         
00284         virtual uint32 getQueryFlags(void) const { return mQueryFlags; }
00285 
00288         static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; }
00289 
00292         static uint32 getDefaultQueryFlags(uint32 flags) { return msDefaultQueryFlags; }
00293 
00294         
00301         virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; }
00302 
00305         virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; }
00306             
00309         virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; }
00310         
00312         virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; }
00313 
00316         static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; }
00317         
00320         static uint32 getDefaultVisibilityFlags(uint32 flags) { return msDefaultVisibilityFlags; }
00321 
00323         EdgeData* getEdgeList(void) { return NULL; }
00325         ShadowRenderableListIterator getShadowVolumeRenderableIterator(
00326             ShadowTechnique shadowTechnique, const Light* light, 
00327             HardwareIndexBufferSharedPtr* indexBuffer, 
00328             bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
00329         
00331         const AxisAlignedBox& getLightCapBounds(void) const;
00333         const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const;
00346         void setCastShadows(bool enabled) { mCastShadows = enabled; }
00348         bool getCastShadows(void) const { return mCastShadows; }
00350         Real getPointExtrusionDistance(const Light* l) const;
00361         virtual uint32 getTypeFlags(void) const;
00362 
00363 
00364 
00365 
00366 
00367     };
00368 
00374     class _OgreExport MovableObjectFactory 
00375     {
00376     protected:
00378         unsigned long mTypeFlag;
00379 
00381         virtual MovableObject* createInstanceImpl(
00382             const String& name, const NameValuePairList* params = 0) = 0;
00383     public:
00384         MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {}
00385         virtual ~MovableObjectFactory() {}
00387         virtual const String& getType(void) const = 0;
00388 
00396         virtual MovableObject* createInstance(
00397             const String& name, SceneManager* manager, 
00398             const NameValuePairList* params = 0);
00400         virtual void destroyInstance(MovableObject* obj) = 0;
00401 
00415         virtual bool requestTypeFlags(void) const { return false; }
00424         void _notifyTypeFlags(unsigned long flag) { mTypeFlag = flag; }
00425 
00431         unsigned long getTypeFlags(void) const { return mTypeFlag; }
00432 
00433     };
00434 
00435 }
00436 #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 Sep 17 15:39:10 2006