balljoint.cc
Go to the documentation of this file.00001
00002
00003
00004
00005 #include "physics/balljoint.h"
00006 #include "gfx2/ngfxserver2.h"
00007
00008 namespace Physics
00009 {
00010 ImplementRtti(Physics::BallJoint, Physics::Joint);
00011 ImplementFactory(Physics::BallJoint);
00012
00013
00016 BallJoint::BallJoint() :
00017 Joint(Joint::BallJoint)
00018 {
00019
00020 }
00021
00022
00025 BallJoint::~BallJoint()
00026 {
00027
00028 }
00029
00030
00035 void
00036 BallJoint::Attach(dWorldID worldID, dJointGroupID groupID, const matrix44& m)
00037 {
00038
00039 this->odeJointId = dJointCreateBall(worldID, groupID);
00040
00041
00042 Joint::Attach(worldID, groupID, m);
00043
00044
00045 this->UpdateTransform(m);
00046 }
00047
00048
00051 void
00052 BallJoint::UpdateTransform(const matrix44& m)
00053 {
00054 vector3 a = m * this->anchor;
00055 dJointSetBallAnchor(this->odeJointId, a.x, a.y, a.z);
00056 }
00057
00058
00061 void
00062 BallJoint::RenderDebug()
00063 {
00064 if (this->IsAttached())
00065 {
00066
00067 matrix44 m;
00068 dVector3 curAnchor;
00069 dJointGetBallAnchor(this->odeJointId, curAnchor);
00070 m.scale(vector3(0.1f, 0.1f, 0.1f));
00071 m.translate(vector3(curAnchor[0], curAnchor[1], curAnchor[2]));
00072 nGfxServer2::Instance()->DrawShape(nGfxServer2::Sphere, m, this->GetDebugVisualizationColor());
00073 }
00074 }
00075
00076 }