17 (
"default_terminal_velocity", 400.0f);
26 _terminal_velocity(_default_terminal_velocity),
31 _position.set(0.0f, 0.0f, 0.0f);
32 _last_position = _position;
33 _velocity.set(0.0f, 0.0f, 0.0f);
34 _orientation.set(1.0 ,0.0f, 0.0f, 0.0f);
35 _rotation = LRotation::ident_quat();
58 _process_me = other._process_me;
60 _position = other._position;
61 _last_position = other._last_position;
62 _velocity = other._velocity;
63 _orientation = other._orientation;
64 _rotation = other._rotation;
65 _terminal_velocity = other._terminal_velocity;
66 _oriented = other._oriented;
88 const LVector3 &force) {
89 nassertv(!offset_from_center_of_mass.is_nan());
90 nassertv(!force.is_nan());
92 _orientation.xform(offset_from_center_of_mass),
93 _orientation.xform(force));
105 const LVector3 &force) {
106 nassertv(!offset.is_nan());
107 nassertv(!force.is_nan());
113 PN_stdfloat angle = a.length();
115 LRotation torque(0, 0, 0, 0);
116 PN_stdfloat spin = force.length()*0.1;
119 assert(IS_THRESHOLD_EQUAL(a.length(), 1.0f, 0.001f));
120 torque.set_from_axis_angle(spin, a);
123 LVector3 impulse = (1.0f - angle) * force;
132 LMatrix4 m = LMatrix4::translate_mat(_position);
136 nassertr(!m.is_nan(), m);
146 return LMatrix4::ident_mat();
155 out<<
"PhysicsObject";
166 out<<
""<<
"PhysicsObject "<<_name<<
"\n";
167 out.width(
indent+2); out<<
""; out<<
"_position "<<_position<<
"\n";
168 out.width(
indent+2); out<<
""; out<<
"_last_position "<<_last_position<<
"\n";
169 out.width(
indent+2); out<<
""; out<<
"_velocity "<<_velocity<<
"\n";
171 out.width(
indent+2); out<<
""; out<<
"_orientation "<<_orientation<<
"\n";
172 out.width(
indent+2); out<<
""; out<<
"(hpr "<<_orientation.get_hpr()<<
")\n";
173 out.width(
indent+2); out<<
""; out<<
"_rotation "<<_rotation<<
"\n";
174 out.width(
indent+2); out<<
""; out<<
"_terminal_velocity "<<_terminal_velocity<<
"\n";
175 out.width(
indent+2); out<<
""; out<<
"_mass "<<_mass<<
"\n";
176 out.width(
indent+2); out<<
""; out<<
"_process_me "<<_process_me<<
"\n";
177 out.width(
indent+2); out<<
""; out<<
"_oriented "<<_oriented<<
"\n";
void add_impulse(const LVector3 &impulse)
Adds an impulse force (i.e.
PhysicsObject()
Default Constructor.
virtual void add_local_impact(const LPoint3 &offset_from_center_of_mass, const LVector3 &impulse)
Adds an impulse and/or torque (i.e.
A body on which physics will be applied.
virtual ~PhysicsObject()
Destructor.
This is a convenience class to specialize ConfigVariable as a floating- point type.
virtual PhysicsObject * make_copy() const
dynamic copy.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
void add_torque(const LRotation &torque)
Adds an torque force (i.e.
virtual LMatrix4 get_inertial_tensor() const
returns a transform matrix that represents the object's willingness to be forced.
LVector3 get_implicit_velocity() const
Velocity Query over the last dt.
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>.
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
TypeHandle is the identifier used to differentiate C++ class types.
virtual void add_impact(const LPoint3 &offset_from_center_of_mass, const LVector3 &impulse)
Adds an impulse and/or torque (i.e.
virtual LMatrix4 get_lcs() const
returns a transform matrix to this object's local coordinate system.