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 
00031 namespace Ogre {
00032 
00033     //-----------------------------------------------------------------------
00034     MovableObject::MovableObject()
00035     {
00036         mParentNode = 0;
00037         mVisible = true;
00038         mUserObject = 0;
00039         mRenderQueueID = RENDER_QUEUE_MAIN;
00040         mQueryFlags = 0xFFFFFFFF;
00041         mWorldAABB.setNull();
00042         mParentIsTagPoint = false;
00043     }
00044     //-----------------------------------------------------------------------
00045     MovableObject::~MovableObject()
00046     {
00047         if (mParentNode && !mParentIsTagPoint)
00048         {
00049             // detach from parent
00050             static_cast<SceneNode*>(mParentNode)->detachObject(this);
00051         }
00052     }
00053     //-----------------------------------------------------------------------
00054     void MovableObject::_notifyAttached(Node* parent, bool isTagPoint)
00055     {
00056         mParentNode = parent;
00057         mParentIsTagPoint = isTagPoint;
00058     }
00059     //-----------------------------------------------------------------------
00060     Node* MovableObject::getParentNode(void) const
00061     {
00062         return mParentNode;
00063     }
00064     //-----------------------------------------------------------------------
00065     bool MovableObject::isAttached(void) const
00066     {
00067         return (mParentNode != 0);
00068 
00069     }
00070     //-----------------------------------------------------------------------
00071     void MovableObject::setVisible(bool visible)
00072     {
00073         mVisible = visible;
00074     }
00075     //-----------------------------------------------------------------------
00076     bool MovableObject::isVisible(void) const
00077     {
00078         return mVisible;
00079 
00080     }
00081     //-----------------------------------------------------------------------
00082     void MovableObject::setRenderQueueGroup(RenderQueueGroupID queueID)
00083     {
00084         mRenderQueueID = queueID;
00085     }
00086     //-----------------------------------------------------------------------
00087     RenderQueueGroupID MovableObject::getRenderQueueGroup(void) const
00088     {
00089         return mRenderQueueID;
00090     }
00091     //-----------------------------------------------------------------------
00092     Matrix4 MovableObject::_getParentNodeFullTransform(void) const
00093     {
00094         
00095         if(mParentNode)
00096         {
00097             // object attached to a sceneNode
00098             return mParentNode->_getFullTransform();
00099         }
00100         // fallback
00101         return Matrix4::IDENTITY;
00102     }
00103     //-----------------------------------------------------------------------
00104     const AxisAlignedBox& MovableObject::getWorldBoundingBox(bool derive) const
00105     {
00106         if (derive)
00107         {
00108             mWorldAABB = this->getBoundingBox();
00109             mWorldAABB.transform(_getParentNodeFullTransform());
00110         }
00111 
00112         return mWorldAABB;
00113 
00114     }
00115     //-----------------------------------------------------------------------
00116     const Sphere& MovableObject::getWorldBoundingSphere(bool derive) const
00117     {
00118         if (derive)
00119         {
00120             mWorldBoundingSphere.setRadius(getBoundingRadius());
00121             mWorldBoundingSphere.setCenter(mParentNode->_getDerivedPosition());
00122         }
00123         return mWorldBoundingSphere;
00124     }
00125 
00126 }
00127 

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:19 2004