Panda3D
|
00001 // Filename: linearSourceForce.cxx 00002 // Created by: charles (21Jun00) 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 #include "linearSourceForce.h" 00016 00017 TypeHandle LinearSourceForce::_type_handle; 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function : LinearSourceForce 00021 // Access : Public 00022 // Description : Simple constructor 00023 //////////////////////////////////////////////////////////////////// 00024 LinearSourceForce:: 00025 LinearSourceForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a, 00026 bool mass) : 00027 LinearDistanceForce(p, f, r, a, mass) { 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function : LinearSourceForce 00032 // Access : Public 00033 // Description : Simple constructor 00034 //////////////////////////////////////////////////////////////////// 00035 LinearSourceForce:: 00036 LinearSourceForce() : 00037 LinearDistanceForce(LPoint3(0.0f, 0.0f, 0.0f), FT_ONE_OVER_R_SQUARED, 00038 1.0f, 1.0f, true) { 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function : LinearSourceForce 00043 // Access : Public 00044 // Description : copy constructor 00045 //////////////////////////////////////////////////////////////////// 00046 LinearSourceForce:: 00047 LinearSourceForce(const LinearSourceForce ©) : 00048 LinearDistanceForce(copy) { 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function : ~LinearSourceForce 00053 // Access : Public 00054 // Description : Simple destructor 00055 //////////////////////////////////////////////////////////////////// 00056 LinearSourceForce:: 00057 ~LinearSourceForce() { 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function : make_copy 00062 // Access : Public 00063 // Description : copier 00064 //////////////////////////////////////////////////////////////////// 00065 LinearForce *LinearSourceForce:: 00066 make_copy() { 00067 return new LinearSourceForce(*this); 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function : get_child_vector 00072 // Access : Public 00073 // Description : virtual force query 00074 //////////////////////////////////////////////////////////////////// 00075 LVector3 LinearSourceForce:: 00076 get_child_vector(const PhysicsObject *po) { 00077 return (po->get_position() - get_force_center()) * get_scalar_term(); 00078 } 00079 00080 //////////////////////////////////////////////////////////////////// 00081 // Function : output 00082 // Access : Public 00083 // Description : Write a string representation of this instance to 00084 // <out>. 00085 //////////////////////////////////////////////////////////////////// 00086 void LinearSourceForce:: 00087 output(ostream &out) const { 00088 #ifndef NDEBUG //[ 00089 out<<"LinearSourceForce"; 00090 #endif //] NDEBUG 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function : write 00095 // Access : Public 00096 // Description : Write a string representation of this instance to 00097 // <out>. 00098 //////////////////////////////////////////////////////////////////// 00099 void LinearSourceForce:: 00100 write(ostream &out, unsigned int indent) const { 00101 #ifndef NDEBUG //[ 00102 out.width(indent); out<<""; out<<"LinearSourceForce:\n"; 00103 LinearDistanceForce::write(out, indent+2); 00104 #endif //] NDEBUG 00105 }