Panda3D
|
A body on which physics will be applied. More...
#include "physicsObject.h"
Public Types | |
typedef pvector< PT(PhysicsObject)> | Vector |
Public Member Functions | |
PhysicsObject () | |
Default Constructor. | |
PhysicsObject (const PhysicsObject ©) | |
copy constructor | |
virtual | ~PhysicsObject () |
Destructor. | |
virtual void | add_impact (const LPoint3 &offset_from_center_of_mass, const LVector3 &impulse) |
Adds an impulse and/or torque (i.e. | |
void | add_impulse (const LVector3 &impulse) |
Adds an impulse force (i.e. | |
virtual void | add_local_impact (const LPoint3 &offset_from_center_of_mass, const LVector3 &impulse) |
Adds an impulse and/or torque (i.e. | |
void | add_local_impulse (const LVector3 &impulse) |
Adds an impulse force (i.e. | |
void | add_local_torque (const LRotation &torque) |
Adds an torque force (i.e. | |
void | add_torque (const LRotation &torque) |
Adds an torque force (i.e. | |
virtual TypeHandle | force_init_type () |
bool | get_active () const |
Process Flag Query. | |
LVector3 | get_implicit_velocity () const |
Velocity Query over the last dt. | |
virtual LMatrix4 | get_inertial_tensor () const |
returns a transform matrix that represents the object's willingness to be forced. | |
LPoint3 | get_last_position () const |
Get the position of the physics object at the start of the most recent do_physics. | |
virtual LMatrix4 | get_lcs () const |
returns a transform matrix to this object's local coordinate system. | |
PN_stdfloat | get_mass () const |
Get the mass in slugs (or kilograms). | |
const string & | get_name () |
LOrientation | get_orientation () const |
get current orientation. | |
bool | get_oriented () const |
See set_oriented(). | |
LPoint3 | get_position () const |
Position Query. | |
LRotation | get_rotation () const |
get rotation per second. | |
PN_stdfloat | get_terminal_velocity () const |
tv query | |
virtual TypeHandle | get_type () const |
LVector3 | get_velocity () const |
Velocity Query per second. | |
virtual PhysicsObject * | make_copy () const |
dynamic copy. | |
const PhysicsObject & | operator= (const PhysicsObject &other) |
virtual void | output (ostream &out) const |
Write a string representation of this instance to <out>. | |
void | reset_orientation (const LOrientation &orientation) |
set the orientation while clearing the rotation velocity. | |
void | reset_position (const LPoint3 &pos) |
use this to place an object in a completely new position, that has nothing to do with its last position. | |
void | set_active (bool flag) |
Process Flag assignment. | |
void | set_last_position (const LPoint3 &pos) |
Last position assignment. | |
void | set_mass (PN_stdfloat) |
Set the mass in slugs (or kilograms). | |
void | set_name (const string &name) |
void | set_orientation (const LOrientation &orientation) |
void | set_oriented (bool flag) |
Set flag to determine whether this object should do any rotation or orientation calculations. | |
void | set_position (const LPoint3 &pos) |
Vector position assignment. | |
void | set_position (PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) |
Piecewise position assignment. | |
void | set_rotation (const LRotation &rotation) |
set rotation as a quaternion delta per second. | |
void | set_terminal_velocity (PN_stdfloat tv) |
tv assignment | |
void | set_velocity (const LVector3 &vel) |
Vector velocity assignment. | |
void | set_velocity (PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) |
Piecewise velocity assignment. | |
virtual void | write (ostream &out, unsigned int indent=0) const |
Write a string representation of this instance to <out>. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
Static Public Attributes | |
static ConfigVariableDouble | _default_terminal_velocity |
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.
Definition at line 29 of file physicsObject.h.
Default Constructor.
Definition at line 28 of file physicsObject.cxx.
References LQuaternionf::ident_quat().
Referenced by make_copy().
PhysicsObject::PhysicsObject | ( | const PhysicsObject & | copy | ) |
copy constructor
Definition at line 47 of file physicsObject.cxx.
PhysicsObject::~PhysicsObject | ( | ) | [virtual] |
Destructor.
Definition at line 57 of file physicsObject.cxx.
void PhysicsObject::add_impact | ( | const LPoint3 & | offset, |
const LVector3 & | force | ||
) | [virtual] |
Adds an impulse and/or torque (i.e.
an instantanious change in velocity) based on how well the offset and impulse align with the center of mass (aka position). If you wanted to immitate this function you could work out the impulse and torque and call add_impulse and add_torque respectively. offset and force are in global (or parent) coordinates.
Definition at line 123 of file physicsObject.cxx.
References add_impulse(), add_torque(), LVecBase3f::is_nan(), LVecBase3f::length(), LVecBase3f::normalize(), and LQuaternionf::set_from_axis_angle().
Referenced by add_local_impact(), and PhysicsCollisionHandler::apply_net_shove().
void PhysicsObject::add_impulse | ( | const LVector3 & | impulse | ) | [inline] |
Adds an impulse force (i.e.
an instantanious change in velocity). This is a quicker way to get the velocity, add a vector to it and set that value to be the new velocity.
Definition at line 160 of file physicsObject.I.
References LVecBase3f::is_nan().
Referenced by add_impact().
void PhysicsObject::add_local_impact | ( | const LPoint3 & | offset_from_center_of_mass, |
const LVector3 & | force | ||
) | [virtual] |
Adds an impulse and/or torque (i.e.
an instantanious change in velocity) based on how well the offset and impulse align with the center of mass (aka position). If you wanted to immitate this function you could work out the impulse and torque and call add_impulse and add_torque respectively. offset and force are in local coordinates.
Definition at line 102 of file physicsObject.cxx.
References add_impact(), LVecBase3f::is_nan(), and LQuaternionf::xform().
void PhysicsObject::add_local_impulse | ( | const LVector3 & | impulse | ) | [inline] |
Adds an impulse force (i.e.
an instantanious change in velocity). This is a quicker way to get the velocity, add a vector to it and set that value to be the new velocity.
Definition at line 132 of file physicsObject.I.
References LVecBase3f::is_nan(), and LQuaternionf::xform().
void PhysicsObject::add_local_torque | ( | const LRotation & | torque | ) | [inline] |
Adds an torque force (i.e.
an instantanious change in velocity). This is a quicker way to get the angular velocity, add a vector to it and set that value to be the new angular velocity.
Definition at line 118 of file physicsObject.I.
References LVecBase4f::is_nan(), and LQuaternionf::xform().
void PhysicsObject::add_torque | ( | const LRotation & | torque | ) | [inline] |
Adds an torque force (i.e.
an instantanious change in velocity). This is a quicker way to get the angular velocity, add a vector to it and set that value to be the new angular velocity.
Definition at line 146 of file physicsObject.I.
References LVecBase4f::is_nan().
Referenced by add_impact().
bool PhysicsObject::get_active | ( | ) | const [inline] |
Process Flag Query.
Definition at line 242 of file physicsObject.I.
LVector3 PhysicsObject::get_implicit_velocity | ( | ) | const [inline] |
Velocity Query over the last dt.
Definition at line 232 of file physicsObject.I.
Referenced by write().
LMatrix4 PhysicsObject::get_inertial_tensor | ( | ) | const [virtual] |
returns a transform matrix that represents the object's willingness to be forced.
Definition at line 169 of file physicsObject.cxx.
References LMatrix4f::ident_mat().
LPoint3 PhysicsObject::get_last_position | ( | ) | const [inline] |
Get the position of the physics object at the start of the most recent do_physics.
Definition at line 212 of file physicsObject.I.
LMatrix4 PhysicsObject::get_lcs | ( | ) | const [virtual] |
returns a transform matrix to this object's local coordinate system.
Definition at line 153 of file physicsObject.cxx.
References LMatrix4f::is_nan(), and LMatrix4f::translate_mat().
Referenced by PhysicsCollisionHandler::apply_net_shove(), and ActorNode::update_transform().
PN_stdfloat PhysicsObject::get_mass | ( | ) | const [inline] |
Get the mass in slugs (or kilograms).
Definition at line 191 of file physicsObject.I.
LOrientation PhysicsObject::get_orientation | ( | ) | const [inline] |
get current orientation.
Definition at line 284 of file physicsObject.I.
bool PhysicsObject::get_oriented | ( | ) | const [inline] |
See set_oriented().
Definition at line 315 of file physicsObject.I.
LPoint3 PhysicsObject::get_position | ( | ) | const [inline] |
Position Query.
Definition at line 201 of file physicsObject.I.
Referenced by LinearIntegrator::integrate(), and ParticleSystem::update().
LRotation PhysicsObject::get_rotation | ( | ) | const [inline] |
get rotation per second.
Definition at line 294 of file physicsObject.I.
PN_stdfloat PhysicsObject::get_terminal_velocity | ( | ) | const [inline] |
tv query
Definition at line 252 of file physicsObject.I.
LVector3 PhysicsObject::get_velocity | ( | ) | const [inline] |
Velocity Query per second.
Definition at line 222 of file physicsObject.I.
Referenced by PhysicsCollisionHandler::apply_net_shove().
static void PhysicsObject::init_type | ( | ) | [inline, static] |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Reimplemented from TypedReferenceCount.
Definition at line 128 of file physicsObject.h.
References TypedReferenceCount::init_type().
PhysicsObject * PhysicsObject::make_copy | ( | ) | const [virtual] |
dynamic copy.
Reimplemented in BaseParticle, PointParticle, ZSpinParticle, and OrientedParticle.
Definition at line 86 of file physicsObject.cxx.
References PhysicsObject().
void PhysicsObject::output | ( | ostream & | out | ) | const [virtual] |
Write a string representation of this instance to <out>.
Reimplemented in ZSpinParticle, BaseParticle, OrientedParticle, and PointParticle.
Definition at line 180 of file physicsObject.cxx.
void PhysicsObject::reset_orientation | ( | const LOrientation & | orientation | ) | [inline] |
set the orientation while clearing the rotation velocity.
Definition at line 71 of file physicsObject.I.
References LQuaternionf::ident_quat(), and LVecBase4f::is_nan().
void PhysicsObject::reset_position | ( | const LPoint3 & | pos | ) | [inline] |
use this to place an object in a completely new position, that has nothing to do with its last position.
Definition at line 57 of file physicsObject.I.
References LVecBase3f::is_nan().
void PhysicsObject::set_active | ( | bool | flag | ) | [inline] |
Process Flag assignment.
Definition at line 171 of file physicsObject.I.
Referenced by ActorNode::ActorNode(), and BaseParticleFactory::populate_particle().
void PhysicsObject::set_last_position | ( | const LPoint3 & | pos | ) | [inline] |
Last position assignment.
Definition at line 83 of file physicsObject.I.
Referenced by LinearIntegrator::integrate().
void PhysicsObject::set_mass | ( | PN_stdfloat | m | ) | [inline] |
Set the mass in slugs (or kilograms).
Definition at line 21 of file physicsObject.I.
Referenced by BaseParticleFactory::populate_particle().
void PhysicsObject::set_oriented | ( | bool | flag | ) | [inline] |
Set flag to determine whether this object should do any rotation or orientation calculations.
Optimization.
Definition at line 305 of file physicsObject.I.
Referenced by OrientedParticle::OrientedParticle(), and PointParticle::PointParticle().
void PhysicsObject::set_position | ( | const LPoint3 & | pos | ) | [inline] |
Vector position assignment.
This is also used as the center of mass.
Definition at line 33 of file physicsObject.I.
References LVecBase3f::is_nan().
void PhysicsObject::set_position | ( | PN_stdfloat | x, |
PN_stdfloat | y, | ||
PN_stdfloat | z | ||
) | [inline] |
Piecewise position assignment.
Definition at line 44 of file physicsObject.I.
void PhysicsObject::set_rotation | ( | const LRotation & | rotation | ) | [inline] |
set rotation as a quaternion delta per second.
Definition at line 273 of file physicsObject.I.
References LVecBase4f::is_nan().
void PhysicsObject::set_terminal_velocity | ( | PN_stdfloat | tv | ) | [inline] |
tv assignment
Definition at line 181 of file physicsObject.I.
Referenced by BaseParticleFactory::populate_particle().
void PhysicsObject::set_velocity | ( | const LVector3 & | vel | ) | [inline] |
Vector velocity assignment.
Definition at line 93 of file physicsObject.I.
References LVecBase3f::is_nan().
Referenced by PhysicsCollisionHandler::apply_net_shove().
void PhysicsObject::set_velocity | ( | PN_stdfloat | x, |
PN_stdfloat | y, | ||
PN_stdfloat | z | ||
) | [inline] |
Piecewise velocity assignment.
Definition at line 104 of file physicsObject.I.
void PhysicsObject::write | ( | ostream & | out, |
unsigned int | indent = 0 |
||
) | const [virtual] |
Write a string representation of this instance to <out>.
Definition at line 193 of file physicsObject.cxx.
References LQuaternionf::get_hpr(), and get_implicit_velocity().
Referenced by ActorNode::write(), and Physical::write().