Panda3D
|
00001 // Filename: odeMass.I 00002 // Created by: joswilso (27Dec06) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 INLINE int OdeMass:: 00016 check() { 00017 return dMassCheck(&_mass); 00018 } 00019 00020 INLINE void OdeMass:: 00021 set_zero() { 00022 _mass.setZero(); 00023 } 00024 00025 INLINE void OdeMass:: 00026 set_parameters(dReal themass, 00027 dReal cgx, dReal cgy, dReal cgz, 00028 dReal I11, dReal I22, dReal I33, 00029 dReal I12, dReal I13, dReal I23) { 00030 _mass.setParameters(themass, 00031 cgx, cgy, cgz, 00032 I11, I22, I33, 00033 I12, I13, I23); 00034 } 00035 00036 INLINE void OdeMass:: 00037 set_parameters(dReal themass, 00038 const LVecBase3f ¢er, 00039 const LMatrix3f &i) { 00040 set_parameters(themass, 00041 center[0], center[1], center[2], 00042 i(0, 0), i(1, 1), i(2, 2), 00043 i(0, 1), i(0, 2), i(1, 2)); 00044 } 00045 00046 INLINE void OdeMass:: 00047 set_sphere(dReal density, dReal radius) { 00048 _mass.setSphere(density, radius); 00049 } 00050 00051 INLINE void OdeMass:: 00052 set_sphere_total(dReal total_mass, dReal radius) { 00053 dMassSetSphereTotal(&_mass, total_mass, radius); 00054 } 00055 00056 INLINE void OdeMass:: 00057 set_capsule(dReal density, int direction, 00058 dReal radius, dReal length) { 00059 _mass.setCapsule(density, direction, 00060 radius, length); 00061 } 00062 00063 INLINE void OdeMass:: 00064 set_capsule_total(dReal total_mass, int direction, 00065 dReal radius, dReal length) { 00066 dMassSetCapsuleTotal(&_mass, 00067 total_mass, direction, 00068 radius, length); 00069 } 00070 00071 INLINE void OdeMass:: 00072 set_cylinder(dReal density, int direction, 00073 dReal radius, dReal length) { 00074 dMassSetCylinder(&_mass, 00075 density,direction, 00076 radius,length); 00077 } 00078 00079 INLINE void OdeMass:: 00080 set_cylinder_total(dReal total_mass, int direction, 00081 dReal radius, dReal length) { 00082 dMassSetCylinderTotal(&_mass, total_mass, direction, 00083 radius, length); 00084 } 00085 00086 INLINE void OdeMass:: 00087 set_box(dReal density, 00088 dReal lx, dReal ly, dReal lz) { 00089 _mass.setBox(density, 00090 lx, ly, lz); 00091 } 00092 00093 INLINE void OdeMass:: 00094 set_box(dReal density, 00095 const LVecBase3f &size) { 00096 _mass.setBox(density, 00097 size[0], size[1], size[2]); 00098 } 00099 00100 INLINE void OdeMass:: 00101 set_box_total(dReal total_mass, 00102 const LVecBase3f &size) { 00103 dMassSetBoxTotal(&_mass, 00104 total_mass, 00105 size[0], size[1], size[2]); 00106 } 00107 00108 INLINE void OdeMass:: 00109 set_box_total(dReal total_mass, 00110 dReal lx, dReal ly, dReal lz) { 00111 dMassSetBoxTotal(&_mass, 00112 total_mass, 00113 lx, ly, lz); 00114 } 00115 00116 INLINE void OdeMass:: 00117 adjust(dReal newmass) { 00118 _mass.adjust(newmass); 00119 } 00120 00121 INLINE void OdeMass:: 00122 translate(dReal x, dReal y, dReal z) { 00123 _mass.translate(x, y, z); 00124 } 00125 00126 INLINE void OdeMass:: 00127 translate(const LVecBase3f &pos) { 00128 translate(pos[0], pos[1], pos[2]); 00129 } 00130 00131 INLINE void OdeMass:: 00132 rotate(const LMatrix3f &r) { 00133 dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0, 00134 r(1, 0), r(1, 1), r(1, 2), 0, 00135 r(2, 0), r(2, 1), r(2, 2), 0 }; 00136 _mass.rotate(rot); 00137 } 00138 00139 INLINE void OdeMass:: 00140 add(OdeMass &other) { 00141 _mass.add(other.get_mass_ptr()); 00142 } 00143 00144 INLINE dReal OdeMass:: 00145 get_magnitude() const { 00146 return _mass.mass; 00147 } 00148 00149 INLINE LPoint3f OdeMass:: 00150 get_center() const { 00151 return LPoint3f(_mass.c[0], _mass.c[1], _mass.c[2]); 00152 } 00153 00154 INLINE LMatrix3f OdeMass:: 00155 get_inertial_tensor() const { 00156 return LMatrix3f(_mass.I[0], _mass.I[1], _mass.I[2] , 00157 _mass.I[4], _mass.I[5], _mass.I[6] , 00158 _mass.I[8], _mass.I[9], _mass.I[10]); 00159 }