forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphysicsObject.h
More file actions
140 lines (110 loc) · 3.92 KB
/
physicsObject.h
File metadata and controls
140 lines (110 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file physicsObject.h
* @author charles
* @date 2000-06-13
*/
#ifndef PHYSICS_OBJECT_H
#define PHYSICS_OBJECT_H
#include "pandabase.h"
#include "typedReferenceCount.h"
#include "luse.h"
#include "configVariableDouble.h"
/**
* A body on which physics will be applied. If you're looking to add physical
* motion to your class, do NOT derive from this. Derive from Physical
* instead.
*/
class EXPCL_PANDA_PHYSICS PhysicsObject : public TypedReferenceCount {
public:
typedef pvector<PT(PhysicsObject)> Vector;
PUBLISHED:
PhysicsObject();
PhysicsObject(const PhysicsObject ©);
virtual ~PhysicsObject();
const PhysicsObject &operator =(const PhysicsObject &other);
static ConfigVariableDouble _default_terminal_velocity;
INLINE void set_active(bool flag);
INLINE bool get_active() const;
INLINE void set_mass(PN_stdfloat);
INLINE PN_stdfloat get_mass() const;
// INLINE void set_center_of_mass(const LPoint3 &pos); use set_position.
INLINE void set_position(const LPoint3 &pos);
INLINE void set_position(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
INLINE LPoint3 get_position() const;
INLINE void reset_position(const LPoint3 &pos);
INLINE void set_last_position(const LPoint3 &pos);
INLINE LPoint3 get_last_position() const;
INLINE void set_velocity(const LVector3 &vel);
INLINE void set_velocity(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
INLINE LVector3 get_velocity() const;
INLINE LVector3 get_implicit_velocity() const;
// Global instantanious forces
INLINE void add_torque(const LRotation &torque);
INLINE void add_impulse(const LVector3 &impulse);
virtual void add_impact(
const LPoint3 &offset_from_center_of_mass, const LVector3 &impulse);
// Local instantanious forces
INLINE void add_local_torque(const LRotation &torque);
INLINE void add_local_impulse(const LVector3 &impulse);
virtual void add_local_impact(
const LPoint3 &offset_from_center_of_mass, const LVector3 &impulse);
INLINE void set_terminal_velocity(PN_stdfloat tv);
INLINE PN_stdfloat get_terminal_velocity() const;
INLINE void set_oriented(bool flag);
INLINE bool get_oriented() const;
INLINE void set_orientation(const LOrientation &orientation);
INLINE LOrientation get_orientation() const;
INLINE void reset_orientation(const LOrientation &orientation);
INLINE void set_rotation(const LRotation &rotation);
INLINE LRotation get_rotation() const;
virtual LMatrix4 get_inertial_tensor() const;
virtual LMatrix4 get_lcs() const;
virtual PhysicsObject *make_copy() const;
#if !defined(NDEBUG) || !defined(CPPPARSER)
void set_name(const std::string &name) {
_name = name;
}
const std::string &get_name() {
return _name;
}
#endif
virtual void output(std::ostream &out) const;
virtual void write(std::ostream &out, int indent=0) const;
private:
// physical
LPoint3 _position; // aka _center_of_mass
LPoint3 _last_position;
LVector3 _velocity; // aka _linear_velocity
// angular
LOrientation _orientation;
LRotation _rotation; // aka _angular_velocity
PN_stdfloat _terminal_velocity;
PN_stdfloat _mass;
bool _process_me;
bool _oriented;
std::string _name;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
TypedReferenceCount::init_type();
register_type(_type_handle, "PhysicsObject",
TypedReferenceCount::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#include "physicsObject.I"
#endif // __PHYSICS_OBJECT_H__