Fixed: A fix by Francesco Cat applied (mistakes made during code style improvements...
[ode.git] / contrib / DotNetManaged / Geom.cpp
blob3655466ad5ba639d2cb43c59fced6b40efb7f3a7
2 #include "StdAfx.h"
4 #include <ode/ode.h>
5 #include "Geom.h"
8 namespace ODEManaged
11 //Constructors
13 Geom::Geom(void)
15 _id = 0;
19 //Destructor
21 Geom::~Geom(void)
23 dGeomDestroy(this->_id);
27 //Methods
29 //Id
30 dGeomID Geom::Id(void)
32 return _id;
36 //GetBody
37 dBodyID Geom::GetBody(void)
39 return dGeomGetBody(this->_id);
43 //Overloaded SetBody
44 void Geom::SetBody(Body &body)
46 dGeomSetBody(this->_id, body.Id());
49 //void Geom::SetBody(dBodyID b)
50 //{
51 // dGeomSetBody(this->_id, b);
52 //}
55 //SetPosition
56 void Geom::SetPosition(double x, double y, double z)
58 dGeomSetPosition(this->_id, x, y, z);
62 //SetRotation
63 void Geom::SetRotation(Matrix3 rotation)
65 dMatrix3 temp;
66 temp[0] = rotation.m11;
67 temp[4] = rotation.m12;
68 temp[8] = rotation.m13;
69 temp[1] = rotation.m21;
70 temp[5] = rotation.m22;
71 temp[9] = rotation.m23;
72 temp[2] = rotation.m31;
73 temp[6] = rotation.m32;
74 temp[10] = rotation.m33;
75 dGeomSetRotation(_id, temp);
79 //Destroy
80 void Geom::Destroy()
82 if(this->_id) dGeomDestroy(this->_id);
83 _id = 0;
87 //SetData
88 void Geom::SetData(void *data)
90 dGeomSetData(this->_id, data);
94 //GetData
95 void *Geom::GetData(void)
97 return dGeomGetData(this->_id);
101 //GetPosition
102 Vector3 Geom::GetPosition(void)
104 Vector3 retVal;
105 const dReal *temp;
106 temp = dGeomGetPosition(this->_id);
107 retVal.x = temp[0];
108 retVal.y = temp[1];
109 retVal.z = temp[2];
110 return retVal;
114 //GetRotation (left handed system=>transpose)
115 Matrix3 Geom::GetRotation(void)
117 Matrix3 retVal;
118 const dReal *temp;
119 temp = dGeomGetRotation(this->_id);
120 retVal.m11 = temp[0];
121 retVal.m12 = temp[4];
122 retVal.m13 = temp[8];
123 retVal.m21 = temp[1];
124 retVal.m22 = temp[5];
125 retVal.m23 = temp[9];
126 retVal.m31 = temp[2];
127 retVal.m32 = temp[6];
128 retVal.m33 = temp[10];
129 return retVal;
133 //CreateSphere
134 void Geom::CreateSphere(Space &space, double radius)
136 if(this->_id) dGeomDestroy(this->_id);
137 _id = dCreateSphere(space.Id(), radius);
141 //CreateBox
142 void Geom::CreateBox(Space &space, double lx, double ly, double lz)
144 if(this->_id) dGeomDestroy(this->_id);
145 _id = dCreateBox(space.Id(), lx, ly, lz);
149 //CreatePlane
150 void Geom::CreatePlane(Space &space, double a, double b, double c, double d)
152 if(this->_id) dGeomDestroy(this->_id);
153 _id = dCreatePlane(space.Id(), a, b, c, d);
157 //CreateCCylinder
158 void Geom::CreateCCylinder(Space &space, double radius, double length)
160 if(this->_id) dGeomDestroy(this->_id);
161 _id = dCreateCCylinder(space.Id(), radius, length);
165 //SphereGetRadius
166 double Geom::SphereGetRadius(void)
168 return dGeomSphereGetRadius(this->_id);
172 //BoxGetLengths
173 Vector3 Geom::BoxGetLengths(void)
175 Vector3 retVal;
176 dVector3 temp;
177 dGeomBoxGetLengths(this->_id, temp);
178 retVal.x = temp[0];
179 retVal.y = temp[1];
180 retVal.z = temp[2];
181 return retVal;
185 //PlaneGetParams
186 Vector4 Geom::PlaneGetParams(void)
188 Vector4 retVal;
189 dVector4 temp;
190 dGeomPlaneGetParams(this->_id, temp);
191 retVal.W = temp[0];
192 retVal.x = temp[1];
193 retVal.y = temp[2];
194 retVal.z = temp[3];
195 return retVal;
199 //CCylinderGetParams
200 void Geom::CCylinderGetParams(double *radius, double *length)
202 dGeomCCylinderGetParams(this->_id, radius, length);
206 //GetClass
207 int Geom::GetClass(void)
209 return dGeomGetClass(this->_id);