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-2009 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 
00029 #ifndef __MovableObject_H__
00030 #define __MovableObject_H__
00031 
00032 // Precompiler options
00033 #include "OgrePrerequisites.h"
00034 #include "OgreRenderQueue.h"
00035 #include "OgreAxisAlignedBox.h"
00036 #include "OgreSphere.h"
00037 #include "OgreShadowCaster.h"
00038 #include "OgreFactoryObj.h"
00039 #include "OgreAnimable.h"
00040 #include "OgreAny.h"
00041 #include "OgreUserObjectBindings.h"
00042 
00043 namespace Ogre {
00044 
00045     // Forward declaration
00046     class MovableObjectFactory;
00047 
00059     class _OgreExport MovableObject : public ShadowCaster, public AnimableObject, public MovableAlloc
00060     {
00061     public:
00064         class _OgreExport Listener
00065         {
00066         public:
00067             Listener(void) {}
00068             virtual ~Listener() {}
00070             virtual void objectDestroyed(MovableObject*) {}
00072             virtual void objectAttached(MovableObject*) {}
00074             virtual void objectDetached(MovableObject*) {}
00076             virtual void objectMoved(MovableObject*) {}
00081             virtual bool objectRendering(const MovableObject*, const Camera*) { return true; }
00104             virtual const LightList* objectQueryLights(const MovableObject*) { return 0; }
00105         };
00106 
00107     protected:
00109         String mName;
00111         MovableObjectFactory* mCreator;
00113         SceneManager* mManager;
00115         Node* mParentNode;
00116         bool mParentIsTagPoint;
00118         bool mVisible;
00120         bool mDebugDisplay;
00122         Real mUpperDistance;
00123         Real mSquaredUpperDistance;
00125         bool mBeyondFarDistance;    
00127         UserObjectBindings mUserObjectBindings;
00129         uint8 mRenderQueueID;
00131         bool mRenderQueueIDSet;
00133         uint32 mQueryFlags;
00135         uint32 mVisibilityFlags;
00137         mutable AxisAlignedBox mWorldAABB;
00138         // Cached world bounding sphere
00139         mutable Sphere mWorldBoundingSphere;
00141         mutable AxisAlignedBox mWorldDarkCapBounds;
00143         bool mCastShadows;
00144 
00146         bool mRenderingDisabled;
00148         Listener* mListener;
00149 
00151         mutable LightList mLightList;
00153         mutable ulong mLightListUpdated;
00154 
00156         uint32 mLightMask;
00157 
00158         // Static members
00160         static uint32 msDefaultQueryFlags;
00162         static uint32 msDefaultVisibilityFlags;
00163 
00164 
00165 
00166     public:
00168         MovableObject();
00169 
00171         MovableObject(const String& name);
00174         virtual ~MovableObject();
00175 
00177         virtual void _notifyCreator(MovableObjectFactory* fact) { mCreator = fact; }
00179         virtual MovableObjectFactory*  _getCreator(void) const { return mCreator; }
00181         virtual void _notifyManager(SceneManager* man) { mManager = man; }
00183         virtual SceneManager* _getManager(void) const { return mManager; }
00184 
00186         virtual const String& getName(void) const { return mName; }
00187 
00189         virtual const String& getMovableType(void) const = 0;
00190 
00197         virtual Node* getParentNode(void) const;
00198 
00206         virtual SceneNode* getParentSceneNode(void) const;
00207 
00209         virtual bool isParentTagPoint() const { return mParentIsTagPoint; }
00210 
00213         virtual void _notifyAttached(Node* parent, bool isTagPoint = false);
00214 
00216         virtual bool isAttached(void) const;
00217 
00219         virtual void detachFromParent(void);
00220 
00224         virtual bool isInScene(void) const;
00225 
00228         virtual void _notifyMoved(void);
00229 
00235         virtual void _notifyCurrentCamera(Camera* cam);
00236 
00241         virtual const AxisAlignedBox& getBoundingBox(void) const = 0;
00242 
00246         virtual Real getBoundingRadius(void) const = 0;
00247 
00249         virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const;
00251         virtual const Sphere& getWorldBoundingSphere(bool derive = false) const;
00257         virtual void _updateRenderQueue(RenderQueue* queue) = 0;
00258 
00273         virtual void setVisible(bool visible);
00274 
00279         virtual bool getVisible(void) const;
00280 
00285         virtual bool isVisible(void) const;
00286 
00291         virtual void setRenderingDistance(Real dist) { 
00292             mUpperDistance = dist; 
00293             mSquaredUpperDistance = mUpperDistance * mUpperDistance;
00294         }
00295 
00297         virtual Real getRenderingDistance(void) const { return mUpperDistance; }        
00298 
00306         virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); }
00307 
00311         virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); }
00312 
00317         UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
00318 
00323         const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
00324 
00337         virtual void setRenderQueueGroup(uint8 queueID);
00338 
00340         virtual uint8 getRenderQueueGroup(void) const;
00341 
00343         virtual const Matrix4& _getParentNodeFullTransform(void) const;
00344 
00352         virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; }
00353 
00356         virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; }
00357             
00360         virtual void removeQueryFlags(unsigned long flags) { mQueryFlags &= ~flags; }
00361         
00363         virtual uint32 getQueryFlags(void) const { return mQueryFlags; }
00364 
00367         static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; }
00368 
00371         static uint32 getDefaultQueryFlags() { return msDefaultQueryFlags; }
00372 
00373         
00380         virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; }
00381 
00384         virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; }
00385             
00388         virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; }
00389         
00391         virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; }
00392 
00395         static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; }
00396         
00399         static uint32 getDefaultVisibilityFlags() { return msDefaultVisibilityFlags; }
00400 
00406         virtual void setListener(Listener* listener) { mListener = listener; }
00407 
00410         virtual Listener* getListener(void) const { return mListener; }
00411 
00430         virtual const LightList& queryLights(void) const;
00431 
00436         virtual uint32 getLightMask()const { return mLightMask; }
00443         virtual void setLightMask(uint32 lightMask);
00444 
00451         virtual LightList* _getLightList() { return &mLightList; }
00452 
00454         EdgeData* getEdgeList(void) { return NULL; }
00456         bool hasEdgeList(void) { return false; }
00458         ShadowRenderableListIterator getShadowVolumeRenderableIterator(
00459             ShadowTechnique shadowTechnique, const Light* light, 
00460             HardwareIndexBufferSharedPtr* indexBuffer, 
00461             bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
00462         
00464         const AxisAlignedBox& getLightCapBounds(void) const;
00466         const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const;
00479         void setCastShadows(bool enabled) { mCastShadows = enabled; }
00481         bool getCastShadows(void) const { return mCastShadows; }
00485         bool getReceivesShadows();
00486             
00488         Real getPointExtrusionDistance(const Light* l) const;
00499         virtual uint32 getTypeFlags(void) const;
00500 
00512         virtual void visitRenderables(Renderable::Visitor* visitor, 
00513             bool debugRenderables = false) = 0;
00514 
00523         virtual void setDebugDisplayEnabled(bool enabled) { mDebugDisplay = enabled; }
00525         virtual bool isDebugDisplayEnabled(void) const { return mDebugDisplay; }
00526 
00527 
00528 
00529 
00530 
00531     };
00532 
00538     class _OgreExport MovableObjectFactory : public MovableAlloc
00539     {
00540     protected:
00542         unsigned long mTypeFlag;
00543 
00545         virtual MovableObject* createInstanceImpl(
00546             const String& name, const NameValuePairList* params = 0) = 0;
00547     public:
00548         MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {}
00549         virtual ~MovableObjectFactory() {}
00551         virtual const String& getType(void) const = 0;
00552 
00560         virtual MovableObject* createInstance(
00561             const String& name, SceneManager* manager, 
00562             const NameValuePairList* params = 0);
00564         virtual void destroyInstance(MovableObject* obj) = 0;
00565 
00579         virtual bool requestTypeFlags(void) const { return false; }
00588         void _notifyTypeFlags(unsigned long flag) { mTypeFlag = flag; }
00589 
00595         unsigned long getTypeFlags(void) const { return mTypeFlag; }
00596 
00597     };
00601 }
00602 #endif

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