00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "body.h"
00023
00024 using namespace boost;
00025 using namespace oxygen;
00026 using namespace zeitgeist;
00027 using namespace salt;
00028
00029 FUNCTION(Body,enable)
00030 {
00031 obj->Enable();
00032 return true;
00033 }
00034
00035 FUNCTION(Body,disable)
00036 {
00037 obj->Disable();
00038 return true;
00039 }
00040
00041 FUNCTION(Body,isEnabled)
00042 {
00043 return obj->IsEnabled();
00044 }
00045
00046 FUNCTION(Body,useGravity)
00047 {
00048 bool inB;
00049
00050 if (
00051 (in.GetSize() != 1) ||
00052 (! in.GetValue(in.begin(),inB))
00053 )
00054 {
00055 return false;
00056 }
00057
00058 obj->UseGravity(inB);
00059 return true;
00060 }
00061
00062 FUNCTION(Body,setMassParameters)
00063 {
00064 float inMass;
00065 Vector3f inCenter;
00066
00067
00068
00069
00070
00071
00072
00073 if (
00074 (in.GetSize() < 11)
00075 )
00076 {
00077 return false;
00078 }
00079
00080 ParameterList::TVector::const_iterator iter = in.begin();
00081 if (
00082 (! in.AdvanceValue(iter,inMass)) ||
00083 (! in.AdvanceValue(iter,inCenter))
00084 )
00085 {
00086 return false;
00087 }
00088
00089 dMass mass;
00090 mass.mass = inMass;
00091 mass.c[0] = inCenter[0];
00092 mass.c[1] = inCenter[1];
00093 mass.c[2] = inCenter[2];
00094
00095 for (int i=0;i<9;++i)
00096 {
00097 if (! in.AdvanceValue(iter,mass.I[i]))
00098 {
00099 return false;
00100 }
00101 }
00102
00103 obj->SetMassParameters(mass);
00104 return true;
00105 }
00106
00107 FUNCTION(Body,setMass)
00108 {
00109 float inMass;
00110
00111 if (
00112 (in.GetSize() != 1) ||
00113 (! in.GetValue(in.begin(), inMass))
00114 )
00115 {
00116 return false;
00117 }
00118
00119 obj->SetMass(inMass);
00120 return true;
00121 }
00122
00123 FUNCTION(Body,getMass)
00124 {
00125 return obj->GetMass();
00126 }
00127
00128 FUNCTION(Body,setSphere)
00129 {
00130 float inDensity;
00131 float inRadius;
00132
00133 if (
00134 (in.GetSize() != 2) ||
00135 (! in.GetValue(in[0],inDensity)) ||
00136 (! in.GetValue(in[1],inRadius))
00137 )
00138 {
00139 return false;
00140 }
00141
00142 obj->SetSphere(inDensity,inRadius);
00143 return true;
00144 }
00145
00146 FUNCTION(Body,setSphereTotal)
00147 {
00148 float inMassTotal;
00149 float inRadius;
00150
00151 if (
00152 (in.GetSize() != 2) ||
00153 (! in.GetValue(in[0],inMassTotal)) ||
00154 (! in.GetValue(in[1],inRadius))
00155 )
00156 {
00157 return false;
00158 }
00159
00160 obj->SetSphereTotal(inMassTotal,inRadius);
00161 return true;
00162 }
00163
00164 FUNCTION(Body,setBox)
00165 {
00166 float inDensity;
00167 Vector3f inSize;
00168
00169 if (
00170 (in.GetSize() <= 1) ||
00171 (! in.GetValue(in[0],inDensity)) ||
00172 (! in.GetValue(in[1],inSize))
00173 )
00174 {
00175 return false;
00176 }
00177
00178 obj->SetBox(inDensity,inSize);
00179 return true;
00180 }
00181
00182 FUNCTION(Body,setBoxTotal)
00183 {
00184 float inMassTotal;
00185 Vector3f inSize;
00186
00187 if (
00188 (in.GetSize() <= 1) ||
00189 (! in.GetValue(in[0],inMassTotal)) ||
00190 (! in.GetValue(in[1],inSize))
00191 )
00192 {
00193 return false;
00194 }
00195
00196 obj->SetBoxTotal(inMassTotal,inSize);
00197 return true;
00198 }
00199
00200 FUNCTION(Body,setCylinder)
00201 {
00202 float inDensity;
00203 float inRadius;
00204 float inLength;
00205
00206 if (
00207 (in.GetSize() != 3) ||
00208 (! in.GetValue(in[0],inDensity)) ||
00209 (! in.GetValue(in[1],inRadius)) ||
00210 (! in.GetValue(in[2],inLength))
00211 )
00212 {
00213 return false;
00214 }
00215
00216 obj->SetCylinder(inDensity,inRadius,inLength);
00217 return true;
00218 }
00219
00220 FUNCTION(Body,setCylinderTotal)
00221 {
00222 float inMassTotal;
00223 float inRadius;
00224 float inLength;
00225
00226 if (
00227 (in.GetSize() != 3) ||
00228 (! in.GetValue(in[0],inMassTotal)) ||
00229 (! in.GetValue(in[1],inRadius)) ||
00230 (! in.GetValue(in[2],inLength))
00231 )
00232 {
00233 return false;
00234 }
00235
00236 obj->SetCylinderTotal(inMassTotal,inRadius,inLength);
00237 return true;
00238 }
00239
00240 FUNCTION(Body,setCappedCylinder)
00241 {
00242 float inDensity;
00243 float inRadius;
00244 float inLength;
00245
00246 if (
00247 (in.GetSize() != 3) ||
00248 (! in.GetValue(in[0],inDensity)) ||
00249 (! in.GetValue(in[1],inRadius)) ||
00250 (! in.GetValue(in[2],inLength))
00251 )
00252 {
00253 return false;
00254 }
00255
00256 obj->SetCappedCylinder(inDensity,inRadius,inLength);
00257 return true;
00258 }
00259
00260 FUNCTION(Body,setCappedCylinderTotal)
00261 {
00262 float inMassTotal;
00263 float inRadius;
00264 float inLength;
00265
00266 if (
00267 (in.GetSize() != 3) ||
00268 (! in.GetValue(in[0],inMassTotal)) ||
00269 (! in.GetValue(in[1],inRadius)) ||
00270 (! in.GetValue(in[2],inLength))
00271 )
00272 {
00273 return false;
00274 }
00275
00276 obj->SetCappedCylinderTotal(inMassTotal,inRadius,inLength);
00277 return true;
00278 }
00279
00280
00281 FUNCTION(Body,setVelocity)
00282 {
00283 Vector3f inVel;
00284
00285 if (
00286 (in.GetSize() == 0) ||
00287 (! in.GetValue(in.begin(), inVel))
00288 )
00289 {
00290 return false;
00291 }
00292
00293 obj->SetVelocity(inVel);
00294 return true;
00295 }
00296
00297 FUNCTION(Body,setAngularVelocity)
00298 {
00299 Vector3f inVel;
00300
00301 if (
00302 (in.GetSize() == 1) ||
00303 (! in.GetValue(in.begin(), inVel))
00304 )
00305 {
00306 return false;
00307 }
00308
00309 obj->SetAngularVelocity(inVel);
00310 return true;
00311 }
00312
00313 FUNCTION(Body,addForce)
00314 {
00315 Vector3f inForce;
00316
00317 if (
00318 (in.GetSize() == 0) ||
00319 (! in.GetValue(in.begin(), inForce))
00320 )
00321 {
00322 return false;
00323 }
00324
00325 obj->AddForce(inForce);
00326 return true;
00327 }
00328
00329 FUNCTION(Body,addTorque)
00330 {
00331 Vector3f inTorque;
00332
00333 if (
00334 (in.GetSize() == 0) ||
00335 (! in.GetValue(in.begin(), inTorque))
00336 )
00337 {
00338 return false;
00339 }
00340
00341 obj->AddForce(inTorque);
00342 return true;
00343 }
00344
00345 FUNCTION(Body,setPosition)
00346 {
00347 Vector3f inPos;
00348
00349 if (
00350 (in.GetSize() == 0) ||
00351 (! in.GetValue(in.begin(), inPos))
00352 )
00353 {
00354 return false;
00355 }
00356
00357 obj->AddForce(inPos);
00358 return true;
00359 }
00360
00361
00362 void CLASS(Body)::DefineClass()
00363 {
00364 DEFINE_BASECLASS(oxygen/ODEObject);
00365 DEFINE_FUNCTION(enable);
00366 DEFINE_FUNCTION(disable);
00367 DEFINE_FUNCTION(isEnabled);
00368 DEFINE_FUNCTION(useGravity);
00369 DEFINE_FUNCTION(setSphere);
00370 DEFINE_FUNCTION(setSphereTotal);
00371 DEFINE_FUNCTION(setBox);
00372 DEFINE_FUNCTION(setBoxTotal);
00373 DEFINE_FUNCTION(setCylinder);
00374 DEFINE_FUNCTION(setCylinderTotal);
00375 DEFINE_FUNCTION(setCappedCylinder);
00376 DEFINE_FUNCTION(setCappedCylinderTotal);
00377 DEFINE_FUNCTION(setMass);
00378 DEFINE_FUNCTION(getMass);
00379 DEFINE_FUNCTION(setVelocity);
00380 DEFINE_FUNCTION(setAngularVelocity);
00381 DEFINE_FUNCTION(addForce);
00382 DEFINE_FUNCTION(addTorque);
00383 DEFINE_FUNCTION(setPosition);
00384 DEFINE_FUNCTION(setMassParameters);
00385 }