00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <assert.h>
00033 #include <ode/ode.h>
00034
00035 #include "invisibleprimitive.h"
00036
00037 namespace lpzrobots{
00038
00039
00040 InvisibleBox::InvisibleBox(float lengthX, float lengthY, float lengthZ)
00041 : lengthX(lengthX), lengthY(lengthY), lengthZ(lengthZ){
00042 }
00043
00044 void InvisibleBox::init(const OdeHandle& odeHandle, double mass, const OsgHandle& osgHandle,
00045 char mode) {
00046 assert(mode & Body || mode & Geom);
00047 this->mode=mode;
00048 if (mode & Body){
00049 body = dBodyCreate (odeHandle.world);
00050 dMass m;
00051
00052 dMassSetBox(&m, 1, lengthX, lengthY, lengthZ);
00053 dMassAdjust (&m, mass);
00054 dBodySetMass (body,&m);
00055 }
00056 if (mode & Geom){
00057 geom = dCreateBox ( odeHandle.space , lengthX, lengthY, lengthZ);
00058 if (mode & Body){
00059 dGeomSetBody (geom, body);
00060 }
00061 }
00062 }
00063
00064
00065
00066 InvisibleSphere::InvisibleSphere(float radius)
00067 : radius(radius) {
00068 }
00069
00070 void InvisibleSphere::init(const OdeHandle& odeHandle, double mass, const OsgHandle& osgHandle,
00071 char mode) {
00072 assert(mode & Body || mode & Geom);
00073 this->mode=mode;
00074 if (mode & Body){
00075 body = dBodyCreate (odeHandle.world);
00076 dMass m;
00077 dMassSetSphere(&m, 1, radius);
00078 dMassAdjust (&m, mass);
00079 dBodySetMass (body,&m);
00080 }
00081 if (mode & Geom){
00082 geom = dCreateSphere ( odeHandle.space , radius);
00083 if (mode & Body)
00084 dGeomSetBody (geom, body);
00085 }
00086
00087 }
00088
00089
00090 InvisibleCapsule::InvisibleCapsule(float radius, float height)
00091 : radius(radius), height(height) {
00092 }
00093
00094 void InvisibleCapsule::init(const OdeHandle& odeHandle, double mass, const OsgHandle& osgHandle,
00095 char mode) {
00096 assert(mode & Body || mode & Geom);
00097 this->mode=mode;
00098 if (mode & Body){
00099 body = dBodyCreate (odeHandle.world);
00100 dMass m;
00101 dMassSetCappedCylinder(&m, 1.0, 3 , radius, height);
00102 dMassAdjust (&m, mass);
00103 dBodySetMass (body,&m);
00104 }
00105 if (mode & Geom){
00106 geom = dCreateCCylinder ( odeHandle.space , radius, height);
00107 if (mode & Body)
00108 dGeomSetBody (geom, body);
00109 }
00110 }
00111
00112 }