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-2013 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 #include "OgreHeaderPrefix.h" 00043 00044 namespace Ogre { 00045 00046 // Forward declaration 00047 class MovableObjectFactory; 00048 00060 class _OgreExport MovableObject : public ShadowCaster, public AnimableObject, public MovableAlloc 00061 { 00062 public: 00065 class _OgreExport Listener 00066 { 00067 public: 00068 Listener(void) {} 00069 virtual ~Listener() {} 00071 virtual void objectDestroyed(MovableObject*) {} 00073 virtual void objectAttached(MovableObject*) {} 00075 virtual void objectDetached(MovableObject*) {} 00077 virtual void objectMoved(MovableObject*) {} 00082 virtual bool objectRendering(const MovableObject*, const Camera*) { return true; } 00105 virtual const LightList* objectQueryLights(const MovableObject*) { return 0; } 00106 }; 00107 00108 protected: 00110 String mName; 00112 MovableObjectFactory* mCreator; 00114 SceneManager* mManager; 00116 Node* mParentNode; 00117 bool mParentIsTagPoint; 00119 bool mVisible; 00121 bool mDebugDisplay; 00123 Real mUpperDistance; 00124 Real mSquaredUpperDistance; 00125 // Minimum pixel size to still render 00126 Real mMinPixelSize; 00128 bool mBeyondFarDistance; 00130 UserObjectBindings mUserObjectBindings; 00132 uint8 mRenderQueueID; 00134 bool mRenderQueueIDSet; 00136 ushort mRenderQueuePriority; 00138 bool mRenderQueuePrioritySet; 00140 uint32 mQueryFlags; 00142 uint32 mVisibilityFlags; 00144 mutable AxisAlignedBox mWorldAABB; 00145 // Cached world bounding sphere 00146 mutable Sphere mWorldBoundingSphere; 00148 mutable AxisAlignedBox mWorldDarkCapBounds; 00150 bool mCastShadows; 00151 00153 bool mRenderingDisabled; 00155 Listener* mListener; 00156 00158 mutable LightList mLightList; 00160 mutable ulong mLightListUpdated; 00161 00163 uint32 mLightMask; 00164 00165 // Static members 00167 static uint32 msDefaultQueryFlags; 00169 static uint32 msDefaultVisibilityFlags; 00170 00171 00172 00173 public: 00175 MovableObject(); 00176 00178 MovableObject(const String& name); 00181 virtual ~MovableObject(); 00182 00184 virtual void _notifyCreator(MovableObjectFactory* fact) { mCreator = fact; } 00186 virtual MovableObjectFactory* _getCreator(void) const { return mCreator; } 00188 virtual void _notifyManager(SceneManager* man) { mManager = man; } 00190 virtual SceneManager* _getManager(void) const { return mManager; } 00191 00193 virtual const String& getName(void) const { return mName; } 00194 00196 virtual const String& getMovableType(void) const = 0; 00197 00204 virtual Node* getParentNode(void) const; 00205 00213 virtual SceneNode* getParentSceneNode(void) const; 00214 00216 virtual bool isParentTagPoint() const { return mParentIsTagPoint; } 00217 00220 virtual void _notifyAttached(Node* parent, bool isTagPoint = false); 00221 00223 virtual bool isAttached(void) const; 00224 00226 virtual void detachFromParent(void); 00227 00231 virtual bool isInScene(void) const; 00232 00235 virtual void _notifyMoved(void); 00236 00242 virtual void _notifyCurrentCamera(Camera* cam); 00243 00248 virtual const AxisAlignedBox& getBoundingBox(void) const = 0; 00249 00253 virtual Real getBoundingRadius(void) const = 0; 00254 00256 virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const; 00258 virtual const Sphere& getWorldBoundingSphere(bool derive = false) const; 00264 virtual void _updateRenderQueue(RenderQueue* queue) = 0; 00265 00280 virtual void setVisible(bool visible); 00281 00286 virtual bool getVisible(void) const; 00287 00292 virtual bool isVisible(void) const; 00293 00299 virtual void setRenderingDistance(Real dist) { 00300 mUpperDistance = dist; 00301 mSquaredUpperDistance = mUpperDistance * mUpperDistance; 00302 } 00303 00305 virtual Real getRenderingDistance(void) const { return mUpperDistance; } 00306 00312 virtual void setRenderingMinPixelSize(Real pixelSize) { 00313 mMinPixelSize = pixelSize; 00314 } 00315 00318 virtual Real getRenderingMinPixelSize() const { 00319 return mMinPixelSize; 00320 } 00321 00329 OGRE_DEPRECATED virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); } 00330 00334 OGRE_DEPRECATED virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); } 00335 00340 UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; } 00341 00346 const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; } 00347 00360 virtual void setRenderQueueGroup(uint8 queueID); 00361 00377 virtual void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority); 00378 00380 virtual uint8 getRenderQueueGroup(void) const; 00381 00383 virtual const Matrix4& _getParentNodeFullTransform(void) const; 00384 00392 virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; } 00393 00396 virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; } 00397 00400 virtual void removeQueryFlags(uint32 flags) { mQueryFlags &= ~flags; } 00401 00403 virtual uint32 getQueryFlags(void) const { return mQueryFlags; } 00404 00407 static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; } 00408 00411 static uint32 getDefaultQueryFlags() { return msDefaultQueryFlags; } 00412 00413 00420 virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; } 00421 00424 virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; } 00425 00428 virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; } 00429 00431 virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; } 00432 00435 static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; } 00436 00439 static uint32 getDefaultVisibilityFlags() { return msDefaultVisibilityFlags; } 00440 00446 virtual void setListener(Listener* listener) { mListener = listener; } 00447 00450 virtual Listener* getListener(void) const { return mListener; } 00451 00470 virtual const LightList& queryLights(void) const; 00471 00476 virtual uint32 getLightMask()const { return mLightMask; } 00483 virtual void setLightMask(uint32 lightMask); 00484 00491 virtual LightList* _getLightList() { return &mLightList; } 00492 00494 EdgeData* getEdgeList(void) { return NULL; } 00496 bool hasEdgeList(void) { return false; } 00498 ShadowRenderableListIterator getShadowVolumeRenderableIterator( 00499 ShadowTechnique shadowTechnique, const Light* light, 00500 HardwareIndexBufferSharedPtr* indexBuffer, size_t* indexBufferUsedSize, 00501 bool extrudeVertices, Real extrusionDist, unsigned long flags = 0); 00502 00504 const AxisAlignedBox& getLightCapBounds(void) const; 00506 const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const; 00519 void setCastShadows(bool enabled) { mCastShadows = enabled; } 00521 bool getCastShadows(void) const { return mCastShadows; } 00525 bool getReceivesShadows(); 00526 00528 Real getPointExtrusionDistance(const Light* l) const; 00539 virtual uint32 getTypeFlags(void) const; 00540 00552 virtual void visitRenderables(Renderable::Visitor* visitor, 00553 bool debugRenderables = false) = 0; 00554 00563 virtual void setDebugDisplayEnabled(bool enabled) { mDebugDisplay = enabled; } 00565 virtual bool isDebugDisplayEnabled(void) const { return mDebugDisplay; } 00566 00567 00568 00569 00570 00571 }; 00572 00578 class _OgreExport MovableObjectFactory : public MovableAlloc 00579 { 00580 protected: 00582 uint32 mTypeFlag; 00583 00585 virtual MovableObject* createInstanceImpl( 00586 const String& name, const NameValuePairList* params = 0) = 0; 00587 public: 00588 MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {} 00589 virtual ~MovableObjectFactory() {} 00591 virtual const String& getType(void) const = 0; 00592 00600 virtual MovableObject* createInstance( 00601 const String& name, SceneManager* manager, 00602 const NameValuePairList* params = 0); 00604 virtual void destroyInstance(MovableObject* obj) = 0; 00605 00619 virtual bool requestTypeFlags(void) const { return false; } 00628 void _notifyTypeFlags(uint32 flag) { mTypeFlag = flag; } 00629 00635 uint32 getTypeFlags(void) const { return mTypeFlag; } 00636 00637 }; 00641 } 00642 00643 #include "OgreHeaderSuffix.h" 00644 00645 #endif
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:44