00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00042 #include "../include/IPSA/SoPhysicsTorus.h"
00043 #include "../include/IPSA/SoCollisionShape.h"
00044
00045
00046 SO_KIT_SOURCE(SoPhysicsTorus);
00047
00050 void SoPhysicsTorus::initClass()
00051 {
00052 SO_KIT_INIT_CLASS(SoPhysicsTorus, SoPhysics, "Physics");
00053 }
00054
00055
00060 SoPhysicsTorus::SoPhysicsTorus(const SbString& nodeName )
00061 : SoPhysics(nodeName)
00062 {
00063 SO_KIT_CONSTRUCTOR(SoPhysicsTorus);
00064 isBuiltIn = TRUE;
00065
00066 SO_KIT_ADD_FIELD(radius,(1.0f));
00067 SO_KIT_ADD_FIELD(tuberadius,(0.2f));
00068
00069 SO_KIT_INIT_INSTANCE();
00070
00071 updateDependentObjectsTrigger.appendConnection(&radius);
00072 updateDependentObjectsTrigger.appendConnection(&tuberadius);
00073 }
00074
00075
00081 dMass SoPhysicsTorus::getInitialMass() {
00082 printf("initalMass of SoPhysicsTorus\n");
00083 SbVec3f scaling = this->scale.getValue();
00084
00085
00086
00087
00088
00089 inertia.enableNotify(false);
00090 float m = this->mass.getValue();
00091 float r = this->radius.getValue();
00092 float rt = this->tuberadius.getValue();
00093 float a = (m/8.0f) * (5*(r*r) + 4*(rt*rt));
00094 float c = (3*m /(4.0f)) * ((r*r) + (rt*rt));
00095 this->inertia.set1Value(0,a,0,0);
00096 this->inertia.set1Value(1,0,a,0);
00097 this->inertia.set1Value(2,0,0,c);
00098 inertia.enableNotify(true);
00099 SbVec3f i0 = this->inertia[0];
00100 SbVec3f i1 = this->inertia[1];
00101 SbVec3f i2 = this->inertia[2];
00102
00103 dMass mass;
00104 dMassSetParameters(&mass, m, 0,0,0, i0[0],i1[1],i2[2], i0[1],i0[2],i1[2]);
00105
00106 return mass;
00107 }