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-2004 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 #include "OgreMovablePlane.h" 00027 #include "OgreNode.h" 00028 00029 namespace Ogre { 00030 00031 String MovablePlane::msMovableType = "MovablePlane"; 00032 //----------------------------------------------------------------------- 00033 //----------------------------------------------------------------------- 00034 MovablePlane::MovablePlane(const String& name) : Plane(), 00035 mName(name), 00036 mLastTranlate(Vector3::ZERO), 00037 mLastRotate(Quaternion::IDENTITY), 00038 mDirty(true) 00039 { 00040 } 00041 //----------------------------------------------------------------------- 00042 MovablePlane::MovablePlane (const Plane& rhs) : Plane(rhs), 00043 mLastTranlate(Vector3::ZERO), mLastRotate(Quaternion::IDENTITY), 00044 mDirty(true) 00045 { 00046 } 00047 //----------------------------------------------------------------------- 00048 MovablePlane::MovablePlane (const Vector3& rkNormal, Real fConstant) 00049 : Plane (rkNormal, fConstant), mLastTranlate(Vector3::ZERO), 00050 mLastRotate(Quaternion::IDENTITY), mDirty(true) 00051 { 00052 } 00053 //----------------------------------------------------------------------- 00054 MovablePlane::MovablePlane (const Vector3& rkNormal, const Vector3& rkPoint) 00055 : Plane(rkNormal, rkPoint), mLastTranlate(Vector3::ZERO), 00056 mLastRotate(Quaternion::IDENTITY), mDirty(true) 00057 { 00058 } 00059 //----------------------------------------------------------------------- 00060 MovablePlane::MovablePlane (const Vector3& rkPoint0, const Vector3& rkPoint1, 00061 const Vector3& rkPoint2) 00062 : Plane(rkPoint0, rkPoint1, rkPoint2), mLastTranlate(Vector3::ZERO), 00063 mLastRotate(Quaternion::IDENTITY), mDirty(true) 00064 { 00065 } 00066 //----------------------------------------------------------------------- 00067 const Plane& MovablePlane::_getDerivedPlane(void) const 00068 { 00069 if (mParentNode) 00070 { 00071 if (mDirty || 00072 !(mParentNode->_getDerivedOrientation() == mLastRotate && 00073 mParentNode->_getDerivedPosition() == mLastTranlate)) 00074 { 00075 mLastRotate = mParentNode->_getDerivedOrientation(); 00076 mLastTranlate = mParentNode->_getDerivedPosition(); 00077 // Rotate normal 00078 mDerivedPlane.normal = mLastRotate * normal; 00079 // d remains the same in rotation, since rotation happens first 00080 mDerivedPlane.d = d; 00081 // Add on the effect of the translation (project onto new normal) 00082 mDerivedPlane.d -= mDerivedPlane.normal.dotProduct(mLastTranlate); 00083 00084 mDirty = false; 00085 00086 } 00087 } 00088 else 00089 { 00090 return *this; 00091 } 00092 00093 return mDerivedPlane; 00094 } 00095 //----------------------------------------------------------------------- 00096 const String& MovablePlane::getName(void) const 00097 { 00098 return mName; 00099 } 00100 //----------------------------------------------------------------------- 00101 const String& MovablePlane::getMovableType(void) const 00102 { 00103 return msMovableType; 00104 } 00105 }
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:36 2004