Unigine.BodyFracture Class
Inherits: | Body |
This class is used to simulate destructable fracture bodies. There are three patterns of the fracturing:
New surfces that are created when fracturing occurs are assigned their own material and properties.Fracture body is, per se, a rigid body and moves according to the rigid bodies dynamics.
See Also#
- A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/physics/ folder:
- fracture_00
- fracture_01
- fracture_02
- fracture_03
- fracture_04
- fracture_05
- fracture_06
BodyFracture Class
Properties
bool IsBroken#
int CollisionMask#
float Density#
float Error#
int ExclusionMask#
float Friction#
float Threshold#
float Restitution#
int PhysicsIntersectionMask#
float MaxAngularVelocity#
float MaxLinearVelocity#
float FrozenAngularVelocity#
float FrozenLinearVelocity#
float Mass#
BodyRigid BodyRigid#
float LinearDamping#
float AngularDamping#
string Material#
string SurfaceProperty#
Members
static BodyFracture ( ) #
Constructor. Creates a fracture body with default properties.static BodyFracture ( Object object ) #
Constructor. Creates a fracture body with default properties for a given object.Arguments
- Object object - Object represented with the new fracture body.
string GetMaterial ( ) #
Returns the material for fractured verge surfaces appearing after breaking the body.Return value
Material name for the fractured verges.string GetSurfaceProperty ( ) #
Returns the property for fractured verge surfaces appearing after breaking the body.Return value
Property name for the fractured verges.vec3 GetVelocity ( vec3 radius ) #
Returns the total linear velocity in 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.vec3 GetWorldVelocity ( vec3 point ) #
Returns the total linear velocity in 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).
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, in local coordinates.
- 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, in local coordinates.
- 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).
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 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 starting at the body's center of mass, in local coordinates. 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 CreateCrackPieces ( vec3 point, vec3 normal, int num_cuts, int num_rings, float step ) #
Breaks the object into radial cracks combined with concentric splits. If the first concentric split is rendered further than the specified step distance, decrease the volume threshold value.Arguments
- vec3 point - Point of contact.
- vec3 normal - Normal of the contact point.
- int num_cuts - Number of radial cuts that are represented as rays coming from the center of contact point.
- int num_rings - Number of rings that form concentric splits. The number of rings that is will be actually rendered depends on the step value.
- float step - Distance between concentric splits.
Return value
Positive number if the object was successfully broken; otherwise, 0.int CreateShatterPieces ( int num_pieces ) #
Breaks the object into arbitrary shattered pieces.Arguments
- int num_pieces - The number of shattered pieces.
Return value
Positive number if the object was successfully broken; otherwise, 0.int CreateSlicePieces ( vec3 point, vec3 normal ) #
Breaks the object into two slices, slitting the body according to the normal of the specified point.Arguments
- vec3 point - Point of contact.
- vec3 normal - Normal of the contact point.