Panda3D
Loading...
Searching...
No Matches
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 */
36class EXPCL_PANDA_PHYSICS PhysicsManager {
37public:
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.
44 typedef pvector<Physical *> PhysicalsVector;
45 typedef pvector<PT(LinearForce)> LinearForceVector;
46 typedef pvector<PT(AngularForce)> AngularForceVector;
47
48PUBLISHED:
50 virtual ~PhysicsManager();
51
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);
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
82public:
83 friend class Physical;
84 static ConfigVariableInt _random_seed;
85
86private:
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pure virtual parent of all quat-based forces.
Pure virtual base class for physical modeling.
This is a convenience class to specialize ConfigVariable as an integer type.
A force that acts on a PhysicsObject by way of an Integrator.
Definition linearForce.h:23
Pure virtual base class for physical modeling.
Graph node that encapsulated a series of physical objects.
PN_stdfloat get_viscosity() const
Get the global viscosity.
void do_physics(PN_stdfloat dt)
This is the main high-level API call.
void attach_linear_integrator(LinearIntegrator *i)
Hooks a linear integrator into the manager.
void clear_angular_forces()
Resets the physics manager force vector.
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
virtual void write_linear_forces(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
void remove_physical_node(PhysicalNode *p)
Removes a physicalnode from the manager.
void clear_physicals()
Resets the physics manager objects vector.
virtual void write_angular_forces(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
void clear_linear_forces()
Resets the physics manager force vector.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
void attach_physicalnode(PhysicalNode *p)
Please call attach_physical_node instead.
void attach_physical(Physical *p)
Registers a Physical class with the manager.
void set_viscosity(PN_stdfloat viscosity)
Set the global viscosity.
void attach_angular_integrator(AngularIntegrator *i)
Hooks an angular integrator into the manager.
void remove_angular_force(AngularForce *f)
takes an angular force out of the physics list
void attach_physical_node(PhysicalNode *p)
Registers a physicalnode with the manager.
virtual void debug_output(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
void init_random_seed()
One-time config function, sets up the random seed used by the physics and particle systems.
void remove_physical(Physical *p)
takes a physical out of the object list
PhysicsManager()
Default Constructor.
void add_linear_force(LinearForce *f)
Adds a global linear force to the physics manager.
void remove_linear_force(LinearForce *f)
takes a linear force out of the physics list
void add_angular_force(AngularForce *f)
Adds a global angular force to the physics manager.
virtual void write_physicals(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.