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

angularmotor.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: angularmotor.cpp,v 1.2 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 "angularmotor.h"
00021 #include <zeitgeist/logserver/logserver.h>
00022 
00023 using namespace oxygen;
00024 using namespace boost;
00025 using namespace salt;
00026 
00027 AngularMotor::AngularMotor() : Joint()
00028 {
00029 }
00030 
00031 AngularMotor::~AngularMotor()
00032 {
00033 }
00034 
00035 void AngularMotor::OnLink()
00036 {
00037     dWorldID world = GetWorldID();
00038     if (world == 0)
00039         {
00040             return;
00041         }
00042 
00043     mODEJoint = dJointCreateAMotor(world, 0);
00044 }
00045 
00046 void AngularMotor::SetMode(EMotorMode mode)
00047 {
00048     dJointSetAMotorMode(mODEJoint,mode);
00049 }
00050 
00051 AngularMotor::EMotorMode AngularMotor::GetMode()
00052 {
00053     return static_cast<EMotorMode>(dJointGetAMotorMode(mODEJoint));
00054 }
00055 
00056 void AngularMotor::SetNumAxes(int num)
00057 {
00058     if (
00059         (num < 0) ||
00060         (num > 3)
00061         )
00062         {
00063             return;
00064         }
00065 
00066     dJointSetAMotorNumAxes(mODEJoint, num);
00067 }
00068 
00069 int AngularMotor::GetNumAxes()
00070 {
00071     return dJointGetAMotorNumAxes(mODEJoint);
00072 }
00073 
00074 void AngularMotor::SetMotorAxis(EAxisIndex idx, EAxisAnchor anchor,
00075                                 const salt::Vector3f& axis)
00076 {
00077     Vector3f globalAxis = GetWorldTransform() * axis;
00078     dJointSetAMotorAxis (mODEJoint, idx, anchor,
00079                          globalAxis[0], globalAxis[1], globalAxis[2]);
00080 }
00081 
00082 AngularMotor::EAxisAnchor AngularMotor::GetAxisAnchor(EAxisIndex idx)
00083 {
00084     return static_cast<EAxisAnchor>(dJointGetAMotorAxisRel (mODEJoint, idx));
00085 }
00086 
00087 Vector3f AngularMotor::GetMotorAxis(EAxisIndex idx)
00088 {
00089     dVector3 dAxis;
00090     dJointGetAMotorAxis(mODEJoint,idx,dAxis);
00091     return Vector3f(dAxis[0],dAxis[1],dAxis[2]);
00092 }
00093 
00094 void AngularMotor::SetAxisAngle(EAxisIndex idx, float degAngle)
00095 {
00096     dJointSetAMotorAngle(mODEJoint, idx, gDegToRad(degAngle));
00097 }
00098 
00099 float AngularMotor::GetAxisAngle(EAxisIndex idx)
00100 {
00101     return gRadToDeg(dJointGetAMotorAngle(mODEJoint, idx));
00102 }
00103 
00104 float AngularMotor::GetAxisAngleRate(EAxisIndex idx)
00105 {
00106     return gRadToDeg(dJointGetAMotorAngleRate(mODEJoint,idx));
00107 }
00108 
00109 void AngularMotor::SetParameter(int parameter, float value)
00110 {
00111     dJointSetAMotorParam(mODEJoint, parameter, value);
00112 }
00113 
00114 float AngularMotor::GetParameter(int parameter)
00115 {
00116     return dJointGetAMotorParam(mODEJoint, parameter);
00117 }
00118 
00119 
00120 

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