#include
Inherits pe_action.
Public Attributes | |
int | id |
if not set, will be auto-assigned; return value of Action() | |
IPhysicalEntity * | pBuddy |
the second constrained entity; can be WORLD_ENTITY for static attachments | |
Vec3 | pt [2] |
pt[0] must be set; if pt[1] is not set, assumed to be equal to pt[1] | |
int | partid [2] |
if not set, the first part is assumed | |
quaternionf | qframe [2] |
constraint frames for constraint angles computation; if not set, identity in the specified frame is assumed | |
float | xlimits [2] |
rotation limits around x axis ("twist"); if xlimits[0]>=[1], x axis is locked | |
float | yzlimits [2] |
combined yz-rotation - "bending" of x axis; yzlimits[0] is ignored and assumed to be 0 during simulation | |
unsigned int | flags |
see enum constrflags | |
float | damping |
internal constraint damping | |
float | sensorRadius |
used for sampling environment and re-attaching the constraint when something breaks | |
float | maxPullForce |
float | maxBendTorque |
positional and rotational force limits | |
float | hardnessLin |
float | hardnessAng |
sets how fast the solver tries to resolve positional and rotational drift | |
IPhysicalEntity * | pConstraintEntity |
used internally for creating dynamic rope constraints | |
Adds a physical constraint on an entity
#include
// Constrains an entity to the specified point
void AddPointConstraint(IPhysicalEntity& physicalEntity)
{
// Specify the world-space position where the entity will be constrained
const Vec3 constraintPosition(ZERO);
// Specify the axis that our constraint will enforce limits on, in our case up.
const Vec3 constraintAxis(0, 0, 1);
// Set the minimum rotation angle along the specified axis (in our case, up) to be 0 degrees
const float minRotationForAxis = 0.f;
// Set the maximum rotation angle along the specified axis (in our case, up) to be 45 degrees
const float maxRotationForAxis = DEG2RAD(45);
// Disallow rotation on the other axes
const float minRotationOtherAxis = 0.f;
// Disallow rotation on the other axes
const float maxRotationOtherAxis = 0.f;
// Define the constraint
pe_action_add_constraint constraint;
// Create a constraint using world coordinates
constraint.flags = world_frames;
// Constrain the entity to the specified point
constraint.pt[0] = constraintPosition;
// Set the rotational frame for the constraint, based on the specified axis
constraint.qframe[0] = constraint.qframe[1] = Quat::CreateRotationV0V1(Vec3(1, 0, 0), constraintAxis);
// Now apply the constraint limits defined above
// Note that if the max