00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00037 #include "../include/IPSA/SoPhysicsCapsule.h"
00038 #include "../include/IPSA/SoCollisionShape.h"
00039
00040 SO_KIT_SOURCE(SoPhysicsCapsule);
00041
00044 void SoPhysicsCapsule::initClass()
00045 {
00046 SO_KIT_INIT_CLASS(SoPhysicsCapsule, SoPhysicsCylinder, "PhysicsCylinder");
00047 }
00048
00049
00054 SoPhysicsCapsule::SoPhysicsCapsule(const SbString& nodeName )
00055 : SoPhysicsCylinder(nodeName)
00056 {
00057 SO_KIT_CONSTRUCTOR(SoPhysicsCapsule);
00058 isBuiltIn = TRUE;
00059
00060
00061
00062
00063
00064
00065
00066
00067 SO_KIT_INIT_INSTANCE();
00068
00069
00070 }
00071
00072
00078 dMass SoPhysicsCapsule::getInitialMass() {
00079 SbVec3f scaling = this->scale.getValue();
00080
00081
00082
00083 const float x = scaling[0];
00084 const float y = scaling[1];
00085 const float z = scaling[2];
00086
00087 inertia.enableNotify(false);
00088 const float m = this->mass.getValue();
00089 const double a = 0.2 * m * ((y*y) + (z*z));
00090 const double b = 0.2 * m * ((x*x) + (z*z));
00091 const double c = 0.2 * m * ((y*y) + (x*x));
00092 this->inertia.set1Value(0,(float)a,0,0);
00093 this->inertia.set1Value(1,0,(float)b,0);
00094 this->inertia.set1Value(2,0,0,(float)c);
00095 inertia.enableNotify(true);
00096 const SbVec3f i0 = this->inertia[0];
00097 const SbVec3f i1 = this->inertia[1];
00098 const SbVec3f i2 = this->inertia[2];
00099
00100 dMass mass;
00101 dMassSetParameters(&mass, m, 0,0,0, i0[0],i1[1],i2[2], i0[1],i0[2],i1[2]);
00102
00103 return mass;
00104 }
00105
00106
00112 void SoPhysicsCapsule::updateDependentObjects()
00113 {
00114
00115 SoPhysicsCylinder::updateDependentObjects();
00116 }