Types of forces
Panda3D provides two types of forces that you can apply to an object.
LinearVectorForce
A LinearVectorForce treats the object as a point mass.
It applies an acceleration in Newtons to the center of mass of the object it was
added to. The direction of this force is relative to the orientation of the
ForceNode that the
LinearVectorForce was applied to.
Note
Since LinearVectorForce treats the object as a
point mass, it is not possible to apply a rotation of any kind to your
object. For rotational forces, see
AngularVectorForce below.
Example:
PT(LinearForce) lvf = new LinearVectorForce(1, 0, 0); // Push 1 newton in the positive-x direction
force_node->add_force(lvf); // Determine coordinate space of this force node
actor_node->get_physical(0)->add_linear_force(lvf); // Add the force to the object
AngularVectorForce
The AngularVectorForce applies a torque to the object
it is attached to. The acceleration is in Newtons, and
AngularVectorForce may be treated in much the same way
as LinearVectorForce. There are, however, some minor
differences that that should be taken into account.
AngularVectorForce does not have a
.setDependantMass(). The reason for this is simple: mass must be used in
the torque calculations. As such, you will want to make sure your forces are
sufficiently small or your masses are sufficiently large to keep your rotational
velocity sane.
Example:
PT(AngularForce) avf = new AngularVectorForce(1, 0, 0); // Spin around the positive-x axis
force_node->add_force(avf); // Determine which positive-x axis we use for calculation
actor_node->get_physical(0)->add_angular_force(avf); // Add the force to the object
One additional caveat with AngularVectorForce: Angular
forces will not be processed on your object until an
AngularIntegrator is added to the
PhysicsManager.
Example:
