Panda3D
|
A joint which behaves in a similar way to a hinge or axel. More...
#include "physxRevoluteJoint.h"
Public Member Functions | |
virtual TypeHandle | force_init_type () |
float | get_angle () const |
Retrieves the current revolute joint angle. | |
bool | get_flag (PhysxRevoluteJointFlag flag) const |
Returns the value of a single RevoluteJointFlag. | |
PhysxMotorDesc | get_motor () const |
PhysxProjectionMode | get_projection_mode () const |
Retrieves the joints projection mode. | |
PhysxSpringDesc | get_spring () const |
virtual TypeHandle | get_type () const |
float | get_velocity () const |
Retrieves the revolute joint angle's rate of change (angular velocity). | |
void | link (NxJoint *jointPtr) |
void | load_from_desc (const PhysxRevoluteJointDesc &jointDesc) |
Loads the entire state of the joint from a descriptor with a single call. | |
NxJoint * | ptr () const |
void | save_to_desc (PhysxRevoluteJointDesc &jointDesc) const |
Saves the state of the joint object to a descriptor. | |
void | set_flag (PhysxRevoluteJointFlag flag, bool value) |
Sets or clears a single RevoluteJointFlag. | |
void | set_limits (const PhysxJointLimitDesc &low, const PhysxJointLimitDesc &high) |
Sets angular joint limits. | |
void | set_motor (const PhysxMotorDesc &motor) |
Sets motor parameters for the joint. | |
void | set_projection_mode (PhysxProjectionMode mode) |
Sets the joint projection mode. | |
void | set_spring (const PhysxSpringDesc &spring) |
Sets spring parameters. | |
void | unlink () |
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. |
A joint which behaves in a similar way to a hinge or axel.
A hinge joint removes all but a single rotational degree of freedom from two objects. The axis along which the two bodies may rotate is specified with a point and a direction vector.
Definition at line 36 of file physxRevoluteJoint.h.
float PhysxRevoluteJoint::get_angle | ( | ) | const |
Retrieves the current revolute joint angle.
The relative orientation of the bodies is stored when the joint is created, or when set_axis() or set_anchor() is called. This initial orientation returns an angle of zero, and joint angles are measured relative to this pose. The angle is in the range [-180, 180], with positive angles CCW around the axis, measured from body2 to body1.
Definition at line 96 of file physxRevoluteJoint.cxx.
bool PhysxRevoluteJoint::get_flag | ( | PhysxRevoluteJointFlag | flag | ) | const |
Returns the value of a single RevoluteJointFlag.
Definition at line 167 of file physxRevoluteJoint.cxx.
PhysxEnums::PhysxProjectionMode PhysxRevoluteJoint::get_projection_mode | ( | ) | const |
Retrieves the joints projection mode.
Definition at line 134 of file physxRevoluteJoint.cxx.
float PhysxRevoluteJoint::get_velocity | ( | ) | const |
Retrieves the revolute joint angle's rate of change (angular velocity).
It is the angular velocity of body1 minus body2 projected along the axis.
Definition at line 110 of file physxRevoluteJoint.cxx.
static void PhysxRevoluteJoint::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 PhysxJoint.
Definition at line 73 of file physxRevoluteJoint.h.
References PhysxJoint::init_type().
void PhysxRevoluteJoint::load_from_desc | ( | const PhysxRevoluteJointDesc & | jointDesc | ) |
Loads the entire state of the joint from a descriptor with a single call.
Definition at line 76 of file physxRevoluteJoint.cxx.
void PhysxRevoluteJoint::save_to_desc | ( | PhysxRevoluteJointDesc & | jointDesc | ) | const |
Saves the state of the joint object to a descriptor.
Definition at line 63 of file physxRevoluteJoint.cxx.
void PhysxRevoluteJoint::set_flag | ( | PhysxRevoluteJointFlag | flag, |
bool | value | ||
) |
Sets or clears a single RevoluteJointFlag.
Definition at line 146 of file physxRevoluteJoint.cxx.
void PhysxRevoluteJoint::set_limits | ( | const PhysxJointLimitDesc & | low, |
const PhysxJointLimitDesc & | high | ||
) |
Sets angular joint limits.
If either of these limits are set, any planar limits in PhysxJoint are ignored. The limits are angles defined the same way as the values that get_angle() returns.
The following has to hold:
Pi < lowAngle < highAngle < Pi Both limits are disabled by default. Also sets coefficients of restitutions for the low and high angular limits. These settings are only used if valid limits are set using set_limits(). These restitution coefficients work the same way as for contacts.
The coefficient of restitution determines whether a collision with the joint limit is completely elastic (like pool balls, restitution = 1, no energy is lost in the collision), completely inelastic (like putty, restitution = 0, no rebound after collision) or somewhere in between. The default is 0 for both.
This automatically enables the limit.
Definition at line 278 of file physxRevoluteJoint.cxx.
void PhysxRevoluteJoint::set_motor | ( | const PhysxMotorDesc & | motor | ) |
Sets motor parameters for the joint.
For a positive velTarget, the motor pulls the first body towards its pulley, for a negative velTarget, the motor pulls the second body towards its pulley.
velTarget - the relative velocity the motor is trying to achieve. The motor will only be able to reach this velocity if the maxForce is sufficiently large. If the joint is moving faster than this velocity, the motor will actually try to brake. If you set this to infinity then the motor will keep speeding up, unless there is some sort of resistance on the attached bodies.
maxForce - the maximum force the motor can exert. Zero disables the motor. Default is 0, should be >= 0. Setting this to a very large value if velTarget is also very large may not be a good idea.
freeSpin - if this flag is set, and if the joint is moving faster than velTarget, then neither braking nor additional acceleration will result. default: false.
This automatically enables the motor.
Definition at line 241 of file physxRevoluteJoint.cxx.
void PhysxRevoluteJoint::set_projection_mode | ( | PhysxProjectionMode | mode | ) |
Sets the joint projection mode.
Definition at line 122 of file physxRevoluteJoint.cxx.
void PhysxRevoluteJoint::set_spring | ( | const PhysxSpringDesc & | spring | ) |
Sets spring parameters.
The spring is implicitly integrated so no instability should result for arbitrary spring and damping constants. Using these settings together with a motor is not possible -- the motor will have priority and the spring settings are ignored. If you would like to simulate your motor's internal friction, do this by altering the motor parameters directly.
spring - The rotational spring acts along the hinge axis and tries to force the joint angle to zero. A setting of zero disables the spring. Default is 0, should be >= 0.
damper - Damping coefficient; acts against the hinge's angular velocity. A setting of zero disables the damping. The default is 0, should be >= 0.
targetValue - The angle at which the spring is relaxed. In [-Pi,Pi]. Default is 0.
This automatically enables the spring
Definition at line 203 of file physxRevoluteJoint.cxx.