Panda3D
 All Classes Functions Variables Enumerations
linearDistanceForce.h
1 // Filename: linearDistanceForce.h
2 // Created by: charles (21Jun00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef LINEARDISTANCEFORCE_H
16 #define LINEARDISTANCEFORCE_H
17 
18 #include "linearForce.h"
19 
20 class BamReader;
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : LinearDistanceForce
24 // Description : Pure virtual class for sinks and sources
25 ////////////////////////////////////////////////////////////////////
26 class EXPCL_PANDAPHYSICS LinearDistanceForce : public LinearForce {
27 PUBLISHED:
28  enum FalloffType {
29  FT_ONE_OVER_R,
30  FT_ONE_OVER_R_SQUARED,
31  FT_ONE_OVER_R_CUBED
32  };
33 
34  INLINE void set_radius(PN_stdfloat r);
35  INLINE void set_falloff_type(FalloffType ft);
36  INLINE void set_force_center(const LPoint3& p);
37 
38  INLINE PN_stdfloat get_radius() const;
39  INLINE FalloffType get_falloff_type() const;
40  INLINE LPoint3 get_force_center() const;
41 
42  INLINE PN_stdfloat get_scalar_term() const;
43 
44  virtual void output(ostream &out) const;
45  virtual void write(ostream &out, unsigned int indent=0) const;
46 
47 private:
48  LPoint3 _force_center;
49 
50  FalloffType _falloff;
51  PN_stdfloat _radius;
52 
53  virtual LinearForce *make_copy() = 0;
54  virtual LVector3 get_child_vector(const PhysicsObject *po) = 0;
55 
56 protected:
57  LinearDistanceForce(const LPoint3& p, FalloffType ft, PN_stdfloat r, PN_stdfloat a,
58  bool m);
60  virtual ~LinearDistanceForce();
61 
62 public:
63  static TypeHandle get_class_type() {
64  return _type_handle;
65  }
66  static void init_type() {
67  LinearForce::init_type();
68  register_type(_type_handle, "LinearDistanceForce",
69  LinearForce::get_class_type());
70  }
71  virtual TypeHandle get_type() const {
72  return get_class_type();
73  }
74  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
75 
76 private:
77  static TypeHandle _type_handle;
78 };
79 
80 #include "linearDistanceForce.I"
81 
82 #endif // LINEARDISTANCEFORCE_H
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
A body on which physics will be applied.
Definition: physicsObject.h:29
Pure virtual class for sinks and sources.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
A force that acts on a PhysicsObject by way of an Integrator.
Definition: linearForce.h:25
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
Definition: linearForce.cxx:97
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85