Unigine.BodyRigid Class
Inherits: | Body |
This class is used to simulate rigid bodies that move according to the rigid bodies dynamics.
BodyRigid Class
Properties
vec3 AngularVelocity#
vec3 LinearVelocity#
float FrozenAngularVelocity#
float FrozenLinearVelocity#
float MaxAngularVelocity#
float MaxLinearVelocity#
float AngularDamping#
float LinearDamping#
vec3 AngularScale#
vec3 LinearScale#
vec3 WorldCenterOfMass#
vec3 CenterOfMass#
mat3 IWorldInertia#
mat3 Inertia#
float IMass#
float Mass#
bool IsHighPriorityContacts#
bool IsFreezable#
bool IsShapeBased#
Members
static BodyRigid ( ) #
Constructor. Creates a rigid body with default properties.static BodyRigid ( Object object ) #
Constructor. Creates a rigid body with default properties for a given object.Arguments
- Object object - Object approximated with the new rigid body.
vec3 GetVelocity ( vec3 radius ) #
Returns the total linear velocity of the point determined by a given radius vector, specified in the local coordinates.Arguments
- vec3 radius - Radius vector starting in the body's center of mass.
Return value
Total linear velocity in the given point of the body.vec3 GetWorldVelocity ( vec3 point ) #
Returns the total linear velocity of the point specified in world coordinates.Arguments
- vec3 point - Point of the body, in world coordinates.
Return value
Total linear velocity in the given point.void AddForce ( vec3 force ) #
Applies a force to the center of mass of the body.
Unlike impulses, all forces are accumulated first, then the resulting force is calculated and applied to the body (during the physics simulation stage, when the body update() function is called).
- You can call this function only from updatePhysics() function in the world script. Do not apply forces in the update() function, because you will get unstable result that varies each rendering frame.
- If a body is frozen, it can't be immediately unfrozen. If the object's velocities are above minimum, it needs the engine.physics.getNumFrozenFrames() flush frames to be specified to unfreeze. To make sure that force will be applied, check if a body is not frozen by isFrozen() and unfreeze it by setFrozen(0) if needed.
Arguments
- vec3 force - Force to be applied, in world coordinates.
void AddForce ( vec3 radius, vec3 force ) #
Applies a force to a point determined by a given radius vector, specified in the local coordinates. This function calculates the cross product of the radius vector and the force vector. It acts like a lever arm that changes both linear and angular velocities of the body.
Unlike impulses, all forces are accumulated first, then the resulting force is calculated and applied to the body (during the physics simulation stage, when the body update() function is called).
- You can call this function only from updatePhysics() function in the world script. Do not apply forces in the update() function, because you will get unstable result that varies each rendering frame.
- If a body is frozen, it can't be immediately unfrozen. If the object's velocities are above minimum, it needs the engine.physics.getNumFrozenFrames() flush frames to be specified to unfreeze. To make sure that force will be applied, check if a body is not frozen by isFrozen() and unfreeze it by setFrozen(0) if needed.
Arguments
- vec3 radius - Radius vector, traced from the center of mass of the body to the point where the force is applied.
- vec3 force - Force to be applied, in world coordinates.
void AddImpulse ( vec3 radius, vec3 impulse ) #
Applies an impulse to a point determined by a given radius vector, specified in the local coordinates.
Unlike forces, impulses immediately affect both linear and angular velocities of the body.
Arguments
- vec3 radius - Radius vector, traced from the center of mass to the point where the impulse is applied.
- vec3 impulse - Impulse to be applied, in world coordinates.
void AddLinearImpulse ( vec3 impulse ) #
Applies an impulse similar to the addImpulse() method, but affects only the linear velocity.
Arguments
- vec3 impulse - Impulse to be applied, in world coordinates.
void AddAngularImpulse ( vec3 impulse ) #
Applies an impulse similar to the addImpulse() method, but affects only the angular velocity.
Arguments
- vec3 impulse - Impulse to be applied, in world coordinates.
void AddTorque ( vec3 torque ) #
Applies a torque with a pivot point at the center of mass of the body, specified in the local coordinates.
All torque values are accumulated first, then the resulting torque is calculated and applied to the body (during the physics simulation stage, when the body update is called).
- You can call this function only from updatePhysics() function in the world script. Do not apply forces in the update() function, because you will get unstable result that varies each rendering frame.
- If a body is frozen, it can't be immediately unfrozen. If the object's velocities are above minimum, it needs the engine.physics.getNumFrozenFrames() flush frames to be specified to unfreeze. To make sure that torque will be applied, check if a body is not frozen by isFrozen() and unfreeze it by setFrozen(0) if needed.
Arguments
- vec3 torque - Torque to be applied, in world coordinates.
void AddTorque ( vec3 radius, vec3 torque ) #
Applies a torque with a pivot point, determined by a given radius vector, specified in the local coordinates.
This function calculates the cross product of the radius vector and the force vector.
It acts like a lever arm that changes both angular and linear velocities of the body.
All torque values are accumulated first, then the resulting torque is calculated and applied to the body (during the physics simulation stage, when the body update is called).
- You can call this function only from updatePhysics() function in the world script. Do not apply torques in the update() function, because you will get unstable result that varies each rendering frame.
- If a body is frozen, it can't be immediately unfrozen. If the object's velocities are above minimum, it needs the engine.physics.getNumFrozenFrames() flush frames to be specified to unfreeze. To make sure that torque will be applied, check if a body is not frozen by isFrozen() and unfreeze it by setFrozen(0) if needed.
Arguments
- vec3 radius - Radius vector starting at the body's center of mass. Its end is the pivot point for the torque to be applied.
- vec3 torque - Torque to be applied, in world coordinates.
void AddWorldForce ( vec3 point, vec3 force ) #
Applies a force to a given point of the body that is specified in world coordinates. This function calculates the cross product of the radius vector (a vector from the center of mass to the point where force is applied) and the force vector. It acts like a lever arm that changes both linear and angular velocities of the body.
Unlike impulses, all forces are accumulated first, then the resulting force is calculated and applied to the body (during the physics simulation stage, when the body update is called).
- You can call this function only from updatePhysics() function in the world script. Do not apply forces in the update() function, because you will get unstable result that varies each rendering frame.
- If a body is frozen, it can't be immediately unfrozen. If the object's velocities are above minimum, it needs the engine.physics.getNumFrozenFrames() flush frames to be specified to unfreeze. To make sure that force will be applied, check if a body is not frozen by isFrozen() and unfreeze it by setFrozen(0) if needed.
Arguments
- vec3 point - Point of the body, in world coordinates.
- vec3 force - Force to be applied, in world coordinates.
void AddWorldImpulse ( vec3 point, vec3 impulse ) #
Applies an impulse to a given point of the body, that is specified in world coordinates. Unlike forces, impulses immediately affect both linear and angular velocities of the body.Arguments
- vec3 point - Point of the body, in world coordinates.
- vec3 impulse - Impulse to be applied, in world coordinates.
void AddWorldTorque ( vec3 point, vec3 torque ) #
Applies a torque with a pivot point at a given point of the body, that is specified in world coordinates. This function calculates the cross product of the radius vector (a vector from the center of mass to the pivot point) and the torque vector. It acts like a lever arm that changes both angular and linear velocities of the body.
All torque values are accumulated first, then the resulting torque is calculated and applied to the body (during the physics simulation stage, when the body update is called).
- You can call this function only from updatePhysics() function in the world script. Do not apply torques in the update() function, because you will get unstable result that varies each rendering frame.
- If a body is frozen, it can't be immediately unfrozen. If the object's velocities are above minimum, it needs the engine.physics.getNumFrozenFrames() flush frames to be specified to unfreeze. To make sure that force will be applied, check if a body is not frozen by isFrozen() and unfreeze it by setFrozen(0) if needed.
Arguments
- vec3 point - Point of the body, in world coordinates.
- vec3 torque - Torque to be applied, in world coordinates.
int CreateShapes ( int depth = 4, float error = 0.01, float threshold = 0.01 ) #
Removes all previously created shapes and creates one or more convex shapes approximating the mesh.Arguments
- int depth - Degree of decomposition of the mesh. If 0 or a negative value is provided, only one shape will be created. If a positive n is provided, the mesh will be decomposed n times. This is an optional parameter.
- float error - Approximation error, which is used to create convex hulls. This is an optional parameter.
- float threshold - Threshold, which is used to decide, whether two adjoining convex shapes can be replaced with one larger shape. A pair of shapes is replaced with a larger shape, if their volumes are roughly the same. This value is clamped in the range [1 E-6; 1]. This is an optional parameter.
Return value
1 if the convex shapes are created successfully; otherwise 0.void SetHighPriorityContacts ( bool contacts ) #
Sets a value indicating if the body has the priority of handling detected contacts it participates in. A contact can be handled by any of the bodies that participate in it. To which body a contact is assigned is random. If the contact is assigned to and handled by the body it is called an internal one, otherwise it is called external (handled by another body). Iterating through internal contacts is much faster than through external ones, so this method can be used if you want a certain body to handle most of the contacts it participates in (i.e., have them as internal) to gain some performance.Arguments
- bool contacts - true to set high priority of handling detected contacts for the body; otherwise false.