00001 // Filename: linearDistanceForce.I 00002 // Created by: charles (21Jun00) 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 //////////////////////////////////////////////////////////////////// 00020 // Function : set_falloff_type 00021 // Access : Public 00022 // Description : falloff_type encapsulating wrap 00023 //////////////////////////////////////////////////////////////////// 00024 INLINE void LinearDistanceForce:: 00025 set_falloff_type(FalloffType ft) { 00026 _falloff = ft; 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function : set_radius 00031 // Access : Public 00032 // Description : set the radius 00033 //////////////////////////////////////////////////////////////////// 00034 INLINE void LinearDistanceForce:: 00035 set_radius(float r) { 00036 _radius = r; 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function : set_force_center 00041 // Access : Public 00042 // Description : set the force center 00043 //////////////////////////////////////////////////////////////////// 00044 INLINE void LinearDistanceForce:: 00045 set_force_center(const LPoint3f& p) { 00046 _force_center = p; 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function : get_falloff_type 00051 // Access : public 00052 // Description : falloff_type query 00053 //////////////////////////////////////////////////////////////////// 00054 INLINE LinearDistanceForce::FalloffType LinearDistanceForce:: 00055 get_falloff_type(void) const { 00056 return _falloff; 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function : get_radius 00061 // Access : public 00062 // Description : radius query 00063 //////////////////////////////////////////////////////////////////// 00064 INLINE float LinearDistanceForce:: 00065 get_radius(void) const { 00066 return _radius; 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function : get_force_center 00071 // Access : public 00072 // Description : force_center query 00073 //////////////////////////////////////////////////////////////////// 00074 INLINE LPoint3f LinearDistanceForce:: 00075 get_force_center(void) const { 00076 return _force_center; 00077 } 00078 00079 //////////////////////////////////////////////////////////////////// 00080 // Function : get_scalar_term 00081 // Access : private 00082 // Description : calculate the term based on falloff 00083 //////////////////////////////////////////////////////////////////// 00084 INLINE float LinearDistanceForce:: 00085 get_scalar_term(void) const { 00086 float r = _radius; 00087 if (_falloff == FT_ONE_OVER_R_SQUARED) 00088 r = r * r; 00089 else if (_falloff == FT_ONE_OVER_R_CUBED) 00090 r = r * r * r; 00091 00092 return (1.0f / r); 00093 }