Panda3D
 All Classes Functions Variables Enumerations
linearControlForce.h
1 // Filename: linearControlForce.h
2 // Created by: Dave Schuyler (2006)
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 LINEARCONTROLFORCE_H
16 #define LINEARCONTROLFORCE_H
17 
18 #include "linearForce.h"
19 
20 ////////////////////////////////////////////////////////////////
21 // Class : LinearControlForce
22 // Description : Simple directed vector force. This force is
23 // different from the others in that it can be
24 // global and still only affect a single object.
25 // That might not make sense for a physics simulation,
26 // but it's very handy for a game. I.e. this is
27 // the force applied by user on the selected object.
28 ////////////////////////////////////////////////////////////////
29 class EXPCL_PANDAPHYSICS LinearControlForce : public LinearForce {
30 PUBLISHED:
31  LinearControlForce(const PhysicsObject *po = 0, PN_stdfloat a = 1.0f,
32  bool mass = false);
34  virtual ~LinearControlForce();
35 
36  INLINE void clear_physics_object();
37  INLINE void set_physics_object(const PhysicsObject *po);
38  INLINE CPT(PhysicsObject) get_physics_object() const;
39 
40  INLINE void set_vector(const LVector3& v);
41  INLINE void set_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
42 
43  INLINE LVector3 get_local_vector() const;
44 
45  virtual void output(ostream &out) const;
46  virtual void write(ostream &out, unsigned int indent=0) const;
47 
48 private:
49  CPT(PhysicsObject) _physics_object;
50  LVector3 _fvec;
51 
52  virtual LinearForce *make_copy();
53  virtual LVector3 get_child_vector(const PhysicsObject *po);
54 
55 public:
56  static TypeHandle get_class_type() {
57  return _type_handle;
58  }
59  static void init_type() {
60  LinearForce::init_type();
61  register_type(_type_handle, "LinearControlForce",
62  LinearForce::get_class_type());
63  }
64  virtual TypeHandle get_type() const {
65  return get_class_type();
66  }
67  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
68 
69 private:
70  static TypeHandle _type_handle;
71 };
72 
73 #include "linearControlForce.I"
74 
75 #endif // LINEARCONTROLFORCE_H
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
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
A force that acts on a PhysicsObject by way of an Integrator.
Definition: linearForce.h:25
Simple directed vector force.
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