00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
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 , float )
00080 {
00081
00082 }
00083
00084 float BallJoint::GetParameter(int )
00085 {
00086
00087 return 0;
00088 }
00089
00090
00091