00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of the OGRE Reference Application, a layer built 00004 on top of OGRE(Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright © 2000-2003 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 "OgreRefAppJoint.h" 00026 #include "OgreRefAppApplicationObject.h" 00027 00028 namespace OgreRefApp { 00029 00030 //------------------------------------------------------------------------- 00031 Joint::Joint(Joint::JointType jtype) 00032 : mType(jtype), mAnchor(Vector3::ZERO), mOdeJoint(NULL) 00033 { 00034 mAxes.first = Vector3::UNIT_X; 00035 mAxes.second = Vector3::UNIT_Z; 00036 00037 // Subclasses must set attachment since mOdeJoint must be created 00038 00039 } 00040 //------------------------------------------------------------------------- 00041 Joint::JointType Joint::getType(void) 00042 { 00043 return mType; 00044 } 00045 //------------------------------------------------------------------------- 00046 const Vector3& Joint::getAnchorPosition(void) 00047 { 00048 return mAnchor; 00049 } 00050 //------------------------------------------------------------------------- 00051 void Joint::setAttachments(ApplicationObject* obj1, ApplicationObject* obj2) 00052 { 00053 dBodyID b1, b2; 00054 b1 = b2 = 0; 00055 if (obj1) 00056 { 00057 assert(obj1->getOdeBody() && "Cannot attach objects which do not have ODE bodies."); 00058 b1 = obj1->getOdeBody()->id(); 00059 } 00060 if (obj2) 00061 { 00062 assert(obj2->getOdeBody() && "Cannot attach objects which do not have ODE bodies."); 00063 b2 = obj2->getOdeBody()->id(); 00064 } 00065 00066 mOdeJoint->attach(b1, b2); 00067 mAttachedObjects.first = obj1; 00068 mAttachedObjects.second = obj2; 00069 00070 } 00071 //------------------------------------------------------------------------- 00072 const std::pair<ApplicationObject*, ApplicationObject*>& 00073 Joint::getAttachments(void) 00074 { 00075 return mAttachedObjects; 00076 } 00077 //------------------------------------------------------------------------- 00078 const std::pair<Vector3, Vector3>& 00079 Joint::getAxes(void) 00080 { 00081 return mAxes; 00082 } 00083 //------------------------------------------------------------------------- 00084 00085 00086 00087 }
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:24 2004