This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

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.
Notice
Fracture body can be used with meshes in form of a simple primitive: boxes, spheres, capsules, cylinders, etc. Complex meshes cannot be fractured procedurally.

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#

A value indicating if the object is broken or remains its solid state.
set
Sets a value indicating if the object is broken or remains its solid state.
set value - Positive number to indicate the object as broken; 0 for it to remain solid.

int CollisionMask#

The collision bit mask for the body. two objects collide, if they both have matching masks. see also details on additional collision exclusion mask.
set
Sets a collision bit mask for the body. Two objects collide, if they both have matching masks. See also details on additional collision exclusion mask.
set value - Integer, each bit of which is a mask.

float Density#

The current density of the body.
set
Sets density of a body. Changing the density influences the mass, that is computed by multiplying body volume by density.
set value - Density of the body.

float Error#

The current approximation error permissible by creating convex shape for the mesh.
set
Sets approximation error permissible by creating convex shape for the mesh.
set value - Approximation error. If a negative value is provided, 0 will be used instead.

int ExclusionMask#

The bit mask that prevents collisions of the body with other ones. this mask is independent of the collision mask. For bodies with matching collision masks not to collide, at least one bit of their exclusion mask should match.
set
Sets an bit mask to prevent collisions of the body with other ones. This mask is independent of the collision mask. For bodies with matching collision masks not to collide, at least one bit of their exclusion mask should match. 0 is to collide with all bodies with a matching collision mask.
set value - Integer, each bit of which is a mask.

float Friction#

The current friction of the body against other surfaces.
set
Sets friction of the body against other surfaces.
set value - Friction value.

float Threshold#

The current minimum volume threshold for breaking. if the piece volume is less than the threshold value, it cannot be fractured further.
set
Sets the minimum volume threshold for breaking. If the piece volume is less than the threshold value, it cannot be fractured further.
set value - Volume threshold. If a negative value is provided, 0 will be used instead.

float Restitution#

The current restitution that determines body bouncing off the surfaces.
set
Sets the restitution that determines body bouncing off the surfaces.
set value - Restitution value.

int PhysicsIntersectionMask#

set
Sets a physics intersection mask for the body.
set value - Integer, each bit of which is a mask.

float MaxAngularVelocity#

The current maximum possible angular velocity for the body. if the value is lower than the engine.physics.setMaxAngularVelocity one, it is overridden.
set
Sets the maximum possible linear velocity for the body. If the value is lower than the engine.physics.setMaxAngularVelocity one, it is overridden.
set value - Maximum possible angular velocity.

float MaxLinearVelocity#

The current maximum possible linear velocity for the body. if the value is lower than the engine.physics.setMaxLinearVelocity one, it is overridden.
set
Sets the maximum possible linear velocity for the body. If the value is lower than the engine.physics.setMaxLinearVelocity one, it is overridden.
set value - Maximum possible linear velocity.

float FrozenAngularVelocity#

The current angular velocity threshold for freezing body simulation. if body angular velocity remains lower than this threshold during the number of Frozen frames (together with linear one), it stops to be updated.
set
Sets angular velocity threshold for freezing body simulation. If body angular velocity remains lower than this threshold during the number of Frozen frames (together with linear one), it stops to be updated.
set value - "Freeze" angular velocity. If the value is lower than the engine.physics.setFrozenAngularVelocity one, it is overridden.

float FrozenLinearVelocity#

The current linear velocity threshold for freezing body simulation. if body linear velocity remains lower than this threshold during the number of Frozen frames (together with angular one), it stops to be updated.
set
Sets linear velocity threshold for freezing body simulation. If body linear velocity remains lower than this threshold during the number of Frozen frames (together with angular one), it stops to be updated.
set value - "Freeze" linear velocity. If the value is lower than the engine.physics.setFrozenLinearVelocity one, it is overridden.

float Mass#

The current mass of the body.
set
Sets a mass of the body. Changing the mass influences the density, that is computed by dividing the mass by body volume.
set value - Mass of the body.

BodyRigid BodyRigid#

An internal body rigid body that represents fracture body until it is broken.

float LinearDamping#

The current damping of the body linear velocity.
set
Sets the damping of the body linear velocity.
set value - Linear damping value.

float AngularDamping#

The current damping of the body angular velocity.
set
Sets the damping of the body angular velocity.
set value - Angular damping value.

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.

void SetMaterial ( string name ) #

Sets the material for fractured verge surfaces appearing after breaking the body.

Arguments

  • string name - Material name for the fractured verges.

string GetMaterialName ( ) #

Returns the material for fractured verge surfaces appearing after breaking the body.

Return value

Material name for the fractured verges.

void SetSurfaceProperty ( string name ) #

Sets the property for cracked verge surfaces appearing after breaking the body.

Arguments

  • string name - Property name for the fractured verges.

string GetSurfacePropertyName ( ) #

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).

Notice
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.

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).

Notice
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.

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.

Notice
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 impulse will be applied, check if a body is not frozen by isFrozen() and unfreeze it by setFrosen(0) if needed.

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).

Notice
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.

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).

Notice
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.

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).

Notice
You can call this function only from within updatePhysics() in the world script. Do not apply forces in the update(); otherwise, you will get unstable result that varies each rendering frame.

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.
Notice
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 impulse will be applied, check if a body is not frozen by isFrozen() and unfreeze it by setFrosen(0) if needed.

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).

Notice
You can call this function only from within updatePhysics() in the world script. Do not apply torques in the update(); otherwise, you will get unstable result that varies each rendering frame.

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.

Return value

Positive number if the object was successfully broken; otherwise, 0.
Last update: 2020-04-10
Build: ()