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

OgreTagPoint.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 "OgreTagPoint.h"
00028 #include "OgreMatrix4.h"
00029 #include "OgreMatrix3.h"
00030 #include "OgreEntity.h"
00031 #include "OgreSceneNode.h"
00032 #include "OgreSkeleton.h"
00033 #include "OgreQuaternion.h"
00034 
00035 
00036 namespace Ogre {
00037 
00038     //-----------------------------------------------------------------------------
00039     TagPoint::TagPoint(unsigned short handle, Skeleton* creator): Bone(handle, creator)
00040     {
00041         mParentEntity = 0; 
00042         mChildObject = 0; 
00043     }
00044     //-----------------------------------------------------------------------------
00045     TagPoint::~TagPoint()
00046     {
00047     }
00048     //-----------------------------------------------------------------------------
00049     Entity *TagPoint::getParentEntity(void)
00050     {
00051         return mParentEntity;
00052     }
00053     //-----------------------------------------------------------------------------
00054     void TagPoint::setParentEntity(Entity *pEntity)
00055     {
00056         mParentEntity = pEntity;
00057     }
00058     //-----------------------------------------------------------------------------
00059     void TagPoint::setChildObject(MovableObject *pObject)
00060     {
00061         mChildObject = pObject;
00062     }
00063     //-----------------------------------------------------------------------------
00064     Matrix4 TagPoint::_getFullTransform(void)
00065     {
00066         //return getParentEntityTransform() * Node::_getFullTransform();
00067         // Now that we're overriding updateFromParent(), this doesn't need to be different
00068         return Node::_getFullTransform();
00069     }
00070     //-----------------------------------------------------------------------------
00071     Matrix4 TagPoint::_getFullLocalTransform(void)
00072     {
00073         return mFullLocalTransform;
00074     }
00075     //-----------------------------------------------------------------------------
00076     Matrix4 TagPoint::getParentEntityTransform()
00077     {
00078 
00079         return mParentEntity->_getParentNodeFullTransform();
00080     }
00081     //-----------------------------------------------------------------------------
00082     void TagPoint::_update(bool updateChildren, bool parentHasChanged)
00083     {
00084         Node::_update(updateChildren, parentHasChanged);
00085     }
00086     //-----------------------------------------------------------------------------
00087     void TagPoint::needUpdate()
00088     {
00089         // We need to tell parent entities node
00090         if (mParentEntity)
00091         {
00092             Node* n = mParentEntity->getParentNode();
00093             if (n)
00094             {
00095                 n->needUpdate();
00096             }
00097 
00098         }
00099 
00100     }
00101     //-----------------------------------------------------------------------------
00102     void TagPoint::_updateFromParent(void) const
00103     {
00104         // Call superclass
00105         Bone::_updateFromParent();
00106 
00107         // Save transform for local skeleton
00108         makeTransform(mDerivedPosition, mDerivedScale, mDerivedOrientation, mFullLocalTransform);
00109 
00110         // Include Entity transform
00111         if (mParentEntity)
00112         {
00113             Node* entityParentNode = mParentEntity->getParentNode();
00114             if (entityParentNode)
00115             {
00116                 Quaternion mParentQ = entityParentNode->_getDerivedOrientation();
00117                 mDerivedOrientation = mParentQ * mDerivedOrientation;
00118 
00119                 // Change position vector based on parent's orientation
00120                 mDerivedPosition = mParentQ * mDerivedPosition;
00121 
00122 
00123                 // Add altered position vector to parents
00124                 mDerivedPosition += entityParentNode->_getDerivedPosition();
00125             }
00126         }
00127 
00128 
00129     }
00130     //-----------------------------------------------------------------------------
00131     const LightList& TagPoint::getLights(void) const
00132     {
00133         return mParentEntity->getParentSceneNode()->findLights(mParentEntity->getBoundingRadius());
00134     }
00135 
00136 }

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:48 2004