Panda3D
linearControlForce.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 linearControlForce.h
10  * @author Dave Schuyler
11  * @date 2006
12  */
13 
14 #ifndef LINEARCONTROLFORCE_H
15 #define LINEARCONTROLFORCE_H
16 
17 #include "linearForce.h"
18 
19 /**
20  * Simple directed vector force. This force is different from the others in
21  * that it can be global and still only affect a single object. That might
22  * not make sense for a physics simulation, but it's very handy for a game.
23  * I.e. this is the force applied by user on the selected object.
24  */
25 class EXPCL_PANDA_PHYSICS LinearControlForce : public LinearForce {
26 PUBLISHED:
27  explicit LinearControlForce(const PhysicsObject *po = 0, PN_stdfloat a = 1.0f,
28  bool mass = false);
30  virtual ~LinearControlForce();
31 
32  INLINE void clear_physics_object();
33  INLINE void set_physics_object(const PhysicsObject *po);
34  INLINE CPT(PhysicsObject) get_physics_object() const;
35 
36  INLINE void set_vector(const LVector3& v);
37  INLINE void set_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
38 
39  INLINE LVector3 get_local_vector() const;
40 
41  virtual void output(std::ostream &out) const;
42  virtual void write(std::ostream &out, int indent=0) const;
43 
44 private:
45  CPT(PhysicsObject) _physics_object;
46  LVector3 _fvec;
47 
48  virtual LinearForce *make_copy();
49  virtual LVector3 get_child_vector(const PhysicsObject *po);
50 
51 public:
52  static TypeHandle get_class_type() {
53  return _type_handle;
54  }
55  static void init_type() {
56  LinearForce::init_type();
57  register_type(_type_handle, "LinearControlForce",
58  LinearForce::get_class_type());
59  }
60  virtual TypeHandle get_type() const {
61  return get_class_type();
62  }
63  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
64 
65 private:
66  static TypeHandle _type_handle;
67 };
68 
69 #include "linearControlForce.I"
70 
71 #endif // LINEARCONTROLFORCE_H
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
Simple directed vector force.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Definition: linearForce.cxx:95
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
Definition: linearForce.cxx:85
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81