# 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-2006 Torus Knot Software Ltd
    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 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029
    00030 #ifndef __MovableObject_H__
    00031 #define __MovableObject_H__
    00032
    00033 // Precompiler options
    00034 #include "OgrePrerequisites.h"
    00035 #include "OgreRenderQueue.h"
    00036 #include "OgreAxisAlignedBox.h"
    00037 #include "OgreSphere.h"
    00038 #include "OgreShadowCaster.h"
    00039 #include "OgreFactoryObj.h"
    00040 #include "OgreAnimable.h"
    00041 #include "OgreAny.h"
    00042 #include "OgreUserDefinedObject.h"
    00043
    00044 namespace Ogre {
    00045
    00046     // Forward declaration
    00047     class MovableObjectFactory;
    00048
    00054     class _OgreExport MovableObject : public ShadowCaster, public AnimableObject, public MovableAlloc
    00055     {
    00056     public:
    00059         class _OgreExport Listener
    00060         {
    00061         public:
    00062             Listener(void) {}
    00063             virtual ~Listener() {}
    00065             virtual void objectDestroyed(MovableObject*) {}
    00067             virtual void objectAttached(MovableObject*) {}
    00069             virtual void objectDetached(MovableObject*) {}
    00071             virtual void objectMoved(MovableObject*) {}
    00076             virtual bool objectRendering(const MovableObject*, const Camera*) { return true; }
    00099             virtual const LightList* objectQueryLights(const MovableObject*) { return 0; }
    00100         };
    00101
    00102     protected:
    00104         String mName;
    00106         MovableObjectFactory* mCreator;
    00108         SceneManager* mManager;
    00110         Node* mParentNode;
    00111         bool mParentIsTagPoint;
    00113         bool mVisible;
    00115         bool mDebugDisplay;
    00117         Real mUpperDistance;
    00118         Real mSquaredUpperDistance;
    00120         bool mBeyondFarDistance;
    00122         Any mUserAny;
    00124         uint8 mRenderQueueID;
    00126         bool mRenderQueueIDSet;
    00128         uint32 mQueryFlags;
    00130         uint32 mVisibilityFlags;
    00132         mutable AxisAlignedBox mWorldAABB;
    00133         // Cached world bounding sphere
    00134         mutable Sphere mWorldBoundingSphere;
    00136         mutable AxisAlignedBox mWorldDarkCapBounds;
    00138         bool mCastShadows;
    00139
    00141         bool mRenderingDisabled;
    00143         Listener* mListener;
    00144
    00146         mutable LightList mLightList;
    00148         mutable ulong mLightListUpdated;
    00149
    00150         // Static members
    00152         static uint32 msDefaultQueryFlags;
    00154         static uint32 msDefaultVisibilityFlags;
    00155
    00156
    00157
    00158     public:
    00160         MovableObject();
    00161
    00163         MovableObject(const String& name);
    00166         virtual ~MovableObject();
    00167
    00169         virtual void _notifyCreator(MovableObjectFactory* fact) { mCreator = fact; }
    00171         virtual MovableObjectFactory*  _getCreator(void) const { return mCreator; }
    00173         virtual void _notifyManager(SceneManager* man) { mManager = man; }
    00175         virtual SceneManager* _getManager(void) const { return mManager; }
    00176
    00178         virtual const String& getName(void) const { return mName; }
    00179
    00181         virtual const String& getMovableType(void) const = 0;
    00182
    00189         virtual Node* getParentNode(void) const;
    00190
    00198         virtual SceneNode* getParentSceneNode(void) const;
    00199
    00202         virtual void _notifyAttached(Node* parent, bool isTagPoint = false);
    00203
    00205         virtual bool isAttached(void) const;
    00206
    00208         virtual void detatchFromParent(void);
    00209
    00213         virtual bool isInScene(void) const;
    00214
    00217         virtual void _notifyMoved(void);
    00218
    00224         virtual void _notifyCurrentCamera(Camera* cam);
    00225
    00230         virtual const AxisAlignedBox& getBoundingBox(void) const = 0;
    00231
    00235         virtual Real getBoundingRadius(void) const = 0;
    00236
    00238         virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
    00240         virtual const Sphere& getWorldBoundingSphere(bool derive = false) const;
    00246         virtual void _updateRenderQueue(RenderQueue* queue) = 0;
    00247
    00262         virtual void setVisible(bool visible);
    00263
    00268         virtual bool getVisible(void) const;
    00269
    00274         virtual bool isVisible(void) const;
    00275
    00280         virtual void setRenderingDistance(Real dist) {
    00281             mUpperDistance = dist;
    00282             mSquaredUpperDistance = mUpperDistance * mUpperDistance;
    00283         }
    00284
    00286         virtual Real getRenderingDistance(void) const { return mUpperDistance; }
    00287
    00294         virtual void setUserObject(UserDefinedObject* obj) { mUserAny = Any(obj); }
    00298         virtual UserDefinedObject* getUserObject(void)
    00299         {
    00300             return mUserAny.isEmpty() ? 0 : any_cast<UserDefinedObject*>(mUserAny);
    00301         }
    00302
    00310         virtual void setUserAny(const Any& anything) { mUserAny = anything; }
    00311
    00314         virtual const Any& getUserAny(void) const { return mUserAny; }
    00315
    00327         virtual void setRenderQueueGroup(uint8 queueID);
    00328
    00330         virtual uint8 getRenderQueueGroup(void) const;
    00331
    00333         virtual const Matrix4& _getParentNodeFullTransform(void) const;
    00334
    00342         virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; }
    00343
    00346         virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; }
    00347
    00350         virtual void removeQueryFlags(unsigned long flags) { mQueryFlags &= ~flags; }
    00351
    00353         virtual uint32 getQueryFlags(void) const { return mQueryFlags; }
    00354
    00357         static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; }
    00358
    00361         static uint32 getDefaultQueryFlags() { return msDefaultQueryFlags; }
    00362
    00363
    00370         virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; }
    00371
    00374         virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; }
    00375
    00378         virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; }
    00379
    00381         virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; }
    00382
    00385         static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; }
    00386
    00389         static uint32 getDefaultVisibilityFlags() { return msDefaultVisibilityFlags; }
    00390
    00396         virtual void setListener(Listener* listener) { mListener = listener; }
    00397
    00400         virtual Listener* getListener(void) const { return mListener; }
    00401
    00420         virtual const LightList& queryLights(void) const;
    00421
    00428         virtual LightList* _getLightList() { return &mLightList; }
    00429
    00431         EdgeData* getEdgeList(void) { return NULL; }
    00433         bool hasEdgeList(void) { return false; }
    00435         ShadowRenderableListIterator getShadowVolumeRenderableIterator(
    00436             ShadowTechnique shadowTechnique, const Light* light,
    00437             HardwareIndexBufferSharedPtr* indexBuffer,
    00438             bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
    00439
    00441         const AxisAlignedBox& getLightCapBounds(void) const;
    00443         const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const;
    00456         void setCastShadows(bool enabled) { mCastShadows = enabled; }
    00458         bool getCastShadows(void) const { return mCastShadows; }
    00460         Real getPointExtrusionDistance(const Light* l) const;
    00471         virtual uint32 getTypeFlags(void) const;
    00472
    00484         virtual void visitRenderables(Renderable::Visitor* visitor,
    00485             bool debugRenderables = false) = 0;
    00486
    00495         virtual void setDebugDisplayEnabled(bool enabled) { mDebugDisplay = enabled; }
    00497         virtual bool isDebugDisplayEnabled(void) const { return mDebugDisplay; }
    00498
    00499
    00500
    00501
    00502
    00503     };
    00504
    00510     class _OgreExport MovableObjectFactory : public MovableAlloc
    00511     {
    00512     protected:
    00514         unsigned long mTypeFlag;
    00515
    00517         virtual MovableObject* createInstanceImpl(
    00518             const String& name, const NameValuePairList* params = 0) = 0;
    00519     public:
    00520         MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {}
    00521         virtual ~MovableObjectFactory() {}
    00523         virtual const String& getType(void) const = 0;
    00524
    00532         virtual MovableObject* createInstance(
    00533             const String& name, SceneManager* manager,
    00534             const NameValuePairList* params = 0);
    00536         virtual void destroyInstance(MovableObject* obj) = 0;
    00537
    00551         virtual bool requestTypeFlags(void) const { return false; }
    00560         void _notifyTypeFlags(unsigned long flag) { mTypeFlag = flag; }
    00561
    00567         unsigned long getTypeFlags(void) const { return mTypeFlag; }
    00568
    00569     };
    00570
    00571 }
    00572 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sat Apr 11 14:26:43 2009