Panda3D
linearForce.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file linearForce.h
10  * @author charles
11  * @date 2000-06-13
12  */
13 
14 #ifndef LINEARFORCE_H
15 #define LINEARFORCE_H
16 
17 #include "baseForce.h"
18 
19 /**
20  * A force that acts on a PhysicsObject by way of an Integrator. This is a
21  * pure virtual base class.
22  */
23 class EXPCL_PANDA_PHYSICS LinearForce : public BaseForce {
24 PUBLISHED:
25  ~LinearForce();
26 
27  INLINE void set_amplitude(const PN_stdfloat a);
28  INLINE void set_mass_dependent(bool m);
29 
30  INLINE PN_stdfloat get_amplitude() const;
31  INLINE bool get_mass_dependent() const;
32 
33  INLINE void set_vector_masks(bool x, bool y, bool z);
34  INLINE LVector3 get_vector_masks();
35 
36  LVector3 get_vector(const PhysicsObject *po);
37 
38  virtual LinearForce *make_copy() = 0;
39 
40  virtual bool is_linear() const;
41 
42  virtual void output(std::ostream &out) const;
43  virtual void write(std::ostream &out, int indent=0) const;
44 
45 protected:
46  LinearForce(PN_stdfloat a, bool mass);
47  LinearForce(const LinearForce& copy);
48 
49 private:
50  PN_stdfloat _amplitude;
51  bool _mass_dependent;
52 
53  bool _x_mask;
54  bool _y_mask;
55  bool _z_mask;
56 
57  virtual LVector3 get_child_vector(const PhysicsObject *po) = 0;
58 
59 public:
60  static TypeHandle get_class_type() {
61  return _type_handle;
62  }
63  static void init_type() {
64  BaseForce::init_type();
65  register_type(_type_handle, "LinearForce",
66  BaseForce::get_class_type());
67  }
68  virtual TypeHandle get_type() const {
69  return get_class_type();
70  }
71  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
72 
73 private:
74  static TypeHandle _type_handle;
75 };
76 
77 #include "linearForce.I"
78 
79 #endif // BASELINEARFORCE_H
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A body on which physics will be applied.
Definition: physicsObject.h:27
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
A force that acts on a PhysicsObject by way of an Integrator.
Definition: linearForce.h:23
pure virtual base class for all forces that could POSSIBLY exist.
Definition: baseForce.h:29
virtual void write(std::ostream &out, int indent_level=0) const
Write a string representation of this instance to <out>.
Definition: baseForce.cxx:59
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
Definition: baseForce.cxx:51