aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/contrib/DotNetManaged/JointBall.cpp
blob: d9336c9da6eacb6798797e68b9617c47a5c6bdf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "StdAfx.h"

#include <ode/ode.h>
#include "jointball.h"

namespace ODEManaged
{
	
	//Constructors

		JointBall::JointBall(void) : Joint(){}


		JointBall::JointBall(World &world)
		{
			if(this->_id) dJointDestroy(this->_id);
			_id = dJointCreateBall(world.Id(), 0);
		}

		
		JointBall::JointBall(World &world, JointGroup &jointGroup)
		{
			if(this->_id) dJointDestroy(this->_id);
			_id = dJointCreateBall(world.Id(), jointGroup.Id());
		}


	//Destructor

		JointBall::~JointBall(void){}


	//Methods

		//Overloaded Create 
		void JointBall::Create(World &world, JointGroup &jointGroup)
		{
			if(this->_id) dJointDestroy(this->_id);
			_id = dJointCreateBall(world.Id(), jointGroup.Id());
		}

		void JointBall::Create(World &world)
		{
			if(this->_id) dJointDestroy(this->_id);
			_id = dJointCreateBall(world.Id(), 0);
		}


		//Overloaded Attach
		void JointBall::Attach(Body &body1, Body &body2)
		{
			dJointAttach(this->_id, body1.Id(), body2.Id());
		}

		void JointBall::Attach(Body &body1)
		{
			dJointAttach(this->_id, body1.Id(), 0);
		}


		//SetAnchor
		void JointBall::SetAnchor(double x, double y ,double z)
		{
			dJointSetBallAnchor(this->_id, x, y, z);
		}

		//GetAnchor
		Vector3 JointBall::GetAnchor(void)
		{
			Vector3 retVal;
			dVector3 temp;
			dJointGetBallAnchor(this->_id,temp);
			retVal.x = temp[0];
			retVal.y = temp[1];
			retVal.z = temp[2];
			return retVal;
		}

}