The underlying physics technology is versatile enough to break many things, not only tree trunks. It is just a matter of setting up the assets. For the examples below we will concentrate on tree trunks, though.
The Boolean Destructibles system allows you to cause dynamic physical mesh damage (holes) to an otherwise solid object from gunshots or explosions. This is done without the need to pre-model broken states for the object. It uses a pre-modeled 3D shape that is subtracted (boolean operation) from the original object in real-time in the exact location of bullet impacts.
Because the boolean operations happen in real time, the system dynamically re-triangulates the original model (adding polygons) as necessary in order to maintain the original solid shape with the additional holes or missing pieces. The new interior faces that are added to the object take on the material properties and textures (including UVs) of the boolean (subtractive) shape.
The actual performance impact of the boolean system depends on a combination of the geometric complexity of the breakable object:
General performance guidelines:
The system involves a combination of various components (art assets, surface material types, physics script parameters) in order to function fully. Creating new destructible surface types and/or boolean shapes will require some engineer intervention.
These are the required components of the system:
By using an available destructible Surface Type in this object's material (in the Sandbox Material Editor), this object will be boolean-destructible.
Each different type of desired destructible surface (i.e. wood, concrete, brick, etc.) must be defined in the SurfaceTypes.xml and identified with a particular boolean 3D shape (modeled and textured by an artist.
Once a variety of SurfaceTypes (code) and Boolean shapes (art & code) have been created and defined, artists can then easily create destructible 3D objects (art only) to be placed in their levels without additional engineering support.
For the Trunk Material, turn on "physicalize" in the Material Editor in 3dsMax. Set the Parameter for the physics to "default".
Important:
Create a predefined mesh in an extra cgf file, which is used to "cap" the broken parts.
Please take a look at the files shipped with the CryENGINE SDK, they are located in Game\Objects\natural\trees\explosion_shape
. It is not necessary to build for example splinters, but could be later used to create the particle effects around the breaking part.
Game\Scripts\physics.lua
Game\Libs\MaterialEffects\SurfaceTypes.xml
<SurfaceType name="mat_wood_breakable" type="wood">
<Physics friction="0.5" elasticity="0.05" breakable_id="2" pierceability="7" break_energy="7000" hole_size="1.4" hit_points="10" hit_radius="0.4" hit_maxdmg="10" can_shatter="1" />
<BreakageParticles type="joint_break" effect="breakable_objects.tree_break.small" />
<BreakageParticles type="joint_shatter" effect="breakable_objects.tree_break.small" />
<BreakageParticles type="destroy" effect="breakable_objects.tree_break.small" count_per_unit="1" count_scale="1" scale="1" />
<AI fImpactRadius="2.5" fImpactSoundRadius="30" fFootStepRadius="20" proneMult="0.2" crouchMult="0.5" movingMult="2.5" />
</SurfaceType>
Physics.RegisterExplosionShape("Objects/default/explosion_shape/tree_broken_shape.cgf", 7, 2, 1, "",0,"");
Physics.RegisterExplosionShape("Objects/default/explosion_shape/tree_broken_shape2.cgf", 1.3, 3, 1, "",0,"");
Physics.RegisterExplosionShape("Objects/default/explosion_shape/tree_broken_shape3.cgf", 1.3, 5, 1,
"Objects/default/explosion_shape/trunk_splinters_a.cgf",1.6,"breakable_objects.tree_break.small");
The surface type includes only an explosion shape id. The actual mesh is registered in the Game\Scripts\physics.lua
file.
New explosion shape meshes must be added by code. After adding the mesh to physics.lua the surface types has to be changed.
Shoot at the tree to check if it's breakable.