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-2012 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; 00124 // Minimum pixel size to still render 00125 Real mMinPixelSize; 00127 bool mBeyondFarDistance; 00129 UserObjectBindings mUserObjectBindings; 00131 uint8 mRenderQueueID; 00133 bool mRenderQueueIDSet; 00135 ushort mRenderQueuePriority; 00137 bool mRenderQueuePrioritySet; 00139 uint32 mQueryFlags; 00141 uint32 mVisibilityFlags; 00143 mutable AxisAlignedBox mWorldAABB; 00144 // Cached world bounding sphere 00145 mutable Sphere mWorldBoundingSphere; 00147 mutable AxisAlignedBox mWorldDarkCapBounds; 00149 bool mCastShadows; 00150 00152 bool mRenderingDisabled; 00154 Listener* mListener; 00155 00157 mutable LightList mLightList; 00159 mutable ulong mLightListUpdated; 00160 00162 uint32 mLightMask; 00163 00164 // Static members 00166 static uint32 msDefaultQueryFlags; 00168 static uint32 msDefaultVisibilityFlags; 00169 00170 00171 00172 public: 00174 MovableObject(); 00175 00177 MovableObject(const String& name); 00180 virtual ~MovableObject(); 00181 00183 virtual void _notifyCreator(MovableObjectFactory* fact) { mCreator = fact; } 00185 virtual MovableObjectFactory* _getCreator(void) const { return mCreator; } 00187 virtual void _notifyManager(SceneManager* man) { mManager = man; } 00189 virtual SceneManager* _getManager(void) const { return mManager; } 00190 00192 virtual const String& getName(void) const { return mName; } 00193 00195 virtual const String& getMovableType(void) const = 0; 00196 00203 virtual Node* getParentNode(void) const; 00204 00212 virtual SceneNode* getParentSceneNode(void) const; 00213 00215 virtual bool isParentTagPoint() const { return mParentIsTagPoint; } 00216 00219 virtual void _notifyAttached(Node* parent, bool isTagPoint = false); 00220 00222 virtual bool isAttached(void) const; 00223 00225 virtual void detachFromParent(void); 00226 00230 virtual bool isInScene(void) const; 00231 00234 virtual void _notifyMoved(void); 00235 00241 virtual void _notifyCurrentCamera(Camera* cam); 00242 00247 virtual const AxisAlignedBox& getBoundingBox(void) const = 0; 00248 00252 virtual Real getBoundingRadius(void) const = 0; 00253 00255 virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const; 00257 virtual const Sphere& getWorldBoundingSphere(bool derive = false) const; 00263 virtual void _updateRenderQueue(RenderQueue* queue) = 0; 00264 00279 virtual void setVisible(bool visible); 00280 00285 virtual bool getVisible(void) const; 00286 00291 virtual bool isVisible(void) const; 00292 00298 virtual void setRenderingDistance(Real dist) { 00299 mUpperDistance = dist; 00300 mSquaredUpperDistance = mUpperDistance * mUpperDistance; 00301 } 00302 00304 virtual Real getRenderingDistance(void) const { return mUpperDistance; } 00305 00311 virtual void setRenderingMinPixelSize(Real pixelSize) { 00312 mMinPixelSize = pixelSize; 00313 } 00314 00317 virtual Real getRenderingMinPixelSize() const { 00318 return mMinPixelSize; 00319 } 00320 00328 virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); } 00329 00333 virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); } 00334 00339 UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; } 00340 00345 const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; } 00346 00359 virtual void setRenderQueueGroup(uint8 queueID); 00360 00376 virtual void setRenderQueueGroupAndPriority(uint8 queueID, ushort priority); 00377 00379 virtual uint8 getRenderQueueGroup(void) const; 00380 00382 virtual const Matrix4& _getParentNodeFullTransform(void) const; 00383 00391 virtual void setQueryFlags(uint32 flags) { mQueryFlags = flags; } 00392 00395 virtual void addQueryFlags(uint32 flags) { mQueryFlags |= flags; } 00396 00399 virtual void removeQueryFlags(uint32 flags) { mQueryFlags &= ~flags; } 00400 00402 virtual uint32 getQueryFlags(void) const { return mQueryFlags; } 00403 00406 static void setDefaultQueryFlags(uint32 flags) { msDefaultQueryFlags = flags; } 00407 00410 static uint32 getDefaultQueryFlags() { return msDefaultQueryFlags; } 00411 00412 00419 virtual void setVisibilityFlags(uint32 flags) { mVisibilityFlags = flags; } 00420 00423 virtual void addVisibilityFlags(uint32 flags) { mVisibilityFlags |= flags; } 00424 00427 virtual void removeVisibilityFlags(uint32 flags) { mVisibilityFlags &= ~flags; } 00428 00430 virtual uint32 getVisibilityFlags(void) const { return mVisibilityFlags; } 00431 00434 static void setDefaultVisibilityFlags(uint32 flags) { msDefaultVisibilityFlags = flags; } 00435 00438 static uint32 getDefaultVisibilityFlags() { return msDefaultVisibilityFlags; } 00439 00445 virtual void setListener(Listener* listener) { mListener = listener; } 00446 00449 virtual Listener* getListener(void) const { return mListener; } 00450 00469 virtual const LightList& queryLights(void) const; 00470 00475 virtual uint32 getLightMask()const { return mLightMask; } 00482 virtual void setLightMask(uint32 lightMask); 00483 00490 virtual LightList* _getLightList() { return &mLightList; } 00491 00493 EdgeData* getEdgeList(void) { return NULL; } 00495 bool hasEdgeList(void) { return false; } 00497 ShadowRenderableListIterator getShadowVolumeRenderableIterator( 00498 ShadowTechnique shadowTechnique, const Light* light, 00499 HardwareIndexBufferSharedPtr* indexBuffer, 00500 bool extrudeVertices, Real extrusionDist, unsigned long flags = 0); 00501 00503 const AxisAlignedBox& getLightCapBounds(void) const; 00505 const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const; 00518 void setCastShadows(bool enabled) { mCastShadows = enabled; } 00520 bool getCastShadows(void) const { return mCastShadows; } 00524 bool getReceivesShadows(); 00525 00527 Real getPointExtrusionDistance(const Light* l) const; 00538 virtual uint32 getTypeFlags(void) const; 00539 00551 virtual void visitRenderables(Renderable::Visitor* visitor, 00552 bool debugRenderables = false) = 0; 00553 00562 virtual void setDebugDisplayEnabled(bool enabled) { mDebugDisplay = enabled; } 00564 virtual bool isDebugDisplayEnabled(void) const { return mDebugDisplay; } 00565 00566 00567 00568 00569 00570 }; 00571 00577 class _OgreExport MovableObjectFactory : public MovableAlloc 00578 { 00579 protected: 00581 unsigned long mTypeFlag; 00582 00584 virtual MovableObject* createInstanceImpl( 00585 const String& name, const NameValuePairList* params = 0) = 0; 00586 public: 00587 MovableObjectFactory() : mTypeFlag(0xFFFFFFFF) {} 00588 virtual ~MovableObjectFactory() {} 00590 virtual const String& getType(void) const = 0; 00591 00599 virtual MovableObject* createInstance( 00600 const String& name, SceneManager* manager, 00601 const NameValuePairList* params = 0); 00603 virtual void destroyInstance(MovableObject* obj) = 0; 00604 00618 virtual bool requestTypeFlags(void) const { return false; } 00627 void _notifyTypeFlags(unsigned long flag) { mTypeFlag = flag; } 00628 00634 uint32 getTypeFlags(void) const { return mTypeFlag; } 00635 00636 }; 00640 } 00641 #endif
Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:25 2012