Realtime Drill

Warning

Note that this feature is in experimental stage, therefore it is not stable and it can create artifacts on the newly created mesh.

MAGES gives you the ability to perform realitme drilling in meshes. In order to achieve this you will need to attach the Deformable Mesh script to the object containing the mesh and the Drill script to the tool.

Deformable Mesh

Setting up a deformable mesh

To convert a mesh into a deformable mesh, attach the “Deformable Mesh” component on the Game Object that contains its renderer.

../../../_images/ctd_deformable_00.jpg

The deformable mesh can be separated into multiple sections, based on what parts of it may be changed, as well as for optimization purposes. To separate a mesh, a list of predicates is used, which are gameobject hierarchies that contain colliders:

../../../_images/ctd_deformable_01.jpg

You can add predicates by adding to the “Predicates” property in the Deformable Mesh component:

../../../_images/ctd_deformable_02.jpg

After adding the colliders, you can convert the mesh to a deformable mesh, by clicking on the “Separate Mesh” button. This may take a few moments, based on the complexity of the mesh in question:

../../../_images/ctd_deformable_03.jpg

In this case, since we used, 2 predicates, there are a total of 3 different mesh sections:

  • The original mesh

  • And the two separated sections from the vertices that were inside the sphere colliders

In the sections list, you can check the property “Can Modify” to disable modification of the mesh section in question by all CTD scripts.

Finally, in order to be able to save the deformable mesh as a prefab select a valid path and name in the fields shown below and click Save Sections.

../../../_images/SaveDeformableMesh.jpg

Then you can simply parent all the deformable mesh’s components in an empty gameobject and drag n drop it in your assets to create a reusable prefab.


Drill

The drill module enables the developer to set up a Unity GameObject as a drill tool, in order to achieve real time drilling of holes on 3D rigged and static models.

Set up

To use the Drill Module, you need to attach the Drill component onto the gameobject that we want to use as a drill. Simply click Add Component> MAGES > Mesh Deformations > Drill to add the component.

Note

The scale of the gameObject that this script is attached to, affects the scaling of the drill area.

../../../_images/drillComponent1.png

This gives you the following properties:

  1. Parallel Computation:

  • Option to run the code in parallel for increased performance.

  1. Local Densing:

  • Option to split every affected triangle of the drilling into four smaller ones, in order to prevent the smaller diameter holes looking like polygons.

  1. Use Interactable Item

  • Option to use this script in combination with an interactable item, such that when you have this object in your hand and then press the trigger button a drill is performed.

  1. Drill Area:

    • Option to set up the drilling axis and the radius of the drill.

      Note

      Make sure Gizmos are enabled on the Unity editor.

      • Click the edit button shown in the image below:

      ../../../_images/drillAreaEditor1.png
      • Use the handles shown in the scene to adjust the drill area to your requirements as shown below:

      ../../../_images/drillArea1.png

That last step that remains is to add a trigger collider component to the gameObject, that is aligned with the drill axis GUI that we created before:

In our example we are going to add a Box Collider.

../../../_images/colliderDrillArea1.png

Properties

Property

Description

bool parallelize

Minimize running times by executing the code in parallel.

bool localDensing

Split every affected triangle of the drilling into four smaller ones, in order to prevent the smaller diameter holes looking like polygons.

DrillAxis drillArea

Set up the drilling axis and the radius of the drill

UnityEvent OnDrillPerformed

Called whenever after this script successfully modifies a mesh section.