# 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
    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; }
    00096             virtual const LightList* objectQueryLights(const MovableObject*) { return 0; }
    00097         };
    00098
    00099     protected:
    00101         String mName;
    00103         MovableObjectFactory* mCreator;
    00105         SceneManager* mManager;
    00107         Node* mParentNode;
    00108         bool mParentIsTagPoint;
    00110         bool mVisible;
    00112         Real mUpperDistance;
    00113         Real mSquaredUpperDistance;
    00115         bool mBeyondFarDistance;
    00117         Any mUserAny;
    00119         uint8 mRenderQueueID;
    00121         bool mRenderQueueIDSet;
    00123         uint32 mQueryFlags;
    00125         uint32 mVisibilityFlags;
    00127         mutable AxisAlignedBox mWorldAABB;
    00128         // Cached world bounding sphere
    00129         mutable Sphere mWorldBoundingSphere;
    00131         mutable AxisAlignedBox mWorldDarkCapBounds;
    00133         bool mCastShadows;
    00134
    00136         bool mRenderingDisabled;
    00138         Listener* mListener;
    00139
    00141         mutable LightList mLightList;
    00143         mutable ulong mLightListUpdated;
    00144
    00145         // Static members
    00147         static uint32 msDefaultQueryFlags;
    00149         static uint32 msDefaultVisibilityFlags;
    00150
    00151
    00152
    00153     public:
    00155         MovableObject();
    00156
    00158         MovableObject(const String& name);
    00161         virtual ~MovableObject();
    00162
    00164         virtual void _notifyCreator(MovableObjectFactory* fact) { mCreator = fact; }
    00166         virtual MovableObjectFactory*  _getCreator(void) const { return mCreator; }
    00168         virtual void _notifyManager(SceneManager* man) { mManager = man; }
    00170         virtual SceneManager* _getManager(void) const { return mManager; }
    00171
    00173         virtual const String& getName(void) const { return mName; }
    00174
    00176         virtual const String& getMovableType(void) const = 0;
    00177
    00184         virtual Node* getParentNode(void) const;
    00185
    00193         virtual SceneNode* getParentSceneNode(void) const;
    00194
    00197         virtual void _notifyAttached(Node* parent, bool isTagPoint = false);
    00198
    00200         virtual bool isAttached(void) const;
    00201
    00205         virtual bool isInScene(void) const;
    00206
    00209         virtual void _notifyMoved(void);
    00210
    00216         virtual void _notifyCurrentCamera(Camera* cam);
    00217
    00222         virtual const AxisAlignedBox& getBoundingBox(void) const = 0;
    00223
    00227         virtual Real getBoundingRadius(void) const = 0;
    00228
    00230         virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
    00232         virtual const Sphere& getWorldBoundingSphere(bool derive = false) const;
    00238         virtual void _updateRenderQueue(RenderQueue* queue) = 0;
    00239
    00254         virtual void setVisible(bool visible);
    00255
    00260         virtual bool getVisible(void) const;
    00261
    00266         virtual bool isVisible(void) const;
    00267
    00272         virtual void setRenderingDistance(Real dist) {
    00273             mUpperDistance = dist;
    00274             mSquaredUpperDistance = mUpperDistance * mUpperDistance;
    00275         }
    00276
    00278         virtual Real getRenderingDistance(void) const { return mUpperDistance; }
    00279
    00286         virtual void setUserObject(UserDefinedObject* obj) { mUserAny = Any(obj); }
    00290         virtual UserDefinedObject* getUserObject(void)
    00291         {
    00292             return mUserAny.isEmpty() ? 0 : any_cast<UserDefinedObject*>(mUserAny);
    00293         }
    00294
    00302         virtual void setUserAny(const Any& anything) { mUserAny = anything; }
    00303
    00306         virtual const Any& getUserAny(void) const { return mUserAny; }
    00307
    00319         virtual void setRenderQueueGroup(uint8 queueID);
    00320
    00322         virtual uint8 getRenderQueueGroup(void) const;
    00323
    00325         virtual const Matrix4& _getParentNodeFullTransform(void) const;
    00326
    00334         virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; }
    00335
    00338         virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; }
    00339
    00342         virtual void removeQueryFlags(unsigned long flags) { mQueryFlags &= ~flags; }
    00343
    00345         virtual uint32 getQueryFlags(void) const { return mQueryFlags; }
    00346
    00349         static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; }
    00350
    00353         static uint32 getDefaultQueryFlags() { return msDefaultQueryFlags; }
    00354
    00355
    00362         virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; }
    00363
    00366         virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; }
    00367
    00370         virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; }
    00371
    00373         virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; }
    00374
    00377         static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; }
    00378
    00381         static uint32 getDefaultVisibilityFlags() { return msDefaultVisibilityFlags; }
    00382
    00388         virtual void setListener(Listener* listener) { mListener = listener; }
    00389
    00392         virtual Listener* getListener(void) const { return mListener; }
    00393
    00412         virtual const LightList& queryLights(void) const;
    00413
    00415         EdgeData* getEdgeList(void) { return NULL; }
    00417         bool hasEdgeList(void) { return false; }
    00419         ShadowRenderableListIterator getShadowVolumeRenderableIterator(
    00420             ShadowTechnique shadowTechnique, const Light* light,
    00421             HardwareIndexBufferSharedPtr* indexBuffer,
    00422             bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
    00423
    00425         const AxisAlignedBox& getLightCapBounds(void) const;
    00427         const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const;
    00440         void setCastShadows(bool enabled) { mCastShadows = enabled; }
    00442         bool getCastShadows(void) const { return mCastShadows; }
    00444         Real getPointExtrusionDistance(const Light* l) const;
    00455         virtual uint32 getTypeFlags(void) const;
    00456
    00457
    00458
    00459
    00460
    00461     };
    00462
    00468     class _OgreExport MovableObjectFactory
    00469     {
    00470     protected:
    00472         unsigned long mTypeFlag;
    00473
    00475         virtual MovableObject* createInstanceImpl(
    00476             const String& name, const NameValuePairList* params = 0) = 0;
    00477     public:
    00478         MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {}
    00479         virtual ~MovableObjectFactory() {}
    00481         virtual const String& getType(void) const = 0;
    00482
    00490         virtual MovableObject* createInstance(
    00491             const String& name, SceneManager* manager,
    00492             const NameValuePairList* params = 0);
    00494         virtual void destroyInstance(MovableObject* obj) = 0;
    00495
    00509         virtual bool requestTypeFlags(void) const { return false; }
    00518         void _notifyTypeFlags(unsigned long flag) { mTypeFlag = flag; }
    00519
    00525         unsigned long getTypeFlags(void) const { return mTypeFlag; }
    00526
    00527     };
    00528
    00529 }
    00530 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sat May 10 16:25:00 2008