00001 // Filename: linearForce.cxx 00002 // Created by: charles (14Jun00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include <datagram.h> 00020 #include <datagramIterator.h> 00021 #include <bamReader.h> 00022 #include <bamWriter.h> 00023 00024 #include "linearForce.h" 00025 00026 TypeHandle LinearForce::_type_handle; 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function : LinearForce 00030 // Access : Protected 00031 // Description : Default/component-based constructor 00032 //////////////////////////////////////////////////////////////////// 00033 LinearForce:: 00034 LinearForce(float a, bool mass) : 00035 BaseForce(true), 00036 _amplitude(a), _mass_dependent(mass), 00037 _x_mask(true), _y_mask(true), _z_mask(true) { 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function : LinearForce 00042 // Access : Protected 00043 // Description : copy constructor 00044 //////////////////////////////////////////////////////////////////// 00045 LinearForce:: 00046 LinearForce(const LinearForce& copy) : 00047 BaseForce(copy) { 00048 _amplitude = copy._amplitude; 00049 _mass_dependent = copy._mass_dependent; 00050 _x_mask = copy._x_mask; 00051 _y_mask = copy._y_mask; 00052 _z_mask = copy._z_mask; 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function : ~LinearForce 00057 // Access : Public 00058 // Description : Destructor 00059 //////////////////////////////////////////////////////////////////// 00060 LinearForce:: 00061 ~LinearForce(void) { 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function : get_vector 00066 // Access : Public 00067 //////////////////////////////////////////////////////////////////// 00068 LVector3f LinearForce:: 00069 get_vector(const PhysicsObject *po) { 00070 LVector3f child_vector = get_child_vector(po) * _amplitude; 00071 00072 if (_x_mask == false) 00073 child_vector[0] = 0.0f; 00074 00075 if (_y_mask == false) 00076 child_vector[1] = 0.0f; 00077 00078 if (_z_mask == false) 00079 child_vector[2] = 0.0f; 00080 00081 return child_vector; 00082 } 00083 00084 //////////////////////////////////////////////////////////////////// 00085 // Function : is_linear 00086 // Access : Public 00087 //////////////////////////////////////////////////////////////////// 00088 bool LinearForce:: 00089 is_linear(void) const { 00090 return true; 00091 }