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         //It's the parent entity that is currently updating the skeleton and his bones
00085         if(mParentEntity == mCreator->getCurrentEntity())
00086         {
00087             Node::_update(updateChildren, parentHasChanged);
00088         }
00089     }
00090     //-----------------------------------------------------------------------------
00091     void TagPoint::needUpdate()
00092     {
00093         // We need to tell parent entities node
00094         if (mParentEntity)
00095         {
00096             Node* n = mParentEntity->getParentNode();
00097             if (n)
00098             {
00099                 n->needUpdate();
00100             }
00101 
00102         }
00103 
00104     }
00105     //-----------------------------------------------------------------------------
00106     void TagPoint::_updateFromParent(void) const
00107     {
00108         // Call superclass
00109         Bone::_updateFromParent();
00110 
00111         // Save transform for local skeleton
00112         makeTransform(mDerivedPosition, mDerivedScale, mDerivedOrientation, mFullLocalTransform);
00113 
00114         // Include Entity transform
00115         if (mParentEntity)
00116         {
00117             Node* entityParentNode = mParentEntity->getParentNode();
00118             if (entityParentNode)
00119             {
00120                 Quaternion mParentQ = entityParentNode->_getDerivedOrientation();
00121                 mDerivedOrientation = mParentQ * mDerivedOrientation;
00122 
00123                 // Change position vector based on parent's orientation
00124                 mDerivedPosition = mParentQ * mDerivedPosition;
00125 
00126 
00127                 // Add altered position vector to parents
00128                 mDerivedPosition += entityParentNode->_getDerivedPosition();
00129             }
00130         }
00131 
00132 
00133     }
00134     //-----------------------------------------------------------------------------
00135     const LightList& TagPoint::getLights(void) const
00136     {
00137         return mParentEntity->getParentNode()->getLights();
00138     }
00139 
00140 }

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