# 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
    00328         virtual void setRenderQueueGroup(uint8 queueID);
    00329
    00331         virtual uint8 getRenderQueueGroup(void) const;
    00332
    00334         virtual const Matrix4& _getParentNodeFullTransform(void) const;
    00335
    00343         virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; }
    00344
    00347         virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; }
    00348
    00351         virtual void removeQueryFlags(unsigned long flags) { mQueryFlags &= ~flags; }
    00352
    00354         virtual uint32 getQueryFlags(void) const { return mQueryFlags; }
    00355
    00358         static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; }
    00359
    00362         static uint32 getDefaultQueryFlags() { return msDefaultQueryFlags; }
    00363
    00364
    00371         virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; }
    00372
    00375         virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; }
    00376
    00379         virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; }
    00380
    00382         virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; }
    00383
    00386         static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; }
    00387
    00390         static uint32 getDefaultVisibilityFlags() { return msDefaultVisibilityFlags; }
    00391
    00397         virtual void setListener(Listener* listener) { mListener = listener; }
    00398
    00401         virtual Listener* getListener(void) const { return mListener; }
    00402
    00421         virtual const LightList& queryLights(void) const;
    00422
    00429         virtual LightList* _getLightList() { return &mLightList; }
    00430
    00432         EdgeData* getEdgeList(void) { return NULL; }
    00434         bool hasEdgeList(void) { return false; }
    00436         ShadowRenderableListIterator getShadowVolumeRenderableIterator(
    00437             ShadowTechnique shadowTechnique, const Light* light,
    00438             HardwareIndexBufferSharedPtr* indexBuffer,
    00439             bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
    00440
    00442         const AxisAlignedBox& getLightCapBounds(void) const;
    00444         const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const;
    00457         void setCastShadows(bool enabled) { mCastShadows = enabled; }
    00459         bool getCastShadows(void) const { return mCastShadows; }
    00463         bool getReceivesShadows();
    00464
    00466         Real getPointExtrusionDistance(const Light* l) const;
    00477         virtual uint32 getTypeFlags(void) const;
    00478
    00490         virtual void visitRenderables(Renderable::Visitor* visitor,
    00491             bool debugRenderables = false) = 0;
    00492
    00501         virtual void setDebugDisplayEnabled(bool enabled) { mDebugDisplay = enabled; }
    00503         virtual bool isDebugDisplayEnabled(void) const { return mDebugDisplay; }
    00504
    00505
    00506
    00507
    00508
    00509     };
    00510
    00516     class _OgreExport MovableObjectFactory : public MovableAlloc
    00517     {
    00518     protected:
    00520         unsigned long mTypeFlag;
    00521
    00523         virtual MovableObject* createInstanceImpl(
    00524             const String& name, const NameValuePairList* params = 0) = 0;
    00525     public:
    00526         MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {}
    00527         virtual ~MovableObjectFactory() {}
    00529         virtual const String& getType(void) const = 0;
    00530
    00538         virtual MovableObject* createInstance(
    00539             const String& name, SceneManager* manager,
    00540             const NameValuePairList* params = 0);
    00542         virtual void destroyInstance(MovableObject* obj) = 0;
    00543
    00557         virtual bool requestTypeFlags(void) const { return false; }
    00566         void _notifyTypeFlags(unsigned long flag) { mTypeFlag = flag; }
    00567
    00573         unsigned long getTypeFlags(void) const { return mTypeFlag; }
    00574
    00575     };
    00576
    00577 }
    00578 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Dec 27 17:31:06 2009