00001 // Filename: linearUserDefinedForce.cxx 00002 // Created by: charles (31Jul00) 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 "linearUserDefinedForce.h" 00016 00017 TypeHandle LinearUserDefinedForce::_type_handle; 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function : LinearUserDefinedForce 00021 // Access : public 00022 // Description : constructor 00023 //////////////////////////////////////////////////////////////////// 00024 LinearUserDefinedForce:: 00025 LinearUserDefinedForce(LVector3 (*proc)(const PhysicsObject *), 00026 PN_stdfloat a, bool md) : 00027 LinearForce(a, md), 00028 _proc(proc) 00029 { 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function : LinearUserDefinedForce 00034 // Access : public 00035 // Description : copy constructor 00036 //////////////////////////////////////////////////////////////////// 00037 LinearUserDefinedForce:: 00038 LinearUserDefinedForce(const LinearUserDefinedForce ©) : 00039 LinearForce(copy) { 00040 _proc = copy._proc; 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function : ~LinearUserDefinedForce 00045 // Access : public 00046 // Description : destructor 00047 //////////////////////////////////////////////////////////////////// 00048 LinearUserDefinedForce:: 00049 ~LinearUserDefinedForce() { 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function : make_copy 00054 // Access : private, virtual 00055 // Description : child copier 00056 //////////////////////////////////////////////////////////////////// 00057 LinearForce *LinearUserDefinedForce:: 00058 make_copy() { 00059 return new LinearUserDefinedForce(*this); 00060 } 00061 00062 //////////////////////////////////////////////////////////////////// 00063 // Function : get_child_vector 00064 // Access : private, virtual 00065 // Description : force builder 00066 //////////////////////////////////////////////////////////////////// 00067 LVector3 LinearUserDefinedForce:: 00068 get_child_vector(const PhysicsObject *po) { 00069 return _proc(po); 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function : output 00074 // Access : Public 00075 // Description : Write a string representation of this instance to 00076 // <out>. 00077 //////////////////////////////////////////////////////////////////// 00078 void LinearUserDefinedForce:: 00079 output(ostream &out) const { 00080 #ifndef NDEBUG //[ 00081 out<<"LinearUserDefinedForce"; 00082 #endif //] NDEBUG 00083 } 00084 00085 //////////////////////////////////////////////////////////////////// 00086 // Function : write 00087 // Access : Public 00088 // Description : Write a string representation of this instance to 00089 // <out>. 00090 //////////////////////////////////////////////////////////////////// 00091 void LinearUserDefinedForce:: 00092 write(ostream &out, unsigned int indent) const { 00093 #ifndef NDEBUG //[ 00094 out.width(indent); out<<""; out<<"LinearUserDefinedForce:\n"; 00095 LinearForce::write(out, indent+2); 00096 #endif //] NDEBUG 00097 }