Unigine::BodyRigid Class
Header: | #include <UniginePhysics.h> |
Inherits from: | Body |
This class is used to simulate rigid bodies that move according to the rigid bodies dynamics.
See Also#
- The Handling Contacts on Collision usage example
BodyRigid Class
Members
void setAngularVelocity ( const Math::vec3& velocity ) #
Arguments
- const Math::vec3& velocity - The angular velocity in radians per second, in world coordinates.
Math::vec3 getAngularVelocity() const#
Return value
Current angular velocity in radians per second, in world coordinates.void setLinearVelocity ( const Math::vec3& velocity ) #
Arguments
- const Math::vec3& velocity - The linear velocity in units per second, in world coordinates.
Math::vec3 getLinearVelocity() const#
Return value
Current linear velocity in units per second, in world coordinates.void setFrozenAngularVelocity ( float velocity ) #
Arguments
- float velocity - The "freeze" angular velocity. If the value is lower than the setFrozenAngularVelocity of the Physics class, it is overridden.
float getFrozenAngularVelocity() const#
Return value
Current "freeze" angular velocity. If the value is lower than the setFrozenAngularVelocity of the Physics class, it is overridden.void setFrozenLinearVelocity ( float velocity ) #
Arguments
- float velocity - The "freeze" linear velocity. If the value is lower than the setFrozenLinearVelocity of the Physics class, it is overridden.
float getFrozenLinearVelocity() const#
Return value
Current "freeze" linear velocity. If the value is lower than the setFrozenLinearVelocity of the Physics class, it is overridden.void setMaxAngularVelocity ( float velocity ) #
Arguments
- float velocity - The maximum angular velocity in radians per second. If a negative value is provided, 0 will be used instead.
float getMaxAngularVelocity() const#
Return value
Current maximum angular velocity in radians per second. If a negative value is provided, 0 will be used instead.void setMaxLinearVelocity ( float velocity ) #
Arguments
- float velocity - The maximum linear velocity in radians per second. If a negative value is provided, 0 will be used instead.
float getMaxLinearVelocity() const#
Return value
Current maximum linear velocity in radians per second. If a negative value is provided, 0 will be used instead.void setAngularDamping ( float damping ) #
Arguments
- float damping - The angular damping. If a negative value is provided, 0 will be used instead.
float getAngularDamping() const#
Return value
Current angular damping. If a negative value is provided, 0 will be used instead.void setLinearDamping ( float damping ) #
Arguments
- float damping - The linear damping. If a negative value is provided, 0 will be used instead.
float getLinearDamping() const#
Return value
Current linear damping. If a negative value is provided, 0 will be used instead.void setAngularScale ( const Math::vec3& scale ) #
Arguments
- const Math::vec3& scale - The angular scale per axis, in world coordinates.
Math::vec3 getAngularScale() const#
Return value
Current angular scale per axis, in world coordinates.void setLinearScale ( const Math::Vec3& scale ) #
Arguments
- const Math::Vec3& scale - The linear scale per axis, in world coordinates.
Math::Vec3 getLinearScale() const#
Return value
Current linear scale per axis, in world coordinates.Math::Vec3 getWorldCenterOfMass() const#
Return value
Current world coordinates of the body's center of mass.void setCenterOfMass ( const Math::vec3& mass ) #
Arguments
- const Math::vec3& mass - The coordinates of the center of mass in local space of the body.
Math::vec3 getCenterOfMass() const#
Return value
Current coordinates of the center of mass in local space of the body.Math::mat3 getIWorldInertia() const#
Return value
Current inverse inertia tensor of the body, in the world coordinates.void setInertia ( const Math::mat3& inertia ) #
Arguments
- const Math::mat3& inertia - The inertia tensor.
Math::mat3 getInertia() const#
Return value
Current inertia tensor.float getIMass() const#
Return value
Current inverse mass of the body.void setMass ( float mass ) #
Arguments
- float mass - The mass of the body.
float getMass() const#
Return value
Current mass of the body.void setHighPriorityContacts ( bool contacts ) #
Arguments
- bool contacts - Set true to enable high priority of handling detected contacts for the body; false - to disable it.
bool isHighPriorityContacts() const#
Return value
true if high priority of handling detected contacts for the body is enabled; otherwise false.void setFreezable ( bool freezable ) #
Arguments
- bool freezable - Set true to enable the "freezable" state of the body; false - to disable it.
bool isFreezable() const#
Return value
true if the "freezable" state of the body is enabled; otherwise false.void setShapeBased ( bool based ) #
Arguments
- bool based - Set true to enable calculation of mass and inertia based on shape properties; false - to disable it.
bool isShapeBased() const#
Return value
true if calculation of mass and inertia based on shape properties is enabled; otherwise false.static BodyRigidPtr create ( ) #
Constructor. Creates a rigid body with default properties.static BodyRigidPtr create ( const Ptr<Object> & object ) #
Constructor. Creates a rigid body with default properties for a given object.Arguments
Math::vec3 getVelocity ( const Math::vec3 & radius ) const#
Returns the total linear velocity of the point determined by a given radius vector, specified in the local coordinates.Arguments
- const Math::vec3 & radius - Radius vector starting in the body's center of mass.
Return value
Total linear velocity in the given point of the body.Math::vec3 getWorldVelocity ( const Math::Vec3 & point ) const#
Returns the total linear velocity of the point specified in world coordinates.Arguments
- const Math::Vec3 & point - Point of the body, in world coordinates.
Return value
Total linear velocity in the given point.void addForce ( const Math::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).
Arguments
- const Math::vec3 & force - Force to be applied, in world coordinates.
void addForce ( const Math::vec3 & radius, const Math::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).
Arguments
- const Math::vec3 & radius - Radius vector, traced from the center of mass of the body to the point where the force is applied.
- const Math::vec3 & force - Force to be applied, in world coordinates.
void addImpulse ( const Math::vec3 & radius, const Math::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
- const Math::vec3 & radius - Radius vector, traced from the center of mass to the point where the impulse is applied.
- const Math::vec3 & impulse - Impulse to be applied, in world coordinates.
void addLinearImpulse ( const Math::vec3 & impulse ) #
Applies an impulse similar to the addImpulse() method, but affects only the linear velocity.Arguments
- const Math::vec3 & impulse - Impulse to be applied, in world coordinates.
void addAngularImpulse ( const Math::vec3 & impulse ) #
Applies an impulse similar to the addImpulse() method, but affects only the angular velocity.Arguments
- const Math::vec3 & impulse - Impulse to be applied, in world coordinates.
void addTorque ( const Math::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).
Arguments
- const Math::vec3 & torque - Torque to be applied, in world coordinates.
void addTorque ( const Math::vec3 & radius, const Math::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).
Arguments
- const Math::vec3 & radius - Radius vector starting at the body's center of mass. Its end is the pivot point for the torque to be applied.
- const Math::vec3 & torque - Torque to be applied, in world coordinates.
void addWorldForce ( const Math::Vec3 & point, const Math::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).
Arguments
- const Math::Vec3 & point - Point of the body, in world coordinates.
- const Math::vec3 & force - Force to be applied, in world coordinates.
void addWorldImpulse ( const Math::Vec3 & point, const Math::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
- const Math::Vec3 & point - Point of the body, in world coordinates.
- const Math::vec3 & impulse - Impulse to be applied, in world coordinates.
void addWorldTorque ( const Math::Vec3 & point, const Math::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).
Arguments
- const Math::Vec3 & point - Point of the body, in world coordinates.
- const Math::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.