15 #include "physicsObject.h"
18 (
"default_terminal_velocity", 400.0f);
29 _terminal_velocity(_default_terminal_velocity),
34 _position.set(0.0f, 0.0f, 0.0f);
35 _last_position = _position;
36 _velocity.set(0.0f, 0.0f, 0.0f);
37 _orientation.set(1.0 ,0.0f, 0.0f, 0.0f);
67 _process_me = other._process_me;
69 _position = other._position;
70 _last_position = other._last_position;
71 _velocity = other._velocity;
72 _orientation = other._orientation;
73 _rotation = other._rotation;
74 _terminal_velocity = other._terminal_velocity;
75 _oriented = other._oriented;
104 nassertv(!offset_from_center_of_mass.
is_nan());
105 nassertv(!force.
is_nan());
107 _orientation.
xform(offset_from_center_of_mass),
108 _orientation.
xform(force));
125 nassertv(!offset.
is_nan());
126 nassertv(!force.
is_nan());
132 PN_stdfloat angle = a.length();
135 PN_stdfloat spin = force.
length()*0.1;
138 assert(IS_THRESHOLD_EQUAL(a.length(), 1.0f, 0.001f));
142 LVector3 impulse = (1.0f - angle) * force;
182 out<<
"PhysicsObject";
193 write(ostream &out,
unsigned int indent)
const {
196 out<<
""<<
"PhysicsObject "<<_name<<
"\n";
197 out.width(indent+2); out<<
""; out<<
"_position "<<_position<<
"\n";
198 out.width(indent+2); out<<
""; out<<
"_last_position "<<_last_position<<
"\n";
199 out.width(indent+2); out<<
""; out<<
"_velocity "<<_velocity<<
"\n";
201 out.width(indent+2); out<<
""; out<<
"_orientation "<<_orientation<<
"\n";
202 out.width(indent+2); out<<
""; out<<
"(hpr "<<_orientation.
get_hpr()<<
")\n";
203 out.width(indent+2); out<<
""; out<<
"_rotation "<<_rotation<<
"\n";
204 out.width(indent+2); out<<
""; out<<
"_terminal_velocity "<<_terminal_velocity<<
"\n";
205 out.width(indent+2); out<<
""; out<<
"_mass "<<_mass<<
"\n";
206 out.width(indent+2); out<<
""; out<<
"_process_me "<<_process_me<<
"\n";
207 out.width(indent+2); out<<
""; out<<
"_oriented "<<_oriented<<
"\n";
static const LQuaternionf & ident_quat()
Returns an identity quaternion.
static const LMatrix4f & ident_mat()
Returns an identity matrix.
This is a unit quaternion representing a rotation.
static LMatrix4f translate_mat(const LVecBase3f &trans)
Returns a matrix that applies the indicated translation.
virtual LMatrix4 get_inertial_tensor() const
returns a transform matrix that represents the object's willingness to be forced. ...
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.
LVector3 get_implicit_velocity() const
Velocity Query over the last dt.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
float length() const
Returns the length of the vector, by the Pythagorean theorem.
virtual ~PhysicsObject()
Destructor.
This is a convenience class to specialize ConfigVariable as a floating-point type.
LVecBase3f xform(const LVecBase3f &v) const
Transforms a 3-d vector by the indicated rotation.
virtual PhysicsObject * make_copy() const
dynamic copy.
This is a 4-by-4 transform matrix.
void add_torque(const LRotation &torque)
Adds an torque force (i.e.
virtual LMatrix4 get_lcs() const
returns a transform matrix to this object's local coordinate system.
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
TypeHandle is the identifier used to differentiate C++ class types.
void set_from_axis_angle(float angle_deg, const LVector3f &axis)
angle_deg is the angle about the axis in degrees.
bool normalize()
Normalizes the vector in place.
virtual void add_impact(const LPoint3 &offset_from_center_of_mass, const LVector3 &impulse)
Adds an impulse and/or torque (i.e.
LVecBase3f get_hpr(CoordinateSystem cs=CS_default) const
Extracts the equivalent Euler angles from the unit quaternion.
bool is_nan() const
Returns true if any component of the matrix is not-a-number, false otherwise.
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.