Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreMovableObject.cpp

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 © 2000-2002 The OGRE Team
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 */
00025 #include "OgreStableHeaders.h"
00026 
00027 #include "OgreMovableObject.h"
00028 #include "OgreSceneNode.h"
00029 #include "OgreTagPoint.h"
00030 #include "OgreLight.h"
00031 
00032 namespace Ogre {
00033 
00034     //-----------------------------------------------------------------------
00035     MovableObject::MovableObject()
00036     {
00037         mParentNode = 0;
00038         mVisible = true;
00039         mUserObject = 0;
00040         mRenderQueueID = RENDER_QUEUE_MAIN;
00041         mQueryFlags = 0xFFFFFFFF;
00042         mWorldAABB.setNull();
00043         mParentIsTagPoint = false;
00044         mCastShadows = true;
00045     }
00046     //-----------------------------------------------------------------------
00047     MovableObject::~MovableObject()
00048     {
00049         if (mParentNode && !mParentIsTagPoint)
00050         {
00051             // detach from parent
00052             static_cast<SceneNode*>(mParentNode)->detachObject(this);
00053         }
00054     }
00055     //-----------------------------------------------------------------------
00056     void MovableObject::_notifyAttached(Node* parent, bool isTagPoint)
00057     {
00058         mParentNode = parent;
00059         mParentIsTagPoint = isTagPoint;
00060     }
00061     //-----------------------------------------------------------------------
00062     Node* MovableObject::getParentNode(void) const
00063     {
00064         return mParentNode;
00065     }
00066     //-----------------------------------------------------------------------
00067     bool MovableObject::isAttached(void) const
00068     {
00069         return (mParentNode != 0);
00070 
00071     }
00072     //-----------------------------------------------------------------------
00073     void MovableObject::setVisible(bool visible)
00074     {
00075         mVisible = visible;
00076     }
00077     //-----------------------------------------------------------------------
00078     bool MovableObject::isVisible(void) const
00079     {
00080         return mVisible;
00081 
00082     }
00083     //-----------------------------------------------------------------------
00084     void MovableObject::setRenderQueueGroup(RenderQueueGroupID queueID)
00085     {
00086         mRenderQueueID = queueID;
00087     }
00088     //-----------------------------------------------------------------------
00089     RenderQueueGroupID MovableObject::getRenderQueueGroup(void) const
00090     {
00091         return mRenderQueueID;
00092     }
00093     //-----------------------------------------------------------------------
00094     Matrix4 MovableObject::_getParentNodeFullTransform(void) const
00095     {
00096         
00097         if(mParentNode)
00098         {
00099             // object attached to a sceneNode
00100             return mParentNode->_getFullTransform();
00101         }
00102         // fallback
00103         return Matrix4::IDENTITY;
00104     }
00105     //-----------------------------------------------------------------------
00106     const AxisAlignedBox& MovableObject::getWorldBoundingBox(bool derive) const
00107     {
00108         if (derive)
00109         {
00110             mWorldAABB = this->getBoundingBox();
00111             mWorldAABB.transform(_getParentNodeFullTransform());
00112         }
00113 
00114         return mWorldAABB;
00115 
00116     }
00117     //-----------------------------------------------------------------------
00118     const Sphere& MovableObject::getWorldBoundingSphere(bool derive) const
00119     {
00120         if (derive)
00121         {
00122             mWorldBoundingSphere.setRadius(getBoundingRadius());
00123             mWorldBoundingSphere.setCenter(mParentNode->_getDerivedPosition());
00124         }
00125         return mWorldBoundingSphere;
00126     }
00127 
00128     //-----------------------------------------------------------------------
00129     const AxisAlignedBox& MovableObject::getLightCapBounds(void) const
00130     {
00131         // Same as original bounds
00132         return getWorldBoundingBox();
00133     }
00134     //-----------------------------------------------------------------------
00135     const AxisAlignedBox& MovableObject::getDarkCapBounds(const Light& light, Real extrusionDist) const
00136     {
00137         // Extrude own light cap bounds
00138         mWorldDarkCapBounds = getLightCapBounds();
00139         this->extrudeBounds(mWorldDarkCapBounds, light.getAs4DVector(), 
00140             extrusionDist);
00141         return mWorldDarkCapBounds;
00142 
00143     }
00144     //-----------------------------------------------------------------------
00145     Real MovableObject::getPointExtrusionDistance(const Light* l) const
00146     {
00147         if (mParentNode)
00148         {
00149             return getExtrusionDistance(mParentNode->_getDerivedPosition(), l);
00150         }
00151         else
00152         {
00153             return 0;
00154         }
00155     }
00156 
00157 
00158 }
00159 

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:28 2004