Panda3D
physicsManager.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 physicsManager.h
10  * @author charles
11  * @date 2000-06-14
12  */
13 
14 #ifndef PHYSICSMANAGER_H
15 #define PHYSICSMANAGER_H
16 
17 #include "pandabase.h"
18 #include "pointerTo.h"
19 
20 #include "physical.h"
21 #include "linearForce.h"
22 #include "angularForce.h"
23 #include "linearIntegrator.h"
24 #include "angularIntegrator.h"
25 #include "physicalNode.h"
26 
27 #include "plist.h"
28 #include "pvector.h"
29 
30 #include "configVariableInt.h"
31 
32 /**
33  * Physics don't get much higher-level than this. Attach as many Physicals
34  * (particle systems, etc..) as you want, pick an integrator and go.
35  */
36 class EXPCL_PANDA_PHYSICS PhysicsManager {
37 public:
38  // NOTE that the physicals container is NOT reference counted. this does
39  // indeed mean that you are NOT supposed to use this as a primary storage
40  // container for the physicals. This is so because physicals, on their
41  // death, ask to be removed from their current physicsmanager, if one
42  // exists, relieving the client from the task and also allowing for
43  // dynamically created and destroyed physicals.
47 
48 PUBLISHED:
50  virtual ~PhysicsManager();
51 
52  INLINE void attach_linear_integrator(LinearIntegrator *i);
53  INLINE void attach_angular_integrator(AngularIntegrator *i);
54  INLINE void attach_physical(Physical *p);
55  INLINE void attach_physicalnode(PhysicalNode *p); // use attach_physical_node instead.
56  INLINE void attach_physical_node(PhysicalNode *p);
57  INLINE void add_linear_force(LinearForce *f);
58  INLINE void add_angular_force(AngularForce *f);
59  INLINE void clear_linear_forces();
60  INLINE void clear_angular_forces();
61  INLINE void clear_physicals();
62 
63  INLINE void set_viscosity(PN_stdfloat viscosity);
64  INLINE PN_stdfloat get_viscosity() const;
65 
66  void remove_physical(Physical *p);
67  void remove_physical_node(PhysicalNode *p);
68  void remove_linear_force(LinearForce *f);
69  void remove_angular_force(AngularForce *f);
70  void do_physics(PN_stdfloat dt);
71  void do_physics(PN_stdfloat dt, Physical *p);
72  void init_random_seed();
73 
74  virtual void output(std::ostream &out) const;
75  virtual void write_physicals(std::ostream &out, int indent=0) const;
76  virtual void write_linear_forces(std::ostream &out, int indent=0) const;
77  virtual void write_angular_forces(std::ostream &out, int indent=0) const;
78  virtual void write(std::ostream &out, int indent=0) const;
79 
80  virtual void debug_output(std::ostream &out, int indent=0) const;
81 
82 public:
83  friend class Physical;
84  static ConfigVariableInt _random_seed;
85 
86 private:
87  PN_stdfloat _viscosity;
88  PhysicalsVector _physicals;
89  LinearForceVector _linear_forces;
90  AngularForceVector _angular_forces;
91 
92  PT(LinearIntegrator) _linear_integrator;
93  PT(AngularIntegrator) _angular_integrator;
94 };
95 
96 #include "physicsManager.I"
97 
98 #endif // PHYSICSMANAGER_H
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Pure virtual base class for physical modeling.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A force that acts on a PhysicsObject by way of an Integrator.
Definition: linearForce.h:23
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Graph node that encapsulated a series of physical objects.
Definition: physicalNode.h:28
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
Physics don't get much higher-level than this.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Defines a set of physically modeled attributes.
Definition: physical.h:37
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pure virtual parent of all quat-based forces.
Definition: angularForce.h:22
Pure virtual base class for physical modeling.
This is a convenience class to specialize ConfigVariable as an integer type.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.