A fracture is a type of asset that let you predefine how a Mesh will break, crack or shatter. The process is done using a two-phase process. First, you need to define the FractureType you want to use; once the parameters and settings are set you need to generate slices by calling the BuildSlices
function.
The second step consists of building a series of chunks causing the Mesh to be cut by the slices defined in the previous step. To create these chunks use the BuildChunks
function.
Once this process is done the chunks can be saved and converted to shards (a PhysicObject created internally for each chunk) when the Fracture is connected to a FracturedMesh creating a destructible Object.
At runtime collisions applied on the FracturedMesh will cause theses shards to break, crack and/or shattered in real-time.
See Also
Static Variables
Name | Description |
asset | Parent Asset where the active Fracture data is located. |
Declaration
|
mesh | The active Mesh connected to the Fracture. |
Declaration
|
chunk_count | The current amount of chunks generated. |
Declaration unsigned short chunk_count
|
settings | Current FractureSettings that determines how the connected Mesh will be fractured. |
Declaration FractureSettings settings
|
Variables
Functions
Name | Description |
SetMesh | Connect a Mesh to the active Fracture. |
Declaration void SetMesh( Mesh *mesh ) Parameters
mesh : An existing Mesh reference pointer; pass nil to disconnect any Mesh previously connected.
|
ClearSlices | Destroy all existing FractureSlice. |
Declaration
|
CleanSlices | Clear up the FractureSlice cache. |
Declaration
|
BuildSlices | Build new slices using the active settings. |
Declaration Return Value
The amount of FractureSlice generated; -1 if no Mesh is connected to the Fracture.
|
ClearChunks | Destroy all chunks. |
Declaration
|
SetChunkOptions | Assign a set of FractureChunkOptions to a specific chunk. |
Declaration bool SetChunkOptions( unsigned short chunk_index, const FractureChunkOptions options ) Return Value
true of the option set have been assigned to the chunk specified index; false if the chunk_index is invalid.
|
GetChunkOptions | Retrieve the FractureChunkOptions assigned to a specific chunk. |
Declaration int GetChunkOptions( unsigned short chunk_index ) Parameters
chunk_index : The index of the chunk to to retrieve its current options.
Return Value
Options assigned to the specified by index received in parameter to the function; -1 if the chunk_index is invalid.
|
BuildChunks | Use the active slices to cut and generate chunks. |
Declaration Return Value
The amount of chunks generated; -1 if the Mesh connected to the Fracture is not a closed Geometry. -2 if the Fracture use a core; and the core Mesh specified is not a closed Geometry.
|
FractureOptions
List of all option flags that can be affected by the Fracture that will be used by the editor and the chunks generator.
fDisplayChunks
: Toggle the visibility of the slices in the viewport on or off.
fDisplayCore
: Visualize the core Mesh representation in the 3d viewport.
fResolveHoles
: Resolve and patch holes based on the topology of the shell used for slicing.
fImproveTriangulation
: Allow you to select which triangulator to use; either if this flag is off the default one will be used; else a slower but more accurate triangulator will be used to generate the slices.
FractureChunkOptions
Options that can be affected by each and every chunks independently.
fDestructable
: Determine whether or not the corresponding shard should be treated as a static object (which is indestructible).
fSupport
: Tells the system that if this shard gets activated (or its constraint is broken) all upper-level shards resting on top of it should get activated.
fHole
: Do not generate a shard for this chunk.
FractureType
The list of slice types; a visual representation of each and every fracture type can be found in the following manual help section: Fractured Mesh Slices.
kManual
: Allows you to manually select and place existing mesh(es) that will be used to slice the base mesh during the generation process.
kVoronoi
: Best way to simulate rocks, ice, glass-like shattering. Using this type you can allocate control points (either manually or randomly) that will then be converted into a tri-dimensional Voronoi cell.
kPlanes
: Creates precise or noisy cuts by using planes.
kChips
: This type of slice allows you to simulate dents, pucks and/or broken pieces using flat or noisy cuboids.
FractureSettings
Settings allowing you to access parameter for the active FractureType of the Fracture and setup the slice's configuration.
Static Variables
Variables
Name | Description |
shell_scale | Allows you to control the scale of the shell around the Mesh. |
Declaration
|
core_mesh | Optional core mesh asset id that will be placed at the center of the fractured mesh. |
Declaration
|
core_transform | Local transformation to offset and adjust the core Mesh. |
Declaration
|
selection_index | Internal slice index selection used by the editor to modify a slice parameters. |
Declaration
|
ManualFracture
A structure that holds parameters to set up kManual
slices. When dealing with manual slices, you will have to provide and place all the shape manually. The following API allows you to set which shape should be used for each slot and specify their local transformation (location, rotation, and scale).
Variables
Name | Description |
shape_count | Total amount of shapes that can be used by the manual fracture type. |
Declaration unsigned short shape_count
|
Functions
Name | Description |
SetShape | Assign an existing Geometry to an existing shape slot. |
Declaration bool SetShape( unsigned short index, unsigned int shape ) Parameters
index : Index of the slot to connect a Geometry to.
shape : An existing Mesh uid to extract and connect its Geometry to the slot specified by index . To disconnect any geometry from slot pass 0 .
Return Value
true on success; false if the index received in parameter is invalid.
|
GetLocation | Retrieve the active location set to a specific shape slot. |
Declaration vec3 GetLocation( unsigned short index ) Parameters
index : Index of the slot to retrieve the location for.
Return Value
The shape location vector. If index is invalid return zero.
|
SetLocation | Set the location of a shape using its index as key. |
Declaration bool SetLocation( unsigned short index, const vec3 v ) Parameters
index : The shape slot index to assign the location to.
v : The new local location of the shape specified as a vector.
Return Value
true if the shape location have been updated; false if the slot index is invalid.
|
GetRotation | Retrieve the active rotation of a shape slot. |
Declaration vec3 GetRotation( unsigned short index ) Parameters
index : Index of the slot to retrieve the rotation for.
Return Value
The shape rotation vector. If index is invalid a nil vector (all zeros).
|
SetRotation | Set the rotation of a shape using its index as key. |
Declaration bool SetRotation( unsigned short index, const vec3 v ) Parameters
index : The shape slot index to assign the rotation to.
v : The new local rotation of the shape specified as a vector.
Return Value
true if the shape rotation have been updated; false if the slot index is invalid.
|
GetScale | Retrieve the active scale assigned to a specific shape slot. |
Declaration vec3 GetScale( unsigned short index ) Parameters
index : Index of the slot to retrieve the scale for.
Return Value
The shape scale vector. If the index is invalid return zero.
|
SetScale | Set the scale of a shape using its index as key. |
Declaration bool SetScale( unsigned short index, const vec3 v ) Parameters
index : The shape slot index to assign the scale to.
v : The new local scale to apply specified as a vector.
Return Value
true if the shape scale have been updated; false if the slot index is invalid.
|
VoronoiFracture
Contains the settings of a kVoronoi
fracture type. Using this type of fracture you will have to set points (either manually or randomly) inside a shell. Once ready theses point will be turned into Voronoi cells that will then be turned into chunks.
Variables
Name | Description |
point_spread | The spread type you want to use; 0 for random, else the spread need to be manually set. |
Declaration Range 1 or 0
|
point_count | Controls the maximum amount of control points. |
Declaration unsigned short point_count
|
shell_bounds | Specify the type of envelope (as CollisionBounds) that will be used to generate the cells. |
Declaration CollisionBounds shell_bounds - Warning
- Only
kConvexHull or kBox are accepted.
|
Functions
Name | Description |
GetPoint | Return the location of a specific control point. |
Declaration vec3 GetPoint( unsigned short index ) Parameters
index : The index of the point to get the location for.
Return Value
A vector that contains the location of the point; a zeroed vector in case the index is out of bounds.
|
SetPoint | Set the location of a specific control point. |
Declaration bool SetPoint( unsigned short index, const vec3 v ) Parameters
index : Specify the index of the control point you want to set the location for.
Return Value
true of the point location was updated successfully; false if the index is invalid.
|
PlanesFracture
Parameters available when the FractureType is set to kPlanes
. Using this type of fracture you will need to place cutting planes; either manually, evenly or randomly, around the Mesh connected to the Fracture. For best results ensure that each plane fully intersects the geometry.
Variables
Name | Description |
plane_spread | Specify the spread type to place the planes. |
Declaration Range 0 to 2 - Note
- A value of
0 will force the planes to be placed randomly; 1 evenly on the XY and Z axis based on the distribution parameter; 2 each plane have to be set manually.
|
subdiv | Controls the general amount of subdivision apply on all planes. |
Declaration Range 0 to 4
|
noise | Set the density of the noise that should be applied randomly all planes. |
Declaration Range 0.0 to inf. - Note
- Setting a value of
1.0 will tell the system that the noise range should be from -1.0 to 1.0 .
|
distribution | Specify the amount of planes that should be placed on each axis. |
Declaration Range 0 to 65535
|
random_rotation | Randomize the rotation of the planes. |
Declaration
|
rotation_range | Set the random rotational range in degree that should affect the planes. |
Declaration
|
plane_count | Total amount of planes to used to slice up the base Mesh. |
Declaration unsigned short plane_count
|
Functions
Name | Description |
GetLocation | Return the location of a specific plane. |
Declaration vec3 GetLocation( unsigned short index ) Parameters
index : The index of the plane to get the location for.
Return Value
A vector that contains the location of the plane; a nil vector in case the index is incorrect.
|
SetLocation | Manually specify the location of a plane using its index as key. |
Declaration bool SetLocation( unsigned short index, const vec3 v ) Parameters
index : The index of the plane to get the location for.
v : A vector containing the location of the plane to update.
Return Value
true if the plane index is valid and the plane location have been updated; false in the event that the index is incorrect.
|
GetRotation | Return the current rotation of a specific plane. |
Declaration vec3 GetRotation( unsigned short index ) Parameters
index : The index of the plane to get the rotation for.
Return Value
A vector that contains the rotation of the plane; a nil vector in case the index is incorrect.
|
SetRotation | Manually specify the rotation of a plane by using its index. |
Declaration bool SetRotation( unsigned short index, const vec3 v ) Parameters
index : The index of the plane to get the rotation for.
v : A vector containing the rotation of the plane to update.
Return Value
true if the plane index is correct and the rotation have been updated; false if the index is incorrect.
|
GetScale | Return the scale of a specific plane. |
Declaration vec2 GetScale( unsigned short index ) Parameters
index : The index of the plane to get the scale for.
Return Value
A two dimensional vector containing the with and height of the plane; a nil vector in case the index is incorrect.
|
SetScale | Manually specify the scale of a plane using its index as key. |
Declaration bool SetScale( unsigned short index, const vec2 v ) Parameters
index : The index of the plane to get the scale for.
v : Two dimensional vectors that specify the new width and height of the plane.
Return Value
true if the plane index is valid and the plane size have been updated; false if the index is incorrect.
|
GetParam | Return the amount of noise (X ) and the number of subdivision (Y ) for a plane. |
Declaration vec2 GetParam( unsigned short index ) Parameters
index : Plane index to retrieve the active parameters of.
Return Value
A two dimensional floating plane vector containing the noise level in X and the amount of subdivision in Y .
|
SetParam | Tweak the amount of noise and subdivision a plane. |
Declaration bool SetParam( unsigned short index, const vec2 v ) Parameters
index : The index of the plane to update.
v : The parameters value to update passing the noise level in X and the subdivision amount in Y .
Return Value
false if the index is invalid else returns true if the plane parameters have been updated.
- Note
- The
noise level should be expressed as a unit (ie. 1.0 = 1m) and the subdivision the amount should be greater or equal than zero and should not exceed a maximum of 4.0 for best results.
|
ChipsFracture
A kChips
FractureType is very similar to a ChipsFracture at the exception that instead of dealing with chips you will be dealing with cuboids.
Variables
Name | Description |
chip_spread | Specify the way the chips should be placed around the Mesh connected to the Fracture. |
Declaration Range 0 to 2 - Note
- A value of
0 will force the chips to be placed randomly; 1 evenly on the XY and Z axis based on the distribution parameter; 2 each chip have to be set manually.
|
subdiv | Controls the general amount of subdivision to be applied on all chips. |
Declaration Range 0 to 4
|
noise | Controls the density of the noise that to randomly apply on all chips. |
Declaration Range 0.0 to inf. - Note
- The internal system will interpret a value of
1.0 as a range of -1.0 to 1.0 .
|
distribution | The chips distribution factor on each axis. |
Declaration Range 0.0 to 65535
|
random_rotation | Enable rotation randomization for each chips. |
Declaration
|
rotation_range | Rotational range in degree that should affect the chips. |
Declaration Range 0.0 to 360.0
|
random_scale | Enable scale randomization for each chips. |
Declaration
|
scale_range | Rotational range in degree that should affect the chips. |
Declaration Range 0.01 to inf.
|
chip_count | Total amount of chips to place around the base Mesh. |
Declaration unsigned short chip_count
|
Functions
Name | Description |
GetLocation | Get the location of a specific chip. |
Declaration vec3 GetLocation( unsigned short index ) Parameters
index : The index of the chip to get the location for.
Return Value
A vector that contains the location of the chip; a nil vector in case the index is incorrect.
|
SetLocation | Set the location of a chip by index. |
Declaration bool SetLocation( unsigned short index, const vec3 v ) Parameters
index : The index of the chip to get the location for.
v : A vector containing the location of the chip to update.
Return Value
true if the chip index is valid and the chip location have been updated; false in the event that the index is incorrect.
|
GetRotation | Return the current rotation of a chip. |
Declaration vec3 GetRotation( unsigned short index ) Parameters
index : The index of the chip to get the rotation for.
Return Value
A vector that contains the rotation of the chip; a nil vector in case the index is incorrect.
|
SetRotation | Manually set the rotation of a chip. |
Declaration bool SetRotation( unsigned short index, const vec3 v ) Parameters
index : The index of the chip to get the rotation for.
v : A vector containing the rotational angles for each axis.
Return Value
true if the chip index is correct and the rotation have been updated; false if the index is incorrect.
|
GetScale | Return the scale value used by a chip. |
Declaration vec2 GetScale( unsigned short index ) Parameters
index : The index of the chip to get the scale for.
Return Value
A two dimensional vector containing the size of the chip for each of its dominant axis; a nil vector in case the index is incorrect.
|
SetScale | Tweak the scale of a specific chip. |
Declaration bool SetScale( unsigned short index, const vec2 v ) Parameters
index : Chip index to get the size for.
v : Two dimensional vector that specify the size of the chip.
Return Value
true if the chip index is valid and the chip size have been updated; false if the index is incorrect.
|
GetParam | Get the amount of noise and subdivisions (XY ) of a chip. |
Declaration vec2 GetParam( unsigned short index ) Parameters
index : Chip index to retrieve the active parameters of.
Return Value
Two dimensional vector containing the noise level and amount of subdivisions.
|
SetParam | Tweak the amount of noise and subdivision a chip. |
Declaration bool SetParam( unsigned short index, const vec2 v ) Parameters
index : The index of the chip to update.
v : The noise level in X and the amount of subdivision in Y .
Return Value
true if the chip parameters have been updated; false if the index is invalid.
- Note
noise level should be a unit like 1.0 = 1m; and the number of subdivisions should be greater or equal than zero (no noise) and should not be more than 4.0 for performances reasons.
|
FractureSlice
Structure that contain the transformation and geometric information of an individual fracture slice.
Static Variables
Name | Description |
geometry | Geometry information for the active slice. |
Declaration
|
Variables
Name | Description |
local_matrix | Local 4x4 transformation matrix of the slice. |
Declaration
|