00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "datagram.h"
00016 #include "datagramIterator.h"
00017 #include "bamReader.h"
00018 #include "bamWriter.h"
00019
00020 #include "linearForce.h"
00021
00022 TypeHandle LinearForce::_type_handle;
00023
00024
00025
00026
00027
00028
00029 LinearForce::
00030 LinearForce(PN_stdfloat a, bool mass) :
00031 BaseForce(true),
00032 _amplitude(a), _mass_dependent(mass),
00033 _x_mask(true), _y_mask(true), _z_mask(true) {
00034 }
00035
00036
00037
00038
00039
00040
00041 LinearForce::
00042 LinearForce(const LinearForce& copy) :
00043 BaseForce(copy) {
00044 _amplitude = copy._amplitude;
00045 _mass_dependent = copy._mass_dependent;
00046 _x_mask = copy._x_mask;
00047 _y_mask = copy._y_mask;
00048 _z_mask = copy._z_mask;
00049 }
00050
00051
00052
00053
00054
00055
00056 LinearForce::
00057 ~LinearForce() {
00058 }
00059
00060
00061
00062
00063
00064 LVector3 LinearForce::
00065 get_vector(const PhysicsObject *po) {
00066 LVector3 child_vector = get_child_vector(po) * _amplitude;
00067 nassertr(!child_vector.is_nan(), LVector3::zero());
00068
00069 if (_x_mask == false)
00070 child_vector[0] = 0.0f;
00071
00072 if (_y_mask == false)
00073 child_vector[1] = 0.0f;
00074
00075 if (_z_mask == false)
00076 child_vector[2] = 0.0f;
00077
00078 return child_vector;
00079 }
00080
00081
00082
00083
00084
00085 bool LinearForce::
00086 is_linear() const {
00087 return true;
00088 }
00089
00090
00091
00092
00093
00094
00095
00096 void LinearForce::
00097 output(ostream &out) const {
00098 #ifndef NDEBUG //[
00099 out<<"LinearForce (id "<<this<<")";
00100 #endif //] NDEBUG
00101 }
00102
00103
00104
00105
00106
00107
00108
00109 void LinearForce::
00110 write(ostream &out, unsigned int indent) const {
00111 #ifndef NDEBUG //[
00112 out.width(indent); out<<""; out<<"LinearForce (id "<<this<<")\n";
00113 out.width(indent+2); out<<""; out<<"_amplitude "<<_amplitude<<"\n";
00114 out.width(indent+2); out<<""; out<<"_mass_dependent "<<_mass_dependent<<"\n";
00115 out.width(indent+2); out<<""; out<<"_x_mask "<<_x_mask<<"\n";
00116 out.width(indent+2); out<<""; out<<"_y_mask "<<_y_mask<<"\n";
00117 out.width(indent+2); out<<""; out<<"_z_mask "<<_z_mask<<"\n";
00118 BaseForce::write(out, indent+2);
00119 #endif //] NDEBUG
00120 }