Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

balljoint.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002    this file is part of rcssserver3D
00003    Fri May 9 2003
00004    Copyright (C) 2003 Koblenz University
00005    $Id: balljoint.cpp,v 1.5 2004/05/01 11:30:31 rollmark Exp $
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; version 2 of the License.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 #include "balljoint.h"
00021 
00022 using namespace oxygen;
00023 using namespace boost;
00024 using namespace salt;
00025 
00026 BallJoint::BallJoint() : Joint()
00027 {
00028 }
00029 
00030 BallJoint::~BallJoint()
00031 {
00032 }
00033 
00034 void BallJoint::OnLink()
00035 {
00036     dWorldID world = GetWorldID();
00037     if (world == 0)
00038         {
00039             return;
00040         }
00041 
00042     mODEJoint = dJointCreateBall(world, 0);
00043 }
00044 
00045 void BallJoint::SetAnchor(const Vector3f& anchor)
00046 {
00047     // calculate anchor position in world coordinates
00048     Vector3f gAnchor = GetWorldTransform() * anchor;
00049     dJointSetBallAnchor (mODEJoint, gAnchor[0], gAnchor[1], gAnchor[2]);
00050 }
00051 
00052 Vector3f BallJoint::GetAnchor(EBodyIndex idx)
00053 {
00054     Vector3f pos(0,0,0);
00055 
00056     switch (idx)
00057         {
00058         case BI_FIRST:
00059             {
00060                 dReal anchor[3];
00061                 dJointGetBallAnchor (mODEJoint, anchor);
00062                 pos = Vector3f(anchor[0],anchor[1],anchor[2]);
00063             }
00064 
00065         case BI_SECOND:
00066             {
00067                 dReal anchor[3];
00068                 dJointGetBallAnchor2(mODEJoint, anchor);
00069                 pos = Vector3f(anchor[0],anchor[1],anchor[2]);
00070             }
00071 
00072         default:
00073             break;
00074         }
00075 
00076     return GetLocalPos(pos);
00077 }
00078 
00079 void BallJoint::SetParameter(int /*parameter*/, float /*value*/)
00080 {
00081     // no ode set param fkt. defined
00082 }
00083 
00084 float BallJoint::GetParameter(int /*parameter*/)
00085 {
00086     // no ode get param fkt. defined
00087     return 0;
00088 }
00089 
00090 
00091 

Generated on Thu Apr 6 15:25:37 2006 for rcssserver3d by  doxygen 1.4.4